x402-list-mcp 0.4.1 → 0.5.1
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/CHANGELOG.md +74 -0
- package/README.md +32 -8
- package/SKILL.md +14 -11
- package/dist/api.d.ts +64 -1
- package/dist/api.js +3 -2
- package/dist/api.js.map +1 -1
- package/dist/http.js +24 -19
- package/dist/http.js.map +1 -1
- package/dist/server.js +3 -3
- package/dist/server.js.map +1 -1
- package/dist/sessions.d.ts +25 -0
- package/dist/sessions.js +86 -0
- package/dist/sessions.js.map +1 -0
- package/dist/tools.js +367 -87
- package/dist/tools.js.map +1 -1
- package/package.json +7 -4
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to `x402-list-mcp` are recorded here. This project follows semantic
|
|
4
|
+
versioning: while the major version is 0, a minor bump may carry a breaking change.
|
|
5
|
+
|
|
6
|
+
## 0.5.1 - 2026-09-01
|
|
7
|
+
|
|
8
|
+
### Added: tool titles and annotations
|
|
9
|
+
|
|
10
|
+
All seven tools now declare a human-readable `title` and tool annotations. The six read-only
|
|
11
|
+
tools carry `readOnlyHint: true`; the paid `x402_assess_services` carries `readOnlyHint: false`.
|
|
12
|
+
Nothing else changed: same names, same parameters, same response shapes, same semantics.
|
|
13
|
+
|
|
14
|
+
## 0.5.0 - 2026-08-21
|
|
15
|
+
|
|
16
|
+
### BREAKING: every tool was renamed into the `x402_*` namespace
|
|
17
|
+
|
|
18
|
+
All six tools that shipped in 0.4.x now answer under a new name. **The old names no longer
|
|
19
|
+
exist.** A `tools/call` for any of them is answered with a JSON-RPC error (`-32602`,
|
|
20
|
+
`Tool <name> not found`), and they do not appear in `tools/list` either. Nothing else about
|
|
21
|
+
the tools changed in this release: same parameters,
|
|
22
|
+
same response shapes, same semantics.
|
|
23
|
+
|
|
24
|
+
| Old name (0.4.x, removed) | New name (0.5.0) |
|
|
25
|
+
| --- | --- |
|
|
26
|
+
| `search_x402_services` | `x402_search_services` |
|
|
27
|
+
| `get_service` | `x402_get_service` |
|
|
28
|
+
| `find_best_service` | `x402_find_best_service` |
|
|
29
|
+
| `check_health` | `x402_check_health` |
|
|
30
|
+
| `get_facilitator_volumes` | `x402_facilitator_volumes` |
|
|
31
|
+
| `assess_services` | `x402_assess_services` |
|
|
32
|
+
|
|
33
|
+
### There are no compatibility aliases, on purpose
|
|
34
|
+
|
|
35
|
+
The old names were not kept as deprecated aliases. Two reasons, both deliberate:
|
|
36
|
+
|
|
37
|
+
1. **One surface to maintain.** Aliases double the number of registered tools, and every one
|
|
38
|
+
of them has to keep its schema, its description and its tests in step with the real tool
|
|
39
|
+
for as long as the alias lives. Two names for one behaviour is two places to get wrong.
|
|
40
|
+
2. **The model's context budget is the scarce resource.** Every registered tool spends tokens
|
|
41
|
+
in the agent's preamble before a single question is asked, and a deprecated duplicate spends
|
|
42
|
+
them twice over while also forcing a paragraph of "prefer the new name" guidance. Keeping the
|
|
43
|
+
aliases would have made the preamble worse in exactly the dimension this release is trying to
|
|
44
|
+
improve.
|
|
45
|
+
|
|
46
|
+
Breaking now is cheap and it will never be cheaper: the installed base is small, and a clean
|
|
47
|
+
namespace is what makes the tools legible next to the other MCP servers an agent has loaded.
|
|
48
|
+
|
|
49
|
+
### What you need to do to upgrade
|
|
50
|
+
|
|
51
|
+
Search your setup for the six old names and replace them with the new ones, everywhere they are
|
|
52
|
+
written down by hand:
|
|
53
|
+
|
|
54
|
+
- system prompts, skill files and agent instructions that name a tool ("call `get_service`
|
|
55
|
+
after `search_x402_services`");
|
|
56
|
+
- code that calls tools programmatically, for example `client.callTool({ name: "check_health" })`;
|
|
57
|
+
- allow lists, deny lists and per-tool permission rules in your MCP client configuration, which
|
|
58
|
+
match on the tool name and will silently stop matching;
|
|
59
|
+
- evaluation fixtures and transcripts that assert on tool names.
|
|
60
|
+
|
|
61
|
+
Nothing needs to change in your MCP server configuration itself: the package name, the binary,
|
|
62
|
+
the environment variables and the hosted endpoint are all unchanged.
|
|
63
|
+
|
|
64
|
+
### Added: a seventh tool, `x402_change_events`
|
|
65
|
+
|
|
66
|
+
A read-only, free feed of the changes x402-list observes on listed services over time: a service
|
|
67
|
+
moving its payout address, changing an endpoint price, or altering its 402 schema. Filter by
|
|
68
|
+
`service` (a listing slug), by `type` (one of `payto_changed`, `price_changed`, `schema_changed`),
|
|
69
|
+
and by `days`; page through with `page` and `per_page`. Each event carries the observation
|
|
70
|
+
timestamp, a summary, and the before and after snapshots. Payout addresses are returned masked by
|
|
71
|
+
the API, as they are on the website.
|
|
72
|
+
|
|
73
|
+
Use it to answer "has this service changed under me since I last looked", which is the question
|
|
74
|
+
a static listing cannot answer.
|
package/README.md
CHANGED
|
@@ -2,11 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
MCP server for x402-list: discover x402 payment services and on-chain-verified facilitator settlement volume.
|
|
4
4
|
|
|
5
|
+
> **Upgrading from 0.4.x? Every tool was renamed.** 0.5.0 moved all of them into the `x402_*` namespace
|
|
6
|
+
> and removed the old names, with no compatibility aliases: a `tools/call` for `get_service` or
|
|
7
|
+
> `search_x402_services` now comes back as a JSON-RPC `-32602` "Tool not found", and the old names are
|
|
8
|
+
> absent from `tools/list` too. The old-to-new table and the upgrade checklist (prompts, client
|
|
9
|
+
> allow lists, eval fixtures) are in [CHANGELOG.md](./CHANGELOG.md).
|
|
10
|
+
|
|
5
11
|
## What is x402-list
|
|
6
12
|
|
|
7
13
|
[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
14
|
|
|
9
|
-
This package is a **thin wrapper** over the public x402-list HTTP JSON API. It holds no keys, touches no database, and makes no writes to the directory.
|
|
15
|
+
This package is a **thin wrapper** over the public x402-list HTTP JSON API. It holds no keys, touches no database, and makes no writes to the directory. It exposes the directory to AI agents through the Model Context Protocol as seven tools: six are free and read-only, and the seventh, `x402_assess_services`, is the only paid one, a pass-through that relays an x402 payment challenge you sign yourself client-side (the package never holds keys, never signs, and never settles).
|
|
10
16
|
|
|
11
17
|
## Install and quick start
|
|
12
18
|
|
|
@@ -44,12 +50,30 @@ Hosted endpoint: `https://mcp.x402-list.com/mcp`. Health probe: `GET /healthz` r
|
|
|
44
50
|
|
|
45
51
|
| Tool | What it does |
|
|
46
52
|
| --- | --- |
|
|
47
|
-
| `
|
|
48
|
-
| `
|
|
49
|
-
| `
|
|
50
|
-
| `
|
|
51
|
-
| `
|
|
52
|
-
| `
|
|
53
|
+
| `x402_search_services` | Search and filter the directory by query, category, network, status, and `signable` (whether the last observed 402 envelope carries the EIP-712 domain parameters a standard x402 client needs in order to sign); sort by newest/uptime/cheapest/endpoints. |
|
|
54
|
+
| `x402_get_service` | Full detail for one service by slug: endpoints, per-endpoint USD pricing, uptime windows, networks, settlement asset. |
|
|
55
|
+
| `x402_find_best_service` | Ranked recommendation for a need, computed server-side (GET /api/v1/best). Ranks mostly by reliability, x402 compliance and price (status, verified, uptime, response time, USD price), with a small (~10%) weight on per-service on-chain traction that can never dominate those three. The answer carries `ranking_version`, **3** today (see below), and a `units` map holding every scoring caveat in full. |
|
|
56
|
+
| `x402_check_health` | Live status, directory-wide or per service (uptime snapshots, consecutive failures). |
|
|
57
|
+
| `x402_facilitator_volumes` | Per-facilitator on-chain-verified settlement volume (today UTC/7d/30d/all) in USD, tx counts, and an on-chain vs listed flag. The `*_24h` fields cover today (UTC) so far, not a trailing 24-hour window. |
|
|
58
|
+
| `x402_change_events` | Free, read-only feed of what the monitor observed changing on listed services, most recent first, in exactly three event types (`payto_changed`, `price_changed`, `schema_changed`). Filter by `service` (the listing slug: the parameter is named `service`, not `slug`), by `type`, and by `days` (1 to 365, default 90); page with `page` / `per_page` (up to 100 per page). Each event carries the observation timestamp, a diff summary, and the before/after 402 snapshots. Prices inside an event are atomic token amounts, never dollars, and every payout address is returned masked by the API: the feed reports THAT the payTo changed, never the address. |
|
|
59
|
+
| `x402_assess_services` | **Paid** ($0.25 USDC on Base, x402). Fresh on-demand AI comparison of a shortlist of listed services for a stated need. Pass-through: it never holds keys, never signs, and never settles. Call without `payment_signature_b64` to get the x402 challenge verbatim, sign it client-side, then retry with the signature to get the report. Optionally add a `probe` target `{ slug, endpoint_path? }` to also test one listed service live: the price becomes $0.25 plus that endpoint price X (non-refundable), and the report gains a `probe_report` block with a verdict and truncated extracts, never the verbatim third-party body. |
|
|
60
|
+
|
|
61
|
+
## Ranking generations
|
|
62
|
+
|
|
63
|
+
`x402_find_best_service` returns the scoring generation it was produced under. **Today it is 3.** Scores you
|
|
64
|
+
stored under an earlier generation are not comparable with these, because the math moved:
|
|
65
|
+
|
|
66
|
+
- **Generation 2** capped the compliance term at 0.6, the floor of the C band, when at least one of a
|
|
67
|
+
service's EVM routes was observed missing the EIP-712 domain parameters (`extra.name`, `extra.version`)
|
|
68
|
+
a standard x402 client needs in order to sign a payment. A fact about the envelope on the wire, not a
|
|
69
|
+
judgement on the merit of the service.
|
|
70
|
+
- **Generation 3** added the anti-wash rules on the traction term: an absolute floor of $10 on 30d
|
|
71
|
+
settlement volume, below which the term scores 0 because sub-floor volume is indistinguishable from
|
|
72
|
+
dust and must not move rank; a discount on a payout concentrated in one buyer, up to half the traction
|
|
73
|
+
term when a single buyer accounts for all of it, since one buyer is one relationship and not the broad
|
|
74
|
+
demand the term is meant to reward; and a service that publishes no mappable payTo now scores 0 on that
|
|
75
|
+
term instead of having the weight renormalized away, so hiding the payout address no longer beats
|
|
76
|
+
having a measured one.
|
|
53
77
|
|
|
54
78
|
## Units note
|
|
55
79
|
|
|
@@ -57,7 +81,7 @@ All monetary values are decimal US dollars and are passed through verbatim. Ther
|
|
|
57
81
|
|
|
58
82
|
## Honesty note
|
|
59
83
|
|
|
60
|
-
Two different on-chain volume signals; do not conflate them. **Facilitator volume** (`
|
|
84
|
+
Two different on-chain volume signals; do not conflate them. **Facilitator volume** (`x402_facilitator_volumes`) is the ecosystem headline, aggregated per facilitator. **Per-service traction** (the `traction` block on each service, weighed at ~10% inside `x402_find_best_service`) is settlement measured over a service's own payTo via recognized settlers - a deliberate **conservative undercount**, not an estimate: unattributed settlements are left out, never scaled up. When a payTo is shared across services (`shared_payout: true`), only settlement VOLUME is attributed pro-quota, the operator-level volume over that address divided across the services sharing it, which is a declared convention and not an individually observed measure, while transaction count and unique buyers stay whole operator-level integers; a service on a network not yet measured, or a shared-payout member whose probe has been failing, carries no traction term at all and the remaining weights are renormalized over it. Never read shared, pro-quota or unmeasured volume as one service's revenue. To ask "which facilitators have real on-chain volume", use `x402_facilitator_volumes` and read the `verification` flag.
|
|
61
85
|
|
|
62
86
|
## Source
|
|
63
87
|
|
package/SKILL.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
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.
|
|
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, see whether a service has changed its price, payout address or 402 schema since it was last looked at, or look up which x402 facilitators have real on-chain settlement volume.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# x402-list
|
|
@@ -15,19 +15,22 @@ x402-list is a directory of services that accept x402 payments. Its distinctive,
|
|
|
15
15
|
|
|
16
16
|
## Tool guide (when to use each)
|
|
17
17
|
|
|
18
|
-
- `
|
|
19
|
-
- `
|
|
20
|
-
- `
|
|
21
|
-
- `
|
|
22
|
-
- `
|
|
23
|
-
- `
|
|
18
|
+
- `x402_search_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. Add `signable: true` when you intend to pay with a standard x402 client and want only services whose last observed 402 envelope carries the EIP-712 domain parameters needed to sign (`signable: false` returns the opposite set; a service whose latest assessment has not measured that check matches neither value, so omit the parameter to see it).
|
|
19
|
+
- `x402_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
|
+
- `x402_find_best_service`: get a ranked recommendation for a need, computed server-side (GET /api/v1/best). Ranks mostly by reliability, x402 compliance and price (status, verified, uptime_24h, response time, USD price), filtered by category and network, with a small (~10%) weight on per-service on-chain traction (settlement volume, tx count, unique buyers - a conservative undercount). Traction never dominates; a shared payout has only its VOLUME attributed pro-quota (counts stay whole operator-level integers), and an unmeasured-network service, or a shared member whose probe is failing, carries no traction term at all. The response carries `ranking_version`, **3** today, plus a `units` map with every scoring caveat in full; scores stored under an earlier generation are NOT comparable with these, because the math moved twice. Generation 2 introduced the compliance cap: the compliance term is the share of deterministic conformance checks the service passes, capped at 0.6 (the floor of the C band) when at least one of its EVM routes is missing the EIP-712 domain parameters a standard x402 client needs in order to sign a payment, which is a fact about the envelope on the wire and not a judgement on the merit of the service. Generation 3 added the anti-wash rules on the traction term: an absolute $10 floor on 30d settlement volume, under which the term scores 0 because sub-floor volume is indistinguishable from dust and must not move rank; a discount on a payout concentrated in one buyer, up to half the traction term when a single buyer accounts for all of it, since one buyer is one relationship and not broad demand; and a 0 term, instead of a renormalization, for a service that publishes no mappable payTo, so hiding the payout address no longer beats having a measured one.
|
|
21
|
+
- `x402_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
|
+
- `x402_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
|
+
- `x402_change_events`: the drift feed, free and read-only. What the monitor observed changing on listed services, most recent first, in exactly three event types: `payto_changed` (the payout address set changed), `price_changed` (at least one endpoint changed price), `schema_changed` (the 402 envelope gained or lost accepts entries or priced endpoints). Reach for it before trusting anything you cached about a service, and right after a payment failed for no obvious reason. Filter with `service` (the listing slug, the same slug `x402_get_service` takes), `type`, and `days` (1 to 365, default 90); page with `page` and `per_page` (up to 100). **The slug parameter is named `service`, not `slug`**: pass the wrong name and the API answers with the whole unfiltered feed, silently and with no error, so check `filters_applied` in the response before reading the result as one service's history. `total` is the server's count over the whole filtered window, not the length of the page you are holding (`returned` is that). Two units traps: the prices inside an event are ATOMIC token amounts, never dollars, and every payTo is masked by the API by design, so the feed tells you THAT the payout address changed, never what it changed to.
|
|
24
|
+
- `x402_assess_services`: PAID ($0.25 USDC on Base, x402). A fresh on-demand AI comparison of a shortlist of listed services for a stated need. This is a pass-through: it never holds keys, never signs, and never settles. Call it once without `payment_signature_b64` to receive the x402 payment challenge verbatim, sign accepts[0] client-side with your own wallet, then call again with the same question and services plus `payment_signature_b64` to receive the report and a settlement receipt. It charges only for the fresh reasoning, never to read an already-computed assessment (that stays free on `x402_get_service`); a run that cannot be produced answers before settling, so you are never charged, and there is no refund. Optionally add a `probe` target `{ slug, endpoint_path? }` to also test one listed service live: when the server has probing armed the price becomes $0.25 plus that endpoint price X (non-refundable), and the report gains a `probe_report` block with a verdict and truncated extracts, never the verbatim third-party body.
|
|
24
25
|
|
|
25
26
|
## The honesty guard
|
|
26
27
|
|
|
27
|
-
Keep two on-chain signals distinct. **Facilitator volume** (`
|
|
28
|
+
Keep two on-chain signals distinct. **Facilitator volume** (`x402_facilitator_volumes`) is aggregated per facilitator and is the headline metric. **Per-service traction** (the `traction` block on a service, and a ~10% weight inside `x402_find_best_service`) is measured over that service's own payTo via recognized settlers and is a deliberate **conservative undercount** - never an upper bound, never an estimate. When a payTo is shared across services (`shared_payout: true`), only settlement VOLUME is attributed pro-quota, the operator-level volume over that address divided across the services sharing it, which is a declared convention and not an individually observed measure, while transaction count and unique buyers stay whole operator-level integers, never fractional; when a service sits on a network we do not measure, or is a shared-payout member whose probe has been failing, it carries no traction term at all and the other weights are renormalized over it. Do not present shared, pro-quota or unmeasured volume as a single service's revenue. If asked "which service does the most volume", show the measured `traction` where it exists, flag the undercount and any shared/unmeasured caveat, and offer facilitator volumes (via `x402_facilitator_volumes`) for the ecosystem aggregate.
|
|
28
29
|
|
|
29
30
|
## Typical workflows
|
|
30
31
|
|
|
31
|
-
- "Find me a cheap, reliable image-generation x402 API on Base" -> `
|
|
32
|
-
- "Is service X healthy?" -> `
|
|
33
|
-
- "Which x402 facilitators are real (have on-chain volume)?" -> `
|
|
32
|
+
- "Find me a cheap, reliable image-generation x402 API on Base" -> `x402_find_best_service` with category, network `Base`, your need as `q`, and `prefer: cheapest`, then `x402_get_service` on the top pick.
|
|
33
|
+
- "Is service X healthy?" -> `x402_check_health` with `slug: X`.
|
|
34
|
+
- "Which x402 facilitators are real (have on-chain volume)?" -> `x402_facilitator_volumes` with `timeframe: 30d`, then read each `verification` flag.
|
|
35
|
+
- "I integrated service X last month and the call just started failing / costing more" -> `x402_change_events` with `service: X` and a `days` window that covers the gap, then read the newest `price_changed` or `schema_changed` event and re-check the current record with `x402_get_service`.
|
|
36
|
+
- "Is it still safe to pay this service?" -> `x402_change_events` with `service: X` and `type: payto_changed`: a recent payout change is the signal to re-verify before sending money, and the addresses themselves come back masked, so verify against the live 402 envelope rather than against this feed.
|
package/dist/api.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const USER_AGENT = "x402-list-mcp/0.
|
|
1
|
+
export declare const USER_AGENT = "x402-list-mcp/0.5.1 (+https://x402-list.com)";
|
|
2
2
|
export interface ApiEnvelope<T> {
|
|
3
3
|
data: T;
|
|
4
4
|
meta?: Record<string, unknown>;
|
|
@@ -21,12 +21,26 @@ export interface AiMarkedField<T = string> {
|
|
|
21
21
|
confidence: number;
|
|
22
22
|
source: "ai";
|
|
23
23
|
}
|
|
24
|
+
/** Staleness of a compliance GRADE (T3 B-24#0 + A-07#1). The grade is a snapshot off the last
|
|
25
|
+
* captured 402 envelope, not re-derived on every probe, so `updated_at` cannot tell an agent the
|
|
26
|
+
* host is still reachable or how old the capture is. Two independent machine-keyable signals:
|
|
27
|
+
* probe_failing the up-probe has been failing past the decay window (grade no longer being
|
|
28
|
+
* re-confirmed; may be an unreachable host). Keyed off last_success_at.
|
|
29
|
+
* last_success_at the timestamp probe_failing derives from, distinct from updated_at.
|
|
30
|
+
* envelope_captured_at when the 402 envelope the grade was computed from was last captured; can be
|
|
31
|
+
* weeks old while probes still pass. The grade's OWN staleness. */
|
|
32
|
+
export interface ComplianceStaleness {
|
|
33
|
+
probe_failing: boolean;
|
|
34
|
+
last_success_at: string | null;
|
|
35
|
+
envelope_captured_at: string | null;
|
|
36
|
+
}
|
|
24
37
|
/** Compact assessment summary carried on each list item (backs ranking). */
|
|
25
38
|
export interface AssessmentSummary {
|
|
26
39
|
compliance_grade: "A" | "B" | "C" | "D" | "F" | "unknown" | null;
|
|
27
40
|
compliance_passed: number | null;
|
|
28
41
|
compliance_total: number | null;
|
|
29
42
|
compliance_failed_checks: string[] | null;
|
|
43
|
+
compliance_staleness: ComplianceStaleness | null;
|
|
30
44
|
reliability_uptime_30d: number | null;
|
|
31
45
|
response_p95_ms: number | null;
|
|
32
46
|
price_usd: number | null;
|
|
@@ -72,6 +86,7 @@ export interface AssessmentDetail {
|
|
|
72
86
|
}[];
|
|
73
87
|
pay_to_source: "payTo" | "payToAddress" | "treasury" | null;
|
|
74
88
|
pay_to_location: "accept" | "element" | null;
|
|
89
|
+
staleness: ComplianceStaleness | null;
|
|
75
90
|
} | null;
|
|
76
91
|
site: {
|
|
77
92
|
homepage: boolean | null;
|
|
@@ -318,6 +333,15 @@ export declare const getServices: (q: {
|
|
|
318
333
|
q?: string;
|
|
319
334
|
/** true = verified only, false = unverified only, omit = no filter. Filtered SQL-side, so meta.total follows. */
|
|
320
335
|
verified?: boolean;
|
|
336
|
+
/**
|
|
337
|
+
* Signability of the last observed 402 envelope (C-compliance). true = no EVM route was seen
|
|
338
|
+
* missing the EIP-712 domain parameters a standard x402 client needs in order to sign, false =
|
|
339
|
+
* at least one such route was seen, omit = no filter. Both values are forwarded verbatim (false
|
|
340
|
+
* is a REAL filter here, unlike `verified` on the tool side, so it must not be dropped); a
|
|
341
|
+
* service whose latest assessment has not measured that check matches neither and is only
|
|
342
|
+
* returned when the parameter is omitted. Filtered SQL-side, so meta.total follows.
|
|
343
|
+
*/
|
|
344
|
+
signable?: boolean;
|
|
321
345
|
}) => Promise<ServicesListResponse>;
|
|
322
346
|
export interface BestData {
|
|
323
347
|
recommendations: unknown[];
|
|
@@ -381,6 +405,45 @@ export interface NetworkItem {
|
|
|
381
405
|
avg_uptime: number | null;
|
|
382
406
|
}
|
|
383
407
|
export declare const getNetworks: () => Promise<ApiEnvelope<NetworkItem[]>>;
|
|
408
|
+
export type ChangeEventType = "payto_changed" | "price_changed" | "schema_changed";
|
|
409
|
+
export interface ChangeEvent {
|
|
410
|
+
slug: string;
|
|
411
|
+
name: string;
|
|
412
|
+
type: ChangeEventType;
|
|
413
|
+
observed_at: string;
|
|
414
|
+
/**
|
|
415
|
+
* Per-type diff digest; the shape follows `type`:
|
|
416
|
+
* payto_changed { payToAdded: string[], payToRemoved: string[] } (addresses MASKED by the API)
|
|
417
|
+
* price_changed { priceChanges: [{ network, endpoint, oldPrice, newPrice, assetName }] }
|
|
418
|
+
* oldPrice/newPrice are ATOMIC token amounts (uint256 strings), NOT dollars.
|
|
419
|
+
* schema_changed { schemaAdded, schemaRemoved, endpointsAdded, endpointsRemoved: string[] }
|
|
420
|
+
* Left as `unknown` on purpose: it is passed through verbatim and never rescaled or reshaped.
|
|
421
|
+
*/
|
|
422
|
+
summary: unknown;
|
|
423
|
+
/** The service's full accepts array before the change. payTo values are MASKED by the API
|
|
424
|
+
* (finding B-21#0, deliberate) and `price` inside is an ATOMIC token amount, not dollars. */
|
|
425
|
+
old_snapshot: unknown;
|
|
426
|
+
/** Same shape as old_snapshot, after the change. */
|
|
427
|
+
new_snapshot: unknown;
|
|
428
|
+
}
|
|
429
|
+
export interface ChangesResponse {
|
|
430
|
+
data: ChangeEvent[];
|
|
431
|
+
meta: {
|
|
432
|
+
total: number;
|
|
433
|
+
page: number;
|
|
434
|
+
per_page: number;
|
|
435
|
+
total_pages: number;
|
|
436
|
+
days: number;
|
|
437
|
+
};
|
|
438
|
+
}
|
|
439
|
+
export declare const getChanges: (q: {
|
|
440
|
+
/** Service slug. The wire name is `service`; sending `slug` is silently ignored by the API. */
|
|
441
|
+
service?: string;
|
|
442
|
+
type?: ChangeEventType;
|
|
443
|
+
days?: number;
|
|
444
|
+
page?: number;
|
|
445
|
+
per_page?: number;
|
|
446
|
+
}) => Promise<ChangesResponse>;
|
|
384
447
|
export interface AssessPostResult {
|
|
385
448
|
status: number;
|
|
386
449
|
body: unknown;
|
package/dist/api.js
CHANGED
|
@@ -10,7 +10,7 @@ const PREFIX = "/api/v1";
|
|
|
10
10
|
const DEFAULT_TIMEOUT_MS = Number(process.env.X402_LIST_TIMEOUT_MS ?? 15000);
|
|
11
11
|
// version: keep in sync with package.json / server.json / SERVER_INFO in server.ts.
|
|
12
12
|
// Exported so the version-sync test can assert it carries the same version as the others.
|
|
13
|
-
export const USER_AGENT = "x402-list-mcp/0.
|
|
13
|
+
export const USER_AGENT = "x402-list-mcp/0.5.1 (+https://x402-list.com)";
|
|
14
14
|
export class ApiError extends Error {
|
|
15
15
|
status;
|
|
16
16
|
body;
|
|
@@ -67,7 +67,7 @@ export async function apiGet(path, query, opts) {
|
|
|
67
67
|
// Full-text search param is `q`; pagination is `page` / `per_page`.
|
|
68
68
|
// `verified` IS a real query filter on /services, applied SQL-side by the API: meta.total counts the
|
|
69
69
|
// filtered set, so list_services passes it through instead of filtering the page it got back.
|
|
70
|
-
// (
|
|
70
|
+
// (x402_find_best_service still narrows its own scored pool in tools.ts: that is ranking, not this param.)
|
|
71
71
|
export const getServices = (q) => apiGet("/services", q);
|
|
72
72
|
export const getBest = (q) => apiGet("/best", q);
|
|
73
73
|
export const getService = (slug) => apiGet(`/services/${encodeURIComponent(slug)}`);
|
|
@@ -78,6 +78,7 @@ export const getFacilitators = (q) => apiGet("/facilitators", q);
|
|
|
78
78
|
export const getStatus = () => apiGet("/status");
|
|
79
79
|
export const getCategories = () => apiGet("/categories");
|
|
80
80
|
export const getNetworks = () => apiGet("/networks");
|
|
81
|
+
export const getChanges = (q) => apiGet("/changes", q);
|
|
81
82
|
/**
|
|
82
83
|
* POST a body to /assess. Unlike apiGet this does NOT throw on a non-2xx status: a 402 is the
|
|
83
84
|
* expected payment challenge and a 400/503 is a normal control answer the caller must see. Only a
|
package/dist/api.js.map
CHANGED
|
@@ -1 +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,oFAAoF;AACpF,0FAA0F;AAC1F,MAAM,CAAC,MAAM,UAAU,GAAG,8CAA8C,CAAC;AAOzE,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,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C,CAAC,CAAC;IAClB,CAAC;IACD,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC;IAC9B,IAAI,IAAI,GAAY,IAAI,CAAC;IACzB,IAAI,CAAC;QACH,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACxC,CAAC;IAAC,MAAM,CAAC;QACP,IAAI,GAAG,IAAI,CAAC,CAAC,sCAAsC;IACrD,CAAC;IACD,OAAO;QACL,MAAM,EAAE,GAAG,CAAC,MAAM;QAClB,IAAI;QACJ,wBAAwB,EAAE,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC;QAC7D,wBAAwB,EAAE,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC;KAC9D,CAAC;AACJ,CAAC"}
|
package/dist/http.js
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
// Streamable HTTP transport server (hosted mode), built on Node's native http.
|
|
2
2
|
// One McpServer instance per MCP session, per the MCP spec. The SDK transport
|
|
3
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
|
|
4
|
+
// wrapper only handles routing, CORS, the /healthz probe, and the session registry
|
|
5
|
+
// (bounded: idle TTL + LRU cap, see sessions.ts).
|
|
5
6
|
import { createServer } from "node:http";
|
|
6
7
|
import { randomUUID } from "node:crypto";
|
|
7
8
|
import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
|
|
8
9
|
import { isInitializeRequest } from "@modelcontextprotocol/sdk/types.js";
|
|
9
10
|
import { buildServer } from "./server.js";
|
|
11
|
+
import { SessionRegistry } from "./sessions.js";
|
|
10
12
|
const MAX_BODY_BYTES = 1024 * 1024; // ~1 MB
|
|
13
|
+
const SWEEP_INTERVAL_MS = 60_000;
|
|
11
14
|
const ALLOWED_ORIGINS = (process.env.MCP_ALLOWED_ORIGINS ?? "")
|
|
12
15
|
.split(",")
|
|
13
16
|
.map((s) => s.trim())
|
|
@@ -69,7 +72,9 @@ function jsonRpcError(res, status, message) {
|
|
|
69
72
|
});
|
|
70
73
|
}
|
|
71
74
|
export async function startHttp(port) {
|
|
72
|
-
const transports = new
|
|
75
|
+
const transports = new SessionRegistry();
|
|
76
|
+
// unref: the sweeper must never be the reason the process stays up.
|
|
77
|
+
setInterval(() => transports.sweep(), SWEEP_INTERVAL_MS).unref();
|
|
73
78
|
const httpServer = createServer((req, res) => {
|
|
74
79
|
void handle(req, res).catch((e) => {
|
|
75
80
|
console.error("HTTP handler error:", e);
|
|
@@ -110,39 +115,39 @@ export async function startHttp(port) {
|
|
|
110
115
|
jsonRpcError(res, 400, `Invalid request body: ${e.message}`);
|
|
111
116
|
return;
|
|
112
117
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
118
|
+
// get() also refreshes the session's idle clock.
|
|
119
|
+
let transport = sid ? transports.get(sid) : undefined;
|
|
120
|
+
if (!transport) {
|
|
121
|
+
if (sid || !isInitializeRequest(body)) {
|
|
122
|
+
jsonRpcError(res, 400, "No valid session. Send an initialize request first.");
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
const created = new StreamableHTTPServerTransport({
|
|
119
126
|
sessionIdGenerator: () => randomUUID(),
|
|
120
127
|
onsessioninitialized: (id) => {
|
|
121
|
-
transports.set(id,
|
|
128
|
+
transports.set(id, created);
|
|
122
129
|
},
|
|
123
130
|
...(ALLOWED_HOSTS.length > 0
|
|
124
131
|
? { enableDnsRebindingProtection: true, allowedHosts: ALLOWED_HOSTS }
|
|
125
132
|
: {}),
|
|
126
133
|
});
|
|
127
|
-
|
|
128
|
-
if (
|
|
129
|
-
transports.delete(
|
|
134
|
+
created.onclose = () => {
|
|
135
|
+
if (created.sessionId)
|
|
136
|
+
transports.delete(created.sessionId);
|
|
130
137
|
};
|
|
131
|
-
await buildServer().connect(
|
|
132
|
-
|
|
133
|
-
else {
|
|
134
|
-
jsonRpcError(res, 400, "No valid session. Send an initialize request first.");
|
|
135
|
-
return;
|
|
138
|
+
await buildServer().connect(created);
|
|
139
|
+
transport = created;
|
|
136
140
|
}
|
|
137
141
|
await transport.handleRequest(req, res, body);
|
|
138
142
|
return;
|
|
139
143
|
}
|
|
140
144
|
if (req.method === "GET" || req.method === "DELETE") {
|
|
141
|
-
|
|
145
|
+
const transport = sid ? transports.get(sid) : undefined;
|
|
146
|
+
if (!transport) {
|
|
142
147
|
jsonRpcError(res, 400, "No valid session.");
|
|
143
148
|
return;
|
|
144
149
|
}
|
|
145
|
-
await
|
|
150
|
+
await transport.handleRequest(req, res);
|
|
146
151
|
return;
|
|
147
152
|
}
|
|
148
153
|
res.writeHead(405);
|
package/dist/http.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.js","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,8EAA8E;AAC9E,iFAAiF;AACjF
|
|
1
|
+
{"version":3,"file":"http.js","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,8EAA8E;AAC9E,iFAAiF;AACjF,mFAAmF;AACnF,kDAAkD;AAElD,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;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEhD,MAAM,cAAc,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC,QAAQ;AAC5C,MAAM,iBAAiB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B,OAAO,CAAC,KAAK,CAAC,0BAA0B,IAAI,MAAM,CAAC,CAAC;IACtD,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/dist/server.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
// Builds a configured McpServer with all
|
|
1
|
+
// Builds a configured McpServer with all 7 tools registered, plus the stdio
|
|
2
2
|
// start helper. The HTTP start helper lives in http.ts.
|
|
3
3
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
4
4
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
5
5
|
import { registerTools } from "./tools.js";
|
|
6
6
|
// version: keep in sync with package.json and server.json (and the user-agent in api.ts).
|
|
7
|
-
export const SERVER_INFO = { name: "x402-list-mcp", version: "0.
|
|
7
|
+
export const SERVER_INFO = { name: "x402-list-mcp", version: "0.5.1" };
|
|
8
8
|
export function buildServer() {
|
|
9
9
|
const server = new McpServer(SERVER_INFO, {
|
|
10
10
|
capabilities: { tools: {} },
|
|
11
|
-
instructions: "x402-list is the directory of services that accept x402 payments,
|
|
11
|
+
instructions: "x402-list is the directory of services that accept x402 payments: more than 500 listed and live-monitored, plus on-chain-verified settlement volume per facilitator. Reach for it when an agent must choose a paid API, confirm one is still safe to call, or price a call, before writing payment code. Discover with x402_search_services, inspect one with x402_get_service, pick for a stated need with x402_find_best_service, confirm it is up with x402_check_health, see which facilitator actually settles volume with x402_facilitator_volumes, and catch a moved payout address or a reprice with x402_change_events. When the free ranking cannot decide, x402_assess_services buys a fresh AI comparison of a shortlist for $0.25 USDC on Base, signed by your own wallet: this server holds no keys. On-chain figures are a conservative undercount and money fields are decimal US dollars.",
|
|
12
12
|
});
|
|
13
13
|
registerTools(server);
|
|
14
14
|
return server;
|
package/dist/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,wDAAwD;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CAAC,KAAK,CAAC,gCAAgC,CAAC,CAAC;AAClD,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export interface ClosableSession {
|
|
2
|
+
sessionId?: string;
|
|
3
|
+
close(): void | Promise<void>;
|
|
4
|
+
}
|
|
5
|
+
export interface SessionRegistryOptions {
|
|
6
|
+
ttlMs?: number;
|
|
7
|
+
maxSessions?: number;
|
|
8
|
+
now?: () => number;
|
|
9
|
+
}
|
|
10
|
+
export declare const DEFAULT_SESSION_TTL_MS = 600000;
|
|
11
|
+
export declare const DEFAULT_MAX_SESSIONS = 256;
|
|
12
|
+
export declare class SessionRegistry<T extends ClosableSession> {
|
|
13
|
+
readonly ttlMs: number;
|
|
14
|
+
readonly maxSessions: number;
|
|
15
|
+
private readonly now;
|
|
16
|
+
private readonly entries;
|
|
17
|
+
constructor(opts?: SessionRegistryOptions);
|
|
18
|
+
get size(): number;
|
|
19
|
+
set(id: string, session: T): void;
|
|
20
|
+
get(id: string): T | undefined;
|
|
21
|
+
delete(id: string): boolean;
|
|
22
|
+
sweep(now?: number): number;
|
|
23
|
+
closeAll(): void;
|
|
24
|
+
private evict;
|
|
25
|
+
}
|