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

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

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")
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool reads a file, implying a read-only operation, but doesn't specify permissions required, error handling (e.g., if the path doesn't exist), or any side effects. This is a significant gap for a tool that accesses files, lacking details on safety or constraints.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, clear sentence that directly states the tool's purpose and key parameter context. It's front-loaded with essential information and has no wasted words, making it highly efficient and easy to parse.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool has an output schema (which likely describes the returned workflow file content), the description doesn't need to explain return values. However, with no annotations and a simple parameter, it adequately covers the basic operation but lacks behavioral details like error handling or permissions, making it minimally viable but with gaps.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 0%, but the description adds meaning by explaining that 'relative_path' refers to a path 'inside the configured workflow directory'. This clarifies the parameter's context beyond the schema's basic string type. However, it doesn't detail format examples or constraints, so it partially compensates but not fully, aligning with the baseline expectation.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('Read') and resource ('a specific workflow file'), specifying it's identified by 'relative path inside the configured workflow directory'. This distinguishes it from sibling tools like 'list_workflows' which presumably list workflows rather than read individual files. However, it doesn't explicitly contrast with siblings, keeping it at 4 instead of 5.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'list_workflows' or 'list_models'. It mentions the context ('configured workflow directory') but offers no explicit when/when-not instructions or prerequisites, leaving usage unclear beyond the basic operation.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

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