rail402 MCP Discovery
Provides tools for discovering and calling paid APIs on the Stellar network using x402 payments, including a spend-capped paid-call tool.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@rail402 MCP DiscoverySearch Bazaar for a weather API and make a call with a 5 XLM cap."
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Rail402
x402 payments and discovery for Stellar. Rail402 is an x402 facilitator: it verifies and settles pay-per-request payments on Stellar and pays the network fee, so buyers need no XLM. Every API or MCP tool that gets paid through it is cataloged in its Bazaar, where agents and developers can find it with filters or plain-language search.
Works with the stock x402 packages (
@x402/fetch,@x402/express,@x402/stellar); nothing Rail402-specific to install in your client or server.Two schemes:
exact(a fixed price) andupto(the buyer signs a cap, the seller settles what the call used, through a Soroban settlement contract).Non-custodial: the buyer signs the payment, the seller receives it directly, Rail402 only sponsors the fee.
Agent tools: a buyer SDK, an MCP server (
rail402-mcp) and a CLI (rail402) that find and pay resources under a spending cap.Hosted testnet instance, free and without an API key; or run your own with one command.
Apache-2.0.
Release state. The npm packages are at 0.4.1 (2026-10-09): the facilitator, the Bazaar and search,
upto, the agent tools (@rail402.dev/sdk, @rail402.dev/mcp, @rail402.dev/cli) and their browser
entries. The hosted testnet service runs 0.4.1 with exact and upto. The latest container image and GitHub
release is 0.2.1 (exact only); later versions of the service run from a checkout. The
changelog lists what each release adds. The sections below say which release each command
uses.
Documentation: docs.rail402.dev
Try it in a minute
The hosted testnet facilitator (0.4.1, exact and upto) is public:
curl https://testnet.rail402.dev/supported
curl "https://testnet.rail402.dev/discovery/search?query=weather%20forecast%20under%201%20cent"Related MCP server: x402-gateway-mcp
Sell an API
Point a stock x402 resource server at Rail402. With Express:
npm install express@5 @x402/express@2.27.0 @x402/core@2.27.0 @x402/stellar@2.27.0 @x402/extensions@2.27.0import express from "express";
import { HTTPFacilitatorClient, x402ResourceServer } from "@x402/core/server";
import { paymentMiddleware } from "@x402/express";
import { bazaarResourceServerExtension, declareDiscoveryExtension } from "@x402/extensions/bazaar";
import { ExactStellarScheme } from "@x402/stellar/exact/server";
const facilitator = new HTTPFacilitatorClient({ url: "https://testnet.rail402.dev" });
const server = new x402ResourceServer(facilitator)
.register("stellar:testnet", new ExactStellarScheme())
.registerExtension(bazaarResourceServerExtension);
const app = express();
app.use(
paymentMiddleware(
{
"GET /weather": {
accepts: { scheme: "exact", price: "$0.01", network: "stellar:testnet", payTo: process.env.PAY_TO! },
description: "Current weather for a city",
extensions: declareDiscoveryExtension({ input: { city: "Ankara" } }),
},
},
server,
),
);
app.get("/weather", (_req, res) => res.json({ temperature: 21, conditions: "sunny" }));
app.listen(4021);Each paid request settles in testnet USDC straight to PAY_TO. Deployed on a public host, the endpoint is
listed in the Bazaar after its first payment. Full walkthrough, including a receiving account with a USDC
trustline: Quickstart for sellers.
Pay for one
npm install @x402/fetch@2.27.0 @x402/core@2.27.0 @x402/stellar@2.27.0import { wrapFetchWithPaymentFromConfig } from "@x402/fetch";
import { createEd25519Signer } from "@x402/stellar";
import { ExactStellarScheme } from "@x402/stellar/exact/client";
const pay = wrapFetchWithPaymentFromConfig(fetch, {
schemes: [
{
network: "stellar:testnet",
client: new ExactStellarScheme(createEd25519Signer(process.env.BUYER_SECRET!, "stellar:testnet")),
},
],
});
const response = await pay("https://demo.rail402.dev/weather?city=Ankara");
console.log(response.status, await response.json());The buyer needs testnet USDC and no XLM for fees. Creating a funded account takes one script: Quickstart for buyers.
Run your own facilitator
With the released container image (0.2.1, exact only), a testnet facilitator is three commands. Create a fee sponsor, fund it with
Friendbot, and start the service (STORE=memory keeps state in the process; use Postgres for anything
that must survive a restart):
docker run --rm ghcr.io/tolgayayci/rail402:0.2.1 node -e \
'const k = require("@stellar/stellar-sdk").Keypair.random(); console.log(k.publicKey(), k.secret())'
curl "https://friendbot.stellar.org?addr=G..." # the public key printed above
docker run -p 8080:8080 -e STORE=memory \
-e TESTNET_RPC_URL=https://soroban-testnet.stellar.org -e TESTNET_SPONSOR_SECRET=S... \
ghcr.io/tolgayayci/rail402:0.2.1curl localhost:8080/ready answers 200 once the channel accounts exist, within seconds.
For a durable setup with Postgres, one command each from a clone (this builds the checked-out source, so it includes everything below); both create a fee sponsor funded by Friendbot and wait until the service is ready:
git clone https://github.com/tolgayayci/rail402.git && cd rail402
./deploy/docker.sh # Docker on this machine: Postgres + Rail402 on 127.0.0.1:8080
./deploy/railway.sh my-facilitator # Railway (after `railway login`): Postgres + Rail402 + a public domainOr embed the settlement engine in your own server with npm install @rail402.dev/facilitator:
In-process.
Configuration, keys and operations: Configuration,
Operations.
What's inside
Feature | Endpoint or command | Details |
Facilitator |
| x402 v2 |
|
| Capped payments settled for the amount used through the Soroban |
Bazaar |
| Listings created from settled payments, bound to the paid |
Search |
| BM25F plus local embeddings, fused with RRF; filters and constraints read from the query |
Agent tools | SDK, | Find, pay and call resources under a spending cap, with SSRF-safe egress |
Playground |
| A browser page that pays on the testnet and shows every message, signature and transaction |
Every rejection has a stable code and a reason: Verification rules.
The upstream x402 e2e suite passes against Rail402 on the Stellar testnet
(conformance runs), and search quality is measured on a
public dataset with one command, pnpm eval (search evaluation).
stellar:pubnet can be configured; the hosted instance runs on testnet.
Packages
Package | What it is | On npm |
The settlement engine, usable in-process as an x402 facilitator | 0.4.1 | |
The Bazaar catalog built from settled payments | 0.4.1 | |
Natural-language search over the catalog | 0.4.1 | |
Postgres stores for settlements, channel accounts and the catalog | 0.4.1 | |
Stellar payload inspection and failure diagnosis | 0.4.1 | |
Stable error codes and reasons | 0.4.1 | |
The | 0.4.1 | |
Buyer SDK: pay under a spending cap, discover through the Bazaar | 0.4.1 | |
MCP server ( | 0.4.1 | |
Command-line tool ( | 0.4.1 | |
Outbound HTTP for untrusted URLs, SSRF-safe | 0.4.1 |
Develop
Requires Node.js 24.11 or later and pnpm 11 (corepack enable, or mise install), and Docker for the
integration tests. See CONTRIBUTING.md.
pnpm install
pnpm verify # format, lint, typecheck, unit tests, licence gate
docker compose --profile stellar up -d # Postgres + a private Stellar network
pnpm test:integrationPath | Contents |
| The HTTP service |
| A public example seller built only from the stock x402 packages |
| The Playground: a page and server for trying x402 payments in a browser |
| Settlement engine on |
| The |
| Stellar payload inspection, reason codes, diagnosis of on-chain failures |
| The catalog: integrity rules, origin verification, version history |
| Natural-language search |
| Durable ledger, channel leases, catalog, rate limits and metering |
| Buyer SDK: spending policy, budget ledger, discovery and paid calls |
| MCP server for agents |
| Command-line tool |
| SSRF-safe outbound HTTP |
| The |
| Test contracts: the TEST6 token, a spending-limit policy, composition tests |
| An SDK buyer and an MCP agent |
| Conformance runs against a live facilitator, with recorded results |
| Search evaluation dataset, harness and CI gate |
Licence
Apache-2.0. pnpm license:gate fails the build if any production dependency is not permissively
licensed; see the dependency licence report.
This server cannot be deployed
Maintenance
Related MCP Connectors
Verify and settle x402 stablecoin payments; browse the PayAI Bazaar of x402-payable resources.
Discover machine-payable APIs, probe x402 payment terms, and run seller operations. Non-custodial.
Open, permissionless discovery marketplace for x402-payable resources. No account or KYC required.
Pay for APIs with USDC. Read-only x402 payment discovery, verification, evidence, and status.
Related MCP Servers
- AlicenseNot gradedqualityNot gradedmaintenanceEnables AI agents to access a marketplace of paid tools by automatically handling Stellar blockchain payments and wallet management. It utilizes the X-402 protocol to facilitate transparent, automated transactions for tool usage through a marketplace backend.-
- AlicenseAqualityFmaintenanceEnables MCP clients to access all endpoints of an x402 gateway by paying real-time microtransactions (USDC on Base) per API call, with automatic tool discovery and spend guardrails.2357 npmMIT
- AlicenseNot gradedqualityCmaintenanceEnables AI agents to discover, query, and pay for HTTP endpoints and MCP tools using Stellar USDC/SEP-41 stablecoins through a federated P2P bazaar catalog and x402 payment facilitator.Apache 2.0
- AlicenseNot gradedqualityCmaintenanceEnables agents to access production-grade paid MCP tools with real on-chain x402 v2 settlement, including EVM wallet risk scoring, payload normalization, and facilitator discovery, all discoverable via Bazaar-compatible metadata.MIT