tollbooth-x402 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +42 -0
- package/package.json +24 -0
- package/src/server.js +71 -0
package/README.md
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# tollbooth-x402
|
|
2
|
+
|
|
3
|
+
Free **MCP server** for [x402toll.com](https://x402toll.com) — a toll plaza of **verified,
|
|
4
|
+
pay-per-call calculators for AI agents**. Discover the catalog, run free coarse previews, verify any
|
|
5
|
+
paid response's provenance hash, and learn how to pay. The paid endpoints charge a few cents of USDC
|
|
6
|
+
per call over the **x402** protocol on Base — no account, no API key.
|
|
7
|
+
|
|
8
|
+
Why agents pay: the answers depend on exact **2026** data (tax brackets, contribution limits, state
|
|
9
|
+
fees) a model can't reliably know, every answer is checked against hand-verified reference values,
|
|
10
|
+
and each ships with a formula trace and a reproducible SHA-256 hash.
|
|
11
|
+
|
|
12
|
+
## Install
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npx -y tollbooth-x402
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Add to an MCP client (e.g. Claude Desktop / Cursor):
|
|
19
|
+
|
|
20
|
+
```json
|
|
21
|
+
{
|
|
22
|
+
"mcpServers": {
|
|
23
|
+
"tollbooth": { "command": "npx", "args": ["-y", "tollbooth-x402"] }
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Tools (all free, no wallet)
|
|
29
|
+
|
|
30
|
+
- **`tollbooth_catalog`** — every endpoint with prices, input schemas, methods, and golden-vector evidence.
|
|
31
|
+
- **`tollbooth_preview`** — a free rounded preview of a tool (paycheck, self-employment tax, capital gains, mortgage affordability, LLC cost, debt plan, impermanent loss).
|
|
32
|
+
- **`tollbooth_verify_hash`** — re-derive a paid response's hash to confirm it wasn't altered.
|
|
33
|
+
- **`tollbooth_how_to_pay`** — the x402 payment flow for the paid endpoints.
|
|
34
|
+
|
|
35
|
+
Paid calls are made directly against `https://x402toll.com` by an x402-capable wallet/client. Set
|
|
36
|
+
`TOLLBOOTH_URL` to point at a different gateway.
|
|
37
|
+
|
|
38
|
+
## Categories
|
|
39
|
+
|
|
40
|
+
Tax & payroll · Crypto & DeFi · Lending · Real estate · Retirement · Business.
|
|
41
|
+
|
|
42
|
+
MIT licensed. Estimates only — not financial, legal, or tax advice.
|
package/package.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "tollbooth-x402",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Free MCP server for x402toll.com — discover and preview verified pay-per-call calculators (tax, crypto/DeFi, lending, retirement) that AI agents pay for in USDC on Base via x402.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"tollbooth-x402": "src/server.js"
|
|
8
|
+
},
|
|
9
|
+
"main": "src/server.js",
|
|
10
|
+
"mcpName": "io.github.solomonblack/tollbooth-x402",
|
|
11
|
+
"files": ["src", "README.md"],
|
|
12
|
+
"engines": { "node": ">=18" },
|
|
13
|
+
"scripts": {
|
|
14
|
+
"test": "node --test"
|
|
15
|
+
},
|
|
16
|
+
"keywords": ["mcp", "modelcontextprotocol", "x402", "agent", "agentic-payments", "usdc", "base", "calculator", "tax", "crypto", "defi", "ai-agents"],
|
|
17
|
+
"homepage": "https://x402toll.com",
|
|
18
|
+
"repository": { "type": "git", "url": "git+https://github.com/solomonblack/tollbooth-x402.git" },
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
21
|
+
"zod": "^3.25.0"
|
|
22
|
+
},
|
|
23
|
+
"license": "MIT"
|
|
24
|
+
}
|
package/src/server.js
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// tollbooth-x402 — the FREE discovery MCP for the Tollbooth toll plaza (x402toll.com).
|
|
3
|
+
// A thin client: it calls the gateway's free HTTP endpoints (catalog, preview, verify-hash) —
|
|
4
|
+
// it does NOT bundle the calculation engine, so the exact paid math stays server-side. No wallet
|
|
5
|
+
// needed for these tools; the paid endpoints charge USDC per call over x402.
|
|
6
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
7
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
8
|
+
import { z } from 'zod';
|
|
9
|
+
|
|
10
|
+
const BASE = (process.env.TOLLBOOTH_URL || 'https://x402toll.com').replace(/\/+$/, '');
|
|
11
|
+
const text = obj => ({ content: [{ type: 'text', text: typeof obj === 'string' ? obj : JSON.stringify(obj, null, 2) }] });
|
|
12
|
+
|
|
13
|
+
async function api(path, init) {
|
|
14
|
+
const res = await fetch(BASE + path, { ...init, headers: { 'Content-Type': 'application/json', ...(init?.headers) } });
|
|
15
|
+
const body = await res.json().catch(() => ({ error: `non-JSON response (${res.status})` }));
|
|
16
|
+
return { ok: res.ok, status: res.status, body };
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const server = new McpServer({ name: 'tollbooth', version: '0.2.0' });
|
|
20
|
+
|
|
21
|
+
server.registerTool('tollbooth_catalog', {
|
|
22
|
+
description: 'List every Tollbooth paid endpoint at x402toll.com — verified calculators for tax, crypto/DeFi, lending, real estate, retirement, and business — with x402 prices, input schemas, methods, and golden-vector evidence. Free.',
|
|
23
|
+
inputSchema: {}
|
|
24
|
+
}, async () => {
|
|
25
|
+
const { ok, body } = await api('/v1/catalog', { method: 'GET' });
|
|
26
|
+
return text(ok ? body : { error: 'catalog unavailable', detail: body });
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
server.registerTool('tollbooth_preview', {
|
|
30
|
+
description: 'Free coarse preview of a Tollbooth tool (rounded headline figure only; the paid endpoint returns the full verified breakdown). Previewable tools include paycheck, self-employment-tax, capital-gains-tax, mortgage-affordability, llc-cost, debt-plan, impermanent-loss.',
|
|
31
|
+
inputSchema: {
|
|
32
|
+
tool: z.string().describe('The tool id, e.g. "paycheck" (see tollbooth_catalog for ids)'),
|
|
33
|
+
inputs: z.record(z.any()).describe('Tool inputs per the catalog inputSchema')
|
|
34
|
+
}
|
|
35
|
+
}, async ({ tool, inputs }) => {
|
|
36
|
+
const { ok, body } = await api(`/v1/preview/${encodeURIComponent(tool)}`, { method: 'POST', body: JSON.stringify(inputs ?? {}) });
|
|
37
|
+
return text(ok ? body : { error: body.error ?? 'preview failed', status: body });
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
server.registerTool('tollbooth_verify_hash', {
|
|
41
|
+
description: 'Free provenance check: re-derives the SHA-256 response hash of a previous Tollbooth paid response from its inputs and reports whether it matches (detects tampering).',
|
|
42
|
+
inputSchema: {
|
|
43
|
+
response: z.record(z.any()).describe('The full JSON response from a paid Tollbooth call'),
|
|
44
|
+
inputs: z.record(z.any()).describe('The exact inputs sent with that call')
|
|
45
|
+
}
|
|
46
|
+
}, async ({ response, inputs }) => {
|
|
47
|
+
const { ok, body } = await api('/v1/verify-hash', { method: 'POST', body: JSON.stringify({ response, inputs }) });
|
|
48
|
+
return text(ok ? body : { error: body.error ?? 'verification failed' });
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
server.registerTool('tollbooth_how_to_pay', {
|
|
52
|
+
description: 'How an agent pays a Tollbooth endpoint with x402 (v2) on Base: the 402 flow, the PAYMENT-SIGNATURE header, and client library pointers. Free.',
|
|
53
|
+
inputSchema: {}
|
|
54
|
+
}, async () => text({
|
|
55
|
+
gateway: BASE, protocol: 'x402 v2 · USDC on Base (eip155:8453)',
|
|
56
|
+
flow: [
|
|
57
|
+
'1. POST the tool inputs (JSON) to the paid endpoint with no payment.',
|
|
58
|
+
'2. Receive HTTP 402; the PAYMENT-REQUIRED response header is base64 JSON with accepts[] (scheme, network, amount in 6-decimal USDC units, asset, payTo).',
|
|
59
|
+
'3. Sign a USDC transfer authorization for that amount and retry with the PAYMENT-SIGNATURE header.',
|
|
60
|
+
'4. Receive 200 with the full verified result + a provenance block (formula, data vintage, reproducible hash); the PAYMENT-RESPONSE header carries the settlement receipt.'
|
|
61
|
+
],
|
|
62
|
+
clients: [
|
|
63
|
+
'JS/TS: @x402/fetch wrapFetchWithPaymentFromConfig + @x402/evm ExactEvmScheme + a funded Base wallet',
|
|
64
|
+
'MCP wallet servers let Claude/Cursor agents pay without custom code',
|
|
65
|
+
'Cloudflare Agents SDK has first-class x402 support'
|
|
66
|
+
],
|
|
67
|
+
note: 'Idempotent: retrying the same signed payment on the same endpoint returns the identical cached response with no second charge.'
|
|
68
|
+
}));
|
|
69
|
+
|
|
70
|
+
const transport = new StdioServerTransport();
|
|
71
|
+
await server.connect(transport);
|