Skip to main content
Glama

n8n_get_workflow

Read-onlyIdempotent

Retrieve n8n workflows by ID with configurable detail levels: full workflow data, metadata with execution statistics, node/connection structure, or minimal metadata only.

Instructions

Get workflow by ID with different detail levels. Use mode='full' for complete workflow, 'details' for metadata+stats, 'structure' for nodes/connections only, 'minimal' for id/name/active/tags.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesWorkflow ID
modeNoDetail level: full=complete workflow, details=full+execution stats, structure=nodes/connections topology, minimal=metadata onlyfull

Implementation Reference

  • Tool registration and input schema definition for n8n_get_workflow, including support for different detail modes
    {
      name: 'n8n_get_workflow',
      description: `Get workflow by ID with different detail levels. Use mode='full' for complete workflow, 'details' for metadata+stats, 'structure' for nodes/connections only, 'minimal' for id/name/active/tags.`,
      inputSchema: {
        type: 'object',
        properties: {
          id: {
            type: 'string',
            description: 'Workflow ID'
          },
          mode: {
            type: 'string',
            enum: ['full', 'details', 'structure', 'minimal'],
            default: 'full',
            description: 'Detail level: full=complete workflow, details=full+execution stats, structure=nodes/connections topology, minimal=metadata only'
          }
        },
        required: ['id']
      }
    },
  • Primary handler function for fetching full workflow data by ID using N8nApiClient
    export async function handleGetWorkflow(args: unknown, context?: InstanceContext): Promise<McpToolResponse> {
      try {
        const client = ensureApiConfigured(context);
        const { id } = z.object({ id: z.string() }).parse(args);
        
        const workflow = await client.getWorkflow(id);
        
        return {
          success: true,
          data: workflow
        };
      } catch (error) {
        if (error instanceof z.ZodError) {
          return {
            success: false,
            error: 'Invalid input',
            details: { errors: error.errors }
          };
        }
        
        if (error instanceof N8nApiError) {
          return {
            success: false,
            error: getUserFriendlyErrorMessage(error),
            code: error.code
          };
        }
        
        return {
          success: false,
          error: error instanceof Error ? error.message : 'Unknown error occurred'
        };
      }
    }
  • Detailed tool documentation explaining parameters, modes, returns, examples, best practices, and related tools
    import { ToolDocumentation } from '../types';
    
    export const n8nGetWorkflowDoc: ToolDocumentation = {
      name: 'n8n_get_workflow',
      category: 'workflow_management',
      essentials: {
        description: 'Get workflow by ID with different detail levels. Use mode to control response size and content.',
        keyParameters: ['id', 'mode'],
        example: 'n8n_get_workflow({id: "workflow_123", mode: "structure"})',
        performance: 'Fast (50-200ms)',
        tips: [
          'mode="full" (default): Complete workflow with all data',
          'mode="details": Full workflow + execution stats',
          'mode="structure": Just nodes and connections (topology)',
          'mode="minimal": Only id, name, active status, tags'
        ]
      },
      full: {
        description: `**Modes:**
    - full (default): Complete workflow including all nodes with parameters, connections, and settings
    - details: Full workflow plus execution statistics (success/error counts, last execution time)
    - structure: Nodes and connections only - useful for topology analysis
    - minimal: Just id, name, active status, and tags - fastest response`,
        parameters: {
          id: { type: 'string', required: true, description: 'Workflow ID to retrieve' },
          mode: { type: 'string', required: false, description: 'Detail level: "full" (default), "details", "structure", "minimal"' }
        },
        returns: `Depends on mode:
    - full: Complete workflow object (id, name, active, nodes[], connections{}, settings, createdAt, updatedAt)
    - details: Full workflow + executionStats (successCount, errorCount, lastExecution, etc.)
    - structure: { nodes: [...], connections: {...} } - topology only
    - minimal: { id, name, active, tags, createdAt, updatedAt }`,
        examples: [
          '// Get complete workflow (default)\nn8n_get_workflow({id: "abc123"})',
          '// Get workflow with execution stats\nn8n_get_workflow({id: "abc123", mode: "details"})',
          '// Get just the topology\nn8n_get_workflow({id: "abc123", mode: "structure"})',
          '// Quick metadata check\nn8n_get_workflow({id: "abc123", mode: "minimal"})'
        ],
        useCases: [
          'View and edit workflow (mode=full)',
          'Analyze workflow performance (mode=details)',
          'Clone or compare workflow structure (mode=structure)',
          'List workflows with status (mode=minimal)',
          'Debug workflow issues'
        ],
        performance: `Response times vary by mode:
    - minimal: ~20-50ms (smallest response)
    - structure: ~30-80ms (nodes + connections only)
    - full: ~50-200ms (complete workflow)
    - details: ~100-300ms (includes execution queries)`,
        bestPractices: [
          'Use mode="minimal" when listing or checking status',
          'Use mode="structure" for workflow analysis or cloning',
          'Use mode="full" (default) when editing',
          'Use mode="details" for debugging execution issues',
          'Validate workflow after retrieval if planning modifications'
        ],
        pitfalls: [
          'Requires N8N_API_URL and N8N_API_KEY configured',
          'mode="details" adds database queries for execution stats',
          'Workflow must exist or returns 404 error',
          'Credentials are referenced by ID but values not included'
        ],
        relatedTools: ['n8n_list_workflows', 'n8n_update_full_workflow', 'n8n_update_partial_workflow', 'n8n_validate_workflow']
      }
    };
  • Handler for minimal workflow metadata retrieval (supports mode='minimal')
    export async function handleGetWorkflowMinimal(args: unknown, context?: InstanceContext): Promise<McpToolResponse> {
      try {
        const client = ensureApiConfigured(context);
        const { id } = z.object({ id: z.string() }).parse(args);
        
        const workflow = await client.getWorkflow(id);
        
        return {
          success: true,
          data: {
            id: workflow.id,
            name: workflow.name,
            active: workflow.active,
            isArchived: workflow.isArchived,
            tags: workflow.tags || [],
            createdAt: workflow.createdAt,
            updatedAt: workflow.updatedAt
          }
        };
      } catch (error) {
        if (error instanceof z.ZodError) {
          return {
            success: false,
            error: 'Invalid input',
            details: { errors: error.errors }
          };
        }
        
        if (error instanceof N8nApiError) {
          return {
            success: false,
            error: getUserFriendlyErrorMessage(error),
            code: error.code
          };
        }
        
        return {
          success: false,
          error: error instanceof Error ? error.message : 'Unknown error occurred'
        };
      }
    }
  • Tool documentation export and registration in tool-docs index
    n8n_get_workflow: n8nGetWorkflowDoc,
