server.ts•796 B
import { createPaidMcpHandler } from "x402-mcp";
import { z } from "zod";
import { facilitator } from "@coinbase/x402";
const handler = createPaidMcpHandler( // add facilitator as the first argument
(server) => {
server.paidTool(
"add",
"Add two numbers together",
{ price: 0.01 },
{ a: z.number(), b: z.number() },
{},
async ({ a, b }) => {
const result = a + b;
return {
content: [{ type: "text", text: `✅ ${a} + ${b} = ${result}` }],
};
},
);
},
{
serverInfo: {
name: "basic-math-mcp",
version: "0.1.0"
}
}, {
recipient: "0x09BbBa1f31CB4b8458Ac5106545053A61446d641",
facilitator,
network: "base-sepolia"
});
export { handler as GET, handler as POST, handler as DELETE };