Category Archives: 03 – MCP Integration

Mcp Integration

Welcome to the NZRT Wiki Podcast. Today we’re looking at MCP Integration.

So let’s start with why this matters. x402 — NZRT’s micropayment protocol — pairs naturally with MCP, which stands for Model Context Protocol. The idea is that the MCP server acts as the paying client, automatically handling payment responses in a way that’s completely transparent to the language model itself. The LLM never has to think about money — it just asks for something and gets an answer back.

Let’s walk through how that works in practice, starting with the architecture.

Picture Claude — the language model — calling a tool called search wiki, passing in a keyword like “kubernetes”. That call goes down to the MCP server, which is running locally on your machine. The MCP server then makes an HTTP request out to a resource server. The resource server comes back with a 402 status — that’s the standard HTTP code meaning payment required. The MCP server reads the payment requirements, signs a USDC authorization using its wallet, and retries the same request, this time including a payment header. The resource server accepts that, returns the actual content, and the MCP server passes the result back up to Claude as a normal tool result. Claude never sees the payment happen. It just gets its answer. That’s the elegance of this design.

Now let’s look at what the MCP server is actually responsible for. There are five main areas. First, tool exposure — it defines the tools that the language model can call. Second, it acts as the HTTP client, making requests to the resource server on Claude’s behalf. Third, it handles those 402 responses — detecting them, reading the payment requirements, signing the payment, and retrying. Fourth, it holds the payer wallet, meaning it stores the private key used to sign what’s called an EIP-712 payment authorization. And fifth, it manages nonces, generating a random value for each payment to prevent replay attacks.

Speaking of the tools the MCP server exposes, there are two defined in the schema. The first is called search wiki — its job is to search the NZRT knowledge vault by keyword, and it takes a single input, a search query string. The second tool is called get wiki note, which retrieves a specific note from the vault by its file path — something like Wiki slash Flarum slash HOME. Both tools require their input to be provided, so Claude always needs to pass either a query or a path when calling them.

Next, transport. You have two options for how an MCP server can run. The first is stdio, which is local — Claude Desktop spawns the MCP server process directly on the same machine. The second is SSE, which stands for Server-Sent Events and works over HTTP, letting a server run independently while Claude connects to it via a URL. For x402 MCP setups, stdio is the typical choice. The resource server itself can be remote or local, but the MCP server always runs local to wherever the LLM client is.

Now let’s talk about what actually triggers the automatic payment. When the MCP server makes a request and gets back that 402 status, it reads the payment requirements from the response body, signs a payment using the private key it holds, and retries the original request with a header called X-Payment carrying the encoded payment data. If everything checks out, the resource server responds with a 200 and the content, which flows back up to Claude as a normal result.

On the resource server side, you’ve got five responsibilities of its own. First, route protection — it returns 402 for any endpoint that requires payment. Second, payment verification — for each incoming payment header, it calls out to a facilitator service to verify the payment is valid. Third, settlement — once verified, it calls that same facilitator’s settle endpoint to actually execute the on-chain transfer. Fourth, content serving — after a verified payment, it returns the requested content. And fifth, there’s a free health check endpoint always available for monitoring, no payment needed.

So to pull it all together, MCP Integration with x402 creates a clean separation of concerns. Claude stays focused on reasoning and tool use. The MCP server handles all the payment plumbing invisibly in the background. And the resource server enforces access control and handles settlement. The whole thing is designed so that paid API access just works, without the LLM needing to understand anything about wallets, signatures, or blockchain transactions.

That’s it for this episode of the NZRT Wiki Podcast. Thanks for listening.