MCP Client Tool with Google Gemini: "Bad Request - Invalid JSON payload" Error

I’m getting a [400 Bad Request] Invalid JSON payload received. Unknown name “type” at 'tools[0].function_declaration.parameters error when using the MCP Client Tool with Google Gemini 2.5 Flash model in n8n.

Setup Details
n8n Version: 1.107.4
Nodes Used:
MCP Client Tool (v1.1)
Google Gemini Chat Model (v1)
AI Agent (v2.2)
Superset-mcp Server: Custom Python server using FastMCP
Endpoint: SSE connection
Error Details
When I ask the AI Agent to “list all the tools”, the workflow fails with:
[GoogleGenerativeAI Error]: Error fetching from https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash:generateContent:
[400 Bad Request] Invalid JSON payload received. Unknown name “type” at 'tools[0].function_declaration.parameters field is not an object

Please share your workflow
{
“nodes”: [
{
“parameters”: {
“public”: true,
“options”: {}
},
“id”: “a245eadb-4871-4120-a1ba-090e0ade504b”,
“name”: “When chat message received”,
“type”: “@n8n/n8n-nodes-langchain.chatTrigger”,
“position”: [
-400,
-16
],
“webhookId”: “52f72bbb-7d9e-443a-bb9f-75c43ef78e64”,
“typeVersion”: 1.3,
“alwaysOutputData”: false
},
{
“parameters”: {
“promptType”: “define”,
“text”: “={{ $json.chatInput }}”,
“options”: {
“systemMessage”: “=You are an AI assistant with access to Superset tools via mcp client tool. When listing tools, first call the mcp client tool to see what’s available, then provide a formatted list. Handle any schema errors gracefully.”
}
},
“id”: “aeb41737-df95-46c7-ab45-5bf3c2ddebd1”,
“name”: “AI Agent”,
“type”: “@n8n/n8n-nodes-langchain.agent”,
“position”: [
-96,
-16
],
“typeVersion”: 2.2
},
{
“parameters”: {
“options”: {
“temperature”: 0.7
}
},
“id”: “e367cc4c-aed6-4c28-b4d5-0d06309d0235”,
“name”: “Google Gemini Chat Model”,
“type”: “@n8n/n8n-nodes-langchain.lmChatGoogleGemini”,
“position”: [
-256,
192
],
“typeVersion”: 1,
“credentials”: {
“googlePalmApi”: {
“id”: “jCSpZhiYIwOXgUDx”,
“name”: “Google Gemini(PaLM) Api account 2”
}
}
},
{
“parameters”: {
“sessionIdType”: “customKey”,
“sessionKey”: “={{ $json.sessionId }}”,
“contextWindowLength”: 20
},
“id”: “33270cb3-4ed9-4067-9909-ebc2bbf4b56b”,
“name”: “Simple Memory”,
“type”: “@n8n/n8n-nodes-langchain.memoryBufferWindow”,
“position”: [
-96,
208
],
“typeVersion”: 1.3
},
{
“parameters”: {
“endpointUrl”: “http://10.0.16.108:8089/sse”
},
“id”: “bd696515-5d09-4ffd-8337-b7f509875b76”,
“name”: “MCP Client”,
“type”: “@n8n/n8n-nodes-langchain.mcpClientTool”,
“position”: [
80,
208
],
“typeVersion”: 1.1
}
],
“connections”: {
“When chat message received”: {
“main”: [
[
{
“node”: “AI Agent”,
“type”: “main”,
“index”: 0
}
]
]
},
“Google Gemini Chat Model”: {
“ai_languageModel”: [
[
{
“node”: “AI Agent”,
“type”: “ai_languageModel”,
“index”: 0
}
]
]
},
“Simple Memory”: {
“ai_memory”: [
[
{
“node”: “AI Agent”,
“type”: “ai_memory”,
“index”: 0
}
]
]
},
“MCP Client”: {
“ai_tool”: [
[
{
“node”: “AI Agent”,
“type”: “ai_tool”,
“index”: 0
}
]
]
}
},
“pinData”: {},
“meta”: {
“templateCredsSetupCompleted”: true,
“instanceId”: “222b2f481627b103dedd725016ff99afa115f2d6484c23426f38ae8f5c9d3147”
}
}

Share the output returned by the last node

Bad request - please check your parameters
[GoogleGenerativeAI Error]: Error fetching from https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash:generateContent: [400 Bad Request] Invalid JSON payload received. Unknown name “type” at ‘tools[0].function_declarations[3].parameters.properties[0].value’: Proto field is not repeating, cannot start list. Invalid JSON payload received. Unknown name “type” at ‘tools[0].function_declarations[3].parameters.properties[1].value’: Proto field is not repeating, cannot start list. [{“@type”:“type.googleapis.com/google.rpc.BadRequest",“fieldViolations”:[{“field”:“tools[0].function_declarations[3].parameters.properties[0].value”,“description”:"Invalid JSON payload received. Unknown name “type” at ‘tools[0].function_declarations[3].parameters.properties[0].value’: Proto field is not repeating, cannot start list.”},{“field”:“tools[0].function_declarations[3].parameters.properties[1].value”,“description”:“Invalid JSON payload received. Unknown name “type” at ‘tools[0].function_declarations[3].parameters.properties[1].value’: Proto field is not repeating, cannot start list.”}]}]

