Skip to content

Add x402 MCP payment preparation#24

Open
hyperxiaoerxz-hash wants to merge 1 commit into
MetaMask:mainfrom
hyperxiaoerxz-hash:feat/x402-mcp-transport
Open

Add x402 MCP payment preparation#24
hyperxiaoerxz-hash wants to merge 1 commit into
MetaMask:mainfrom
hyperxiaoerxz-hash:feat/x402-mcp-transport

Conversation

@hyperxiaoerxz-hash

Copy link
Copy Markdown

Summary

Adds MCP transport handling to the existing x402 buyer helper so agents can parse an MCP PaymentRequired tool result and prepare the _meta["x402/payment"] payload for a retry.

This keeps the payment flow deliberately narrow:

  • inspect-mcp parses raw PaymentRequired, JSON-RPC result.structuredContent, or JSON text in result.content[0].text without signing or spending.
  • prepare-mcp requires --confirm, signs through the existing MetaMask CLI typed-data path, and prints the MCP retry metadata object.
  • HTTP x402 behavior remains unchanged.
  • Docs and workflow notes now cover HTTP and MCP x402 paths.

Closes #23.

Validation

  • PYTHONDONTWRITEBYTECODE=1 python3 -m py_compile skills/metamask-agent-wallet/scripts/x402_pay.py
  • PYTHONDONTWRITEBYTECODE=1 python3 skills/metamask-agent-wallet/scripts/x402_pay.py inspect-mcp <raw PaymentRequired JSON>
  • PYTHONDONTWRITEBYTECODE=1 python3 skills/metamask-agent-wallet/scripts/x402_pay.py inspect-mcp <JSON-RPC structuredContent result>
  • git diff --check

No live payment was made during validation.

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.

Add the x402 MCP transport to the buyer skill

1 participant