> ## Content Index
> Fetch the complete content index at: https://stablecoininsider.org/llms.txt
> Use this file to discover other available public pages before exploring further.

# How to Charge for MCP Tools with Cloudflare Agents x402 (2026)
- URL: https://stablecoininsider.org/how-to-charge-for-mcp-tools-with-cloudflare-agents-x402/
- Published: 2026-09-17T14:11:55.000Z
- Updated: 2026-09-17T14:11:53.000Z
- Description: Charge USDC per MCP tool call with Cloudflare Agents withX402 and paidTool ($0.01 docs example), base or base-sepolia, and x402.org facilitator.
- Author: Alexandra
- Tags: AI, Stablecoins

**Cloudflare Agents SDK x402** lets sellers charge **USDC** per MCP tool call with **withX402** plus **paidTool**. Clients that lack payment get HTTP 402, pay via x402, retry with proof, then receive the tool result.

This guide is the **seller-side** path on Cloudflare Workers Agents. It is not the buyer-only AgentKit flow, not Stripe checkout for x402, and not Cloudflare's separate Monetization Gateway waitlist product.

📌

Stablecoin Insider's framing: wrap an McpServer with withX402, price tools with paidTool (docs example: square at $0.01), keep free tools on tool(), and test on base-sepolia with Circle faucet USDC before base mainnet.

