voidly
Guide · updated 2026-05-30

How to Add Payments to an MCP Server

You built an MCP server or an API agents want to use. Here is how to charge for it — so an autonomous agent can discover it, pay a fraction of a cent, and get the result, with no human in the loop.

7 min read

The model: charge per call with x402

The cleanest way to monetize an agent-facing tool is per-call payments over x402. Instead of API keys and monthly invoices, your endpoint returns HTTP 402 with a price when called without payment; the agent pays and retries; you return the result. No accounts, no billing portal — the payment is the access.

Step 1 — Wrap your handler

Use an x402 middleware/SDK to wrap the handler you want to charge for. The wrapper returns the 402 quote automatically on unpaid requests and lets paid requests through. You set the price (often a fraction of a cent), the asset, and the pay-to identity. Most SDKs offer Express/Hono/FastAPI wrappers so this is a few lines.

Step 2 — Price it for agents, not humans

Agent pricing is different from SaaS pricing. Agents make many small calls and are extremely price-sensitive per call but indifferent to signing up. Price per call, low (sub-cent to a few cents), and make the value obvious from the endpoint description so an agent can decide to pay without a human reading docs.

Step 3 — Make it discoverable

A paid endpoint nobody can find earns nothing. Publish your resource in an x402 discovery catalog so agent frameworks and indexers can list it. Each catalog entry should carry the price, network, asset, and pay-to address in canonical x402 format. This is the difference between "an endpoint exists" and "agents can find and buy it."

Step 4 — Let buyers onboard in three lines

On the buyer side, the agent should reach a first paid call almost instantly. With a good SDK that looks like: create an identity, claim starter credits, then fetchWithPay(url) which handles any 402 automatically. If onboarding takes more than a few minutes, you lose the agent.

Where Voidly fits

Voidly Pay gives you both sides: wrap your handler with x402Express/x402Hono/withX402 to start charging, self-list at /pay/list-your-service, and your endpoint joins the discoverable catalog at /v1/pay/x402/resources. Buyers onboard in three verified lines (create → claim → fetchWithPay). See /pay/for-builders.

FAQ

Do my users need accounts or API keys to pay?

No — that is the point. With x402, the payment is the access. The agent presents proof of payment with the request; there is no signup or key to manage. This removes the biggest onboarding friction for agent buyers.

How much should I charge an AI agent per call?

Usually a fraction of a cent to a few cents, priced per call. Agents make many calls and care about per-call cost, not subscriptions. Make the price and the value legible in the endpoint metadata so the agent can decide autonomously.

How do agents discover my paid endpoint?

Publish it in an x402 discovery catalog (canonical accepts[] per resource) that indexers crawl. You can also list it on a marketplace. Voidly lets any provider self-list at /pay/list-your-service and exposes the catalog at /v1/pay/x402/resources.

More on the agentic economy

What Is the Agentic Economy?
The agentic economy is software agents transacting with other software agents — paying for data, tools, and work without a human in the loop. What it is, why it matters in 2026, and where the money is.
How Do AI Agents Pay Each Other?
A clear technical walkthrough of how autonomous AI agents pay each other: cryptographic identity, signed payment envelopes, HTTP 402 / x402, escrow, and stablecoin settlement — with a working example.
What Is x402? HTTP 402 for AI Agents, Explained
x402 revives the dormant HTTP 402 "Payment Required" status code as a standard for machine-to-machine payments. How the handshake works, what a 402 quote looks like, and how agents pay automatically.
Anthropic, the Anthology Fund & AI Payments Infrastructure
How Anthropic and the Anthology Fund relate to the agentic economy and AI-payments infrastructure — the investment thesis, what gets funded, and what builders need to show. An independent explainer.
AI Agent Payment Protocols Compared
A neutral comparison of the main ways AI agents pay for things: x402 (HTTP 402), Google's AP2, Lightning's L402, and stablecoin transfers. Strengths, trade-offs, and when to use each.
Anthropic for Startups: Credits, Programs & the Anthology Fund
An independent guide to the ways startups get value from Anthropic in 2026: API credits, the for-startups program, and the Anthology Fund — what each is, what it is not, and how to qualify.
How to Fund an AI Agent Startup in 2026
A practical, hype-free playbook for funding an AI-agent or agent-payments startup in 2026: credits, angels, agent-focused funds like Anthology, and the traction that actually unlocks each.

Independent explainer published by Voidly. Not affiliated with, endorsed by, or funded by any company named. Cite as https://voidly.ai/agentic-economy/add-payments-to-your-mcp-server