Skip to content

fix(@ai-sdk/mcp): add resource_link content type to CallToolResultSchema#14928

Merged
aayush-kapoor merged 3 commits into
vercel:mainfrom
kagura-agent:fix/mcp-resource-link-schema
May 5, 2026
Merged

fix(@ai-sdk/mcp): add resource_link content type to CallToolResultSchema#14928
aayush-kapoor merged 3 commits into
vercel:mainfrom
kagura-agent:fix/mcp-resource-link-schema

Conversation

@kagura-agent
Copy link
Copy Markdown
Contributor

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

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
Comment thread packages/mcp/src/tool/types.ts Outdated
@aayush-kapoor aayush-kapoor added the backport Admins only: add this label to a pull request in order to backport it to the prior version label May 4, 2026
@aayush-kapoor aayush-kapoor self-assigned this May 4, 2026
Copy link
Copy Markdown
Collaborator

@aayush-kapoor aayush-kapoor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bot comment

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.
@kagura-agent
Copy link
Copy Markdown
Contributor Author

Updated — name is now required in ResourceLinkContentSchema, matching the MCP 2025-11-25 schema (name, type, and uri are all required). Thanks for flagging this!

@aayush-kapoor aayush-kapoor merged commit b79094c into vercel:main May 5, 2026
31 of 34 checks passed
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>
@github-actions github-actions Bot removed the backport Admins only: add this label to a pull request in order to backport it to the prior version label May 5, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 5, 2026

✅ 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>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 5, 2026

🚀 Published in:

Package Version
ai 7.0.0-canary.121
@ai-sdk/alibaba 2.0.0-canary.42
@ai-sdk/amazon-bedrock 5.0.0-canary.51
@ai-sdk/angular 3.0.0-canary.121
@ai-sdk/anthropic 4.0.0-canary.46
@ai-sdk/assemblyai 3.0.0-canary.35
@ai-sdk/azure 4.0.0-canary.49
@ai-sdk/baseten 2.0.0-canary.40
@ai-sdk/black-forest-labs 2.0.0-canary.34
@ai-sdk/bytedance 2.0.0-canary.35
@ai-sdk/cerebras 3.0.0-canary.40
@ai-sdk/cohere 4.0.0-canary.36
@ai-sdk/deepgram 3.0.0-canary.34
@ai-sdk/deepinfra 3.0.0-canary.40
@ai-sdk/deepseek 3.0.0-canary.36
@ai-sdk/elevenlabs 3.0.0-canary.34
@ai-sdk/fal 3.0.0-canary.34
@ai-sdk/fireworks 3.0.0-canary.40
@ai-sdk/gateway 4.0.0-canary.71
@ai-sdk/gladia 3.0.0-canary.34
@ai-sdk/google 4.0.0-canary.53
@ai-sdk/google-vertex 5.0.0-canary.72
@ai-sdk/groq 4.0.0-canary.37
@ai-sdk/huggingface 2.0.0-canary.40
@ai-sdk/hume 3.0.0-canary.34
@ai-sdk/klingai 4.0.0-canary.35
@ai-sdk/langchain 3.0.0-canary.121
@ai-sdk/llamaindex 3.0.0-canary.121
@ai-sdk/lmnt 3.0.0-canary.34
@ai-sdk/luma 3.0.0-canary.34
@ai-sdk/mcp 2.0.0-canary.41
@ai-sdk/mistral 4.0.0-canary.38
@ai-sdk/moonshotai 3.0.0-canary.40
@ai-sdk/open-responses 2.0.0-canary.36
@ai-sdk/openai 4.0.0-canary.49
@ai-sdk/openai-compatible 3.0.0-canary.40
@ai-sdk/otel 1.0.0-canary.67
@ai-sdk/perplexity 4.0.0-canary.37
@ai-sdk/prodia 2.0.0-canary.37
@ai-sdk/provider-utils 5.0.0-canary.33
@ai-sdk/react 4.0.0-canary.121
@ai-sdk/replicate 3.0.0-canary.35
@ai-sdk/revai 3.0.0-canary.35
@ai-sdk/rsc 3.0.0-canary.122
@ai-sdk/svelte 5.0.0-canary.121
@ai-sdk/togetherai 3.0.0-canary.40
@ai-sdk/valibot 3.0.0-canary.33
@ai-sdk/vercel 3.0.0-canary.40
@ai-sdk/voyage 1.0.0-canary.7
@ai-sdk/vue 4.0.0-canary.121
@ai-sdk/workflow 1.0.0-canary.36
@ai-sdk/xai 4.0.0-canary.53

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.

@ai-sdk/mcp: CallToolResultSchema rejects resource_link content parts with zod ≥ 4.4.x

2 participants