Problem building ChatGPT-compatible MCP server in n8n — results wrapped in brackets

Hi everyone,

I’ve been experimenting with building a ChatGPT-compatible MCP server in n8n, but I’ve run into an annoying issue.

I’m following the official MCP docs here:
:backhand_index_pointing_right: https://platform.openai.com/docs/mcp

According to the spec, the MCP server must support search and fetch. A correct search response should look like this:

{
  "content": [
    {
      "type": "text",
      "text": "{\"results\":[{\"id\":\"doc-1\",\"title\":\"...\",\"url\":\"...\"}]}"
    }
  ]
}

Here’s my setup so far:

  • I’ve built an MCP server in n8n.

  • The search and fetch tools each point to separate n8n workflows.

The problem:
The MCP server ends up wrapping the result from the tools with [ and ], so ChatGPT receives it as a nested array. That breaks functionality in the ChatGPT MCP client.

I can’t figure out how to get n8n to just return the tool result as is, without this extra wrapping.

Has anyone tried something similar, or know a way around this bracket-wrapping behavior in n8n?

Same problem here

Maybe using a Code node or a Set node I think it can handle it as well.

‘const output = ;

for (const item of items) {
// Access the content array
if (Array.isArray(item.json.content)) {
for (const contentItem of item.json.content) {
// If the text field contains stringified JSON, parse it
if (contentItem.type === “text” && contentItem.text) {
try {
const parsedData = JSON.parse(contentItem.text);
output.push({ json: parsedData });
} catch (e) {
// If parsing fails, return the text as is
output.push({ json: { text: contentItem.text } });
}
}
}
}
}

return output;’