Add get_sampler_scheduler_list MCP Tools.
Browse files- mcp_tools/__init__.py +15 -6
- mcp_tools/get_sampler_scheduler_list.py +18 -0
- mcp_tools/mcp_gradio_integration.py +10 -3
- mcp_tools/tool_handlers.py +2 -0
- requirements.txt +1 -1
mcp_tools/__init__.py
CHANGED
|
@@ -8,15 +8,22 @@ from .get_model_architecture_list import handle_get_model_architecture_list
|
|
| 8 |
from .get_model_list import handle_get_model_list
|
| 9 |
from .get_feature_list import handle_get_feature_list
|
| 10 |
from .get_model_features import handle_get_model_features
|
|
|
|
| 11 |
from .run import handle_run
|
| 12 |
from .get_task_status import handle_get_task_status
|
| 13 |
from .error_schema import make_error, make_validation_error, make_not_found_error
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
MCP_FUNCTIONS = [
|
| 22 |
handle_get_task_list,
|
|
@@ -24,6 +31,7 @@ MCP_FUNCTIONS = [
|
|
| 24 |
handle_get_model_list,
|
| 25 |
handle_get_feature_list,
|
| 26 |
handle_get_model_features,
|
|
|
|
| 27 |
handle_run,
|
| 28 |
handle_get_task_status,
|
| 29 |
]
|
|
@@ -34,6 +42,7 @@ __all__ = [
|
|
| 34 |
"handle_get_model_list",
|
| 35 |
"handle_get_feature_list",
|
| 36 |
"handle_get_model_features",
|
|
|
|
| 37 |
"handle_run",
|
| 38 |
"handle_get_task_status",
|
| 39 |
"make_error",
|
|
|
|
| 8 |
from .get_model_list import handle_get_model_list
|
| 9 |
from .get_feature_list import handle_get_feature_list
|
| 10 |
from .get_model_features import handle_get_model_features
|
| 11 |
+
from .get_sampler_scheduler_list import handle_get_sampler_scheduler_list
|
| 12 |
from .run import handle_run
|
| 13 |
from .get_task_status import handle_get_task_status
|
| 14 |
from .error_schema import make_error, make_validation_error, make_not_found_error
|
| 15 |
+
try:
|
| 16 |
+
from .mcp_gradio_integration import (
|
| 17 |
+
register_high_level_mcp_apis,
|
| 18 |
+
cleanup_dependencies_api_names,
|
| 19 |
+
patch_gradio_api_suppression,
|
| 20 |
+
HIGH_LEVEL_MCP_API_NAMES,
|
| 21 |
+
)
|
| 22 |
+
except ImportError:
|
| 23 |
+
register_high_level_mcp_apis = None
|
| 24 |
+
cleanup_dependencies_api_names = None
|
| 25 |
+
patch_gradio_api_suppression = None
|
| 26 |
+
HIGH_LEVEL_MCP_API_NAMES = set()
|
| 27 |
|
| 28 |
MCP_FUNCTIONS = [
|
| 29 |
handle_get_task_list,
|
|
|
|
| 31 |
handle_get_model_list,
|
| 32 |
handle_get_feature_list,
|
| 33 |
handle_get_model_features,
|
| 34 |
+
handle_get_sampler_scheduler_list,
|
| 35 |
handle_run,
|
| 36 |
handle_get_task_status,
|
| 37 |
]
|
|
|
|
| 42 |
"handle_get_model_list",
|
| 43 |
"handle_get_feature_list",
|
| 44 |
"handle_get_model_features",
|
| 45 |
+
"handle_get_sampler_scheduler_list",
|
| 46 |
"handle_run",
|
| 47 |
"handle_get_task_status",
|
| 48 |
"make_error",
|
mcp_tools/get_sampler_scheduler_list.py
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
MCP Tool: get_sampler_scheduler_list
|
| 3 |
+
Query all supported Sampler algorithms and Noise Schedulers available for image generation tasks.
|
| 4 |
+
"""
|
| 5 |
+
|
| 6 |
+
try:
|
| 7 |
+
from comfy_integration.nodes import SAMPLER_CHOICES, SCHEDULER_CHOICES
|
| 8 |
+
except Exception:
|
| 9 |
+
SAMPLER_CHOICES = ['euler', 'dpmpp_2m_sde_gpu']
|
| 10 |
+
SCHEDULER_CHOICES = ['normal', 'karras']
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
def handle_get_sampler_scheduler_list() -> dict:
|
| 14 |
+
"""Query all supported Sampler algorithms and Noise Schedulers available for image generation tasks."""
|
| 15 |
+
return {
|
| 16 |
+
"samplers": list(SAMPLER_CHOICES),
|
| 17 |
+
"schedulers": list(SCHEDULER_CHOICES),
|
| 18 |
+
}
|
mcp_tools/mcp_gradio_integration.py
CHANGED
|
@@ -15,6 +15,7 @@ from .get_model_architecture_list import handle_get_model_architecture_list
|
|
| 15 |
from .get_model_list import handle_get_model_list
|
| 16 |
from .get_feature_list import handle_get_feature_list
|
| 17 |
from .get_model_features import handle_get_model_features
|
|
|
|
| 18 |
from .run import handle_run
|
| 19 |
from .get_task_status import handle_get_task_status
|
| 20 |
|
|
@@ -24,6 +25,7 @@ HIGH_LEVEL_MCP_API_NAMES = {
|
|
| 24 |
"get_model_list",
|
| 25 |
"get_feature_list",
|
| 26 |
"get_model_features",
|
|
|
|
| 27 |
"run",
|
| 28 |
"get_task_status",
|
| 29 |
}
|
|
@@ -48,7 +50,7 @@ def patch_gradio_api_suppression():
|
|
| 48 |
def cleanup_dependencies_api_names(demo):
|
| 49 |
"""
|
| 50 |
Clean up residual auto-generated API names in demo.fns and demo.dependencies.
|
| 51 |
-
Force only
|
| 52 |
"""
|
| 53 |
for fn in demo.fns.values():
|
| 54 |
api_name = getattr(fn, "api_name", None)
|
|
@@ -71,7 +73,7 @@ def cleanup_dependencies_api_names(demo):
|
|
| 71 |
|
| 72 |
def register_high_level_mcp_apis(demo):
|
| 73 |
"""
|
| 74 |
-
Explicitly register
|
| 75 |
Using gr.api() never adds any visual UI components (such as Row, Textbox, Button, etc.), avoiding duplicate interface rendering.
|
| 76 |
"""
|
| 77 |
def get_task_list() -> list:
|
|
@@ -102,6 +104,10 @@ def register_high_level_mcp_apis(demo):
|
|
| 102 |
model_str = model.strip() if isinstance(model, str) else ""
|
| 103 |
return sanitize_keys(handle_get_model_features(model_str))
|
| 104 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 105 |
def run(json_params: str = "{}") -> dict:
|
| 106 |
"""[Recommended Discovery Flow Step 4] Unified image generation task execution interface. Accepts a JSON string or dict of parameters.
|
| 107 |
|
|
@@ -142,6 +148,7 @@ Paste-and-Run Example (With chain):
|
|
| 142 |
get_model_list,
|
| 143 |
get_feature_list,
|
| 144 |
get_model_features,
|
|
|
|
| 145 |
run,
|
| 146 |
get_task_status,
|
| 147 |
]
|
|
@@ -153,4 +160,4 @@ Paste-and-Run Example (With chain):
|
|
| 153 |
if getattr(fn, "api_name", None) in HIGH_LEVEL_MCP_API_NAMES:
|
| 154 |
fn.show_api = True
|
| 155 |
|
| 156 |
-
print("[MCP Integration] Successfully registered
|
|
|
|
| 15 |
from .get_model_list import handle_get_model_list
|
| 16 |
from .get_feature_list import handle_get_feature_list
|
| 17 |
from .get_model_features import handle_get_model_features
|
| 18 |
+
from .get_sampler_scheduler_list import handle_get_sampler_scheduler_list
|
| 19 |
from .run import handle_run
|
| 20 |
from .get_task_status import handle_get_task_status
|
| 21 |
|
|
|
|
| 25 |
"get_model_list",
|
| 26 |
"get_feature_list",
|
| 27 |
"get_model_features",
|
| 28 |
+
"get_sampler_scheduler_list",
|
| 29 |
"run",
|
| 30 |
"get_task_status",
|
| 31 |
}
|
|
|
|
| 50 |
def cleanup_dependencies_api_names(demo):
|
| 51 |
"""
|
| 52 |
Clean up residual auto-generated API names in demo.fns and demo.dependencies.
|
| 53 |
+
Force only high-level abstract MCP APIs to be exposed as public endpoints.
|
| 54 |
"""
|
| 55 |
for fn in demo.fns.values():
|
| 56 |
api_name = getattr(fn, "api_name", None)
|
|
|
|
| 73 |
|
| 74 |
def register_high_level_mcp_apis(demo):
|
| 75 |
"""
|
| 76 |
+
Explicitly register high-level abstract MCP API endpoints on the Gradio demo using gr.api.
|
| 77 |
Using gr.api() never adds any visual UI components (such as Row, Textbox, Button, etc.), avoiding duplicate interface rendering.
|
| 78 |
"""
|
| 79 |
def get_task_list() -> list:
|
|
|
|
| 104 |
model_str = model.strip() if isinstance(model, str) else ""
|
| 105 |
return sanitize_keys(handle_get_model_features(model_str))
|
| 106 |
|
| 107 |
+
def get_sampler_scheduler_list() -> dict:
|
| 108 |
+
"""Query all supported Sampler algorithms and Noise Schedulers available for image generation tasks."""
|
| 109 |
+
return sanitize_keys(handle_get_sampler_scheduler_list())
|
| 110 |
+
|
| 111 |
def run(json_params: str = "{}") -> dict:
|
| 112 |
"""[Recommended Discovery Flow Step 4] Unified image generation task execution interface. Accepts a JSON string or dict of parameters.
|
| 113 |
|
|
|
|
| 148 |
get_model_list,
|
| 149 |
get_feature_list,
|
| 150 |
get_model_features,
|
| 151 |
+
get_sampler_scheduler_list,
|
| 152 |
run,
|
| 153 |
get_task_status,
|
| 154 |
]
|
|
|
|
| 160 |
if getattr(fn, "api_name", None) in HIGH_LEVEL_MCP_API_NAMES:
|
| 161 |
fn.show_api = True
|
| 162 |
|
| 163 |
+
print(f"[MCP Integration] Successfully registered {len(funcs)} High-Level Abstract MCP APIs via gr.api().")
|
mcp_tools/tool_handlers.py
CHANGED
|
@@ -8,6 +8,7 @@ from .get_model_architecture_list import handle_get_model_architecture_list
|
|
| 8 |
from .get_model_list import handle_get_model_list
|
| 9 |
from .get_feature_list import handle_get_feature_list
|
| 10 |
from .get_model_features import handle_get_model_features
|
|
|
|
| 11 |
from .run import handle_run
|
| 12 |
from .get_task_status import handle_get_task_status
|
| 13 |
from .common import (
|
|
@@ -23,6 +24,7 @@ __all__ = [
|
|
| 23 |
"handle_get_model_list",
|
| 24 |
"handle_get_feature_list",
|
| 25 |
"handle_get_model_features",
|
|
|
|
| 26 |
"handle_run",
|
| 27 |
"handle_get_task_status",
|
| 28 |
]
|
|
|
|
| 8 |
from .get_model_list import handle_get_model_list
|
| 9 |
from .get_feature_list import handle_get_feature_list
|
| 10 |
from .get_model_features import handle_get_model_features
|
| 11 |
+
from .get_sampler_scheduler_list import handle_get_sampler_scheduler_list
|
| 12 |
from .run import handle_run
|
| 13 |
from .get_task_status import handle_get_task_status
|
| 14 |
from .common import (
|
|
|
|
| 24 |
"handle_get_model_list",
|
| 25 |
"handle_get_feature_list",
|
| 26 |
"handle_get_model_features",
|
| 27 |
+
"handle_get_sampler_scheduler_list",
|
| 28 |
"handle_run",
|
| 29 |
"handle_get_task_status",
|
| 30 |
]
|
requirements.txt
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
comfyui-frontend-package==1.48.7
|
| 2 |
-
comfyui-workflow-templates==0.11.
|
| 3 |
comfyui-embedded-docs==0.5.9
|
| 4 |
torch
|
| 5 |
torchsde
|
|
|
|
| 1 |
comfyui-frontend-package==1.48.7
|
| 2 |
+
comfyui-workflow-templates==0.11.39
|
| 3 |
comfyui-embedded-docs==0.5.9
|
| 4 |
torch
|
| 5 |
torchsde
|