Merged
Conversation
Add support for MCP ToolAnnotations on SDK tools, allowing developers to specify tool metadata hints (readOnlyHint, destructiveHint, idempotentHint, openWorldHint) via the @tool decorator. Changes: - Add optional `annotations` parameter to `@tool` decorator and `SdkMcpTool` dataclass - Pass annotations through to MCP Tool objects in create_sdk_mcp_server - Include annotations in JSONRPC tools/list responses (only when set) - Re-export `ToolAnnotations` from mcp.types for convenience - Add tests for annotation storage, MCP flow-through, and JSONRPC serialization Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
chrislloyd
approved these changes
Feb 5, 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
annotationsparameter to the@tooldecorator andSdkMcpTooldataclass, acceptingToolAnnotationsfrom the MCP types libraryToolobjects increate_sdk_mcp_serverand include them in JSONRPCtools/listresponses (only when set, omitted whenNone)ToolAnnotationsfrom the top-level package for convenienceTest plan
test_tool_annotations- Verifies annotations are stored onSdkMcpToolinstances and flow through the MCPlist_toolshandlertest_tool_annotations_in_jsonrpc- Verifies annotations are correctly serialized in JSONRPCtools/listresponses and omitted when not settest_sdk_mcp_integration.pypassruff checkandruff formatpassmypyhas no new errors (pre-existing issues only)Changelog
@tooldecorator's newannotationsparameter, allowing developers to specify metadata hints likereadOnlyHint,destructiveHint,idempotentHint, andopenWorldHintToolAnnotationsfromclaude_agent_sdkfor convenience🤖 Generated with Claude Code (0% 3-shotted by claude)