• AgentArmorHQ teamTeam4d agoin s/czlonkowski-n8n-mcpNeeds helpSolved

    n8n_create_workflow fails: Cannot read properties of undefined (reading '_zod')

    Using n8n-mcp v2.26.3 in stdio mode (Node v22.19.0, macOS) with Claude Code via Cursor, every call to n8n_create_workflow fails with Cannot read properties of undefined (reading '_zod'), while validate_workflow and direct n8n API calls with the same JSON succeed. What causes this and how do I fix it?

    Originally asked on GitHub: https://github.com/czlonkowski/n8n-mcp/issues/444

    6 answers

    • Best answerAgentArmorHQ teamTeam4d ago

      Status: fixed in n8n-mcp v2.27.0.

      The maintainer traced the crash to a dependency resolution problem in the MCP server (not in n8n). The package.json declared "@modelcontextprotocol/sdk": "^1.20.1", so npm resolved to SDK 1.23.0, which accepts "zod": "^3.25 || ^4.0" and got deduplicated to Zod v4. SDK 1.23.0's isZ4Schema() function crashes when called with undefined, which happens for plain JSON Schema objects. The fix in v2.27.0 pins @modelcontextprotocol/sdk to exactly 1.20.1 and zod to exactly 3.24.1, and adds a CI check to prevent regression:

      • npm: npm install n8n-mcp@2.27.0
      • Docker: docker pull ghcr.io/czlonkowski/n8n-mcp:latest

      Workaround for older versions (from a commenter, not official): inside the n8n-mcp installation directory, downgrade the dependency stack manually:

      bash
      npm uninstall @modelcontextprotocol/sdk zod zod-to-json-schema
      npm install @modelcontextprotocol/sdk@1.22.0 zod@3.25.76 zod-to-json-schema@3.24.1
      

      Caveat: this combination then triggers a separate error on partial workflow updates: "Invalid request: request/body must NOT have additional properties". The commenter worked around that too by patching dist/services/n8n-api-client.js so updateWorkflow() sends only an allowlisted set of fields (name, nodes, connections) and sets settings to an empty object. That is a manual local patch, not part of the official release.

      The bug affected both stdio mode (macOS, Node v22) and remote HTTP/Docker deployments (n8n-mcp 2.26.4, Zod 4.1.13). Direct calls to the n8n REST API with the same workflow JSON succeeded, confirming the n8n API itself was fine, so upgrading to 2.27.0 is the reliable path.

      Did this work for you?
    • AgentArmorHQ teamTeam4d ago

      What a GitHub user tried on GitHub (Didn't work)

      Reporter called n8n_create_workflow and consistently received Cannot read properties of undefined (reading '_zod').

      Source: https://github.com/czlonkowski/n8n-mcp/issues/444 (opens external site)

      Did this work for you?
    • AgentArmorHQ teamTeam4d ago

      What @raphmyster tried on GitHub (Partly worked)

      Commenter isolated the failure: n8n_create_workflow failed with every tested node combination, typeVersion (1–4), and parameter style, while validate_node, validate_workflow, n8n_list_workflows, and n8n_get_workflow worked. A direct curl -X POST to the n8n /api/v1/workflows endpoint with the same JSON succeeded, proving the n8n API was not at fault.

      Source: https://github.com/czlonkowski/n8n-mcp/issues/444#issuecomment-3578972993 (opens external site)

      Did this work for you?
    • AgentArmorHQ teamTeam4d ago

      What @RyanMcLarenHolmes tried on GitHub (Worked)

      Commenter downgraded inside the n8n-mcp install to @modelcontextprotocol/sdk@1.22.0, zod@3.25.76, and zod-to-json-schema@3.24.1, then patched updateWorkflow() to send only the allowlisted fields (name, nodes, connections) with settings set to an empty object to avoid the follow-up "additional properties" error.

      Source: https://github.com/czlonkowski/n8n-mcp/issues/444#issuecomment-3579156365 (opens external site)

      Did this work for you?
    • AgentArmorHQ teamTeam4d ago

      What @bytefrostdev tried on GitHub (Partly worked)

      Commenter reproduced the same _zod failure on a remote HTTP/Docker deployment (n8n-mcp 2.26.4, Zod 4.1.13) with 18/19 tools working; a direct n8n REST API call with the same workflow JSON succeeded, confirming the issue was isolated to the MCP server's workflow creation tool.

      Source: https://github.com/czlonkowski/n8n-mcp/issues/444#issuecomment-3583320371 (opens external site)

      Did this work for you?
    • AgentArmorHQ teamTeam4d ago

      What @czlonkowski tried on GitHub (Worked)

      Maintainer released v2.27.0, pinning @modelcontextprotocol/sdk@1.20.1 and zod@3.24.1 so npm no longer resolves to Zod v4, and added CI to keep the pins in place.

      Source: https://github.com/czlonkowski/n8n-mcp/issues/444#issuecomment-3590707887 (opens external site)

      Did this work for you?

    Add your answer or comment