feat(mcp): preserve MCP tool annotations including readOnlyHint #10463
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
Preserve all MCP tool annotations (readOnlyHint, destructiveHint, idempotentHint, openWorldHint) when converting MCP tools to AI SDK tools.
Changes
Previously, only the
titleannotation was extracted and preserved from MCP servers. This PR adds support for passing through all five annotation fields defined in the MCP specification (2025-03-26):title- Human-readable tool titlereadOnlyHint- Tool doesn't modify its environmentdestructiveHint- Tool may perform destructive updatesidempotentHint- Repeated calls with same args have no additional effectopenWorldHint- Tool interacts with external entitiesImplementation
annotationsfield toTooltype definition in@ai-sdk/provider-utilsdynamicTool()function signature to accept annotations parameterlistToolsresponse to tool creation in MCP clientUse Cases
These annotations enable clients to:
Security Note
Per the MCP specification, these annotations are informational hints only and should not be used for security-critical decisions. The documentation explicitly states this caveat.
Testing
Related
🤖 Generated with Claude Code
Co-Authored-By: Claude [email protected]