-
Notifications
You must be signed in to change notification settings - Fork 712
feat(mcp): Add WithAny for flexible tool properties #618
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Introduces `mcp.WithAny`, a new tool option that allows defining a property of `any` type. This is useful for creating tools that can accept a variety of data structures for a given parameter. - `mcp.WithAny` function: A new WithAny function has been added to to support properties of any type in tool schemas. This allows for more flexible tool definitions where a property can accept a string, number, boolean, object, slice, etc. - Testing: `TestToolWithAny`, has been introduced ensure the `WithAny` functionality is working correctly. The tests cover various data types to validate that the schema is correctly generated and that arguments are properly parsed. - Example Usage: The `typed_tools`` example has been updated to demonstrate how to use `mcp.WithAny`. This includes adding a new field of type any to the arguments struct and updating the tool handler to process the new field
WalkthroughThis PR adds support for schema-less "any" type tool arguments to the mcp-go SDK. It introduces a new Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes The PR introduces a straightforward new function following established patterns (mirroring Possibly related PRs
Suggested labels
Suggested reviewers
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 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 |
|
@coderabbitai generate docstrings |
✅ Actions performedInitiated docstring generation; will generate only if new commits exist. |
|
Note Docstrings generation - SUCCESS |
Docstrings generation was requested by @otaviof. * #618 (comment) The following files were modified: * `examples/typed_tools/main.go` * `mcp/tools.go`
|
Apologies, I didn't know CodeRabbit would create yet another PR directly. 🫥 |
* 📝 Add docstrings to `issue-345-withany` Docstrings generation was requested by @otaviof. * #618 (comment) The following files were modified: * `examples/typed_tools/main.go` * `mcp/tools.go` * Update tools.go --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: Ed Zynda <[email protected]>
Description
Introduces
mcp.WithAny(), a new tool option that allows defining a property ofanyGolang type. This is useful for creating tools that can accept a variety of data structures for a given parameter.Fixes #345
Type of Change
Checklist
MCP Spec Compliance
Summary by CodeRabbit