Skip to content

Conversation

Copy link

Copilot AI commented Nov 27, 2025

Description

n8n's remote HTTP MCP sends metadata fields (sessionId, action, chatInput, toolCallId) in tool arguments, causing Pydantic validation to fail with "Unexpected keyword argument" errors.

Changes

Core Fix

  • Parameter filtering monkey-patch: Filters arguments against function signature before Pydantic validation in FunctionTool.run
  • FastMCP upgrade: 2.10.5 → 2.13.1 for latest improvements

Testing

  • n8n compatibility tests: 4 integration tests validating tool calls with extra parameters
  • Test infrastructure fix: Cast Neo4j port to string in conftest.py for testcontainers compatibility

Example

# n8n sends this:
{
  "query": "MATCH (n) RETURN n",
  "sessionId": "abc-123",        # filtered out
  "action": "sendMessage",        # filtered out
  "chatInput": "show me data",    # filtered out
  "toolCallId": "tool-456"        # filtered out
}

# Tool receives only valid params:
{
  "query": "MATCH (n) RETURN n"
}

Type of Change

  • Bug fix
  • Project configuration change

Complexity

  • MEDIUM

Complexity: Monkey-patches FastMCP's validation layer to filter parameters. Duplicates some core method logic to maintain functionality after filtering.

How Has This Been Tested?

  • Integration tests (35 existing + 4 new n8n compatibility tests)
  • Manual tests

Checklist

  • Documentation has been updated
  • Integration tests have been updated
  • CHANGELOG.md updated if appropriate
Original prompt

i have an issue with using the cypher mcp server that has the following error when being queried by n8n using remote http mcp with the following error

System: You are a helpful assistant that is an expert at Cartography Neo4j Cypher queries. Assume the data requested is in the database \n\nFIRST Use your tools to research a proper query from the documents\n\nSECOND run the cypher for the results\nHuman: what cloudflare dns records are available\nAI: Calling Cartography Neo4j with input: {"sample_size":100,"tool":"get_neo4j_schema","id":"276a9908-a157-4eb3-bdf9-044c506220d4"}\nTool: [{"response":[{"type":"text","text":"4 validation errors for call[get_neo4j_schema]\nsessionId\n Unexpected keyword argument [type=unexpected_keyword_argument, input_value='197cdce49d30476c8aa3b74bb65aec4a', input_type=str]\n For further information visit https://errors.pydantic.dev/2.12/v/unexpected_keyword_argument\naction\n Unexpected keyword argument [type=unexpected_keyword_argument, input_value='sendMessage', input_type=str]\n For further information visit https://errors.pydantic.dev/2.12/v/unexpected_keyword_argument\nchatInput\n Unexpected keyword argument [type=unexpected_keyword_argument, input_value='what cloudflare dns records are available', input_type=str]\n For further information visit https://errors.pydantic.dev/2.12/v/unexpected_keyword_argument\ntoolCallId\n Unexpected keyword argument [type=unexpected_keyword_argument, input_value='276a9908-a157-4eb3-bdf9-044c506220d4', input_type=str]\n For further information visit https://errors.pydantic.dev/2.12/v/unexpected_keyword_argument"}]}]\nAI: Calling Cartography Neo4j with input: {"sample_size":100,"tool":"get_neo4j_schema","id":"e57d1db5-e6f6-401b-b94a-d6335fa12df8"}\nTool: [{"response":[{"type":"text","text":"4 validation errors for call[get_neo4j_schema]\nsessionId\n Unexpected keyword argument [type=unexpected_keyword_argument, input_value='197cdce49d30476c8aa3b74bb65aec4a', input_type=str]\n For further information visit https://errors.pydantic.dev/2.12/v/unexpected_keyword_argument\naction\n Unexpected keyword argument [type=unexpected_keyword_argument, input_value='sendMessage', input_type=str]\n For further information visit https://errors.pydantic.dev/2.12/v/unexpected_keyword_argument\nchatInput\n Unexpected keyword argument [type=unexpected_keyword_argument, input_value='what cloudflare dns records are available', input_type=str]\n For further information visit https://errors.pydantic.dev/2.12/v/unexpected_keyword_argument\ntoolCallId\n Unexpected keyword argument [type=unexpected_keyword_argument, input_value='e57d1db5-e6f6-401b-b94a-d6335fa12df8', input_type=str]\n For further information visit https://errors.pydantic.dev/2.12/v/unexpected_keyword_argument"}]}]


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits November 27, 2025 22:59
- Upgraded FastMCP from 2.10.5 to 2.13.1
- Implemented monkey-patch to filter extra parameters before validation
- Added comprehensive n8n compatibility tests
- Fixed conftest.py port type issue

Co-authored-by: egallis31 <18443524+egallis31@users.noreply.github.com>
Co-authored-by: egallis31 <18443524+egallis31@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix cypher mcp server query error in n8n Fix n8n HTTP MCP compatibility by filtering extra parameters before validation Nov 27, 2025
Copilot AI requested a review from egallis31 November 27, 2025 23:06
@egallis31 egallis31 closed this Dec 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants