Model Context Protocol (MCP) integration for ComfyUI, enabling workflows to connect to and interact with any MCP-compatible server.
- 🔌 Connect to MCP Servers: Support for both local (stdio) and remote (SSE) MCP servers
- 🛠️ Execute Tools: Run any tool exposed by MCP servers with automatic type conversion
- 📁 Access Resources: Read resources from MCP servers with support for text, JSON, and binary data
- 🔍 Discovery: Browse available tools and resources with detailed schema information
- 🔄 Lifecycle Management: Automatic server start/stop with workflow execution
- 🔁 Retry Logic: Built-in exponential backoff for resilient connections
- 📊 Progress Tracking: Real-time progress updates during tool execution
- 🗃️ Result Caching: Leverages ComfyUI's caching system to avoid redundant calls
-
Navigate to your ComfyUI custom nodes directory:
cd ComfyUI/custom_nodes/ -
Clone or copy the ComfyUI-MCP folder
-
Install dependencies:
cd ComfyUI-MCP pip install -r requirements.txt -
Restart ComfyUI
Connects to an MCP server and manages its lifecycle.
Inputs:
server_id: Unique identifier for the connectiontransport: Connection type (stdio or sse)connection_string: Command for stdio or URL for sseaction: connect, disconnect, or statuscommand_args: Additional command argumentsenv_vars: Environment variables (KEY=VALUE format)capture_output: Capture server stdout/stderr
Outputs:
server_id: Server identifierstatus: Connection statusinfo: Detailed server information
Executes tools on connected MCP servers.
Inputs:
server_id: Server to execute tool ontool_name: Name of the tool to runarguments: Tool arguments as JSONretry_count: Number of retry attemptsretry_delay: Initial retry delay
Outputs:
result: Tool execution resultsuccess: Whether execution succeedederror: Error message if failed
Reads resources from MCP servers.
Inputs:
server_id: Server to read fromresource_uri: URI of the resourceoutput_format: Format (text, json, base64)
Outputs:
content: Resource contentmime_type: Content MIME typesuccess: Whether read succeedederror: Error message if failed
Lists available tools and resources from a server.
Inputs:
server_id: Server to querydiscovery_type: What to discover (tools, resources, both)output_format: Output format (summary, detailed, names_only)
Outputs:
discovery_info: Formatted discovery informationtools_count: Number of available toolsresources_count: Number of available resourcesstatus: Discovery status
- Add "MCP Server Connect" node
- Set connection_string to:
npx -y @modelcontextprotocol/server-filesystem /path/to/directory - Connect to "MCP Tool Execute" node
- Use tool "read_file" with arguments:
{"path": "file.txt"}
- Add "MCP Server Connect" node
- Set connection_string to:
npx -y @modelcontextprotocol/server-github - Set env_vars to:
GITHUB_TOKEN=your_token - Use discovery node to see available tools
- Add "MCP Server Connect" node
- Set transport to:
sse - Set connection_string to server URL
- Add authentication token if required
For servers requiring authentication:
- Local servers: Use env_vars to pass tokens
- Remote servers: ComfyUI will use MCP_AUTH_TOKEN from environment
Enable output capture to see server logs:
- Set
capture_outputto True in server node - Check ComfyUI console for stdout/stderr
- Use status action to check connection state
- WebSocket transport not yet implemented
- Dynamic tool discovery (UI updates) not supported
- Limited to JSON-serializable data types
To extend or modify:
- Follow ComfyUI node development guidelines
- Maintain compatibility with MCP protocol spec
- Test with various MCP server implementations
Same as ComfyUI