Skip to content

feat: add MCP tool annotations support#551

Merged
ashwin-ant merged 1 commit intomainfrom
ashwin/add-tool-annotations-support
Feb 5, 2026
Merged

feat: add MCP tool annotations support#551
ashwin-ant merged 1 commit intomainfrom
ashwin/add-tool-annotations-support

Conversation

@ashwin-ant
Copy link
Collaborator

Summary

  • Add optional annotations parameter to the @tool decorator and SdkMcpTool dataclass, accepting ToolAnnotations from the MCP types library
  • Pass annotations through to MCP Tool objects in create_sdk_mcp_server and include them in JSONRPC tools/list responses (only when set, omitted when None)
  • Re-export ToolAnnotations from the top-level package for convenience

Test plan

  • test_tool_annotations - Verifies annotations are stored on SdkMcpTool instances and flow through the MCP list_tools handler
  • test_tool_annotations_in_jsonrpc - Verifies annotations are correctly serialized in JSONRPC tools/list responses and omitted when not set
  • All 8 tests in test_sdk_mcp_integration.py pass
  • ruff check and ruff format pass
  • mypy has no new errors (pre-existing issues only)

Changelog

  • Added support for MCP tool annotations via the @tool decorator's new annotations parameter, allowing developers to specify metadata hints like readOnlyHint, destructiveHint, idempotentHint, and openWorldHint
  • Re-exported ToolAnnotations from claude_agent_sdk for convenience

🤖 Generated with Claude Code (0% 3-shotted by claude)

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>
@ashwin-ant ashwin-ant requested a review from a team February 5, 2026 17:52
@ashwin-ant ashwin-ant merged commit 451f2f4 into main Feb 5, 2026
10 checks passed
@ashwin-ant ashwin-ant deleted the ashwin/add-tool-annotations-support branch February 5, 2026 18:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants