x402-list-mcp 0.1.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 ADDED
@@ -0,0 +1,72 @@
1
+ # x402-list-mcp
2
+
3
+ MCP server for x402-list: discover x402 payment services and on-chain-verified facilitator settlement volume.
4
+
5
+ ## What is x402-list
6
+
7
+ [x402-list](https://x402-list.com) is the directory of services that accept x402 (HTTP 402 stablecoin) payments. Its distinctive, defensible data is **on-chain-verified settlement volume per facilitator**, not self-reported numbers. Listed services are continuously health-monitored (uptime, response time, status).
8
+
9
+ This package is a **thin, read-only wrapper** over the public x402-list HTTP JSON API. It holds no keys, touches no database, and makes no writes. It exposes the directory to AI agents through the Model Context Protocol.
10
+
11
+ ## Install and quick start
12
+
13
+ ### stdio (local MCP clients)
14
+
15
+ ```
16
+ npx -y x402-list-mcp
17
+ ```
18
+
19
+ Claude Desktop / generic MCP client config:
20
+
21
+ ```json
22
+ { "mcpServers": { "x402-list": { "command": "npx", "args": ["-y", "x402-list-mcp"] } } }
23
+ ```
24
+
25
+ ### Hosted HTTP (Streamable HTTP transport)
26
+
27
+ ```
28
+ MCP_HTTP_PORT=3000 npx -y x402-list-mcp --http
29
+ ```
30
+
31
+ Hosted endpoint: `https://mcp.x402-list.com/mcp`. Health probe: `GET /healthz` returns `{"status":"ok"}`.
32
+
33
+ ## Environment variables
34
+
35
+ | Variable | Default | Purpose |
36
+ | --- | --- | --- |
37
+ | `X402_LIST_BASE_URL` | `https://x402-list.com` | API base URL. The `/api/v1` prefix is appended automatically. |
38
+ | `X402_LIST_TIMEOUT_MS` | `15000` | Per-request timeout in milliseconds. |
39
+ | `MCP_HTTP_PORT` / `PORT` | `3000` | HTTP port. Setting `MCP_HTTP_PORT` selects HTTP transport. |
40
+ | `MCP_ALLOWED_ORIGINS` | (empty, permissive) | Comma list of allowed CORS origins for HTTP mode. |
41
+ | `MCP_ALLOWED_HOSTS` | (empty, off) | Comma list that enables DNS-rebinding protection in HTTP mode. |
42
+
43
+ ## Tools
44
+
45
+ | Tool | What it does |
46
+ | --- | --- |
47
+ | `search_x402_services` | Search and filter the directory by query, category, network, status; sort by newest/uptime/cheapest/endpoints. |
48
+ | `get_service` | Full detail for one service by slug: endpoints, per-endpoint USD pricing, uptime windows, networks, settlement asset. |
49
+ | `find_best_service` | Ranked recommendation for a need. Ranks by reliability and price (status, verified, uptime, response time, USD price), NOT by settlement volume. |
50
+ | `check_health` | Live status, directory-wide or per service (uptime snapshots, consecutive failures). |
51
+ | `get_facilitator_volumes` | Per-facilitator on-chain-verified settlement volume (24h/7d/30d/all) in USD, tx counts, and an on-chain vs listed flag. |
52
+
53
+ ## Units note
54
+
55
+ All monetary values are decimal US dollars and are passed through verbatim. There is no cents conversion anywhere. The per-endpoint `pricing[].price` field is a raw atomic on-chain token amount (a uint256 string), not dollars; only `price_usd` is the dollar figure.
56
+
57
+ ## Honesty note
58
+
59
+ Settlement volume is tracked **per facilitator only**, never per service. `find_best_service` does not rank by volume and never implies a per-service revenue figure. To ask "which facilitators have real on-chain volume", use `get_facilitator_volumes` and read the `verification` flag.
60
+
61
+ ## Development
62
+
63
+ ```
64
+ npm install
65
+ npm run build
66
+ npm run smoke # offline: spawns the built server, lists tools
67
+ X402_LIST_SMOKE_LIVE=1 npm run smoke # also calls the live API and checks USD pass-through
68
+ ```
69
+
70
+ ## License
71
+
72
+ MIT
package/SKILL.md ADDED
@@ -0,0 +1,32 @@
1
+ ---
2
+ name: x402-list
3
+ description: Discover x402 payment services and on-chain-verified facilitator settlement volume via the x402-list directory. Use when a user or agent needs to find an API/service that accepts x402 (HTTP 402 stablecoin) payments, compare services by reliability and price, check service uptime/health, or look up which x402 facilitators have real on-chain settlement volume.
4
+ ---
5
+
6
+ # x402-list
7
+
8
+ ## What x402-list is
9
+
10
+ x402-list is the canonical directory of services that accept x402 payments. Its distinctive, defensible data is **on-chain-verified settlement volume per facilitator**, not self-reported figures. Listed services are continuously health-monitored for uptime, response time, and live status. This MCP server is a read-only wrapper over the public x402-list API; it needs no API key.
11
+
12
+ ## Money units (read this first)
13
+
14
+ **All `*_usd` fields are decimal US dollars and are used as-is. There is no cents conversion.** For example `min_price_usd: 0.001` means one tenth of a cent, and `volume_usd_all: 1542635.84` means about 1.54 million dollars. The service-detail `pricing[].price` field is an atomic on-chain token amount (a uint256 string), NOT dollars; only `price_usd` is the dollar figure. Never rescale either one.
15
+
16
+ ## Tool guide (when to use each)
17
+
18
+ - `search_x402_services`: find and filter services by free-text query, category, network, and status; sort by newest, uptime, cheapest, or endpoint count. Start here for discovery.
19
+ - `get_service`: deep-dive one service by slug. Returns every endpoint, per-endpoint USD pricing, uptime windows (24h/7d/30d/90d), accepted networks, and the settlement asset.
20
+ - `find_best_service`: get a ranked recommendation for a need. Ranks by reliability and price (status, verified, uptime_24h, response time, USD price), filtered by category and network. It does NOT rank by volume. State this limitation to the user.
21
+ - `check_health`: live status. With no slug, a directory-wide snapshot (online/degraded/offline/unknown counts plus per-service status). With a slug, that service's status, uptime windows, response time, consecutive failures, and recent daily uptime snapshots.
22
+ - `get_facilitator_volumes`: the headline metric. Per-facilitator settlement volume (24h/7d/30d/all) in USD, transaction counts, and an `on-chain` vs `listed` verification flag. Optional daily timeseries and per-chain breakdown.
23
+
24
+ ## The honesty guard
25
+
26
+ There is NO per-service settlement volume in x402-list. Volume is aggregated **per facilitator**. Do not claim or imply that a given service has X dollars of volume. If asked "which service does the most volume", explain the data model and offer facilitator volumes (via `get_facilitator_volumes`) plus a service reliability ranking (via `find_best_service`) instead.
27
+
28
+ ## Typical workflows
29
+
30
+ - "Find me a cheap, reliable image-generation x402 API on Base" -> `find_best_service` with category, network `Base`, your need as `q`, and `prefer: cheapest`, then `get_service` on the top pick.
31
+ - "Is service X healthy?" -> `check_health` with `slug: X`.
32
+ - "Which x402 facilitators are real (have on-chain volume)?" -> `get_facilitator_volumes` with `timeframe: 30d`, then read each `verification` flag.
package/dist/api.d.ts ADDED
@@ -0,0 +1,191 @@
1
+ export interface ApiEnvelope<T> {
2
+ data: T;
3
+ meta?: Record<string, unknown>;
4
+ }
5
+ export declare class ApiError extends Error {
6
+ status: number;
7
+ body?: unknown;
8
+ constructor(message: string, o: {
9
+ status: number;
10
+ body?: unknown;
11
+ cause?: unknown;
12
+ });
13
+ }
14
+ export declare function apiGet<T>(path: string, query?: Record<string, string | number | boolean | undefined>, opts?: {
15
+ timeoutMs?: number;
16
+ }): Promise<ApiEnvelope<T>>;
17
+ export interface ServiceListItem {
18
+ slug: string;
19
+ name: string;
20
+ description: string;
21
+ base_url: string;
22
+ website_url: string | null;
23
+ category: string;
24
+ status: "online" | "degraded" | "offline" | "unknown";
25
+ verified: boolean;
26
+ endpoint_count: number;
27
+ min_price_usd: number | null;
28
+ networks: string[];
29
+ uptime_24h: number | null;
30
+ avg_response_time_ms: number | null;
31
+ last_checked_at: string | null;
32
+ created_at: string | null;
33
+ }
34
+ export interface ServicesListResponse {
35
+ data: ServiceListItem[];
36
+ meta: {
37
+ total: number;
38
+ page: number;
39
+ per_page: number;
40
+ total_pages: number;
41
+ };
42
+ }
43
+ export interface PricingEntry {
44
+ scheme: string;
45
+ network: string;
46
+ asset_address: string;
47
+ asset_name: string;
48
+ price: string;
49
+ price_usd: string;
50
+ pay_to: string;
51
+ max_timeout_seconds: number;
52
+ }
53
+ export interface ServiceEndpoint {
54
+ id: string;
55
+ method: string;
56
+ path: string;
57
+ description: string | null;
58
+ mime_type: string | null;
59
+ is_active: boolean;
60
+ first_seen_at: string | null;
61
+ last_seen_at: string | null;
62
+ min_price_usd: number | null;
63
+ networks: string[];
64
+ pricing: PricingEntry[];
65
+ }
66
+ export interface ServiceDetail {
67
+ slug: string;
68
+ name: string;
69
+ description: string;
70
+ base_url: string;
71
+ website_url: string | null;
72
+ category: string;
73
+ status: "online" | "degraded" | "offline" | "unknown";
74
+ verified: boolean;
75
+ consecutive_failures: number;
76
+ check_interval_minutes: number;
77
+ last_checked_at: string | null;
78
+ created_at: string | null;
79
+ uptime: {
80
+ "24h": number;
81
+ "7d": number;
82
+ "30d": number;
83
+ "90d": number;
84
+ };
85
+ avg_response_time_ms: number | null;
86
+ total_checks: number;
87
+ networks: string[];
88
+ asset: string;
89
+ endpoints: ServiceEndpoint[];
90
+ }
91
+ export interface UptimeSnapshot {
92
+ period_start: string;
93
+ period_end: string;
94
+ uptime_percentage: number;
95
+ avg_response_time_ms: number;
96
+ total_checks: number;
97
+ successful_checks: number;
98
+ }
99
+ export interface FacilitatorChain {
100
+ network: string;
101
+ token_address: string;
102
+ asset_name: string;
103
+ volume_usd_24h: number;
104
+ volume_usd_7d: number;
105
+ volume_usd_30d: number;
106
+ volume_usd_all: number;
107
+ tx_count_all: number;
108
+ last_activity_at: string | null;
109
+ verification: "on-chain" | "listed";
110
+ }
111
+ export interface Facilitator {
112
+ facilitator_id: string;
113
+ name: string;
114
+ website_url: string | null;
115
+ volume_usd_24h: number;
116
+ volume_usd_7d: number;
117
+ volume_usd_30d: number;
118
+ volume_usd_all: number;
119
+ tx_count_24h: number;
120
+ tx_count_7d: number;
121
+ tx_count_30d: number;
122
+ tx_count_all: number;
123
+ last_activity_at: string | null;
124
+ settler_count: number;
125
+ verification: "on-chain" | "listed";
126
+ timeseries?: Array<{
127
+ date: string;
128
+ volume_usd: number;
129
+ tx_count: number;
130
+ }>;
131
+ chains?: FacilitatorChain[];
132
+ }
133
+ export interface FacilitatorsResponse {
134
+ data: Facilitator[];
135
+ meta: {
136
+ total: number;
137
+ page: number;
138
+ per_page: number;
139
+ total_pages: number;
140
+ timeframe: string;
141
+ };
142
+ }
143
+ export interface StatusServiceItem {
144
+ slug: string;
145
+ name: string;
146
+ status: "online" | "degraded" | "offline" | "unknown";
147
+ last_checked_at: string | null;
148
+ consecutive_failures: number;
149
+ uptime_24h: number | null;
150
+ avg_response_time_ms: number | null;
151
+ }
152
+ export interface StatusResponse {
153
+ total: number;
154
+ online: number;
155
+ degraded: number;
156
+ offline: number;
157
+ unknown: number;
158
+ services: StatusServiceItem[];
159
+ }
160
+ export declare const getServices: (q: {
161
+ page?: number;
162
+ per_page?: number;
163
+ status?: string;
164
+ category?: string;
165
+ network?: string;
166
+ sort?: string;
167
+ q?: string;
168
+ }) => Promise<ServicesListResponse>;
169
+ export declare const getService: (slug: string) => Promise<ApiEnvelope<ServiceDetail>>;
170
+ export declare const getServiceUptime: (slug: string, period?: string) => Promise<ApiEnvelope<UptimeSnapshot[]>>;
171
+ export declare const getFacilitators: (q: {
172
+ page?: number;
173
+ per_page?: number;
174
+ timeframe?: string;
175
+ include?: string;
176
+ days?: number;
177
+ }) => Promise<FacilitatorsResponse>;
178
+ export declare const getStatus: () => Promise<ApiEnvelope<StatusResponse>>;
179
+ export declare const getCategories: () => Promise<ApiEnvelope<string[]>>;
180
+ export interface NetworkItem {
181
+ id: string;
182
+ caip2_id: string;
183
+ name: string;
184
+ abbreviation: string;
185
+ chain_type: string;
186
+ is_mainnet: boolean;
187
+ explorer_url: string | null;
188
+ service_count: number;
189
+ avg_uptime: number | null;
190
+ }
191
+ export declare const getNetworks: () => Promise<ApiEnvelope<NetworkItem[]>>;
package/dist/api.js ADDED
@@ -0,0 +1,74 @@
1
+ // Typed, read-only HTTP client over the PUBLIC x402-list JSON API.
2
+ // No DB, no money-path, no writes. Native fetch only (Node 20+).
3
+ //
4
+ // MONETARY UNITS: every *_usd / *_price_usd / volume_usd_* field is already
5
+ // decimal US dollars and is passed through verbatim. The one trap is
6
+ // pricing[].price, which is an ATOMIC on-chain token amount (uint256 string),
7
+ // NOT money. This module never coerces or rescales any value.
8
+ const BASE = (process.env.X402_LIST_BASE_URL ?? "https://x402-list.com").replace(/\/+$/, "");
9
+ const PREFIX = "/api/v1";
10
+ const DEFAULT_TIMEOUT_MS = Number(process.env.X402_LIST_TIMEOUT_MS ?? 15000);
11
+ const USER_AGENT = "x402-list-mcp/0.1.0 (+https://x402-list.com)";
12
+ export class ApiError extends Error {
13
+ status;
14
+ body;
15
+ constructor(message, o) {
16
+ super(message, { cause: o.cause });
17
+ this.name = "ApiError";
18
+ this.status = o.status;
19
+ this.body = o.body;
20
+ }
21
+ }
22
+ export async function apiGet(path, query, opts) {
23
+ const url = new URL(BASE + PREFIX + path);
24
+ if (query) {
25
+ for (const [k, v] of Object.entries(query)) {
26
+ if (v !== undefined && v !== null && v !== "")
27
+ url.searchParams.set(k, String(v));
28
+ }
29
+ }
30
+ const ctrl = new AbortController();
31
+ const t = setTimeout(() => ctrl.abort(), opts?.timeoutMs ?? DEFAULT_TIMEOUT_MS);
32
+ let res;
33
+ try {
34
+ res = await fetch(url, {
35
+ method: "GET",
36
+ headers: { accept: "application/json", "user-agent": USER_AGENT },
37
+ signal: ctrl.signal,
38
+ });
39
+ }
40
+ catch (e) {
41
+ throw new ApiError(`Network error calling ${path}`, { cause: e, status: 0 });
42
+ }
43
+ finally {
44
+ clearTimeout(t);
45
+ }
46
+ const text = await res.text();
47
+ let body = undefined;
48
+ try {
49
+ body = text ? JSON.parse(text) : undefined;
50
+ }
51
+ catch {
52
+ /* leave undefined */
53
+ }
54
+ if (!res.ok) {
55
+ // upstream error shape: { error: { code, message } }
56
+ const msg = body?.error?.message ?? `HTTP ${res.status} from ${path}`;
57
+ throw new ApiError(msg, { status: res.status, body });
58
+ }
59
+ if (!body || !("data" in body)) {
60
+ throw new ApiError(`Malformed response from ${path} (no data field)`, { status: res.status, body });
61
+ }
62
+ return body;
63
+ }
64
+ // ---- Endpoint wrappers (the ONLY place that knows paths and param names) ----
65
+ // Full-text search param is `q`; pagination is `page` / `per_page`.
66
+ // There is NO `verified` query filter; verified is filtered client-side in tools.ts.
67
+ export const getServices = (q) => apiGet("/services", q);
68
+ export const getService = (slug) => apiGet(`/services/${encodeURIComponent(slug)}`);
69
+ export const getServiceUptime = (slug, period) => apiGet(`/services/${encodeURIComponent(slug)}/uptime`, { period });
70
+ export const getFacilitators = (q) => apiGet("/facilitators", q);
71
+ export const getStatus = () => apiGet("/status");
72
+ export const getCategories = () => apiGet("/categories");
73
+ export const getNetworks = () => apiGet("/networks");
74
+ //# sourceMappingURL=api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA,mEAAmE;AACnE,iEAAiE;AACjE,EAAE;AACF,4EAA4E;AAC5E,qEAAqE;AACrE,8EAA8E;AAC9E,8DAA8D;AAE9D,MAAM,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,kBAAkB,IAAI,uBAAuB,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AAC7F,MAAM,MAAM,GAAG,SAAS,CAAC;AACzB,MAAM,kBAAkB,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,oBAAoB,IAAI,KAAK,CAAC,CAAC;AAC7E,MAAM,UAAU,GAAG,8CAA8C,CAAC;AAOlE,MAAM,OAAO,QAAS,SAAQ,KAAK;IACjC,MAAM,CAAS;IACf,IAAI,CAAW;IACf,YAAY,OAAe,EAAE,CAAsD;QACjF,KAAK,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC;QACnC,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;QACvB,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC;QACvB,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC;IACrB,CAAC;CACF;AAED,MAAM,CAAC,KAAK,UAAU,MAAM,CAC1B,IAAY,EACZ,KAA6D,EAC7D,IAA6B;IAE7B,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,IAAI,GAAG,MAAM,GAAG,IAAI,CAAC,CAAC;IAC1C,IAAI,KAAK,EAAE,CAAC;QACV,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YAC3C,IAAI,CAAC,KAAK,SAAS,IAAI,CAAC,KAAK,IAA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DED
@@ -0,0 +1 @@
1
+ export declare function startHttp(port: number): Promise<void>;
package/dist/http.js ADDED
@@ -0,0 +1,155 @@
1
+ // Streamable HTTP transport server (hosted mode), built on Node's native http.
2
+ // One McpServer instance per MCP session, per the MCP spec. The SDK transport
3
+ // does the protocol work (POST messages, GET SSE stream, DELETE terminate); this
4
+ // wrapper only handles routing, CORS, the /healthz probe, and the session map.
5
+ import { createServer } from "node:http";
6
+ import { randomUUID } from "node:crypto";
7
+ import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
8
+ import { isInitializeRequest } from "@modelcontextprotocol/sdk/types.js";
9
+ import { buildServer } from "./server.js";
10
+ const MAX_BODY_BYTES = 1024 * 1024; // ~1 MB
11
+ const ALLOWED_ORIGINS = (process.env.MCP_ALLOWED_ORIGINS ?? "")
12
+ .split(",")
13
+ .map((s) => s.trim())
14
+ .filter(Boolean);
15
+ const ALLOWED_HOSTS = (process.env.MCP_ALLOWED_HOSTS ?? "")
16
+ .split(",")
17
+ .map((s) => s.trim())
18
+ .filter(Boolean);
19
+ function applyCors(req, res) {
20
+ const origin = req.headers.origin;
21
+ if (ALLOWED_ORIGINS.length === 0) {
22
+ res.setHeader("Access-Control-Allow-Origin", "*");
23
+ }
24
+ else if (origin && ALLOWED_ORIGINS.includes(origin)) {
25
+ res.setHeader("Access-Control-Allow-Origin", origin);
26
+ res.setHeader("Vary", "Origin");
27
+ }
28
+ res.setHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, OPTIONS");
29
+ res.setHeader("Access-Control-Allow-Headers", "content-type, accept, mcp-session-id, last-event-id, mcp-protocol-version, authorization");
30
+ res.setHeader("Access-Control-Expose-Headers", "mcp-session-id");
31
+ }
32
+ function readBody(req) {
33
+ return new Promise((resolve, reject) => {
34
+ const chunks = [];
35
+ let size = 0;
36
+ req.on("data", (c) => {
37
+ size += c.length;
38
+ if (size > MAX_BODY_BYTES) {
39
+ reject(new Error("Request body too large"));
40
+ req.destroy();
41
+ return;
42
+ }
43
+ chunks.push(c);
44
+ });
45
+ req.on("end", () => {
46
+ const raw = Buffer.concat(chunks).toString("utf8");
47
+ if (!raw)
48
+ return resolve(undefined);
49
+ try {
50
+ resolve(JSON.parse(raw));
51
+ }
52
+ catch (e) {
53
+ reject(e);
54
+ }
55
+ });
56
+ req.on("error", reject);
57
+ });
58
+ }
59
+ function sendJson(res, status, body) {
60
+ const text = JSON.stringify(body);
61
+ res.writeHead(status, { "content-type": "application/json" });
62
+ res.end(text);
63
+ }
64
+ function jsonRpcError(res, status, message) {
65
+ sendJson(res, status, {
66
+ jsonrpc: "2.0",
67
+ error: { code: -32000, message },
68
+ id: null,
69
+ });
70
+ }
71
+ export async function startHttp(port) {
72
+ const transports = new Map();
73
+ const httpServer = createServer((req, res) => {
74
+ void handle(req, res).catch((e) => {
75
+ console.error("HTTP handler error:", e);
76
+ if (!res.headersSent)
77
+ jsonRpcError(res, 500, "Internal server error");
78
+ });
79
+ });
80
+ async function handle(req, res) {
81
+ applyCors(req, res);
82
+ if (req.method === "OPTIONS") {
83
+ res.writeHead(204);
84
+ res.end();
85
+ return;
86
+ }
87
+ const url = new URL(req.url ?? "/", "http://localhost");
88
+ const path = url.pathname;
89
+ // Health probe (NOT an MCP route): handled before MCP routing.
90
+ if (path === "/healthz") {
91
+ if (req.method !== "GET") {
92
+ res.writeHead(405);
93
+ res.end();
94
+ return;
95
+ }
96
+ sendJson(res, 200, { status: "ok" });
97
+ return;
98
+ }
99
+ if (path !== "/mcp" && path !== "/") {
100
+ jsonRpcError(res, 404, "Not found");
101
+ return;
102
+ }
103
+ const sid = req.headers["mcp-session-id"];
104
+ if (req.method === "POST") {
105
+ let body;
106
+ try {
107
+ body = await readBody(req);
108
+ }
109
+ catch (e) {
110
+ jsonRpcError(res, 400, `Invalid request body: ${e.message}`);
111
+ return;
112
+ }
113
+ let transport;
114
+ if (sid && transports.has(sid)) {
115
+ transport = transports.get(sid);
116
+ }
117
+ else if (!sid && isInitializeRequest(body)) {
118
+ transport = new StreamableHTTPServerTransport({
119
+ sessionIdGenerator: () => randomUUID(),
120
+ onsessioninitialized: (id) => {
121
+ transports.set(id, transport);
122
+ },
123
+ ...(ALLOWED_HOSTS.length > 0
124
+ ? { enableDnsRebindingProtection: true, allowedHosts: ALLOWED_HOSTS }
125
+ : {}),
126
+ });
127
+ transport.onclose = () => {
128
+ if (transport.sessionId)
129
+ transports.delete(transport.sessionId);
130
+ };
131
+ await buildServer().connect(transport);
132
+ }
133
+ else {
134
+ jsonRpcError(res, 400, "No valid session. Send an initialize request first.");
135
+ return;
136
+ }
137
+ await transport.handleRequest(req, res, body);
138
+ return;
139
+ }
140
+ if (req.method === "GET" || req.method === "DELETE") {
141
+ if (!sid || !transports.has(sid)) {
142
+ jsonRpcError(res, 400, "No valid session.");
143
+ return;
144
+ }
145
+ await transports.get(sid).handleRequest(req, res);
146
+ return;
147
+ }
148
+ res.writeHead(405);
149
+ res.end();
150
+ }
151
+ httpServer.listen(port, () => {
152
+ console.error(`x402-list-mcp HTTP on :${port}/mcp`);
153
+ });
154
+ }
155
+ //# sourceMappingURL=http.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http.js","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,8EAA8E;AAC9E,iFAAiF;AACjF,+EAA+E;AAE/E,OAAO,EAAE,YAAY,EAA6C,MAAM,WAAW,CAAC;AACpF,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,6BAA6B,EAAE,MAAM,oDAAoD,CAAC;AACnG,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,MAAM,cAAc,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC,QAAQ;AAE5C,MAAM,eAAe,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,mBAAmB,IAAI,EAAE,CAAC;KA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AAS,CAAC,OAAO,GAAG,GAAG,EAAE;oBACvB,IAAI,SAAU,CAAC,SAAS;wBAAE,UAAU,CAAC,MAAM,CAAC,SAAU,CAAC,SAAS,CAAC,CAAC;gBACpE,CAAC,CAAC;gBACF,MAAM,WAAW,EAAE,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;YACzC,CAAC;iBAAM,CAAC;gBACN,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,qDAAqD,CAAC,CAAC;gBAC9E,OAAO;YACT,CAAC;YAED,MAAM,SAAU,CAAC,aAAa,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;YAC/C,OAAO;QACT,CAAC;QAED,IAAI,GAAG,CAAC,MAAM,KAAK,KAAK,IAAI,GAAG,CAAC,MAAM,KAAK,QAAQ,EAAE,CAAC;YACpD,IAAI,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;gBACjC,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,mBAAmB,CAAC,CAAC;gBAC5C,OAAO;YACT,CAAC;YACD,MAAM,UAAU,CAAC,GAAG,CAAC,GAAG,CAAE,CAAC,aAAa,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;YACnD,OAAO;QACT,CAAC;QAED,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;QACnB,GAAG,CAAC,GAAG,EAAE,CAAC;IACZ,CAAC;IAED,UAAU,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,EAAE;QAC3B,OAAO,CAAC,KAAK,CAAC,0BAA0B,IAAI,MAAM,CAAC,CAAC;IACtD,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/dist/index.js ADDED
@@ -0,0 +1,40 @@
1
+ #!/usr/bin/env node
2
+ // Entry + bin. Picks transport: stdio by default, Streamable HTTP when --http
3
+ // is passed or MCP_HTTP_PORT is set (e.g. in the Docker image).
4
+ import { startStdio } from "./server.js";
5
+ import { startHttp } from "./http.js";
6
+ const args = process.argv.slice(2);
7
+ const wantHttp = args.includes("--http") || !!process.env.MCP_HTTP_PORT;
8
+ const port = Number(process.env.MCP_HTTP_PORT ?? process.env.PORT ?? 3000);
9
+ if (args.includes("--help") || args.includes("-h")) {
10
+ // stdout is safe here: we are not in an active stdio MCP session.
11
+ console.log([
12
+ "x402-list-mcp: read-only MCP server for the x402-list directory.",
13
+ "",
14
+ "Usage:",
15
+ " x402-list-mcp Run on stdio (default; for local MCP clients).",
16
+ " x402-list-mcp --http Run the Streamable HTTP transport.",
17
+ "",
18
+ "Environment:",
19
+ " X402_LIST_BASE_URL API base (default https://x402-list.com).",
20
+ " X402_LIST_TIMEOUT_MS Per-request timeout in ms (default 15000).",
21
+ " MCP_HTTP_PORT / PORT HTTP port (default 3000). Setting MCP_HTTP_PORT selects HTTP.",
22
+ " MCP_ALLOWED_ORIGINS Comma list of allowed CORS origins (HTTP mode).",
23
+ " MCP_ALLOWED_HOSTS Comma list enabling DNS-rebinding protection (HTTP mode).",
24
+ ].join("\n"));
25
+ process.exit(0);
26
+ }
27
+ if (wantHttp) {
28
+ startHttp(port).catch((e) => {
29
+ console.error(e);
30
+ process.exit(1);
31
+ });
32
+ }
33
+ else {
34
+ // stdio mode: NOTHING may be written to stdout except the MCP protocol stream.
35
+ startStdio().catch((e) => {
36
+ console.error(e);
37
+ process.exit(1);
38
+ });
39
+ }
40
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,8EAA8E;AAC9E,gEAAgE;AAEhE,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACnC,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC;AACxE,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,IAAI,CAAC,CAAC;AAE3E,IAAI,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;IACnD,kEAAkE;IAClE,OAAO,CAAC,GAAG,CACT;QACE,kEAAkE;QAClE,EAAE;QACF,QAAQ;QACR,2EAA2E;QAC3E,+DAA+D;QAC/D,EAAE;QACF,cAAc;QACd,sEAAsE;QACtE,uEAAuE;QACvE,0FAA0F;QAC1F,4EAA4E;QAC5E,sFAAsF;KACvF,CAAC,IAAI,CAAC,IAAI,CAAC,CACb,CAAC;IACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,IAAI,QAAQ,EAAE,CAAC;IACb,SAAS,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;QAC1B,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACjB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC;KAAM,CAAC;IACN,+EAA+E;IAC/E,UAAU,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;QACvB,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACjB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ export declare const SERVER_INFO: {
3
+ name: string;
4
+ version: string;
5
+ };
6
+ export declare function buildServer(): McpServer;
7
+ export declare function startStdio(): Promise<void>;
package/dist/server.js ADDED
@@ -0,0 +1,22 @@
1
+ // Builds a configured McpServer with all 5 tools registered, plus the stdio
2
+ // start helper. The HTTP start helper lives in http.ts.
3
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
4
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
5
+ import { registerTools } from "./tools.js";
6
+ export const SERVER_INFO = { name: "x402-list-mcp", version: "0.1.0" };
7
+ export function buildServer() {
8
+ const server = new McpServer(SERVER_INFO, {
9
+ capabilities: { tools: {} },
10
+ instructions: "x402-list is the directory of services that accept x402 payments, with on-chain-verified settlement volume per facilitator. Use search_x402_services to discover, get_service for detail, find_best_service to recommend (reliability/price, NOT volume), check_health for status, get_facilitator_volumes for the per-facilitator on-chain settlement metric. All money fields are decimal US dollars.",
11
+ });
12
+ registerTools(server);
13
+ return server;
14
+ }
15
+ export async function startStdio() {
16
+ const server = buildServer();
17
+ const transport = new StdioServerTransport();
18
+ await server.connect(transport);
19
+ // stdio hygiene: diagnostics go to stderr only; stdout is the JSON-RPC channel.
20
+ console.error("x402-list-mcp running on stdio");
21
+ }
22
+ //# sourceMappingURL=server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,wDAAwD;AAExD,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3C,MAAM,CAAC,MAAM,WAAW,GAAG,EAAE,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;AAEvE,MAAM,UAAU,WAAW;IACzB,MAAM,MAAM,GAAG,IAAI,SAAS,CAAC,WAAW,EAAE;QACxC,YAAY,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE;QAC3B,YAAY,EACV,yYAAyY;KAC5Y,CAAC,CAAC;IACH,aAAa,CAAC,MAAM,CAAC,CAAC;IACtB,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,UAAU;IAC9B,MAAM,MAAM,GAAG,WAAW,EAAE,CAAC;IAC7B,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAChC,gFAAgF;IAChF,OAAO,CAAC,KAAK,CAAC,gCAAgC,CAAC,CAAC;AAClD,CAAC"}
@@ -0,0 +1,2 @@
1
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ export declare function registerTools(server: McpServer): void;
package/dist/tools.js ADDED
@@ -0,0 +1,524 @@
1
+ // The 5 x402-list MCP tools: schemas, handlers, response mapping.
2
+ //
3
+ // USD PASS-THROUGH RULE: every *_usd field is copied straight from the API value.
4
+ // No Math.round, no multiply, no divide. pricing[].price is copied as the raw
5
+ // atomic-token string and labeled accordingly. There is intentionally no /100,
6
+ // no * 100, and no cents conversion anywhere in this file.
7
+ import { z } from "zod";
8
+ import { ApiError, getServices, getService, getServiceUptime, getFacilitators, getStatus, getNetworks, } from "./api.js";
9
+ // Network input normalization.
10
+ // The API and ServiceListItem.networks[] use ABBREVIATIONS ("BSE","SOL","POL","AVX"),
11
+ // but agents naturally pass the human name ("Base"). The API silently ignores an
12
+ // unknown `network` value and returns everything, so without this an unfiltered
13
+ // result would be reported as if the filter were honored. We resolve either form
14
+ // to the canonical abbreviation, fetched once and cached for the process.
15
+ let networkMapPromise = null;
16
+ function getNetworkMap() {
17
+ if (!networkMapPromise) {
18
+ networkMapPromise = (async () => {
19
+ const m = new Map();
20
+ try {
21
+ const resp = await getNetworks();
22
+ for (const n of resp.data) {
23
+ const abbr = typeof n?.abbreviation === "string" ? n.abbreviation : null;
24
+ if (!abbr)
25
+ continue;
26
+ m.set(abbr.toLowerCase(), abbr);
27
+ if (typeof n?.name === "string")
28
+ m.set(n.name.toLowerCase(), abbr);
29
+ if (typeof n?.caip2_id === "string")
30
+ m.set(n.caip2_id.toLowerCase(), abbr);
31
+ }
32
+ }
33
+ catch {
34
+ // Networks endpoint unreachable: leave the map empty. resolveNetwork then
35
+ // treats the input as a raw abbreviation, which still works for "BSE"-style
36
+ // input and correctly filters to nothing for an unknown value.
37
+ }
38
+ return m;
39
+ })();
40
+ }
41
+ return networkMapPromise;
42
+ }
43
+ async function resolveNetwork(input) {
44
+ const key = input.trim().toLowerCase();
45
+ const hit = (await getNetworkMap()).get(key);
46
+ return hit ? { abbrev: hit, recognized: true } : { abbrev: input.trim(), recognized: false };
47
+ }
48
+ function ok(structured) {
49
+ return {
50
+ structuredContent: structured,
51
+ content: [{ type: "text", text: JSON.stringify(structured, null, 2) }],
52
+ };
53
+ }
54
+ function fail(message) {
55
+ return { isError: true, content: [{ type: "text", text: message }] };
56
+ }
57
+ function describeError(e) {
58
+ if (e instanceof ApiError)
59
+ return e.message;
60
+ if (e instanceof Error)
61
+ return e.message;
62
+ return String(e);
63
+ }
64
+ export function registerTools(server) {
65
+ // -------------------------------------------------------------------------
66
+ // 3.1 search_x402_services
67
+ // -------------------------------------------------------------------------
68
+ server.registerTool("search_x402_services", {
69
+ description: "Search and filter the x402-list directory of services that accept x402 payments. Filter by free-text query, category, network, and live status; sort by newest, uptime, cheapest, or endpoint count. Returns service summaries with price (USD), uptime, status, and verification. Prices are in US dollars.",
70
+ inputSchema: {
71
+ q: z
72
+ .string()
73
+ .trim()
74
+ .min(1)
75
+ .max(200)
76
+ .optional()
77
+ .describe("Free-text search across name, description, category, base_url."),
78
+ category: z
79
+ .string()
80
+ .trim()
81
+ .min(1)
82
+ .max(100)
83
+ .optional()
84
+ .describe("Exact category name (see categories context). Omit for all."),
85
+ network: z
86
+ .string()
87
+ .trim()
88
+ .min(1)
89
+ .max(50)
90
+ .optional()
91
+ .describe("Network name or abbreviation, e.g. 'Base' or 'BSE' (also: SOL, POL, AVX). Omit for all."),
92
+ status: z
93
+ .enum(["online", "degraded", "offline", "unknown", "all"])
94
+ .default("all")
95
+ .describe("Filter by live monitoring status."),
96
+ verified_only: z
97
+ .boolean()
98
+ .default(false)
99
+ .describe("If true, return only verified services (filtered client-side; API has no verified query param)."),
100
+ sort: z
101
+ .enum(["newest", "uptime", "cheapest", "endpoints"])
102
+ .default("newest")
103
+ .describe("Server-side sort order."),
104
+ page: z.number().int().min(1).default(1),
105
+ per_page: z.number().int().min(1).max(100).default(25),
106
+ },
107
+ }, async (args) => {
108
+ try {
109
+ const status = args.status === "all" ? undefined : args.status;
110
+ const net = args.network ? await resolveNetwork(args.network) : null;
111
+ const resp = await getServices({
112
+ q: args.q,
113
+ category: args.category,
114
+ network: net?.abbrev,
115
+ status,
116
+ sort: args.sort,
117
+ page: args.page,
118
+ per_page: args.per_page,
119
+ });
120
+ let services = resp.data;
121
+ // Re-assert the network filter client-side: the API silently ignores an
122
+ // unknown value, so never let an unfiltered list pass as filtered.
123
+ if (net)
124
+ services = services.filter((s) => s.networks.includes(net.abbrev));
125
+ if (args.verified_only)
126
+ services = services.filter((s) => s.verified === true);
127
+ const notes = [
128
+ "min_price_usd values are decimal US dollars.",
129
+ "verified_only filters the current page only.",
130
+ ];
131
+ if (net && !net.recognized) {
132
+ notes.push(`network '${args.network}' did not match any known network (BSE/SOL/POL/AVX or Base/Solana/Polygon/Avalanche); no services match it.`);
133
+ }
134
+ return ok({
135
+ services, // fields verbatim, min_price_usd in decimal USD
136
+ meta: resp.meta,
137
+ returned: services.length,
138
+ filters_applied: {
139
+ q: args.q ?? null,
140
+ category: args.category ?? null,
141
+ network: net ? net.abbrev : null,
142
+ network_recognized: net ? net.recognized : null,
143
+ status: args.status,
144
+ sort: args.sort,
145
+ verified_only: args.verified_only,
146
+ },
147
+ note: notes.join(" "),
148
+ });
149
+ }
150
+ catch (e) {
151
+ return fail(`search_x402_services failed: ${describeError(e)}`);
152
+ }
153
+ });
154
+ // -------------------------------------------------------------------------
155
+ // 3.2 get_service
156
+ // -------------------------------------------------------------------------
157
+ server.registerTool("get_service", {
158
+ description: "Get full detail for one x402 service by slug: live status, uptime over 24h/7d/30d/90d, average response time, accepted networks and settlement asset, and every priced endpoint with its USD price. Use after search_x402_services to inspect a specific service. Prices are in US dollars; the per-endpoint `price` field is a raw on-chain atomic token amount, not dollars.",
159
+ inputSchema: {
160
+ slug: z.string().trim().min(1).max(200).describe("Service slug, e.g. 'my-api'."),
161
+ },
162
+ }, async (args) => {
163
+ try {
164
+ const resp = await getService(args.slug);
165
+ return ok({
166
+ service: resp.data, // full ServiceDetail verbatim
167
+ units: {
168
+ min_price_usd: "decimal US dollars (number)",
169
+ "pricing.price_usd": "decimal US dollars (string)",
170
+ "pricing.price": "ATOMIC on-chain token units (uint256 string), NOT dollars, do not rescale",
171
+ uptime: "percentages 0-100 for windows 24h/7d/30d/90d",
172
+ },
173
+ });
174
+ }
175
+ catch (e) {
176
+ if (e instanceof ApiError && e.status === 404) {
177
+ return fail(`Service '${args.slug}' not found.`);
178
+ }
179
+ return fail(`get_service failed: ${describeError(e)}`);
180
+ }
181
+ });
182
+ // -------------------------------------------------------------------------
183
+ // 3.3 find_best_service (HONESTY-GUARDED: reliability/price, NOT volume)
184
+ // -------------------------------------------------------------------------
185
+ server.registerTool("find_best_service", {
186
+ description: "Recommend the best x402 service(s) for a need, ranked ONLY by fields that exist per service: live status, verification, uptime (24h), response time, and price (USD), filtered by category and network. IMPORTANT: x402-list does NOT track settlement volume per service (volume is per-facilitator only), so this ranking is by reliability and price, not by transaction volume. Optionally attach ecosystem facilitator-volume context separately.",
187
+ inputSchema: {
188
+ category: z
189
+ .string()
190
+ .trim()
191
+ .min(1)
192
+ .max(100)
193
+ .optional()
194
+ .describe("Desired service category."),
195
+ network: z
196
+ .string()
197
+ .trim()
198
+ .min(1)
199
+ .max(50)
200
+ .optional()
201
+ .describe("Required network name or abbreviation, e.g. 'Base' or 'BSE' (also: SOL, POL, AVX)."),
202
+ q: z
203
+ .string()
204
+ .trim()
205
+ .min(1)
206
+ .max(200)
207
+ .optional()
208
+ .describe("Free-text need description to match against name/description."),
209
+ max_price_usd: z
210
+ .number()
211
+ .min(0)
212
+ .optional()
213
+ .describe("Cap on min_price_usd in US dollars; cheaper or equal passes."),
214
+ require_verified: z
215
+ .boolean()
216
+ .default(false)
217
+ .describe("If true, only verified services are eligible."),
218
+ prefer: z
219
+ .enum(["balanced", "cheapest", "fastest", "most_reliable"])
220
+ .default("balanced")
221
+ .describe("Tie-breaking emphasis for the ranking weights."),
222
+ limit: z
223
+ .number()
224
+ .int()
225
+ .min(1)
226
+ .max(20)
227
+ .default(5)
228
+ .describe("How many ranked recommendations to return."),
229
+ include_facilitator_context: z
230
+ .boolean()
231
+ .default(false)
232
+ .describe("If true, also return top facilitators by 7d settlement volume as separate ecosystem context (NOT per-service)."),
233
+ },
234
+ }, async (args) => {
235
+ try {
236
+ const net = args.network ? await resolveNetwork(args.network) : null;
237
+ // 1. Strong candidate pool: online-first, server-sorted by uptime.
238
+ const first = await getServices({
239
+ q: args.q,
240
+ category: args.category,
241
+ network: net?.abbrev,
242
+ status: "online",
243
+ sort: "uptime",
244
+ per_page: 100,
245
+ page: 1,
246
+ });
247
+ const bySlug = new Map();
248
+ for (const s of first.data)
249
+ bySlug.set(s.slug, s);
250
+ // Widen if too few candidates: drop the status filter, merge by slug.
251
+ if (bySlug.size < args.limit) {
252
+ const widen = await getServices({
253
+ q: args.q,
254
+ category: args.category,
255
+ network: net?.abbrev,
256
+ status: undefined,
257
+ sort: "uptime",
258
+ per_page: 100,
259
+ page: 1,
260
+ });
261
+ for (const s of widen.data)
262
+ if (!bySlug.has(s.slug))
263
+ bySlug.set(s.slug, s);
264
+ }
265
+ // 2. Hard filters (re-assert client-side; the API ignores an unknown network).
266
+ let pool = [...bySlug.values()];
267
+ if (net)
268
+ pool = pool.filter((s) => s.networks.includes(net.abbrev));
269
+ if (args.category)
270
+ pool = pool.filter((s) => s.category === args.category);
271
+ if (args.max_price_usd !== undefined) {
272
+ pool = pool.filter((s) => s.min_price_usd !== null && s.min_price_usd <= args.max_price_usd);
273
+ }
274
+ if (args.require_verified)
275
+ pool = pool.filter((s) => s.verified === true);
276
+ const facilitatorContext = args.include_facilitator_context
277
+ ? await topFacilitatorContext()
278
+ : null;
279
+ const rankingBasis = "Ranked by status, verification, uptime_24h, response time, and min_price_usd. x402-list does not expose per-service settlement volume; this is NOT a volume ranking.";
280
+ if (pool.length === 0) {
281
+ return ok({
282
+ recommendations: [],
283
+ ranking_basis: rankingBasis,
284
+ note: net && !net.recognized
285
+ ? `network '${args.network}' did not match any known network (BSE/SOL/POL/AVX or Base/Solana/Polygon/Avalanche); no services match it`
286
+ : "no services match the hard filters",
287
+ facilitator_context: facilitatorContext,
288
+ });
289
+ }
290
+ // 3. Sub-scores normalized to 0..1 (higher = better).
291
+ const statusScore = (s) => ({ online: 1.0, degraded: 0.5, unknown: 0.25, offline: 0.0 }[s.status]);
292
+ const verifiedScore = (s) => (s.verified ? 1.0 : 0.0);
293
+ const uptimeScore = (s) => (s.uptime_24h ?? 0) / 100;
294
+ const rtVals = pool
295
+ .map((s) => s.avg_response_time_ms)
296
+ .filter((v) => v !== null);
297
+ const rtMin = rtVals.length ? Math.min(...rtVals) : 0;
298
+ const rtMax = rtVals.length ? Math.max(...rtVals) : 1;
299
+ const speedScore = (s) => s.avg_response_time_ms === null
300
+ ? 0.5
301
+ : rtMax === rtMin
302
+ ? 1.0
303
+ : 1 - (s.avg_response_time_ms - rtMin) / (rtMax - rtMin);
304
+ const pVals = pool
305
+ .map((s) => s.min_price_usd)
306
+ .filter((v) => v !== null);
307
+ const pMin = pVals.length ? Math.min(...pVals) : 0;
308
+ const pMax = pVals.length ? Math.max(...pVals) : 1;
309
+ const priceScore = (s) => s.min_price_usd === null
310
+ ? 0.5
311
+ : pMax === pMin
312
+ ? 1.0
313
+ : 1 - (s.min_price_usd - pMin) / (pMax - pMin);
314
+ // 4. Weights by `prefer`.
315
+ const weights = {
316
+ balanced: { status: 0.3, verified: 0.2, uptime: 0.25, speed: 0.1, price: 0.15 },
317
+ most_reliable: { status: 0.35, verified: 0.25, uptime: 0.3, speed: 0.05, price: 0.05 },
318
+ cheapest: { status: 0.2, verified: 0.1, uptime: 0.15, speed: 0.05, price: 0.5 },
319
+ fastest: { status: 0.25, verified: 0.1, uptime: 0.15, speed: 0.4, price: 0.1 },
320
+ }[args.prefer];
321
+ // 5. Composite score.
322
+ const scored = pool.map((s) => {
323
+ const score = weights.status * statusScore(s) +
324
+ weights.verified * verifiedScore(s) +
325
+ weights.uptime * uptimeScore(s) +
326
+ weights.speed * speedScore(s) +
327
+ weights.price * priceScore(s);
328
+ return { s, score };
329
+ });
330
+ // 6. Deterministic sort: score desc, verified desc, uptime desc, price asc, slug asc.
331
+ scored.sort((a, b) => {
332
+ if (b.score !== a.score)
333
+ return b.score - a.score;
334
+ if (Number(b.s.verified) !== Number(a.s.verified))
335
+ return Number(b.s.verified) - Number(a.s.verified);
336
+ const ua = a.s.uptime_24h ?? 0;
337
+ const ub = b.s.uptime_24h ?? 0;
338
+ if (ub !== ua)
339
+ return ub - ua;
340
+ const pa = a.s.min_price_usd ?? Number.POSITIVE_INFINITY;
341
+ const pb = b.s.min_price_usd ?? Number.POSITIVE_INFINITY;
342
+ if (pa !== pb)
343
+ return pa - pb;
344
+ return a.s.slug.localeCompare(b.s.slug);
345
+ });
346
+ const recommendations = scored.slice(0, args.limit).map((entry, i) => {
347
+ const s = entry.s;
348
+ return {
349
+ rank: i + 1,
350
+ slug: s.slug,
351
+ name: s.name,
352
+ category: s.category,
353
+ status: s.status,
354
+ verified: s.verified,
355
+ uptime_24h: s.uptime_24h,
356
+ avg_response_time_ms: s.avg_response_time_ms,
357
+ min_price_usd: s.min_price_usd, // decimal USD verbatim
358
+ networks: s.networks,
359
+ endpoint_count: s.endpoint_count,
360
+ score: Math.round(entry.score * 100) / 100,
361
+ why: buildWhy(s),
362
+ };
363
+ });
364
+ return ok({
365
+ recommendations,
366
+ ranking_basis: rankingBasis,
367
+ facilitator_context: facilitatorContext,
368
+ });
369
+ }
370
+ catch (e) {
371
+ return fail(`find_best_service failed: ${describeError(e)}`);
372
+ }
373
+ });
374
+ // -------------------------------------------------------------------------
375
+ // 3.4 check_health
376
+ // -------------------------------------------------------------------------
377
+ server.registerTool("check_health", {
378
+ description: "Check live health of x402 services. With no slug, returns a directory-wide snapshot (counts of online/degraded/offline/unknown plus per-service status). With a slug, returns that service's status, uptime windows, response time, consecutive failures, and recent daily uptime snapshots. No money fields.",
379
+ inputSchema: {
380
+ slug: z
381
+ .string()
382
+ .trim()
383
+ .min(1)
384
+ .max(200)
385
+ .optional()
386
+ .describe("Service slug for a single-service health report. Omit for the whole directory."),
387
+ uptime_period: z
388
+ .enum(["24h", "7d", "30d", "90d"])
389
+ .default("30d")
390
+ .describe("Daily uptime snapshot window for single-service mode."),
391
+ },
392
+ }, async (args) => {
393
+ try {
394
+ if (!args.slug) {
395
+ const resp = await getStatus();
396
+ const d = resp.data;
397
+ return ok({
398
+ mode: "directory",
399
+ summary: {
400
+ total: d.total,
401
+ online: d.online,
402
+ degraded: d.degraded,
403
+ offline: d.offline,
404
+ unknown: d.unknown,
405
+ },
406
+ services: d.services, // StatusServiceItem[] verbatim
407
+ });
408
+ }
409
+ const detail = await getService(args.slug);
410
+ const s = detail.data;
411
+ let snapshots = [];
412
+ let snapshotsError;
413
+ try {
414
+ const up = await getServiceUptime(args.slug, args.uptime_period);
415
+ snapshots = up.data;
416
+ }
417
+ catch (e) {
418
+ snapshotsError = describeError(e);
419
+ }
420
+ const result = {
421
+ mode: "service",
422
+ slug: s.slug,
423
+ name: s.name,
424
+ status: s.status,
425
+ uptime: s.uptime,
426
+ avg_response_time_ms: s.avg_response_time_ms,
427
+ total_checks: s.total_checks,
428
+ consecutive_failures: s.consecutive_failures,
429
+ last_checked_at: s.last_checked_at,
430
+ snapshots,
431
+ };
432
+ if (snapshotsError)
433
+ result.snapshots_error = snapshotsError;
434
+ return ok(result);
435
+ }
436
+ catch (e) {
437
+ if (e instanceof ApiError && e.status === 404) {
438
+ return fail(`Service '${args.slug}' not found.`);
439
+ }
440
+ return fail(`check_health failed: ${describeError(e)}`);
441
+ }
442
+ });
443
+ // -------------------------------------------------------------------------
444
+ // 3.5 get_facilitator_volumes (the core per-facilitator on-chain metric)
445
+ // -------------------------------------------------------------------------
446
+ server.registerTool("get_facilitator_volumes", {
447
+ description: "Get on-chain-verified settlement volume per x402 facilitator (the core x402-list metric). Returns USD settlement volume and transaction counts for 24h/7d/30d/all-time, plus a `verification` flag ('on-chain' when volume has been observed on-chain, else 'listed'). Optionally include a daily timeseries and per-chain breakdown. All volume figures are in US dollars. This is PER-FACILITATOR, not per-service.",
448
+ inputSchema: {
449
+ timeframe: z
450
+ .enum(["24h", "7d", "30d", "all"])
451
+ .default("7d")
452
+ .describe("Drives the sort order of the returned facilitators."),
453
+ include_timeseries: z
454
+ .boolean()
455
+ .default(false)
456
+ .describe("Include a daily volume_usd / tx_count series per facilitator."),
457
+ include_chains: z
458
+ .boolean()
459
+ .default(false)
460
+ .describe("Include a per-chain (network/asset) volume breakdown per facilitator."),
461
+ days: z
462
+ .number()
463
+ .int()
464
+ .min(1)
465
+ .max(90)
466
+ .default(30)
467
+ .describe("Length of the timeseries in days (only used when include_timeseries is true)."),
468
+ page: z.number().int().min(1).default(1),
469
+ per_page: z.number().int().min(1).max(100).default(25),
470
+ },
471
+ }, async (args) => {
472
+ try {
473
+ const includes = [
474
+ args.include_timeseries && "timeseries",
475
+ args.include_chains && "chains",
476
+ ]
477
+ .filter(Boolean)
478
+ .join(",");
479
+ const resp = await getFacilitators({
480
+ timeframe: args.timeframe,
481
+ include: includes || undefined,
482
+ days: args.days,
483
+ page: args.page,
484
+ per_page: args.per_page,
485
+ });
486
+ return ok({
487
+ facilitators: resp.data, // Facilitator[] verbatim, USD passed through
488
+ meta: resp.meta,
489
+ units: {
490
+ "volume_usd_24h/7d/30d/all": "decimal US dollars",
491
+ "tx_count_*": "integer transaction counts",
492
+ verification: "'on-chain' iff observed on-chain volume > 0, else 'listed'",
493
+ },
494
+ });
495
+ }
496
+ catch (e) {
497
+ return fail(`get_facilitator_volumes failed: ${describeError(e)}`);
498
+ }
499
+ });
500
+ }
501
+ // ---- helpers ----
502
+ function buildWhy(s) {
503
+ const parts = [s.status];
504
+ if (s.verified)
505
+ parts.push("verified");
506
+ if (s.uptime_24h !== null)
507
+ parts.push(`${s.uptime_24h}% 24h uptime`);
508
+ if (s.avg_response_time_ms !== null)
509
+ parts.push(`${s.avg_response_time_ms}ms`);
510
+ if (s.min_price_usd !== null)
511
+ parts.push(`$${s.min_price_usd} min price`);
512
+ return parts.join(", ");
513
+ }
514
+ async function topFacilitatorContext() {
515
+ const resp = await getFacilitators({ timeframe: "7d", per_page: 10, page: 1 });
516
+ return resp.data.map((f) => ({
517
+ facilitator_id: f.facilitator_id,
518
+ name: f.name,
519
+ volume_usd_7d: f.volume_usd_7d, // decimal USD verbatim
520
+ tx_count_7d: f.tx_count_7d,
521
+ verification: f.verification,
522
+ }));
523
+ }
524
+ //# sourceMappingURL=tools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools.js","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,EAAE;AACF,kFAAkF;AAClF,8EAA8E;AAC9E,+EAA+E;AAC/E,2DAA2D;AAE3D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EACL,QAAQ,EACR,WAAW,EACX,UAAU,EACV,gBAAgB,EAChB,eAAe,EACf,SAAS,EACT,WAAW,GAEZ,MAAM,UAAU,CAAC;AAElB,+BAA+B;AAC/B,sFAAsF;AACtF,iFAAiF;AACjF,gFAAgF;AAChF,iFAAiF;AACjF,0EAA0E;AAC1E,IAAI,iBAAiB,GAAwC,IAAI,CAAC;AAClE,SAAS,aAAa;IACpB,I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AAC,UAAU,CAAC,CAAC;IACvC,IAAI,CAAC,CAAC,UAAU,KAAK,IAAI;QAAE,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,UAAU,cAAc,CAAC,CAAC;IACrE,IAAI,CAAC,CAAC,oBAAoB,KAAK,IAAI;QAAE,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,oBAAoB,IAAI,CAAC,CAAC;IAC/E,IAAI,CAAC,CAAC,aAAa,KAAK,IAAI;QAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,aAAa,YAAY,CAAC,CAAC;IAC1E,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAED,KAAK,UAAU,qBAAqB;IAClC,MAAM,IAAI,GAAG,MAAM,eAAe,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC;IAC/E,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QAC3B,cAAc,EAAE,CAAC,CAAC,cAAc;QAChC,IAAI,EAAE,CAAC,CAAC,IAAI;QACZ,aAAa,EAAE,CAAC,CAAC,aAAa,EAAE,uBAAuB;QACvD,WAAW,EAAE,CAAC,CAAC,WAAW;QAC1B,YAAY,EAAE,CAAC,CAAC,YAAY;KAC7B,CAAC,CAAC,CAAC;AACN,CAAC"}
package/package.json ADDED
@@ -0,0 +1,55 @@
1
+ {
2
+ "name": "x402-list-mcp",
3
+ "version": "0.1.0",
4
+ "description": "MCP server for x402-list: discover x402 payment services and on-chain-verified facilitator settlement volume. Read-only wrapper over the public x402-list API.",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "engines": {
8
+ "node": ">=20.0.0"
9
+ },
10
+ "bin": {
11
+ "x402-list-mcp": "dist/index.js"
12
+ },
13
+ "main": "dist/index.js",
14
+ "exports": {
15
+ ".": "./dist/index.js"
16
+ },
17
+ "files": [
18
+ "dist",
19
+ "SKILL.md",
20
+ "README.md"
21
+ ],
22
+ "keywords": [
23
+ "mcp",
24
+ "model-context-protocol",
25
+ "x402",
26
+ "payments",
27
+ "stablecoin",
28
+ "usdc",
29
+ "base",
30
+ "facilitator",
31
+ "ai-agents"
32
+ ],
33
+ "homepage": "https://x402-list.com",
34
+ "repository": {
35
+ "type": "git",
36
+ "url": "https://github.com/mcccsm/x402-list",
37
+ "directory": "mcp"
38
+ },
39
+ "scripts": {
40
+ "build": "tsc -p tsconfig.json && node -e \"import('node:fs').then(fs=>fs.chmodSync('dist/index.js',0o755))\"",
41
+ "start": "node dist/index.js",
42
+ "start:http": "MCP_HTTP_PORT=${PORT:-3000} node dist/index.js --http",
43
+ "dev": "node --experimental-strip-types src/index.ts",
44
+ "smoke": "node smoke-test.mjs",
45
+ "prepublishOnly": "npm run build"
46
+ },
47
+ "dependencies": {
48
+ "@modelcontextprotocol/sdk": "1.29.0",
49
+ "zod": "3.25.76"
50
+ },
51
+ "devDependencies": {
52
+ "@types/node": "20.14.10",
53
+ "typescript": "5.6.3"
54
+ }
55
+ }