Primary sources: [Charge for MCP tools](https://developers.cloudflare.com/agents/agentic-payments/x402/charge-for-mcp-tools/), [Pay from Agents SDK](https://developers.cloudflare.com/agents/agentic-payments/x402/pay-from-agents-sdk/), and [x402 on Cloudflare Agents](https://developers.cloudflare.com/agents/tools/payments/x402/). Working sample: [cloudflare/agents examples/x402-mcp](https://github.com/cloudflare/agents/blob/main/examples/x402-mcp/README.md).

[Cloudflare Opens Waitlist for Stablecoin-Powered Monetization Gateway Built on the x402 ProtocolNews on Cloudflare's Monetization Gateway waitlist. Distinct from Agents SDK paidTool for MCP.![](https://stablecoininsider.org/favicon.ico)Stablecoin Insider](https://stablecoininsider.org/cloudflare-opens-waitlist-for-stablecoin-powered-monetization-gateway-built-on-the-x402-protocol/)

### Key Takeaways

- Seller path: wrap McpServer with withX402, then charge with paidTool while free tools stay on tool().
- Docs example prices paidTool "square" at $0.01 USD per call; mix paid and free tools in one server.
- X402Config uses network base or base-sepolia, a recipient wallet, and facilitator https://x402.org/facilitator.
- Buyers wrap the MCP client with withX402Client; unpaid paidTool calls return 402 until payment proof retries.
- Test on base-sepolia with Circle faucet USDC; use wrangler secrets for private keys, never commit keys.

⚠️

Named downside: unpaid clients hit 402 until they can pay. Facilitator choice, wallet custody, and base vs base-sepolia must be locked before you advertise public paid MCP endpoints.

## What Cloudflare Agents x402 MCP billing is (and is not)

x402 is a payment standard built around HTTP 402 Payment Required. The server returns payment details; the client signs a payment payload and retries with a PAYMENT-SIGNATURE header.

On Cloudflare Agents, **agents/x402** adds **withX402** for MCP servers and **withX402Client** for MCP clients. Sellers define price in USD on **paidTool**; settlement is USDC on the configured network via a facilitator.

This object is not [Cloudflare Monetization Gateway waitlist](https://stablecoininsider.org/cloudflare-opens-waitlist-for-stablecoin-powered-monetization-gateway-built-on-the-x402-protocol/) news, not [how to pay for an x402 API with Coinbase AgentKit](https://stablecoininsider.org/how-to-pay-for-an-x402-api-with-coinbase-agentkit/) (buyer AgentKit), and not [how to accept x402 USDC payments on Stripe](https://stablecoininsider.org/how-to-accept-x402-usdc-payments-on-stripe/). For protocol basics, see [x402 protocol](https://stablecoininsider.org/x402-protocol/).

## Who this is for (and who should skip it)

Use this when the team ships MCP tools on Cloudflare Agents and wants per-call USDC pricing without API keys or session accounts for each buyer agent.

Skip it when the job is only buying someone else's x402 API (use AgentKit or [Circle agent nanopayment](https://stablecoininsider.org/how-to-make-a-circle-agent-nanopayment-in-usdc/) guides), when you need Stripe-hosted acceptance, or when you are waiting on Monetization Gateway and do not yet run Agents SDK MCP.

## Seller checklist: charge for MCP tools (2026)

### 1\. Confirm Agents SDK and x402 imports

Cloudflare docs import **McpServer** from **@modelcontextprotocol/sdk/server/mcp.js**, **McpAgent** from **agents/mcp**, and **withX402** plus **X402Config** from **agents/x402**. Zod schemas define tool inputs.

Keep the Agents Worker project on a current **agents** package so **paidTool** is available as a drop-in replacement for **tool**.

### 2\. Set X402Config (network, recipient, facilitator)

Docs configuration fields:

| Field           | Docs value                   | Notes                                          |
| --------------- | ---------------------------- | ---------------------------------------------- |
| **network**     | base or base-sepolia         | base for production; base-sepolia for testing  |
| **recipient**   | 0xYourWalletAddress          | Wallet that receives USDC                      |
| **facilitator** | https://x402.org/facilitator | Public facilitator used in Cloudflare examples |

Facilitators verify and settle without holding funds. Cloudflare examples use <https://x402.org/facilitator>. For facilitator selection tradeoffs, see [how to choose an x402 facilitator for USDC](https://stablecoininsider.org/how-to-choose-an-x402-facilitator-for-usdc/).

[Open Charge for MCP tools docs](https://developers.cloudflare.com/agents/agentic-payments/x402/charge-for-mcp-tools/)

### 3\. Wrap McpServer with withX402

Subclass **McpAgent** and assign **server = withX402(new McpServer({ name, version }), X402\_CONFIG)**. That wrap is what attaches payment requirements to paid tools.

Without **withX402**, **paidTool** is not the documented path. Free tools still register with **this.server.tool(...)** on the same wrapped server.

### 4\. Register paidTool and free tool side by side

paidTool signature from Cloudflare docs: name, description, price in USD, Zod input schema, MCP annotations object, async handler.

Docs example: **paidTool("square", "Squares a number", 0.01, { number: z.number() }, {}, handler)**. Price **0.01** means $0.01 USD per call. A free **echo** tool uses **this.server.tool** with no price.

When a client calls a paid tool without payment, the server returns **402** with payment requirements. After x402 payment proof, the client retries and receives the result.

### 5\. Buyer side: withX402Client on Agents SDK

Paying agents connect to the MCP endpoint, build a wallet account (docs use **privateKeyToAccount** from viem), then wrap the MCP client with **withX402Client**.

Docs show **callTool** with an optional confirmation callback (**onPaymentRequired**) or **null** for automatic payment. Store **MY\_PRIVATE\_KEY** in **.dev.vars** locally and **wrangler secret put MY\_PRIVATE\_KEY** in production.

[Open Pay from Agents SDK docs](https://developers.cloudflare.com/agents/agentic-payments/x402/pay-from-agents-sdk/)

### 6\. Test on base-sepolia, then promote to base

Set **network: "base-sepolia"** while integrating. Cloudflare points testers to the [Circle faucet](https://faucet.circle.com/) for test USDC. Flip to **network: "base"** only after recipient, facilitator, and tool prices are verified.

Use the official [x402-mcp GitHub example](https://github.com/cloudflare/agents/blob/main/examples/x402-mcp/README.md) as a complete working reference. Do not invent undocumented paidTool fields beyond the docs signature.

## paidTool vs free tool vs Monetization Gateway

| Option                            | What it is                                     | When to use                                                                 |
| --------------------------------- | ---------------------------------------------- | --------------------------------------------------------------------------- |
| **paidTool + withX402**           | Per MCP tool call USDC price on Agents SDK     | You already run MCP on Cloudflare Agents and need seller-side micropayments |
| **tool() (free)**                 | Same MCP server, no 402 gate                   | Health checks, discovery, or unmetered helpers beside paid tools            |
| **Monetization Gateway waitlist** | Separate Cloudflare product on x402 (waitlist) | You want Cloudflare's gateway product, not Agents SDK MCP wrappers          |
| **AgentKit buyer path**           | Client pays third-party x402 APIs              | Your agent consumes paid APIs; you are not the MCP seller                   |

Operators comparing acceptance surfaces should also read [how to accept x402 USDC payments from AI agents](https://stablecoininsider.org/how-to-accept-x402-usdc-payments-from-ai-agents/). Keep seller MCP wrapping and buyer AgentKit runbooks in separate docs so credentials never mix.

## Stablecoin Insider's take

💡

Stablecoin Insider's take: withX402 plus paidTool is the cleanest seller path for MCP micropayments on Cloudflare Agents today. Price in USD, settle in USDC, and treat facilitator plus network choice as production controls before you publish a paid tool catalog.

If the stack is buyer-only, stay on [AgentKit x402 pay how-to](https://stablecoininsider.org/how-to-pay-for-an-x402-api-with-coinbase-agentkit/) or Circle nanopayment guides. If the roadmap is Monetization Gateway, track the waitlist post and do not conflate it with Agents SDK MCP billing.

---

Need the protocol frame before you wrap MCP?

[Read the x402 protocol explainer ](https://stablecoininsider.org/x402-protocol/) 

[Open Cloudflare x402 Agents docs](https://developers.cloudflare.com/agents/tools/payments/x402/)

## FAQ

#### What is paidTool in Cloudflare Agents?

paidTool is a drop-in replacement for tool that adds an x402 payment requirement on an MCP server wrapped with withX402.

Clients pay per tool call in USDC on the configured network; free tools can still use tool() on the same server.

#### How much does the Cloudflare docs example charge?

The Charge for MCP tools docs price the sample paidTool named square at $0.01 USD per call.

Teams set their own USD price argument; do not assume $0.01 is a platform fee.

#### Which network and facilitator do Cloudflare examples use?

X402Config uses network base for production or base-sepolia for testing, plus facilitator URL https://x402.org/facilitator.

Recipient is the merchant wallet address that receives USDC.

#### What happens if a client calls a paid tool without paying?

The server returns HTTP 402 with payment requirements. The client pays via x402, retries with payment proof, and then receives the tool result.

withX402Client on the Agents SDK automates that client loop.

#### Is this the same as Cloudflare Monetization Gateway?

No. Monetization Gateway is a separate Cloudflare waitlist product built on x402.

This guide covers Agents SDK withX402 and paidTool for MCP servers you operate.

#### How should teams test before mainnet?

Use network base-sepolia and get test USDC from the Circle faucet, as Cloudflare docs recommend.

Keep private keys in wrangler secrets or .dev.vars; never commit them.

#### Where is the official end-to-end example?

Cloudflare points to the x402-mcp example under cloudflare/agents on GitHub.

Pair it with the Charge for MCP tools and Pay from Agents SDK docs pages.

This content is provided for informational and educational purposes only and does not constitute financial, investment, legal, or tax advice; no material herein should be interpreted as a recommendation, endorsement, or solicitation to buy or sell any financial instrument, and readers should conduct their own independent research or consult a qualified professional.