Skip to main content
Glama

add_node

Adds nodes to ComfyUI workflows by specifying node types, IDs, and input connections to build or modify automation pipelines.

Instructions

Add a node to a workflow.

Args: workflow: Existing workflow dict node_id: Unique identifier for this node node_type: Node class name (use list_nodes() to find) inputs: Input values. For connections use ["source_node_id", output_index]. Examples: # Simple value input add_node(wf, "1", "StringInput_fal", {"text": "a cat"}) # Connection to another node add_node(wf, "2", "CLIPTextEncode", { "text": "prompt", "clip": ["1", 0] # Connect to node "1" output 0 }) Returns the modified workflow dict.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
workflowYesWorkflow dict to modify
node_idYesUnique node ID (e.g., '1', 'prompt')
node_typeYesNode class name
inputsYesNode inputs

Implementation Reference

  • MCP tool handler for 'add_node': decorated with @mcp.tool(), defines parameters with Pydantic Field descriptions (serving as schema), and implements logic to insert node into workflow dict.
    @mcp.tool() def add_node( workflow: dict = Field(description="Workflow dict to modify"), node_id: str = Field(description="Unique node ID (e.g., '1', 'prompt')"), node_type: str = Field(description="Node class name"), inputs: dict = Field(description="Node inputs"), ctx: Context = None, ) -> dict: """Add a node to a workflow. Args: workflow: Existing workflow dict node_id: Unique identifier for this node node_type: Node class name (use list_nodes() to find) inputs: Input values. For connections use ["source_node_id", output_index]. Examples: # Simple value input add_node(wf, "1", "StringInput_fal", {"text": "a cat"}) # Connection to another node add_node(wf, "2", "CLIPTextEncode", { "text": "prompt", "clip": ["1", 0] # Connect to node "1" output 0 }) Returns the modified workflow dict. """ if ctx: ctx.info(f"Adding node {node_id}: {node_type}") workflow[node_id] = {"class_type": node_type, "inputs": inputs} return workflow
  • Within register_all_tools(mcp), calls register_workflow_tools(mcp) which defines and registers the add_node tool.
    register_workflow_tools(mcp)
  • Initial registration call from main module: register_all_tools(mcp), which chains to workflow tools registration including add_node.
    register_all_tools(mcp)
  • Supporting method on Workflow Pydantic model for adding nodes, similar logic to the tool handler.
    def add_node(self, node_id: str, class_type: str, inputs: dict) -> "Workflow": """Add a node to the workflow.""" self.nodes[node_id] = WorkflowNode(class_type=class_type, inputs=inputs) return self

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/IO-AtelierTech/comfyui-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server