Spaces:
Running on Zero
Running on Zero
Add get_sampler_scheduler_list MCP Tools.
Browse filesFiles changed (5)
7 unmodified lines8910111213141514151617181916171819202122232425262728291 unmodified line313233343536374 unmodified lines424344454647487 unmodified linesfrom .get_model_list import handle_get_model_list
from .get_feature_list import handle_get_feature_list
from .get_model_features import handle_get_model_features
from .get_sampler_scheduler_list import handle_get_sampler_scheduler_list
from .run import handle_run
from .get_task_status import handle_get_task_status
from .error_schema import make_error, make_validation_error, make_not_found_error
try:
from .mcp_gradio_integration import (
register_high_level_mcp_apis,
cleanup_dependencies_api_names,
patch_gradio_api_suppression,
HIGH_LEVEL_MCP_API_NAMES,
)
from .mcp_gradio_integration import (
register_high_level_mcp_apis,
cleanup_dependencies_api_names,
patch_gradio_api_suppression,
HIGH_LEVEL_MCP_API_NAMES,
)
except ImportError:
register_high_level_mcp_apis = None
cleanup_dependencies_api_names = None
patch_gradio_api_suppression = None
HIGH_LEVEL_MCP_API_NAMES = set()
MCP_FUNCTIONS = [
handle_get_task_list,1 unmodified line handle_get_model_list,
handle_get_feature_list,
handle_get_model_features,
handle_get_sampler_scheduler_list,
handle_run,
handle_get_task_status,
]4 unmodified lines "handle_get_model_list",
"handle_get_feature_list",
"handle_get_model_features",
"handle_get_sampler_scheduler_list",
"handle_run",
"handle_get_task_status",
"make_error",123456789101112131415161718"""MCP Tool: get_sampler_scheduler_listQuery all supported Sampler algorithms and Noise Schedulers available for image generation tasks."""
try: from comfy_integration.nodes import SAMPLER_CHOICES, SCHEDULER_CHOICESexcept Exception: SAMPLER_CHOICES = ['euler', 'dpmpp_2m_sde_gpu'] SCHEDULER_CHOICES = ['normal', 'karras']
def handle_get_sampler_scheduler_list() -> dict: """Query all supported Sampler algorithms and Noise Schedulers available for image generation tasks.""" return { "samplers": list(SAMPLER_CHOICES), "schedulers": list(SCHEDULER_CHOICES), }14 unmodified lines151617181920213 unmodified lines2526272829303118 unmodified lines505152515354555616 unmodified lines737475747677787924 unmodified lines10410510610710810911011111211334 unmodified lines1481491501511521531545 unmodified lines16016116215616314 unmodified linesfrom .get_model_list import handle_get_model_list
from .get_feature_list import handle_get_feature_list
from .get_model_features import handle_get_model_features
from .get_sampler_scheduler_list import handle_get_sampler_scheduler_list
from .run import handle_run
from .get_task_status import handle_get_task_status
3 unmodified lines "get_model_list",
"get_feature_list",
"get_model_features",
"get_sampler_scheduler_list",
"run",
"get_task_status",
}18 unmodified linesdef cleanup_dependencies_api_names(demo):
"""
Clean up residual auto-generated API names in demo.fns and demo.dependencies.
Force only the 7 high-level abstract MCP APIs to be exposed as public endpoints.
Force only high-level abstract MCP APIs to be exposed as public endpoints.
"""
for fn in demo.fns.values():
api_name = getattr(fn, "api_name", None)16 unmodified lines
def register_high_level_mcp_apis(demo):
"""
Explicitly register 7 high-level abstract MCP API endpoints on the Gradio demo using gr.api.
Explicitly register high-level abstract MCP API endpoints on the Gradio demo using gr.api.
Using gr.api() never adds any visual UI components (such as Row, Textbox, Button, etc.), avoiding duplicate interface rendering.
"""
def get_task_list() -> list:24 unmodified lines model_str = model.strip() if isinstance(model, str) else ""
return sanitize_keys(handle_get_model_features(model_str))
def get_sampler_scheduler_list() -> dict:
"""Query all supported Sampler algorithms and Noise Schedulers available for image generation tasks."""
return sanitize_keys(handle_get_sampler_scheduler_list())
def run(json_params: str = "{}") -> dict:
"""[Recommended Discovery Flow Step 4] Unified image generation task execution interface. Accepts a JSON string or dict of parameters.
34 unmodified lines get_model_list,
get_feature_list,
get_model_features,
get_sampler_scheduler_list,
run,
get_task_status,
]5 unmodified lines if getattr(fn, "api_name", None) in HIGH_LEVEL_MCP_API_NAMES:
fn.show_api = True
print("[MCP Integration] Successfully registered 7 High-Level Abstract MCP APIs via gr.api().") print(f"[MCP Integration] Successfully registered {len(funcs)} High-Level Abstract MCP APIs via gr.api().")7 unmodified lines8910111213149 unmodified lines242526272829307 unmodified linesfrom .get_model_list import handle_get_model_list
from .get_feature_list import handle_get_feature_list
from .get_model_features import handle_get_model_features
from .get_sampler_scheduler_list import handle_get_sampler_scheduler_list
from .run import handle_run
from .get_task_status import handle_get_task_status
from .common import (9 unmodified lines "handle_get_model_list",
"handle_get_feature_list",
"handle_get_model_features",
"handle_get_sampler_scheduler_list",
"handle_run",
"handle_get_task_status",
]122345comfyui-frontend-package==1.48.7
comfyui-workflow-templates==0.11.37
comfyui-workflow-templates==0.11.39
comfyui-embedded-docs==0.5.9
torch
torchsdemcp_tools/__init__.py+15-6
mcp_tools/get_sampler_scheduler_list.pyAdded+18
mcp_tools/mcp_gradio_integration.py+10-3
mcp_tools/tool_handlers.py+2
requirements.txt+1-1