Skip to content

Conversation

mattzcarey
Copy link
Collaborator

@mattzcarey mattzcarey commented Oct 13, 2025

Adds custom RPC transport for MCP.

  • Core Implementation (packages/agents/src/mcp/rpc.ts) implements RPCClientTransport and RPCServerTransport with full JSON-RPC 2.0 validation, batch request support, and session management.

  • Agent Integration (packages/agents/src/index.ts) addRpcMcpServer() method to Agent class for connecting to MCP servers via RPC bindings.

  • McpAgent Support (packages/agents/src/mcp/index.ts) implements handleMcpMessage() with automatic transport recreation after hibernation.

  • Example (examples/mcp-rpc-transport/) showing Agent calling McpAgent via RPC with counter tool.

  • Documentation (docs/mcp-transports.md) guide covering all three transports (Streamable HTTP, SSE, RPC) with step-by-step setup.

  • Tests (packages/agents/src/tests/mcp/transports/rpc.test.ts)

Closes #548

Copy link

changeset-bot bot commented Oct 13, 2025

⚠️ No Changeset found

Latest commit: cae6c3e

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

Copy link

pkg-pr-new bot commented Oct 13, 2025

Open in StackBlitz

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

commit: cae6c3e

@mattzcarey mattzcarey marked this pull request as ready for review October 14, 2025 09:30
@mattzcarey mattzcarey marked this pull request as draft October 14, 2025 10:23
@mattzcarey mattzcarey marked this pull request as ready for review October 16, 2025 14:29
@mattzcarey mattzcarey marked this pull request as draft October 17, 2025 16:48
@mattzcarey mattzcarey marked this pull request as ready for review October 17, 2025 19:05
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.

feat: define Agent and McpAgent in the same worker

2 participants