Behavior3/5

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

Annotations already indicate readOnlyHint=true, openWorldHint=true, and idempotentHint=true, covering safety and idempotency. The description adds context about the different detail levels (modes), which is useful behavioral information beyond annotations. However, it doesn't disclose additional traits like rate limits, auth needs, or response format, leaving some gaps.

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, dense sentence that efficiently explains the tool's purpose and parameter usage. It is front-loaded with the core action and avoids unnecessary words, making every part of the sentence earn its place without waste.

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

Completeness4/5

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

Given the tool's moderate complexity (2 parameters, no output schema), the description is largely complete. It covers the purpose, usage, and parameter semantics adequately. However, it lacks details on response format or error handling, which could be useful given the absence of an output schema, leaving minor gaps in completeness.

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?

Schema description coverage is 100%, with clear descriptions for both parameters (id and mode). The description adds semantic meaning by explaining what each mode value represents (e.g., 'structure' for nodes/connections topology), which complements the schema. Since the schema already documents parameters well, the baseline is 3, and the description provides moderate added value.

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

Purpose5/5

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

The description clearly states the verb ('Get') and resource ('workflow by ID'), specifying it retrieves workflows with different detail levels. It distinguishes from siblings like 'n8n_list_workflows' (which lists multiple workflows) and 'n8n_create_workflow' (which creates rather than retrieves), making the purpose specific and differentiated.

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

Usage Guidelines5/5

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

The description explicitly provides usage guidance by detailing when to use each mode (e.g., 'full' for complete workflow, 'minimal' for metadata only). It implicitly distinguishes from alternatives like 'n8n_list_workflows' for bulk retrieval, offering clear context for parameter selection without exclusions.

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/czlonkowski/n8n-mcp'

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