n8n - 💡(How to fix) Fix Builder MCP `create_workflow_from_code` returns 500 on any `@n8n/n8n-nodes-langchain.*` root node, despite `validate_workflow` accepting it [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
n8n-io/n8n#29660Fetched 2026-05-05 06:03:20
View on GitHub
Comments
1
Participants
2
Timeline
6
Reactions
0
Author
Timeline (top)
labeled ×3commented ×1mentioned ×1subscribed ×1

The official n8n Workflow Builder MCP server (public preview, announced 2026-04-29) accepts workflow code containing @n8n/n8n-nodes-langchain.* root nodes via validate_workflow but returns HTTP 500 on create_workflow_from_code and update_workflow for the same code. Reproduced across multiple node types and configurations.

Error Message

create_workflow_from_code returns HTTP 500 with no error body for any workflow that includes a @n8n/n8n-nodes-langchain.* root node. Workflows using only n8n-nodes-base.* nodes persist successfully. This adds 10-15 minutes of UI work per workflow and re-introduces the manual error surface the MCP is designed to remove.

Root Cause

  1. Build the skeleton via MCP using placeholder Set nodes shaped to mimic the langchain output (e.g. `{ message: { content: 'TODO' } }` for v2.1, `{ content: 'TODO' }` for v2.3).
  2. Open n8n in the browser.
  3. Manually swap each placeholder for the real langchain node.
  4. Bind credentials and update downstream references because the placeholder output shape rarely matches the real node exactly.

Fix Action

Fix / Workaround

create_workflow_from_code should persist the workflow when validate_workflow accepts the same code. The validate/persist asymmetry forces a brittle workaround.

Happy to provide additional repros, MCP request/response logs, or test against any patched build.

Code Example

import { workflow, trigger, node } from '@n8n/workflow-sdk';

const webhookTrigger = trigger({
  type: 'n8n-nodes-base.webhook',
  version: 2.1,
  config: {
    name: 'Webhook',
    parameters: { httpMethod: 'POST', path: 'mcp-test-min' },
    position: [240, 300],
  },
  output: [{ body: {} }],
});

const messageModel = node({
  type: '@n8n/n8n-nodes-langchain.openAi',
  version: 2.3,
  config: {
    name: 'Message a model',
    parameters: { resource: 'text', operation: 'response' },
    position: [540, 300],
  },
  output: [{}],
});

export default workflow('mcp-test-min', '[mcp-test] msg model minimal')
  .add(webhookTrigger)
  .to(messageModel);

---

import { workflow, trigger, node, languageModel, newCredential } from '@n8n/workflow-sdk';

const chatModel = languageModel({
  type: '@n8n/n8n-nodes-langchain.lmChatOpenAi',
  version: 1.3,
  config: {
    name: 'OpenAI Chat Model',
    parameters: { model: { __rl: true, mode: 'list', value: 'gpt-4.1-mini' } },
    credentials: { openAiApi: newCredential('OpenAI') },
    position: [540, 500],
  },
});

const aiAgent = node({
  type: '@n8n/n8n-nodes-langchain.agent',
  version: 3.1,
  config: {
    name: 'AI Agent',
    parameters: { promptType: 'define', text: '={{ \$json.body.prompt }}' },
    subnodes: { model: chatModel },
    position: [540, 300],
  },
  output: [{ output: 'agent response' }],
});

// + webhookTrigger and workflow().add(...).to(aiAgent)
RAW_BUFFERClick to expand / collapse

Summary

The official n8n Workflow Builder MCP server (public preview, announced 2026-04-29) accepts workflow code containing @n8n/n8n-nodes-langchain.* root nodes via validate_workflow but returns HTTP 500 on create_workflow_from_code and update_workflow for the same code. Reproduced across multiple node types and configurations.

Environment

  • MCP server: official n8n Workflow Builder (Cloud)
  • SDK: @n8n/workflow-sdk
  • Tested via Claude Code MCP integration
  • First observed 2026-04-30 with @n8n/n8n-nodes-langchain.openAi v2.1
  • Re-tested 2026-05-03 with v2.3 and the AI Agent + Chat Model pattern

Reproduction 1 — minimal v2.3 OpenAI Message a model

import { workflow, trigger, node } from '@n8n/workflow-sdk';

const webhookTrigger = trigger({
  type: 'n8n-nodes-base.webhook',
  version: 2.1,
  config: {
    name: 'Webhook',
    parameters: { httpMethod: 'POST', path: 'mcp-test-min' },
    position: [240, 300],
  },
  output: [{ body: {} }],
});

const messageModel = node({
  type: '@n8n/n8n-nodes-langchain.openAi',
  version: 2.3,
  config: {
    name: 'Message a model',
    parameters: { resource: 'text', operation: 'response' },
    position: [540, 300],
  },
  output: [{}],
});

export default workflow('mcp-test-min', '[mcp-test] msg model minimal')
  .add(webhookTrigger)
  .to(messageModel);

validate_workflow returns { valid: true, nodeCount: 2 }. create_workflow_from_code with the same code returns HTTP 500.

Reproduction 2 — full v2.3 OpenAI Message a model with credentials

Same shape with full parameters (modelId, responses.values, builtInTools, options) and newCredential('OpenAI'). Same outcome: validates, 500s on persist.

Reproduction 3 — AI Agent + OpenAI Chat Model (the canonical pattern)

import { workflow, trigger, node, languageModel, newCredential } from '@n8n/workflow-sdk';

const chatModel = languageModel({
  type: '@n8n/n8n-nodes-langchain.lmChatOpenAi',
  version: 1.3,
  config: {
    name: 'OpenAI Chat Model',
    parameters: { model: { __rl: true, mode: 'list', value: 'gpt-4.1-mini' } },
    credentials: { openAiApi: newCredential('OpenAI') },
    position: [540, 500],
  },
});

const aiAgent = node({
  type: '@n8n/n8n-nodes-langchain.agent',
  version: 3.1,
  config: {
    name: 'AI Agent',
    parameters: { promptType: 'define', text: '={{ \$json.body.prompt }}' },
    subnodes: { model: chatModel },
    position: [540, 300],
  },
  output: [{ output: 'agent response' }],
});

// + webhookTrigger and workflow().add(...).to(aiAgent)

Validates fine. create_workflow_from_code 500s.

Expected behavior

create_workflow_from_code should persist the workflow when validate_workflow accepts the same code. The validate/persist asymmetry forces a brittle workaround.

Actual behavior

create_workflow_from_code returns HTTP 500 with no error body for any workflow that includes a @n8n/n8n-nodes-langchain.* root node. Workflows using only n8n-nodes-base.* nodes persist successfully.

Impact

Anyone using the Builder MCP to scaffold workflows that include LLM operations is forced to:

  1. Build the skeleton via MCP using placeholder Set nodes shaped to mimic the langchain output (e.g. `{ message: { content: 'TODO' } }` for v2.1, `{ content: 'TODO' }` for v2.3).
  2. Open n8n in the browser.
  3. Manually swap each placeholder for the real langchain node.
  4. Bind credentials and update downstream references because the placeholder output shape rarely matches the real node exactly.

This adds 10-15 minutes of UI work per workflow and re-introduces the manual error surface the MCP is designed to remove.

Suggested triage

The asymmetry between `validate_workflow` (accepts) and `create_workflow_from_code` (500s) suggests the validation path doesn't exercise the same persistence code path. Either the validator is permissive about langchain nodes that the persistence layer rejects, or the persistence layer has a bug specific to the langchain namespace.

Happy to provide additional repros, MCP request/response logs, or test against any patched build.

extent analysis

TL;DR

The issue can be temporarily worked around by manually swapping placeholder nodes with langchain nodes in the n8n browser interface after creating a skeleton workflow via the MCP.

Guidance

  • Investigate the difference in validation and persistence code paths for langchain nodes to identify the root cause of the asymmetry.
  • Verify that the issue is specific to the @n8n/n8n-nodes-langchain.* namespace by testing other node types.
  • Consider adding logging or debugging statements to the persistence layer to capture more detailed error information.
  • Test the workflow creation process with a minimal langchain node configuration to isolate the issue.

Example

No code example is provided as the issue is related to a specific library and namespace, and any code changes would be speculative without further investigation.

Notes

The issue may be related to a bug in the persistence layer or a mismatch between the validation and persistence code paths. Further investigation is needed to determine the root cause.

Recommendation

Apply a workaround by using the manual process described in the issue until a fix is available. This will allow users to create workflows with langchain nodes, although it will require additional manual steps.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

create_workflow_from_code should persist the workflow when validate_workflow accepts the same code. The validate/persist asymmetry forces a brittle workaround.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

n8n - 💡(How to fix) Fix Builder MCP `create_workflow_from_code` returns 500 on any `@n8n/n8n-nodes-langchain.*` root node, despite `validate_workflow` accepting it [1 comments, 2 participants]