Skip to content

feat(x402): route payments through mcp.openmm.io proxy via split execution#31

Merged
adacapo21 merged 4 commits intomainfrom
feat/mcp-facilitator-settlement
Apr 1, 2026
Merged

feat(x402): route payments through mcp.openmm.io proxy via split execution#31
adacapo21 merged 4 commits intomainfrom
feat/mcp-facilitator-settlement

Conversation

@adacapo21
Copy link
Copy Markdown
Member

Summary

  • Replaces withX402 + withAutoPayment with wrapWithSplitPayment from @qbtlabs/x402/split
  • PAYMENT_SERVER now defaults to https://mcp.openmm.io instead of going directly to x402.org/facilitator
  • Deletes src/payment-client.ts — split gate handles signing, retry, and JWT verification internally
  • src/payment.ts rewritten as applyPaymentGate(server) — one call before registerTools, no per-tool wrappers
  • .env.example and README updated: X402_EVM_ADDRESSX402_PRIVATE_KEY, proxy URL documented

Split execution flow

1. Tool called → gate intercepts
2. Gate POSTs to mcp.openmm.io/verify-payment
3. Proxy returns 402 with EIP-3009 requirements (amount + payTo)
4. Gate signs locally with X402_PRIVATE_KEY — key never leaves process
5. Gate retries with X-PAYMENT header → proxy verifies on-chain, issues JWT
6. Gate verifies JWT, executes handler, injects settlement tx hash in response

Process isolation: indigo-mcp never holds the recipient wallet — only the payer key. Verification and settlement are handled by the openmm.io proxy.

Dependencies

Stacks on top of #30 (feat/3rd-400-x402-integration). Merge #30 first, then this.

…ution

- Replace withX402 + withAutoPayment interceptor with wrapWithSplitPayment
  from @qbtlabs/x402/split — payment verification and settlement now route
  through https://mcp.openmm.io by default instead of x402.org/facilitator
- payment.ts: rewrite as applyPaymentGate(server) — no configure/setToolPrices,
  just wrapWithSplitPayment with privateKey, workerUrl, testnet, freeTools
- server.ts: replace manual server.tool interceptor with applyPaymentGate(server)
  called before registerTools; must be called before tool registration
- Delete payment-client.ts — split gate handles signing + retry internally
- .env.example: replace X402_EVM_ADDRESS with X402_PRIVATE_KEY; PAYMENT_SERVER
  now defaults to https://mcp.openmm.io
- README: update x402 section to document split flow, new env vars, and
  correct MCP client config examples

Split execution flow (mirrors openmm-mcp architecture):
  1. Tool called — no payment header required from caller
  2. Gate POSTs to workerUrl/verify-payment
  3. Worker returns 402 with EIP-3009 requirements
  4. Gate signs locally with X402_PRIVATE_KEY (key never leaves process)
  5. Gate retries with X-PAYMENT header → worker issues JWT
  6. Gate verifies JWT locally, executes handler, injects tx hash in response
@adacapo21 adacapo21 changed the base branch from feat/3rd-400-x402-integration to main April 1, 2026 17:34
@adacapo21 adacapo21 merged commit 63abb63 into main Apr 1, 2026
3 checks passed
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.

1 participant