Hi @Ruchitha_Nataraja
Welcome to the community
The error occurs because Gemini doesn’t allow the type field to be in a list; it expects properties to be an object, not an array. To fix this, make sure that properties is structured as an object with key-value pairs rather than as a list. For example, instead of using an array for properties, use an object like this: "properties": { "key1": { "type": "string", "value": "example" } }. This will match the format Gemini expects and resolve the error.

Thank you @Msquare_Automation for replying

I am running a superset-mcp server that uses FastMCP, and on top of that I wrote code to create an SSE endpoint to connect to the MCP Client Tool in n8n.

My flow in n8n looks like this:

  1. Chat Message

  2. AI Agent: Google Gemini (gemini-2.5-flash)

  3. MCP Client Tool → connected via SSE endpoint

The MCP server exposes Superset-related tools (list datasets, create charts, etc.).


Problem

The Gemini node in n8n keeps throwing this error when trying to use the tools:

Bad request - please check your parameters
[GoogleGenerativeAI Error]: Invalid JSON payload received.
Unknown name "type" at 'tools[0].function_declarations[3].parameters.properties[0].value':
Proto field is not repeating, cannot start list.

From what I’ve read, the issue is that Gemini expects properties in a tool schema to be an object (map of key/value), not an array.

What is the correct way to fix this in the MCP server code?

The example tool it is there like this in superset-mcp server
@mcp.tool()

requires_auth

handle_api_errors

async def superset_dashboard_list(ctx: Context) → Dict[str, Any]:

“”"

Get a list of dashboards from Superset

Makes a request to the /api/v1/dashboard/ endpoint to retrieve all dashboards

the current user has access to view. Results are paginated.

Returns:

A dictionary containing dashboard data including id, title, url, and metadata

“”"

return await make_api_request(ctx, “get”, “/api/v1/dashboard/”)

If i do through code change can you suggest what change i need to do

{
“nodes”: [
{
“parameters”: {
“public”: true,
“options”: {}
},
“id”: “a245eadb-4871-4120-a1ba-090e0ade504b”,
“name”: “When chat message received”,
“type”: “@n8n/n8n-nodes-langchain.chatTrigger”,
“position”: [
-400,
-16
],
“webhookId”: “52f72bbb-7d9e-443a-bb9f-75c43ef78e64”,
“typeVersion”: 1.3,
“alwaysOutputData”: false
},
{
“parameters”: {
“options”: {
“systemMessage”: “==You are an AI assistant with access to Superset tools via mcp client tool. When listing tools, first call the mcp client tool to see what’s available, then provide a formatted list. Handle any schema errors gracefully. REMEMBER TO ALWAYS USE format_final_response at the end of every response.”
}
},
“id”: “aeb41737-df95-46c7-ab45-5bf3c2ddebd1”,
“name”: “AI Agent”,
“type”: “@n8n/n8n-nodes-langchain.agent”,
“position”: [
-96,
-16
],
“typeVersion”: 2.2
},
{
“parameters”: {
“options”: {
“temperature”: 0.7
}
},
“id”: “e367cc4c-aed6-4c28-b4d5-0d06309d0235”,
“name”: “Google Gemini Chat Model”,
“type”: “@n8n/n8n-nodes-langchain.lmChatGoogleGemini”,
“position”: [
-272,
192
],
“typeVersion”: 1,
“credentials”: {
“googlePalmApi”: {
“id”: “jCSpZhiYIwOXgUDx”,
“name”: “Google Gemini(PaLM) Api account 2”
}
}
},
{
“parameters”: {
“sessionIdType”: “customKey”,
“sessionKey”: “={{ $json.sessionId }}”,
“contextWindowLength”: 20
},
“id”: “33270cb3-4ed9-4067-9909-ebc2bbf4b56b”,
“name”: “Simple Memory”,
“type”: “@n8n/n8n-nodes-langchain.memoryBufferWindow”,
“position”: [
-96,
208
],
“typeVersion”: 1.3
},
{
“parameters”: {
“endpointUrl”: “http://10.0.16.108:8089/sse”
},
“id”: “bd696515-5d09-4ffd-8337-b7f509875b76”,
“name”: “MCP Client”,
“type”: “@n8n/n8n-nodes-langchain.mcpClientTool”,
“position”: [
80,
208
],
“typeVersion”: 1.1
}
],
“connections”: {
“When chat message received”: {
“main”: [
[
{
“node”: “AI Agent”,
“type”: “main”,
“index”: 0
}
]
]
},
“Google Gemini Chat Model”: {
“ai_languageModel”: [
[
{
“node”: “AI Agent”,
“type”: “ai_languageModel”,
“index”: 0
}
]
]
},
“Simple Memory”: {
“ai_memory”: [
[
{
“node”: “AI Agent”,
“type”: “ai_memory”,
“index”: 0
}
]
]
},
“MCP Client”: {
“ai_tool”: [
[
{
“node”: “AI Agent”,
“type”: “ai_tool”,
“index”: 0
}
]
]
}
},
“pinData”: {},
“meta”: {
“templateCredsSetupCompleted”: true,
“instanceId”: “222b2f481627b103dedd725016ff99afa115f2d6484c23426f38ae8f5c9d3147”
}
}

