fix(@ai-sdk/mcp): add resource_link content type to CallToolResultSchema#14928
Merged
aayush-kapoor merged 3 commits intoMay 5, 2026
Merged
Conversation
The MCP spec defines resource_link as a content type variant, but CallToolResultSchema and PromptMessageSchema only accepted text, image, and embedded resource. With zod >= 4.4.x (within the declared peer-dep range), the missing union arm causes hard rejection when an MCP server returns resource_link content parts. Add ResourceLinkContentSchema to both unions. Fixes vercel#14925
aayush-kapoor
approved these changes
May 4, 2026
Per the MCP 2025-11-25 schema, 'name' is a required field on resource_link content (alongside 'type' and 'uri'). Update the Zod schema to match.
Contributor
Author
|
Updated — |
aayush-kapoor
approved these changes
May 5, 2026
github-actions Bot
added a commit
that referenced
this pull request
May 5, 2026
…ema (#14928) ## Summary Adds the MCP spec's `resource_link` content type to `CallToolResultSchema` and `PromptMessageSchema` unions. ## Problem `CallToolResultSchema` only accepts `text`, `image`, and `resource` (embedded) content types. The MCP specification defines a fourth variant — `resource_link` — which servers may return. With zod ≥ 4.4.x (within the declared peer-dep range `^3.25.76 || ^4.1.8`), unknown discriminated union variants are hard-rejected, causing `Failed to parse server response` errors from `callTool()`. ## Fix - Add `ResourceLinkContentSchema` (`{ type: 'resource_link', uri, name?, description?, mimeType? }`) - Include it in `CallToolResultSchema.content` array union - Include it in `PromptMessageSchema.content` union ## Testing The schema change is purely additive (new union variant). Existing tests pass unchanged since they don't produce `resource_link` content. The fix allows servers that do return `resource_link` parts to work correctly. Closes #14925 --------- Co-authored-by: Aayush Kapoor <83492835+aayush-kapoor@users.noreply.github.com>
Contributor
|
✅ Backport PR created: #15008 |
aayush-kapoor
added a commit
that referenced
this pull request
May 5, 2026
…lResultSchema (#15008) This is an automated backport of #14928 to the release-v6.0 branch. FYI @kagura-agent Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Aayush Kapoor <83492835+aayush-kapoor@users.noreply.github.com>
Contributor
|
🚀 Published in:
|
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
Adds the MCP spec's
resource_linkcontent type toCallToolResultSchemaandPromptMessageSchemaunions.Problem
CallToolResultSchemaonly acceptstext,image, andresource(embedded) content types. The MCP specification defines a fourth variant —resource_link— which servers may return. With zod ≥ 4.4.x (within the declared peer-dep range^3.25.76 || ^4.1.8), unknown discriminated union variants are hard-rejected, causingFailed to parse server responseerrors fromcallTool().Fix
ResourceLinkContentSchema({ type: 'resource_link', uri, name?, description?, mimeType? })CallToolResultSchema.contentarray unionPromptMessageSchema.contentunionTesting
The schema change is purely additive (new union variant). Existing tests pass unchanged since they don't produce
resource_linkcontent. The fix allows servers that do returnresource_linkparts to work correctly.Closes #14925