fix: pass tool annotations to McpServer.tool() before the callback - #267
Open
vishalhabib99 wants to merge 1 commit into
Open
vishalhabib99 wants to merge 1 commit into
vishalhabib99 wants to merge 1 commit into
Conversation
idosal#210 added readOnlyHint/destructiveHint annotations, but they were passed after the callback, wrapped in { annotations }. McpServer.tool() only reads annotations between paramsSchema and the callback, so the trailing argument was ignored and tools/list returned no annotations. Fixes idosal#266 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
VOUCHAVOUCHA is currently in early access and is not enabled for this repository yet. To request access, contact @idosal. VOUCHA has not added a comprehension check to this PR. |
This branch has not been deployed
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 #266.
#210 added
readOnlyHint: true/destructiveHint: falseto the tools, but the live server doesn't return them.src/index.tspassed them after the callback, wrapped in{ annotations }. In the locked SDK (1.11.2),McpServer.tool()only reads annotations betweenparamsSchemaand the callback, then treatsrest[0]as the callback, so the trailing argument was silently dropped.This passes the annotations object itself, in the position the SDK expects (
tool(name, description, paramsSchema, annotations, cb), an overload in the 1.11.2 type definitions). Tools without annotations are registered exactly as before.Tested against
@modelcontextprotocol/sdk@1.11.2: tools registered both ways, then listed through a realClientoverInMemoryTransport:I didn't run the Worker end to end (
wrangler dev), so a quicktools/listagainst a preview deploy would confirm it live.Why it matters: without annotations, clients fall back to the spec defaults (
readOnlyHint: false,destructiveHint: true), so cautious hosts treat every documentation fetch as potentially destructive and may ask for approval on each call.🤖 Generated with Claude Code