I keep on getting the same error from the google gemini (gemini 2.5 flash) for the above n8n flow is there any thing i need to change through system prompt i need to change through code level itself , can any one please assist this above issue.

@Ruchitha_Nataraja
Could you share the workflow. the provided json is invalid

Here’s my n8n workflow JSON:

```json
{
“nodes”: [
{
“parameters”: {
“public”: true,
“options”: {}
},
“id”: “a245eadb-4871-4120-a1ba-090e0ade504b”,
“name”: “When chat message received”,
“type”: “@n8n/n8n-nodes-langchain.chatTrigger”,
“position”: [
-400,
-16
],
“webhookId”: “52f72bbb-7d9e-443a-bb9f-75c43ef78e64”,
“typeVersion”: 1.3,
“alwaysOutputData”: false
},
{
“parameters”: {
“options”: {
“systemMessage”: “=\nYou are the Superset MCP AI Agent. Your role is simple: when a user asks you for help, you must only call the MCP client tool to list all available tools and then return the list clearly.\n\n\n\n\nYour only goal is to list the tools exposed by the MCP server in mcp client tool when the user asks.\n\n\n\n### How I Work\n- I receive user input through n8n. \n- I call the MCP Client Tool with the “list_tools” request. \n- I return the names and descriptions of the tools to the user. \n\nImportant:\n- Do not attempt to execute tools other than “list_tools”. \n- If the user asks anything unrelated, politely explain that I can only list the tools right now. \n\n\n<output_format>\n- Respond in a friendly and clear tone. \n- Show the list of tools in bullet points with their names and short descriptions. \n- If no tools are available, return: “No tools found from MCP server.” \n</output_format>\n\n”
}
},
“id”: “aeb41737-df95-46c7-ab45-5bf3c2ddebd1”,
“name”: “AI Agent”,
“type”: “@n8n/n8n-nodes-langchain.agent”,
“position”: [
-96,
-16
],
“typeVersion”: 2.2
},
{
“parameters”: {
“options”: {
“temperature”: 0.3
}
},
“id”: “e367cc4c-aed6-4c28-b4d5-0d06309d0235”,
“name”: “Google Gemini Chat Model”,
“type”: “@n8n/n8n-nodes-langchain.lmChatGoogleGemini”,
“position”: [
-272,
192
],
“typeVersion”: 1,
“credentials”: {
“googlePalmApi”: {
“id”: “jCSpZhiYIwOXgUDx”,
“name”: “Google Gemini(PaLM) Api account 2”
}
}
},
{
“parameters”: {
“sessionIdType”: “customKey”,
“sessionKey”: “={{ $json.sessionId }}”,
“contextWindowLength”: 10
},
“id”: “33270cb3-4ed9-4067-9909-ebc2bbf4b56b”,
“name”: “Simple Memory”,
“type”: “@n8n/n8n-nodes-langchain.memoryBufferWindow”,
“position”: [
-96,
208
],
“typeVersion”: 1.3
},
{
“parameters”: {
“endpointUrl”: “http://:8089/sse”
},
“id”: “bd696515-5d09-4ffd-8337-b7f509875b76”,
“name”: “MCP Client”,
“type”: “@n8n/n8n-nodes-langchain.mcpClientTool”,
“position”: [
80,
208
],
“typeVersion”: 1.1
}
],
“connections”: {
“When chat message received”: {
“main”: [
[
{
“node”: “AI Agent”,
“type”: “main”,
“index”: 0
}
]
]
},
“Google Gemini Chat Model”: {
“ai_languageModel”: [
[
{
“node”: “AI Agent”,
“type”: “ai_languageModel”,
“index”: 0
}
]
]
},
“Simple Memory”: {
“ai_memory”: [
[
{
“node”: “AI Agent”,
“type”: “ai_memory”,
“index”: 0
}
]
]
},
“MCP Client”: {
“ai_tool”: [
[
{
“node”: “AI Agent”,
“type”: “ai_tool”,
“index”: 0
}
]
]
}
},
“pinData”: {},
“meta”: {
“templateCredsSetupCompleted”: true,
“instanceId”: “222b2f481627b103dedd725016ff99afa115f2d6484c23426f38ae8f5c9d3147”
}
}
```

can anyone please assist with this above error

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.