DEV Community

kevin2003050666-coder
kevin2003050666-coder

Posted on

What a seller-side HTTP 402 + MCP paywall looks like

I needed agents to pay per call against an existing HTTP API without handing out API keys. x402-micro-tollgate is a thin Express process that is both an HTTP 402 reverse proxy and an MCP server.

Unpaid gated routes (default /v1) return protocol 402. After settlement, the request is proxied to UPSTREAM_URL. /health stays free. Same process exposes MCP tools: server_info (free), get_quote / proxy_request (paid).

Demo (no CDP keys):

curl -i https://x402-micro-tollgate.onrender.com/v1/quote
# HTTP/1.1 402 Payment Required
Enter fullscreen mode Exit fullscreen mode

Self-host:

npx x402-micro-tollgate
Enter fullscreen mode Exit fullscreen mode

Repo: https://github.com/kevin2003050666-coder/x402-micro-tollgate
npm: https://www.npmjs.com/package/x402-micro-tollgate
MCP Registry: io.github.kevin2003050666-coder/x402-micro-tollgate

Top comments (0)