refactor: flatten tool args, keep responses as pydantic models#47
Merged
Conversation
MCP tool methods now take their arguments as flat parameters (e.g. name: str) rather than a single wrapper Pydantic model (request: HelloRequest). Responses stay as Pydantic models so the tool still exposes an explicit typed output schema. Flat args surface each parameter as its own field in the MCP tool schema, which is how clients expect to call tools. Wrapping args in a single request model nests everything under a "request" field, which is noisier for callers and less idiomatic for MCP. - Drop HelloRequest from api/models.py; keep HelloResponse. - Update hello() in api/tools.py to take name: str directly. - Update the Implementing New Tools README example to match, and add a Key Points note spelling out the flat-args / pydantic- response convention.
glageju
approved these changes
Apr 23, 2026
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.
Summary
MCP tools take flat arguments (e.g.
name: str) instead of a single wrapper Pydantic model (request: HelloRequest). Responses are still Pydantic models so the output schema stays explicit and typed.Why
Flat args surface each parameter as its own field in the MCP tool schema, which is how clients expect to call tools. A single wrapper model nests everything under a
requestfield, which is noisier for callers and less idiomatic for MCP.Changes
HelloRequestfromapi/models.py; keepHelloResponse.hello()inapi/tools.pynow takesname: strdirectly.Test plan
task linttask typechecktask test— 11 unit tests pass, 3 integration tests skipped