Skip to content

Conversation

@threepointone
Copy link
Contributor

No description provided.

@changeset-bot
Copy link

changeset-bot bot commented Nov 18, 2025

🦋 Changeset detected

Latest commit: 3579d12

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
hono-agents Patch
agents Patch

Not sure what this means? Click here to learn what changesets are.

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

@claude
Copy link

claude bot commented Nov 18, 2025

Claude Code Review

MCP SDK Migration: 1.21.0 → 1.22.0

Issues Found

1. Type Safety: Missing as const in x402.ts

packages/agents/src/mcp/x402.ts:95-96, 131-132

The x402 integration inconsistently applies type literals. While outer objects use as const, inner content type fields don't:

return {
  isError: true,
  _meta: { "x402/error": payload },
  content: [{ type: "text", text: JSON.stringify(payload) }]  // Missing 'as const'
} as const;

This differs from the pattern used elsewhere (e.g., worker.ts:77, mcp-worker-authenticated/src/index.ts:46). Should be:

content: [{ type: "text" as const, text: JSON.stringify(payload) }]

2. Missing Test Coverage: x402 Integration

No dedicated test file exists for packages/agents/src/mcp/x402.ts despite handling critical payment flows:

  • Payment verification
  • Token decoding
  • Settlement logic
  • Client-side confirmation flows

The migration to registerTool API in this file is untested.

3. Breaking Change Uncommented

packages/agents/src/tests/worker.ts:51-52

// disable because types started failing in 1.22.0
// elicitation: { form: {}, url: {} }

Elicitation capability was disabled due to type failures but lacks:

  • Root cause investigation
  • Migration path documentation
  • Issue tracking

4. Inconsistent Type Safety Across Examples

Files inconsistently apply as const to type: "text" fields. Some use it (worker.ts, mcp-worker-authenticated), others don't (x402-mcp, mcp/server.ts). This risks type widening from "text" literal to string.

Recommendations

  1. Add as const to all type: "text" literals in x402.ts
  2. Create packages/agents/src/tests/mcp/x402.test.ts
  3. Investigate elicitation type failure or document as known breaking change
  4. Standardize as const usage across all registerTool callbacks

Migration Pattern: ✅ The core API migration from server.tool() to server.registerTool() is correctly implemented across all files.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Nov 18, 2025

Open in StackBlitz

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

commit: 3579d12

agents-git-bot bot pushed a commit to cloudflare/cloudflare-docs that referenced this pull request Nov 21, 2025
This sync updates the documentation to reflect the breaking API change
in @modelcontextprotocol/sdk v1.22.0, which changed tool registration
from:
  server.tool(name, description, schema, handler)
to:
  server.registerTool(name, { description, inputSchema }, handler)

Updated files:
- model-context-protocol/mcp-agent-api.mdx
- model-context-protocol/tools.mdx
- model-context-protocol/authorization.mdx
- model-context-protocol/mcp-handler-api.mdx
- x402.mdx

Synced from cloudflare/agents PR #659
cloudflare/agents#659

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

Co-Authored-By: Claude <[email protected]>
@threepointone threepointone merged commit 48849be into main Nov 25, 2025
5 checks passed
@threepointone threepointone deleted the update-deps branch November 25, 2025 15:16
@github-actions github-actions bot mentioned this pull request Nov 25, 2025
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.

2 participants