Repository navigation
fix(mcp): accept camelCase argument names agents copy from the REST API - #135
Merged
Merged
Conversation
Agents send postId, accountId, contentType, mediaItems, dateFrom: the names the REST API and docs use. Every MCP tool takes snake_case, so pydantic rejected several hundred calls a day from 100+ users (Axiom zernio-mcp, posts_get_post alone ~800/week). ArgumentNamesMiddleware renames a key the tool does not take when, ignoring case, underscores and hyphens, it names exactly one parameter the call did not also pass. An explicit snake_case value is never overwritten and unknown keys still fail validation. Calls already in snake_case skip the lookup; parameter sets are cached per tool. FastMCP re-runs the middleware for the tool call_tool dispatches, so proxied arguments are covered; call_tool also takes tool_name for name. Registered on both the main and ChatGPT servers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ll cases postId and PostID together used to rename the first and reject the second; now neither is renamed, so the error names both. Tests now cover the fast path skipping the tool lookup, nested keys reaching the API untouched, and tools with camelCase or colliding parameters (none exist in Zernio today). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Agents send the camelCase names that the Zernio REST API and docs use, but every MCP tool takes snake_case, so pydantic rejects the call as
InvalidArgumentsbefore it reaches the API. Axiom (zernio-mcp, fieldinvalid_arguments) shows ~550 failed calls a day from 100+ users, at a steady rate (chronic, not a regression), from Claude, Cursor, ChatGPT, codex and Executor. Last 24 h, for example:posts_get_postpostIdposts_getpostIdcall_tooltool_namemedia_get_media_presigned_urlcontentTypemessages_get_inbox_conversation_messagesconversationId,accountIdmessages_list_inbox_conversationsaccountIdcomments_get_inbox_post_commentspostId,accountIdposts_create_postmediaItems,scheduledForposts_list_postsdateFrom,dateToHow it works
ArgumentNamesMiddleware(src/late/mcp/middleware/argument_names.py) is anon_call_toolmiddleware registered on the main server and the ChatGPT server.-passes through untouched, with no schema lookup. That's nearly every correct call._and-ignored. It renames the key only if that matches exactly one parameter that the call did not also pass and no other key claims.call_toolalso acceptstool_nameforname, through an explicit per-tool alias table.call_tooldispatches, so arguments proxied throughcall_toolare covered without extra code.ToolGuidanceMiddleware(which readscall_tool'sname) and outsideToolTelemetryMiddleware, so telemetry records the arguments the tool actually ran with.Deliberately not renamed
post_idandpostIdare sent, the call is rejected exactly as before.postId+PostID): neither is renamed; the error names both.postIdentifier) are left alone, so the normal validation error still fires.platforms[].accountId,media_items[].altText) are untouched. Those dicts go to the API verbatim and the API expects camelCase there.Tests
tests/test_mcp_camelcase_arguments.py:posts_get_post(postId=…)→post_id, direct and viacall_toolmessages_get_inbox_conversation_messages(conversationId, accountId, sortOrder)→ all renamedcall_tool(tool_name="posts_get_post", arguments={"postId": …})→nameandpost_idpost_id="A"+postId="B"→ rejected, API not calledpostIdentifier→ normal validation errorposts_create_postwithplatforms=[{"accountId": …}]→ nested key sent to the API asaccountIdpostId+PostID→ neither renamed, error names both, API not calledget_post(postId=…)(intests/test_chatgpt_server.py)Plus body field
contentTypeonmedia_get_media_presigned_url, and pinnedposts_get(postId=…).Checks
pytest tests→ 3842 passed, 44 skippedruff check src tests→ All checks passed!mypy src --ignore-missing-imports→ Success: no issues found in 168 source files🤖 Generated with Claude Code