How to stop n8n from stringifying your json in AI Agent node?

Describe the problem/error/question

Human: start a crawl on target.com\nAI: Calling MCP_Client with input: {“seedUrls”:“["https://target.com"]”,“tool”:“scan_crawl_start”,“id”:“call_a1bf35ff074bb0f3”}\nTool: [{“response”:[{“type”:“text”,“text”:“Invalid tool arguments: Expected JsonArray, but had JsonLiteral as the serialized body of kotlin.collections.ArrayList at element: $.seedUrls\nJSON input: "[\"https://target.com\"]"”}]}]

I am building a workflow where an n8n AI Agent connects to a local Burp Suite MCP server. I am running into a strict type coercion issue when the Agent tries to pass an array to the MCP Tool.

When the AI Agent uses a tool that requires a JSON array (like passing seedUrls to start a crawl), n8n automatically stringifies the array before passing it to the tool execution.

Expected Payload: {"seedUrls": ["https://target.com"]}

Actual Payload sent by n8n: {"seedUrls": "[\"https://target.com\"]"}

Because the array is wrapped in a string, the strict Kotlin backend of the MCP server rejects it and crashes with an Expected JsonArray, but had JsonLiteral error. Is there a way to force the AI Agent to pass a native JSON array to a tool without n8n aggressively stringifying it?

What is the error message (if any)?

Invalid tool arguments: Expected JsonArray, but had JsonLiteral as the serialized body of kotlin.collections.ArrayList at element: $.seedUrls\nJSON input: “[\“https://target.com\”]”

Please share your workflow

I can't share with you, but i'm using a Chat node connected to an Ai Agent node that has a local AI Agent and a MCP Client Tool connected to it. All of them deployed locally.

Share the output returned by the last node

Calling MCP_Client with input: {“seedUrls”:[“https://target.com”],“tool”:“scan_crawl_start”,“id”:“call_4f17113f00d58536”}

Information on your n8n setup

  • n8n version: 2.11.2
  • Database (default: SQLite): SQLite
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app): docker
1 Like

Hi @6xS0beit

I think this is known n8n bug

Workaround if you control the Burp MCP server: add a JSON.parse on the seedUrls field before processing.

Workaround on the n8n side: replace the MCP Client Tool with a Code Tool that manually builds and sends the correct request to your Burp server. This bypasses the MCP Client entirely and gives you full control over serialization.

Yeah this is a known bug with the MCP Client node, it stringifies arrays before passing them to the tool. Theres open issues on GitHub for it but no fix yet. Your best bet is to swap the MCP Client for a Code Tool node where you manually build the JSON payload and send it to your Burp server yourself, that way you get full control over the serialization and can pass a proper array

Hi @6xS0beit Welcome!
Consider using a Strong model like GPT-5.1 and then create a solid system prompt that should make it work.

the model is deciding the value should be a string — so you need to tell it explicitly in the tool description that seedUrls must be a JSON array, not a string.

in your MCP tool description add something like: ”seedUrls”: array of strings (NOT a stringified array, e.g. [“``https://example.com``”]). models are very literal — if the description doesn’t say “array”, they’ll serialize it.

alternatively, add a note in the system prompt: “when passing arrays to tools, always use native JSON arrays, never stringify them.”

this bug is real and a classic example of why i still put a fallback around MCP Client nodes in production workflows. the Code Tool workaround is the right call — gives you full control over serialization. for security-related MCP integrations specifically, i’d recommend starting with an HTTP Request node and only using the MCP Client for simpler, well-documented servers.