-
Notifications
You must be signed in to change notification settings - Fork 718
tools: add WithObject and WithArray to supplement type definition utility #47
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
WalkthroughThis update introduces multiple new functions in the Changes
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
🔇 Additional comments (14)
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
mcp/tools.go (1)
371-486: Overall implementation addresses the PR objectives wellThe additions effectively extend the schema capabilities to support complex data structures like objects and arrays, addressing the limitation mentioned in the PR objectives. The implementation is consistent with the existing codebase patterns and follows JSON Schema standards.
A potential enhancement could be to add some example usage in the function comments to make it clearer how to use these new functions together, especially for complex nested structures.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
mcp/tools.go(1 hunks)
🔇 Additional comments (9)
mcp/tools.go (9)
371-396: Implementation of WithObject looks goodThis function extends the schema capabilities by allowing you to define object properties, following the same pattern as the existing
WithString,WithNumber, andWithBooleanfunctions. It correctly initializes an empty properties map and handles the "required" attribute properly.
398-422: Implementation of WithArray looks goodThe
WithArrayfunction complementsWithObjectand follows the same established pattern. It correctly handles the array type and the required attribute logic.
424-429: Properties function implementation is correctThis function allows defining the properties for an object schema, which is essential for working with object types.
431-437: AdditionalProperties implementation is flexible and correctUsing
interface{}as the parameter type is appropriate here since JSON Schema supports both boolean values and schema objects for additionalProperties.
439-451: MinProperties and MaxProperties implementations look goodThese functions correctly implement the corresponding JSON Schema validation keywords for objects.
453-458: PropertyNames implementation is correctThis function appropriately sets up the schema for property names validation.
460-465: Items implementation is correct and flexibleThe use of
interface{}as the parameter type allows for both single schema and tuple validation approaches in JSON Schema.
467-479: MinItems and MaxItems implementations look goodThese functions correctly implement the corresponding JSON Schema validation keywords for arrays.
481-486: UniqueItems implementation is correctThis function appropriately handles the uniqueItems constraint for arrays.
|
@ezynda3 hi May I know how is this going? MCP is cooking, we gophers need also catch up, a better library can boost go MCP! |
|
@xhd2015 would you mind adding one or two tests showing that this new code works as intended? |
|
Will update soon |
|
@ezynda3 hi please kindly review, thanks! |
The problem: current With* only provides basic strings and numbers, which is insufficient for practical usage.
In my program, I need to pass an
args []stringto the server.Summary by CodeRabbit
New Features
Tests