Skip to main content
Glama

@piprail/sdk @piprail/mcp types license x402 v2 chains

Let any HTTP endpoint charge for itself, and any agent pay for itself — across 28 chains, in a couple of lines.

Website · npm · Full docs →


@piprail/sdk implements the open x402 "402 Payment Required" standard with no backend, no database, no account, and no fee. Payments settle straight into your wallet, verified locally against your own RPC — across every major EVM chain plus Solana, TON, Tron, NEAR, Sui, Aptos, Algorand, Stellar & the XRP Ledger.

npm install @piprail/sdk viem

💸 Charge for an endpoint

import { requirePayment } from '@piprail/sdk'

app.get('/report',
  requirePayment({ chain: 'base', token: 'USDC', amount: '0.05', payTo: '0xYourWallet…' }),
  (_req, res) => res.json({ report: 'TOP SECRET' }),
)

That route now costs 0.05 USDC on Base, paid straight to your wallet. The first request gets a 402 with payment instructions; once the caller pays on-chain, it goes through. One parameter picks the chain.

🤖 Let an agent pay for it

import { PipRailClient } from '@piprail/sdk'

const client = new PipRailClient({ chain: 'base', wallet: { privateKey: process.env.AGENT_KEY } })

// Hits a 402, pays it on-chain, waits for confirmation, retries with proof — automatically.
const res = await client.fetch('https://api.example.com/report')

The same app can take payments and make them. Built for autonomous agents: install, add a wallet, monetize or pay — nothing else to wire up.

🔌 …or hand any AI agent a wallet — no code

@piprail/mcp is an MCP server that gives Claude Desktop, Cursor, Claude Code, Windsurf, VS Code, or Cline a budget-bound wallet. Add one block to your client config and the agent pays, discovers, and registers x402 URLs on its own — capped by a spend policy it cannot exceed:

{ "mcpServers": { "piprail": {
  "command": "npx", "args": ["-y", "@piprail/mcp"],
  "env": { "PIPRAIL_PRIVATE_KEY": "0x…", "PIPRAIL_CHAIN": "base", "PIPRAIL_MAX_AMOUNT": "0.10" } } } }

Five tools appear — piprail_discover, piprail_quote_payment, piprail_plan_payment, piprail_pay_request, piprail_register. Runs locally with your key; no backend, no custody. → MCP guide

🧭 Be discoverable — get found, find others

A 402 endpoint is payable, but nobody can find it. PipRail closes that gap with $0, no backend — built on the open x402 indexes (402 Index, CDP Bazaar), nothing PipRail-hosted:

await client.register('https://api.example.com/report', { name: 'Market Report', priceUsd: 0.05 })
const hits = await client.discover({ query: 'market data' }) // find payable APIs to use

Emit a machine-readable manifest (buildOpenApi / buildWellKnownX402 / buildX402DnsTxt), register on the open indexes (no auth, any chain), and discover resources to pay. → DISCOVERY.md

🌐 Supported chains

28 chains across 10 families — name one with a single chain: parameter. Non-EVM families lazy-load on first use, so a pure-EVM install never downloads their libraries.

Family

Built-in chains

Tokens

EVM (19)

Ethereum · Base · Arbitrum · Optimism · Polygon · BNB · Avalanche · Mantle · Sonic · Linea · Scroll · Celo · zkSync · Unichain · World Chain · Sei · Injective · HyperEVM · Monad

USDC + USDT*

Solana

Solana

USDC · USDT

TON

The Open Network

USD₮

Tron

Tron

USD₮

NEAR

NEAR

USDC · USDT

Sui

Sui

USDC

Aptos

Aptos

USDC · USDT

Algorand

Algorand

USDC

Stellar

Stellar

USDC · EURC

XRP Ledger

XRPL

USDC · RLUSD

*USDC on every EVM chain; USDT on all of them except Base, World Chain, Sei, HyperEVM, and Monad (their "USDT" is USDT0/LayerZero, not Tether-native — omitted). Any other EVM chain works via a viem Chain or { id, rpcUrl } — no allowlist. Every token address was verified on-chain before shipping.

✨ Why PipRail

Anything should be able to charge for itself — an API, a dataset, a model, an agent — and anyone should be able to get paid for it in seconds, without asking a platform for permission. The agent economy will run on millions of tiny, machine-to-machine payments, and that rail should be open, free, and self-custodial — not a toll booth owned by a middleman.

So we built it that way: no backend, no fees, no gatekeeper — an MIT library that turns any endpoint into a paid one and any agent into a paying customer, on every major chain. The goal is simple and audacious: make open, self-custodial payments the default rail for the agent economy.

⚙️ How it works

Agent                                  Your server
  │  GET /report                            │
  │ ───────────────────────────────────────►│  requirePayment
  │ ◄──────────── 402 + payment-required ────│  (issues a challenge)
  │  pay on-chain (one transfer to payTo)    │
  │ ───────────────────►  [the chain]        │
  │  GET /report  + payment-signature        │
  │ ───────────────────────────────────────►│  verifies the tx against
  │ ◄──────────── 200 + your content ────────│  its own RPC, then next()

Verification is local and confirms the transaction succeeded, is recent, and actually moved the required amount of the right token to payTo. The x402 v2 spec (§7) explicitly endorses merchant-local verification — no facilitator required — so this is a spec-compliant shape, not a workaround. Self-custody throughout: the payer signs and broadcasts their own transfer straight to your wallet; PipRail never holds funds and never takes a cut.

📦 What's in here

piprail/
├── sdk/         # @piprail/sdk — the core SDK (the product)            → published to npm
├── mcp/         # @piprail/mcp — the MCP server wrapping the SDK        → published to npm
├── site/        # piprail.com — the landing site (Astro 5 + Tailwind v4, deploys to Netlify)
├── examples/    # runnable merchant + agent demos + a live Anvil end-to-end
└── .github/     # CI: build/test checks · npm publish on sdk-v* / mcp-v* tags

Two packages are published to npm: @piprail/sdk (the core library) and @piprail/mcp (the MCP server, also listed in the MCP registry as io.github.piprail/mcp). site/ is the source of piprail.com; examples/ holds runnable demos — both live here in the repo but aren't published.

→ Full API & guides: sdk/README.md · MCP: mcp/README.md · discovery: sdk/DISCOVERY.md

No contracts/, no server, no database. PipRail is a tool you install, not a platform you sign up for.

🛠️ Quick start

npm install              # install workspace deps

npm run build:sdk        # build the SDK   (build it before the MCP — the MCP imports its dist)
npm run test:sdk         # run the SDK test suite
npm run build:mcp        # build the MCP server
npm run test:mcp         # run the MCP test suite
npm run typecheck        # typecheck the SDK + MCP

npm run dev              # run the landing site → http://localhost:4321

Live, end-to-end proofs (real published packages, no mocks) live in examples/: node run-all.mjs in examples/sdk-sandbox (the gate, client, policy, a real on-chain round-trip on a local Anvil fork, and live discovery) or examples/mcp-sandbox (the MCP server attacked as a greedy AI). A runnable examples/discovery calls emit / register / discover against the real open indexes.

Releasing a new version? See RELEASING.md — the publish is tag-driven CI, and a build-time guard keeps the site's docs in sync with the packages.

📄 License & trademark

Code: MIT — use it, fork it, ship it, commercially or otherwise.

Name & brand: PipRail™, the logo, and the @piprail npm scope are trademarks of the PipRail project — MIT covers the code, not the name. Build on it freely; just don't call a fork "PipRail" or imply it's official. See TRADEMARK.md.

Contributions welcome — see CONTRIBUTING.md (a simple DCO sign-off, no CLA).

Built for the agent economy · piprail.com

A
license - permissive license
-
quality - not tested
B
maintenance

Maintenance

Maintainers
Response time
0dRelease cycle
18Releases (12mo)

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/piprail/piprail'

If you have feedback or need assistance with the MCP directory API, please join our Discord server