10 ମିନିଟ୍ରେ ତୁମର MCP ସେର୍ଭରକୁ ମୋନେଟାଇଜ୍ କର।
@blockchain0x/mcp ଇନଷ୍ଟଲ୍ କରନ୍ତୁ, ଏବଂ premium tool ଭିତରେ caller ପେମେଣ୍ଟ କରିନଥିବାବେଳେ requirePayment କଲ୍ କରନ୍ତୁ - ଏହା hosted checkout URL ସହିତ ଏକ x402 402 challenge ତିଆରି କରେ, ଯାହାକୁ ଆପଣ ଫେରାଇଦେବେ। payment.received webhook settlement confirm କଲେ, ଆପଣ ନିଜ store ଭିତରେ caller କୁ paid ଭାବେ ଚିହ୍ନଟ କରନ୍ତି ଏବଂ tool ଚାଲେ। Free tools free ହିଁ ରହେ। ସାଧାରଣ HTTP server ପାଇଁ, receive-side x402 adapter ସେଇ କାମ କରେ।
ଆପଣ ଆରମ୍ଭ କରିବା ପୂର୍ବରୁ।
- ଏକ କାମ କରୁଥିବା MCP ସର୍ଭର୍ ଯାହା ନୋଡ୍ କିମ୍ବା ପାଇଥନ୍ରେ ଅଧିକାରୀ Model Context Protocol SDK ବ୍ୟବହାର କରେ। ଯଦି ତୁମର ଏକ ନାହିଁ, ତେବେ ପ୍ରଥମେ ଉପସ୍ଥାପନ ଟେମ୍ପଲେଟ୍ ସହିତ ଏକ ଗଢ଼।
- ଏକ Blockchain0x account ଏବଂ ଏକ agent profile (5-minute setup ପାଇଁ add-payments-to-agent guide ଦେଖନ୍ତୁ)।
- ଏକ API key (ଏହି ଗାଇଡ ପାଇଁ
sk_test_ବ୍ୟବହାର କରନ୍ତୁ)। - କେଉଁଠି ଦେୟ ହୋଇଛି (ଏକ ଡାଟାବେସ୍ ରୋ ଅଥବା ଏକ Redis କୀ) ମନେ ରଖିବା ପାଇଁ ଏକ ଛୋଟ ଷ୍ଟୋର୍ - ଆପଣଙ୍କର କୋଡ୍ ଏହାକୁ ମାଲିକୀତ୍ୱ ଦେଇଛି, ଯାହା ଦେୟ webhook ଦ୍ୱାରା ଅଦ୍ୟତିତ।
- କେଉଁ tool ଗୁଡ଼ିକ ପାଇଁ ଆପଣ ଶୁଳ୍କ ନେବାକୁ ଚାହୁଁଛନ୍ତି ଏବଂ ପ୍ରତି call ଦର କେତେ, ସେଥିରେ ସ୍ପଷ୍ଟ ଧାରଣା। design patterns ପାଇଁ paid MCP tool glossary entry ଦେଖନ୍ତୁ।
package ଇନଷ୍ଟଲ୍ କରନ୍ତୁ।
@blockchain0x/mcp exports requirePayment, a pure function that mints an x402 402 challenge for a tool. It is npm (TypeScript) only. If you run a plain HTTP server instead of an MCP one, install the receive-side x402 adapter and gate routes with it.
# Gate your own MCP tools with the requirePayment 402 builder:
npm install @blockchain0x/mcp
# Or gate a plain HTTP server with the receive-side x402 adapter + SDK:
npm install @blockchain0x/x402 @blockchain0x/noderequirePayment ସହିତ ଏକ ଟୁଲ୍ ଗେଟ୍ କରନ୍ତୁ।
Inside the tool, check your own paid-state for the caller. If they have not paid, call requirePayment and return the resulting 402 body; if they have, run the work. requirePayment is a pure builder - it does not wrap the handler and does not track payment, so the gating policy stays in your code.
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { requirePayment } from "@blockchain0x/mcp";
import { z } from "zod";
const server = new McpServer({ name: "premium-data-mcp", version: "1.0.0" });
server.tool(
"get_quote_realtime",
"Real-time quote (paid)",
{ ticker: z.string() },
async ({ ticker }, extra) => {
if (!hasPaid(extra)) {
// Pure function: mint an x402 402 challenge and hand the body back.
const { body } = requirePayment({
amountUsdc: "0.005",
payTo: "0xYourWallet",
hostedUrl: "https://pay.blockchain0x.com/checkout/abc",
});
return { content: [{ type: "text", text: JSON.stringify(body) }], isError: true };
}
const quote = await fetchLiveQuote(ticker);
return { content: [{ type: "text", text: JSON.stringify(quote) }] };
},
);import express from "express";
import { createX402Middleware } from "@blockchain0x/x402/server/express";
import { createClient } from "@blockchain0x/node";
const sdk = createClient({ apiKey: process.env.BLOCKCHAIN0X_API_KEY! });
const app = express();
// Not an MCP server? Gate a plain HTTP route the same way. The middleware
// answers unpaid requests with a 402 and lets paid ones through.
// Configure the price and recipient per the x402 docs.
app.use("/quote", createX402Middleware({ sdk }));ଅଦାୟ caller କୁ requirePayment ଫେରାଇଥିବା 402 body:
// requirePayment returns { status: 402, body }. The body an unpaid caller sees:
{
"error": "payment_required",
"amountUsdc": "0.005",
"payTo": "0xYourWallet",
"hostedUrl": "https://pay.blockchain0x.com/checkout/abc",
"network": "mainnet"
}ଦେୟ ନିଶ୍ଚୟ କରନ୍ତୁ, ପରେ କିଏ ଦେୟ ଦେଇଛି ସେଥିରେ ମନେ ରଖନ୍ତୁ।
When a caller pays the checkout, Blockchain0x POSTs a signed payment.received event to your webhook. Verify it with webhooks.verify from @blockchain0x/node, then write the paid state to a store you control - a database row, a Redis key, your call. That store is what the tool checks in Step 2. There is no shipped receipt cache; you own where paid-state lives and how long it lasts.
import express from "express";
import { webhooks } from "@blockchain0x/node";
const app = express();
app.use(express.raw({ type: "application/json" }));
app.post("/webhooks/payment", (req, res) => {
const result = webhooks.verify({
headers: req.headers,
rawBody: req.body, // RAW bytes
secret: process.env.BLOCKCHAIN0X_WEBHOOK_SECRET!,
});
if (!result.ok) return res.status(400).json({ code: result.code });
if (result.eventType === "payment.received") {
// Remember the payer however you like - a DB row, a Redis key, your call.
markPaid(result.eventId);
}
res.status(200).send("ok");
});କେତେ ସମୟ ଏକ ଭୁଗତାନ ଆକ୍ସେସ୍ ଦେଇଥାଏ ତାହା ଆପଣଙ୍କର ନିଷ୍ପତ୍ତି - ଏକ ଏକକ କଲ୍, ଏକ ସେସନ୍, ଏକ ଘଣ୍ଟା। ଯାହାକି ଆପଣ ଟୁଲ୍ କୁ କିପରି ମୂଲ୍ୟ ଦିଅନ୍ତି ସେହିପରି ଭୁଗତାନ-ରାଜ୍ୟ କୀରେ ଏକ ଅବଧି ସେଟ୍ କରନ୍ତୁ। ଏତେ ଦୀର୍ଘ ଯେ ଏକ ସାଧାରଣ ସେସନ୍ ଗୋଟିଏ ଭୁଗତାନକୁ ପୁନର୍ବ୍ୟବହାର କରେ, ଏତେ ଛୋଟ ଯେ ଅବ୍ୟବହାର ସୀମିତ।
ଡିପ୍ଲୟ୍ କରନ୍ତୁ ଏବଂ ଭେରିଫାଇ କରନ୍ତୁ।
Server କୁ ship କରନ୍ତୁ। Free tools ତୁରନ୍ତ ତାଙ୍କର result ଫେରାଇବା ଉଚିତ୍; gated tools ନୂତନ client ର ପ୍ରଥମ call ରେ 402 body ଫେରାଇବା ଉଚିତ୍, ତାପରେ ସେ caller paid ଭାବେ ଚିହ୍ନଟ ହେଲେ run କରିବା ଉଚିତ୍। Live ହେବା ପୂର୍ବରୁ Base Sepolia ବିରୋଧରେ sk_test_ key ସହ ଦୁଇଟି ପଥ ଯାଞ୍ଚ କରନ୍ତୁ।
ପ୍ରଥମ ଦିନରେ ଦେଖିବାକୁ ଦୁଇଟି ସଙ୍କେତ: ଫେରାଇଥିବା 402 ଗଣନା (ଆପଣଙ୍କର ଟପ୍-ଓଫ୍-ଫନେଲ୍) ଏବଂ 402 ପରେ ସଫଳ ଟୁଲ୍ ଚଲାଇବାର ଗଣନା (ଆପଣଙ୍କର ପରିବର୍ତ୍ତନ)। ଯଦି ପରିବର୍ତ୍ତନ ଆଶା କରାଯାଇଥିବା ଠାରୁ ବହୁତ କମ୍ ଅଟକିଛି, ତେବେ ମୂଲ୍ୟ ସମ୍ଭବତଃ ଭୁଲ। ଆପଣଙ୍କର ପେଡ୍-ସ୍ଟେଟ୍ ସ୍ଟୋରର ହିଟ୍ ହାରକୁ ମଧ୍ୟ ଦେଖନ୍ତୁ - ଯଦି ଏହା ଶୂନ୍ୟକୁ ନିକଟ, ତେବେ ଆପଣଙ୍କର ଆକ୍ସେସ୍ ୱିଣ୍ଡୋ ଅତି କ୍ଷୁଦ୍ର ଏବଂ ପେଇଁ ଡାକୁଥିବା କଲରା ଆବାର ପେଇବାକୁ ଅନୁରୋଧ କରାଯାଉଛି।
ପ୍ରଥମ ବେଳେ MCP ମୋନେଟାଇଜର୍ମାନେ ଦାନ୍ତ କାଟିବାକୁ ଯୋଗ୍ୟ ପାଞ୍ଚ ଜିନିଷ।
ଦୁର୍ବାସ୍ଥାରେ ମୁକ୍ତ ଉପକରଣଗୁଡିକୁ ଗେଟ୍ କରିବା
ପ୍ରତ୍ୟେକ tool କୁ 'just in case' ଭାବରେ gate କରିବାକୁ ମନ ହୁଏ। କରନ୍ତୁ ନାହିଁ। paid MCP servers ର ସମ୍ପୂର୍ଣ୍ଣ ମୂଲ୍ୟ ଏହାଇ ଯେ free tools ଏବଂ paid ones ଏକେ server ରେ ସହଅବସ୍ଥାନ କରେ, ସେଥିପାଇଁ client free discovery ଏବଂ metadata tools କୁ pay ନକରି ବ୍ୟବହାର କରିପାରେ। କେବଳ ସେହି tools ପାଇଁ 402 mint କରନ୍ତୁ ଯେଉଁମାନେ ପ୍ରକୃତରେ premium resources ଖର୍ଚ୍ଚ କରେ; ଅନ୍ୟଗୁଡ଼ିକୁ plain results ଭାବରେ ରଖନ୍ତୁ।
requirePayment ଗୋଟିଏ builder, middleware ନୁହେଁ
requirePayment ଗୋଟିଏ pure function: tool unpaid ହେଲେ ଆପଣ ଏହାକୁ call କରନ୍ତି, ଏହା { status: 402, body } ଫେରାଏ, ଏବଂ ଆପଣ body କୁ ଫେରାନ୍ତୁ। ଏହା ଆପଣଙ୍କ handler କୁ wrap କରେ ନାହିଁ ଏବଂ କିଏ pay କଲା ତାହା track କରେ ନାହିଁ। ଏହା amountUsdc, payTo, hostedUrl, ଏବଂ ଏକ ଐଚ୍ଛିକ network ଏବଂ description ନେଇଥାଏ - ଆଉ କିଛି ନୁହେଁ। caller pay କରିଛି କି ନାହିଁ ତାହା ଆପଣଙ୍କ own store ବିରୁଦ୍ଧରେ ଯାଞ୍ଚ କରିବାକୁ ହୁଏ।
shipped receipt cache ନାହିଁ
Blockchain0x 402 builder ଏବଂ settlement webhook ଦେଇଥାଏ, receipt-store helper ନୁହେଁ। 'ଏହି caller paid' କେଉଁଠି ରହିବ - database row, Redis key, single process ପାଇଁ in-memory map - ଆପଣ ନିର୍ଣ୍ଣୟ କରନ୍ତି, ଏବଂ payment.received webhook ଆସିଲେ ଆପଣ ତାହାକୁ flip କରନ୍ତି। ଏଥିରେ policy (ଗୋଟିଏ payment କେତେ ସମୟ access ଦେବ) ସମ୍ପୂର୍ଣ୍ଣ ଭାବରେ ଆପଣଙ୍କ ହାତରେ ରହେ।
ଗ୍ରାହକ ଯାହା ଦାବୀ କରେ ତାହାର ରସିଦକୁ ବିଶ୍ୱାସ କରିବା
କଲରକୁ ଏହା ଭୁଗତାନ କରିଛି ବୋଲି ଦାବି କରିବାକୁ ଦିଅନ୍ତୁ ନାହିଁ। ସତ୍ୟର ସ୍ରୋତ ହେଉଛି payment.received ୱେବହୁକ୍, ଯାହାକୁ ଆପଣଙ୍କର ୱେବହୁକ୍ ସିକ୍ରେଟ୍ ବିରୁଦ୍ଧରେ webhooks.verify (କିମ୍ବା ଡକ୍ୟୁମେଣ୍ଟ କରାଯାଇଥିବା HMAC) ସହିତ ଯାଞ୍ଚ କରାଯାଇଛି। ଏକ ଯାଞ୍ଚିତ ଘଟଣା ପରେ ମାର୍କ କରନ୍ତୁ ଯେ ପେୟର ଭୁଗତାନ କରିଛି, ଏବଂ ସେହି ସର୍ଭର-ପାର୍ଶ୍ୱ ଅବସ୍ଥାରେ ଟୁଲକୁ ଗେଟ୍ କରନ୍ତୁ - କେବଳ କ୍ଲାଇଏଣ୍ଟ ଯାହା ପଠାଇଛି ତାହାରେ ନୁହେଁ।
ପେଇଡ୍-ଟୁଲ୍ ଲେଟେନ୍ସିରେ କୌଣସି ମେଟ୍ରିକ୍ସ ନାହିଁ
କ୍ଲାଇଏଣ୍ଟ୍ ଓ ଟୁଲ୍ କାର୍ଯ୍ୟାନ୍ବୟନ ମଧ୍ୟରେ ଏକ ଦେୟ ପଦକ୍ଷେପ ରଖିବା ପ୍ରଥମ କଲ୍ ଉପରେ ଦେୟ କରିବାକୁ ଓ ସେଟ୍ କରିବାକୁ ଆହୁରି ସମୟ ଯୋଗ କରେ, ପରେ ଆପଣ ସେମାନେ ଦେୟ କରିଥିବା ବେଳେ ନିକଟ-ଶୂନ୍ୟ। ଦୁଇଟି ଶାଖାକୁ ଯନ୍ତ୍ରଣା କରନ୍ତୁ ଯାହାକି ଆପଣ 'ଟୁଲ୍ ଧୀର' କୁ 'ଦେୟ ଧୀର' ଭାବରେ ଜାଣିପାରିବେ ଯେତେବେଳେ ଗ୍ରାହକ ଅଭିଯୋଗ କରେ। ମେଟ୍ରିକ୍ ବିନା ଆପଣ ବୋଟଲ୍ନେକ୍ କୁ ଭୁଲ ଚିହ୍ନଟ୍ କରିବେ।
ଏକଥର ପେଡ୍ ଟ୍ରାଫିକ୍ ବହୁଛି।
monetization ଥିବାବେଳେ, ସବୁଠୁ ଉପଯୋଗୀ follow-up ହେଲା dependable webhook handling (ଯାହାଦ୍ୱାରା payment events miss ନହୁଅନ୍ତି), spend controls (ଯାହାଦ୍ୱାରା ଆପଣ ତିଆରି କରୁଥିବା ଏବଂ ଅନ୍ୟ agents କୁ ମଧ୍ୟ ପେ କରୁଥିବା MCP server bounded ରହେ), ଏବଂ testnet-first flow (ଯାହାଦ୍ୱାରା ଆପଣ real money ଖର୍ଚ୍ଚ ନକରି pricing changes ship କରିପାରିବେ)।
developer ମାନେ ସବୁଠାରୁ ଅଧିକ ପଚାରୁଥିବା webhook pattern
ପ୍ରମ୍ପ୍ଟ ଇଞ୍ଜେକ୍ସନ୍ କୁ ଅତିକ୍ରମ କରିବା ପାଇଁ ଏଜେଣ୍ଟ ବ୍ୟୟ ନିୟନ୍ତ୍ରଣ ସେଟ୍ କରନ୍ତୁ
ବାସ୍ତବିକ ଟଙ୍କା ବିନା ପରୀକ୍ଷା ଏଜେଣ୍ଟ ପେମେଣ୍ଟ
docs.blockchain0x.com ରେ ପୂର୍ଣ୍ଣ API ସନ୍ଦର୍ଭ। ସମ୍ବନ୍ଧିତ ଉତ୍ପାଦ ସତହ: MCP ଇଣ୍ଟେଗ୍ରେସନ୍.