fix: accept camelCase tool arguments (calendarId, timeMin, ...) via normalization middleware - #921
Open
Bortlesboat wants to merge 1 commit into
Open
Conversation
Callers that mirror Google API field names (calendarId, timeMin, maxResults) fail schema validation because every tool declares snake_case parameters with additionalProperties: false. Add a FastMCP middleware that renames a camelCase argument to its snake_case equivalent when the tool declares the snake_case parameter and the caller did not pass it explicitly. Fixes taylorwilsdon#918
Contributor
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughAdds ChangesCamelCase argument handling
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant Client
participant CamelCaseArgumentsMiddleware
participant FastMCPToolSchema
participant Tool
Client->>CamelCaseArgumentsMiddleware: Submit tool arguments
CamelCaseArgumentsMiddleware->>FastMCPToolSchema: Read declared properties
FastMCPToolSchema-->>CamelCaseArgumentsMiddleware: Return parameter names
CamelCaseArgumentsMiddleware->>Tool: Forward normalized arguments
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Fixes #918
Every tool declares snake_case parameters with
additionalProperties: false, so callers that mirror the Google API field names (calendarId,timeMin,maxResults, ...) fail schema validation before the request ever reaches Google — including the Hermes google-workspace skill wrapper mentioned in the issue.This adds a small FastMCP middleware on the
call_toolpath that renames an argument key only when all of these hold:Ambiguous input (two spellings normalizing to the same parameter, e.g.
iCalUid+iCalUID) is left untouched so validation still rejects it instead of silently picking a winner. Tools that genuinely declare camelCase params are unaffected, and unknown arguments keep failing exactly as before.Went with the middleware so it covers all tools at once rather than aliasing the calendar ones — happy to scope it down to explicit calendar aliases instead if you'd rather keep argument handling strict.
Tested with the reproduction from #918 through an in-memory client — 8 tests in
tests/core/test_camel_case_middleware.pycovering the camelCase path, snake_case passthrough, explicit-key precedence, collisions, declared-camelCase params, and unknown tools/args.ruff checkandruff formatclean;tests/core+tests/gcalendarpass locally.Summary by CodeRabbit
New Features
Tests