Skip to content

Fix x402 MCP payment retry metadata - #344

Open
mohamedkuch wants to merge 2 commits into
apify:mainfrom
mohamedkuch:codex/fix-mcp-x402-retry-meta
Open

Fix x402 MCP payment retry metadata#344
mohamedkuch wants to merge 2 commits into
apify:mainfrom
mohamedkuch:codex/fix-mcp-x402-retry-meta

Conversation

@mohamedkuch

Copy link
Copy Markdown

Summary

  • decode the signed x402 payload before retrying a payment-required MCP tool result
  • attach the payload to params._meta["x402/payment"] for regular, task, and detached calls
  • preserve caller metadata and clear the cached signature after the bounded retry
  • add regression coverage for payment payload decoding

Live compatibility proof

Tested the patched build against https://api.utilia.ink/base/mcp with released mcpc 0.5.1 as the baseline. The initial call returned payment-required terms, the patched retry settled exactly $0.002 USDC on Base, and the tool returned a successful result.

Transaction: 0x1815f8271c194700aa3d178ca1ff4bc76d4c0e82bdea4e0e369008cbfd3e63cb

This was a bounded operator compatibility test. It was not organic traffic.

Validation

  • pnpm run build
  • pnpm run lint with 5 pre-existing warnings and 0 errors
  • pnpm run test:unit: 867 passed
  • Node E2E: 47 passed
  • Bun E2E: skipped because Bun is not installed in the test environment
  • real Base x402 MCP call: passed with one settlement

Fixes #343

Attach the decoded payment payload to MCP request metadata on the single retry, including task-based tool calls. Clear the cached signature after the attempt and cover payload decoding with regression tests.

Fixes apify#343
@mohamedkuch

Copy link
Copy Markdown
Author

@jancurn, could you please review PR #344 when convenient? The change is limited to propagating the freshly decoded x402 payload through params._meta["x402/payment"] on the immediate paid retry while preserving caller metadata. It adds focused regression tests, and the full Node unit and E2E suites, build, formatting, lint, and PR-diff secret scan pass. It does not introduce or broaden session-level payment-signature reuse.

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.

x402 MCP retry omits payment metadata with Streamable HTTP transport

2 participants