MCP payment middleware should inspect, not seize spending authority.
Use MCP for capability discovery and contract inspection. For paid targets, fetch the fresh PAYMENT-REQUIRED challenge. The caller's wallet/policy decides whether to create the matching PAYMENT-SIGNATURE.
Current x402 Gateway: https://mcp-x402.onrender.com/mcp. GitLab is current source authority.
Package status → · GitLab source →
Where payment fits in an MCP call?
MCP describes what a tool does. x402 describes what it costs. Good middleware keeps the two separate so a model can browse tools freely while money only moves under the caller's rules.
- The client lists tools and reads their descriptions. This step is always free.
- The client calls a paid tool. The server answers with the x402 payment requirements for that call.
- The middleware shows the exact price, asset, network and receiver to the caller's policy, not to the model.
- Only if the policy approves does the wallet sign a payment for that one challenge, and the call is retried.
- The server verifies, settles and returns the result with settlement evidence.
Rules worth enforcing
- The model never holds signing keys.
- Every payment has a per-call cap and a daily limit.
- Payment terms come from the live challenge, never from a cached tool description.
- A failed or partial delivery is recorded, not counted as revenue.
See the x402 Gateway and how to monetize an MCP server.