Skip to content

Conversation

@agcty
Copy link
Contributor

@agcty agcty commented Dec 9, 2025

Summary

Move @modelcontextprotocol/sdk from direct dependencies to peer dependencies, allowing consumers to control their own MCP SDK version.

Problem

Currently, @modelcontextprotocol/sdk is pinned as a direct dependency ("^1.23.0"). This causes issues for consumers using different MCP SDK versions:

  • Duplicate packages get installed
  • Type mismatches when consumers reference MCP types (Tool, Prompt, Resource, ServerCapabilities) from their own code
  • The agents package exposes MCP SDK types in its public API (e.g., MCPServersState, McpAgent.server)

Solution

  • @modelcontextprotocol/sdk: required peer dep (>=1.0.0)

Unlike the AI SDK packages where some are optional, MCP is a required peer dependency because:

  1. MCP functionality is core to the package (every Agent has this.mcp built-in)
  2. Types like MCPServersState and McpAgent are fundamental exports
  3. The McpAgent abstract class directly exposes McpServer | Server types

Breaking Changes

Consumers who don't already have @modelcontextprotocol/sdk installed will need to add it explicitly. However, anyone using MCP features is likely already interacting with MCP types.

Related to #42

🤖 Generated with Claude Code

Move `@modelcontextprotocol/sdk` from direct dependencies to peer
dependencies, allowing consumers to control their own MCP SDK version.

This prevents duplicate package installations when consumers use
different MCP SDK versions and ensures type compatibility for consumers
who reference MCP types (Tool, Prompt, Resource, ServerCapabilities)
from their own code.

- `@modelcontextprotocol/sdk`: required peer dep (>=1.0.0)

Related to discussion cloudflare#42

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@changeset-bot
Copy link

changeset-bot bot commented Dec 9, 2025

⚠️ No Changeset found

Latest commit: 1c2efb4

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@pkg-pr-new
Copy link

pkg-pr-new bot commented Dec 9, 2025

Open in StackBlitz

npm i https://pkg.pr.new/cloudflare/agents@724

commit: 1c2efb4

@whoiskatrin
Copy link
Contributor

@agcty don't merge it just yet, please

"x402": "^0.7.3"
},
"peerDependencies": {
"@modelcontextprotocol/sdk": ">=1.0.0",
Copy link
Contributor

Choose a reason for hiding this comment

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

because the mcp sdk does breaking changes in minors right now, I don't think we can actually guarantee this. not a great situation for us to be in unfortunately. we need to think through this.

tagging @mattzcarey for visibility

Copy link
Contributor

@threepointone threepointone left a comment

Choose a reason for hiding this comment

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

blocking this while we figure out what to do here

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.

3 participants