Skip to content

fix(mcp): preserve existing metadata#2318

Open
EfeDurmaz16 wants to merge 2 commits into
x402-foundation:mainfrom
EfeDurmaz16:fix/mcp-meta-preservation
Open

fix(mcp): preserve existing metadata#2318
EfeDurmaz16 wants to merge 2 commits into
x402-foundation:mainfrom
EfeDurmaz16:fix/mcp-meta-preservation

Conversation

@EfeDurmaz16
Copy link
Copy Markdown

Summary

Preserves existing MCP _meta fields when x402 attaches payment request or settlement metadata.

MCP _meta can carry non-payment context such as trace IDs, auth hints, evidence handles, or other transport metadata. The current helpers and server wrapper replace _meta when adding x402 metadata, which can drop that context.

Changes

  • Preserve existing request _meta in attachPaymentToMeta
  • Preserve existing result _meta in attachPaymentResponseToMeta
  • Preserve handler-provided _meta when createPaymentWrapper attaches settlement response metadata
  • Add unit coverage for all three preservation paths

Verification

  • pnpm --dir typescript --filter @x402/mcp exec vitest run test/unit/utils.test.ts test/unit/server.test.ts
  • pnpm --dir typescript --filter @x402/mcp lint:check
  • git diff --check

Note: the full pnpm --dir typescript --filter @x402/mcp test suite currently fails in test/unit/client.test.ts because @x402/core/schemas cannot be resolved from src/client/x402MCPClient.ts in this local workspace setup. The two test files covering this change pass.

@vercel
Copy link
Copy Markdown

vercel Bot commented May 15, 2026

@EfeDurmaz16 is attempting to deploy a commit to the Coinbase Team on Vercel.

A member of the Team first needs to authorize it.

@EfeDurmaz16 EfeDurmaz16 force-pushed the fix/mcp-meta-preservation branch from e685e37 to 572b03e Compare May 15, 2026 18:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant