tollstile
v0.1.2
Published
Open-source payment middleware for APIs, MCP tools, and AI agents. Accept x402 and MPP payments with subscriptions, credits, spend limits, refunds, and a merchant-owned ledger.
Maintainers
Readme
tollstile
Open-source payment middleware for APIs, MCP tools, and AI agents. Accept x402 and MPP payments with subscriptions, credits, spend limits, refunds, and a merchant-owned ledger.
npm install tollstileimport { createTollstile, memoryLedger, testRail, upTo } from "tollstile";
const toll = createTollstile({ rails: [testRail()], ledger: memoryLedger() });
const perCall = toll.price("$0.05"); // fixed price
const perUse = toll.price(upTo("$0.50")); // settle what the handler usedPut the price in front of a route with the adapter for your framework — the handler you already have stays as it is:
| Where | Adapter |
|---|---|
| Next.js App Router | @tollstile/next — export const GET = paid(toll.price("$0.05"), handler) |
| Express | @tollstile/express |
| Hono | @tollstile/hono |
| Workers, Deno, Bun, any fetch handler | @tollstile/fetch |
| MCP servers | @tollstile/mcp — paidTool(), with human approval and checkout |
| A service in any language | @tollstile/proxy — a paid gateway in front of it |
Payment rails are separate packages too: @tollstile/x402, @tollstile/mpp, @tollstile/l402, @tollstile/kyapay; ledgers: @tollstile/postgres, @tollstile/sqlite. Docs: https://tollstile.com/docs
| Export | Purpose |
|---|---|
| createTollstile, upTo | Instance, prices, reconciliation |
| subscriber, credits, payPerCall, memoryBalance | Access policies |
| limit, payers, when, amountOver | Requirements |
| testRail, memoryLedger | Local development and tests |
| createRail | Build a rail for any payment protocol or provider (guide) |
| tollstile/testing | fakeClock, httpContext, mcpContext, railConformance |
Run reconciliation from a terminal or cron: npx tollstile reconcile --config tollstile.config.mjs --older-than 15m (guide). Each run examines at most 500 charges, most recently updated first, and the CLI keeps going while report.truncated is true.
Docs: https://tollstile.com/docs · For coding agents: https://tollstile.com/llms.txt
MIT © 2026 Paradigm AI Inc.
