Skip to main content
Glama

read_workflow

Retrieve a specific workflow file from the configured directory using its relative path. This tool enables access to ComfyUI workflow templates for orchestration and image generation tasks.

Instructions

Read a specific workflow file by its relative path inside the configured workflow directory.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
relative_pathYes

Implementation Reference

  • The main handler function for the 'read_workflow' tool. It reads the workflow file content using the WorkflowRepository, attempts to parse it as JSON, handles parsing errors by setting parsed to None, logs an info message via context if provided, and returns a dictionary containing the relative_path, raw text, and parsed JSON object.
    async def read_workflow(relative_path: str, context: Context | None = None) -> dict[str, Any]: """Return the contents of a workflow JSON file.""" text = await anyio.to_thread.run_sync(workflow_repo.read, relative_path) parsed: Any try: parsed = json.loads(text) except json.JSONDecodeError: parsed = None if context is not None: await context.info(f"Read workflow {relative_path}") return { "relative_path": relative_path, "text": text, "json": parsed, }
  • Registers the 'read_workflow' tool on the FastMCP server instance using the @server.tool decorator, specifying the tool name and a description of its purpose.
    @server.tool( name="read_workflow", description=( "Read a specific workflow file by its relative path inside the" " configured workflow directory." ), )
  • Supporting helper method in the WorkflowRepository class that securely reads a workflow file by relative path, preventing path traversal attacks and raising appropriate errors if the file doesn't exist or is outside the root directory. This is called by the tool handler.
    def read(self, relative_path: str) -> str: """Read a workflow file by its relative path.""" candidate = (self.root / relative_path).resolve() if not str(candidate).startswith(str(self.root)): raise ValueError("Attempted to read workflow outside of the configured directory") if not candidate.exists(): raise FileNotFoundError(f"Workflow '{relative_path}' not found") return candidate.read_text(encoding="utf-8")
Install Server

Other Tools

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/neutrinotek/ComfyUI_MCP'

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