-
Notifications
You must be signed in to change notification settings - Fork 679
fix: tool annotation #165
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
fix: tool annotation #165
Conversation
WalkthroughThe changes introduce enhancements to the MCP client's test suite by adding and validating tool annotations, including multiple hint fields. The test now asserts the presence and correctness of annotation metadata in tool definitions. Additionally, the Changes
Possibly related PRs
Tip ⚡💬 Agentic Chat (Pro Plan, General Availability)
✨ Finishing Touches
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. 🪧 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)
client/sse_test.go (1)
109-119
: The annotation verification test could be improved with better error messages.The test correctly verifies all annotation fields, but the error message is generic and doesn't indicate which specific annotation field failed to match the expected value.
Consider improving the error message to specify which annotation field failed:
- t.Errorf("The annotations of the tools are invalid") + t.Errorf("Tool annotations mismatch: got Title=%q, ReadOnlyHint=%v, DestructiveHint=%v, IdempotentHint=%v, OpenWorldHint=%v", + testToolAnnotations.Title, + testToolAnnotations.ReadOnlyHint, + testToolAnnotations.DestructiveHint, + testToolAnnotations.IdempotentHint, + testToolAnnotations.OpenWorldHint)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
client/sse_test.go
(2 hunks)mcp/tools.go
(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
client/sse_test.go (1)
mcp/tools.go (3)
WithToolAnnotation
(193-197)ToolAnnotation
(116-127)Title
(221-225)
🔇 Additional comments (3)
mcp/tools.go (1)
105-105
: Properly includes annotations field in JSON output.This change ensures that the
Annotations
field of aTool
is included in the JSON output during marshaling, which is necessary for serializing tool annotation metadata. This is a critical fix to match the intended behavior.client/sse_test.go (2)
28-34
: LGTM! The tool annotation is properly configured with multiple hint fields.The test now correctly initializes a tool with specific annotation metadata that will be used to verify the serialization behavior.
105-105
: Good improvement to capture the ListTools result for validation.Assigning the result to
toolListResult
enables subsequent validation of the tool annotations.
if toolListResult == nil || len((*toolListResult).Tools) == 0 { | ||
t.Errorf("Expected one tool") | ||
} | ||
testToolAnnotations := (*toolListResult).Tools[0].Annotations |
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.
What prevents you from using proper asserts to check for all the values?
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.
Align with the previous coding style.
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.
I think it is bad practice. On error you don't know what is wrong but understand your standpoint.
fix for client can not get tool annotation, and add some tests
Summary by CodeRabbit