taoswap-mcp 0.3.0 → 0.4.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/README.md +61 -43
- package/dist/catalog.d.ts +1 -0
- package/dist/catalog.js +1 -0
- package/dist/cli.js +7 -3
- package/dist/documents.d.ts +73 -0
- package/dist/documents.js +290 -0
- package/dist/http.d.ts +3 -0
- package/dist/http.js +85 -5
- package/dist/manifest.json +1 -1
- package/dist/metrics.d.ts +21 -0
- package/dist/metrics.js +144 -0
- package/dist/prompts.d.ts +12 -2
- package/dist/prompts.js +18 -4
- package/dist/server.d.ts +13 -2
- package/dist/server.js +209 -41
- package/dist/tools.d.ts +2 -0
- package/dist/tools.js +4 -14
- package/dist/upstream.d.ts +3 -0
- package/dist/upstream.js +11 -1
- package/npm-shrinkwrap.json +6 -6
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -4,14 +4,20 @@ MCP server for the [Taoswap API](https://api.taoswap.org/llms.txt): free Bittens
|
|
|
4
4
|
|
|
5
5
|
```sh
|
|
6
6
|
npx -y taoswap-mcp@latest # follows releases
|
|
7
|
-
npx -y taoswap-mcp@0.
|
|
7
|
+
npx -y taoswap-mcp@0.4.1 # pins this version
|
|
8
8
|
```
|
|
9
9
|
|
|
10
10
|
It speaks MCP over stdio, or over Streamable HTTP with `--http` (see [Remote (HTTP)](#remote-http)), and needs Node 20.3 or later. The package ships an `npm-shrinkwrap.json`, so `npx` installs exactly the dependency tree reviewed for that version: `@modelcontextprotocol/server`, its `@modelcontextprotocol/core`, `zod` and the [`taoswap`](https://www.npmjs.com/package/taoswap) client, which has no dependency. Pin the version where you want to review each update.
|
|
11
11
|
|
|
12
12
|
## Add it to your assistant
|
|
13
13
|
|
|
14
|
-
**Claude Code
|
|
14
|
+
**By its URL**: `https://mcp.taoswap.org/mcp` is the server Taoswap runs, over Streamable HTTP, for clients that add a server by its URL, such as claude.ai custom connectors, Claude mobile and ChatGPT. In Claude Code:
|
|
15
|
+
|
|
16
|
+
```sh
|
|
17
|
+
claude mcp add --transport http taoswap https://mcp.taoswap.org/mcp
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
**Claude Code**, running the server on your machine:
|
|
15
21
|
|
|
16
22
|
```sh
|
|
17
23
|
claude mcp add taoswap -- npx -y taoswap-mcp@latest
|
|
@@ -49,34 +55,37 @@ args = ["-y", "taoswap-mcp@latest"]
|
|
|
49
55
|
|
|
50
56
|
All tools are read-only and call `https://api.taoswap.org` only; the four `prepare_` tools sign nothing and send nothing.
|
|
51
57
|
|
|
52
|
-
| Tool | Answers
|
|
53
|
-
| -------------------------- |
|
|
54
|
-
| `list_subnets` | Every subnet with price, market cap, emission and volume, sortable here
|
|
55
|
-
| `get_subnet` | One subnet: identity, price, pools, emission, burn, holders, dereg risk
|
|
56
|
-
| `get_subnet_candles` | OHLCV candles of a subnet's alpha price
|
|
57
|
-
| `get_subnet_history` | A subnet's emissions, pool reserves, price, holders and burns per day
|
|
58
|
-
| `get_tao_price` | Daily TAO price in USD or EUR
|
|
59
|
-
| `list_validators` | Validators with take, root and alpha yields, stake and delegators
|
|
60
|
-
| `get_validator` | One validator, its subnets, history and delegators
|
|
61
|
-
| `get_validator_history` | A validator's root and alpha stake and its delegator counts per day
|
|
62
|
-
| `list_subnet_validators` | A subnet's validators with their yields
|
|
63
|
-
| `get_metagraph` | A subnet's neurons: stake, vtrust, incentive, dividends, rewards
|
|
64
|
-
| `get_portfolio` | A coldkey's balance per day
|
|
65
|
-
| `get_portfolio_pnl` | A coldkey's APY and realized and unrealized PnL
|
|
66
|
-
| `get_account_ledger` | A coldkey's TAO and alpha movements
|
|
67
|
-
| `get_account_transactions` | A coldkey's stake operations and TAO transfers
|
|
68
|
-
| `list_trades` | Buys and sells against the subnet pools, filterable
|
|
69
|
-
| `search` |
|
|
70
|
-
| `
|
|
71
|
-
| `
|
|
72
|
-
| `
|
|
73
|
-
| `
|
|
74
|
-
| `
|
|
75
|
-
| `
|
|
76
|
-
| `
|
|
58
|
+
| Tool | Answers | API operation |
|
|
59
|
+
| -------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------- |
|
|
60
|
+
| `list_subnets` | Every subnet with price, market cap, emission and volume, sortable here | `GET /v2/subnets/` |
|
|
61
|
+
| `get_subnet` | One subnet: identity, price, pools, emission, burn, holders, dereg risk | `GET /v2/subnets/{netuid}/` |
|
|
62
|
+
| `get_subnet_candles` | OHLCV candles of a subnet's alpha price | `GET /subnet-price-history/` |
|
|
63
|
+
| `get_subnet_history` | A subnet's emissions, pool reserves, price, holders and burns per day | `GET /v2/subnets/{netuid}/history/` |
|
|
64
|
+
| `get_tao_price` | Daily TAO price in USD or EUR | `GET /price-history/` |
|
|
65
|
+
| `list_validators` | Validators with take, root and alpha yields, stake and delegators | `GET /v2/validators/` |
|
|
66
|
+
| `get_validator` | One validator, its subnets, history and delegators | `GET /v2/validators/{hotkey}/` |
|
|
67
|
+
| `get_validator_history` | A validator's root and alpha stake and its delegator counts per day | `GET /v2/validators/{hotkey}/history/` |
|
|
68
|
+
| `list_subnet_validators` | A subnet's validators with their yields | `GET /v2/subnets/{netuid}/validators/` |
|
|
69
|
+
| `get_metagraph` | A subnet's neurons: stake, vtrust, incentive, dividends, rewards | `GET /metagraph/{netuid}/` |
|
|
70
|
+
| `get_portfolio` | A coldkey's balance per day | `GET /portfolio-balance/` |
|
|
71
|
+
| `get_portfolio_pnl` | A coldkey's APY and realized and unrealized PnL | `GET /portfolio-pnl-apy/` |
|
|
72
|
+
| `get_account_ledger` | A coldkey's TAO and alpha movements | `GET /v1/account-ledger/` |
|
|
73
|
+
| `get_account_transactions` | A coldkey's stake operations and TAO transfers | `GET /account-transactions/` |
|
|
74
|
+
| `list_trades` | Buys and sells against the subnet pools, filterable | `GET /trades/` |
|
|
75
|
+
| `search` | Subnets, validators, coldkeys, blocks and extrinsics by name, number or address, and the collections a question needs, as ids, titles and taoswap.org pages | `GET /search/` |
|
|
76
|
+
| `fetch` | One search result whole: a subnet, a validator, a coldkey's balances, a block, an extrinsic or a collection | the operation that serves it |
|
|
77
|
+
| `get_network_stats` | How the network's TAO splits between root, pools and free balances | `GET /network-stats/` |
|
|
78
|
+
| `list_api_operations` | Every GET operation, or one with its parameters and each field's unit | the bundled schema, no request |
|
|
79
|
+
| `call_api` | Any other GET operation of the schema, on the pinned host | the path you pass |
|
|
80
|
+
| `prepare_trade` | A taoswap.org link to stake, unstake or swap between subnets | the subnets and validators, to check |
|
|
81
|
+
| `prepare_limit_order` | A taoswap.org link to place a limit buy, take-profit or stop-loss | `GET /v2/subnets/{netuid}/`, to check |
|
|
82
|
+
| `prepare_transfer` | A taoswap.org link to send TAO | no request |
|
|
83
|
+
| `prepare_new_wallet` | The taoswap.org link that creates a wallet in the user's browser | no request |
|
|
77
84
|
|
|
78
85
|
The named tools call operations Taoswap keeps stable, with at least 180 days of notice before a removal. Large lists (`/v2/subnets/` is about 160 KB compressed) are cut down here with `fields`, `sort_by` and `max_items`, and the answer says so, since the API itself returns the whole list. A field or a `sort_by` that no row has is an error listing the fields the rows carry, and an argument a tool does not take is refused before any request. Answers stay under 40,000 characters, their URL and notes included; set `TAOSWAP_MCP_MAX_CHARS` to change that, 2,000 at least.
|
|
79
86
|
|
|
87
|
+
`search` and `fetch` answer in the shape that ChatGPT's deep research and company knowledge read. `search` takes one `query` and returns `results`, each an `id`, a `title` and the taoswap.org page to cite; `fetch` takes one of those ids and returns the document's `title`, `url`, `text` and `metadata.api_url`, as structured content and as the same JSON in its text. A query that the API's search does not find whole is searched by its terms (addresses, hashes, netuids, then names), and a question about subnets, validators, the TAO price or the network adds the matching collection.
|
|
88
|
+
|
|
80
89
|
Subnet and validator names, descriptions, URLs and Discord handles come from on-chain identities that anyone can write. The server cuts each such string at 200 characters, and an answer that carries them says, above the data, that they are untrusted text to read as data, never as instructions.
|
|
81
90
|
|
|
82
91
|
## Actions the user signs
|
|
@@ -104,7 +113,15 @@ The server offers three MCP prompts, which clients often show as slash commands.
|
|
|
104
113
|
| `compare_validators` | `netuid`, and optionally `hotkeys`, comma-separated, 8 at most | A table of take, yields, stake and vtrust for those validators, or the subnet's 10 largest, from `list_subnet_validators` or `get_validator` |
|
|
105
114
|
| `review_portfolio` | `coldkey` | Positions, PnL and yields from `get_portfolio`, `get_portfolio_pnl` and `get_account_ledger`; an action only as a `prepare_` link the user signs in their own wallet |
|
|
106
115
|
|
|
107
|
-
Each argument is checked before it reaches the conversation: a netuid is a whole number from 0 to 65535, and an address a Bittensor SS58 address with a valid checksum. Anything else is refused with an error that names the argument without repeating it. Every prompt says that its figures are data, not financial advice, and that the user never shares a seed phrase, a private key or a password.
|
|
116
|
+
Clients that complete arguments suggest a netuid from its first digits or from its subnet's name. Each argument is checked before it reaches the conversation: a netuid is a whole number from 0 to 65535, and an address a Bittensor SS58 address with a valid checksum. Anything else is refused with an error that names the argument without repeating it. Every prompt says that its figures are data, not financial advice, and that the user never shares a seed phrase, a private key or a password.
|
|
117
|
+
|
|
118
|
+
## Resources
|
|
119
|
+
|
|
120
|
+
The server lists three kinds of resources, which clients such as Claude Code (`@taoswap:taoswap://guide`) attach to the conversation without a tool call:
|
|
121
|
+
|
|
122
|
+
- `taoswap://guide`: what to know before writing code against the API, from units and identifiers to pagination, limits, freshness and stability;
|
|
123
|
+
- `taoswap://operations`: every GET operation, with its rate limit and whether it is stable;
|
|
124
|
+
- `taoswap://operations/{operationId}`: one operation's parameters and response fields with their units, listed for the stable operations and completed for all of them.
|
|
108
125
|
|
|
109
126
|
## Link to Taoswap
|
|
110
127
|
|
|
@@ -118,7 +135,7 @@ Data is as fresh as the API: a block is indexed within about a minute, and route
|
|
|
118
135
|
|
|
119
136
|
## Remote (HTTP)
|
|
120
137
|
|
|
121
|
-
`--http` serves the same tools over Streamable HTTP, for clients that reach a server by its URL instead of starting it, such as claude.ai custom connectors, Claude mobile and ChatGPT. Taoswap runs
|
|
138
|
+
`--http` serves the same tools over Streamable HTTP, for clients that reach a server by its URL instead of starting it, such as claude.ai custom connectors, Claude mobile and ChatGPT. Taoswap runs one at `https://mcp.taoswap.org/mcp`, with the settings below behind its own proxy; to run your own:
|
|
122
139
|
|
|
123
140
|
```sh
|
|
124
141
|
npx -y taoswap-mcp@latest --http # http://127.0.0.1:8080/mcp
|
|
@@ -133,7 +150,7 @@ docker run --rm -i taoswap-mcp # stdio
|
|
|
133
150
|
docker run --rm -p 127.0.0.1:8080:8080 taoswap-mcp --http # http://127.0.0.1:8080/mcp
|
|
134
151
|
```
|
|
135
152
|
|
|
136
|
-
The server keeps no session: it answers each `POST /mcp` on its own, for protocol versions 2024-10-07 to 2025-11-25 after their `initialize` handshake, and for 2026-07-28 on any request that names it in `_meta`, as over stdio. `GET` and `DELETE` on `/mcp` answer `405`, since no stream or session stays open, and `GET /healthz` answers `{"status":"ok"}`. Nothing authenticates a client: the data is public, and the `prepare_` tools only return links. Put a reverse proxy that terminates TLS in front of the server, and set `TAOSWAP_MCP_TRUST_PROXY` and `TAOSWAP_MCP_ALLOWED_HOSTS` for it.
|
|
153
|
+
The server keeps no session: it answers each `POST /mcp` on its own, for protocol versions 2024-10-07 to 2025-11-25 after their `initialize` handshake, and for 2026-07-28 on any request that names it in `_meta`, as over stdio. `GET` and `DELETE` on `/mcp` answer `405`, since no stream or session stays open, and `GET /healthz` answers `{"status":"ok"}`. A browser that opens `/` or `/mcp` gets a short page on adding the server instead, since people open the URL wherever it is shared. Nothing authenticates a client: the data is public, and the `prepare_` tools only return links. Put a reverse proxy that terminates TLS in front of the server, and set `TAOSWAP_MCP_TRUST_PROXY` and `TAOSWAP_MCP_ALLOWED_HOSTS` for it.
|
|
137
154
|
|
|
138
155
|
Every client shares the server's one Taoswap client, and with it the API's limits on the server's one address. So the server:
|
|
139
156
|
|
|
@@ -143,19 +160,20 @@ Every client shares the server's one Taoswap client, and with it the API's limit
|
|
|
143
160
|
- takes 120 requests a minute and 8 at once from each client address (an IPv6 address counts with the rest of its /64), and 64 at once in all, answering `429` or `503` with `Retry-After` past those;
|
|
144
161
|
- refuses a body over 64 KiB with `413`, waits 10 seconds for a request's headers and 15 for the whole request, and answers `504` to a request still without an answer after 60 seconds.
|
|
145
162
|
|
|
146
|
-
| Setting | Default | What it sets
|
|
147
|
-
| ------------------------------- | ----------------------------------------------------------------- |
|
|
148
|
-
| `--port`, `TAOSWAP_MCP_PORT` | `8080` | The port; `0` picks a free one
|
|
149
|
-
| `--host`, `TAOSWAP_MCP_HOST` | `127.0.0.1`, and `0.0.0.0` in the image | The address to listen on
|
|
150
|
-
| `TAOSWAP_MCP_TRUST_PROXY` | `0`, which ignores `X-Forwarded-For` | The reverse proxies in front of the server, each appending to `X-Forwarded-For`: the client's address is the entry that many places from the end, as the client writes the earlier ones
|
|
151
|
-
| `TAOSWAP_MCP_ALLOWED_HOSTS` | `localhost`, `127.0.0.1` and `[::1]` on a loopback host, else any | The `Host` names accepted, comma-separated, or `*` for any: against DNS rebinding, list the server's public name
|
|
152
|
-
| `TAOSWAP_MCP_ALLOWED_ORIGINS` | `localhost`, `127.0.0.1` and `[::1]` | The browser `Origin` names accepted; a request without `Origin`, as clients other than browsers send, passes
|
|
153
|
-
| `TAOSWAP_MCP_RATE_PER_IP` | `120` | Requests a minute per client address, which may all come at once
|
|
154
|
-
| `TAOSWAP_MCP_CONCURRENT_PER_IP` | `8` | Requests at once per client address
|
|
155
|
-
| `TAOSWAP_MCP_CONCURRENT` | `64` | Requests at once in all
|
|
156
|
-
| `TAOSWAP_MCP_TIMEOUT` | `60` | Seconds before a request still without an answer gets a `504`
|
|
157
|
-
| `TAOSWAP_MCP_MAX_QUEUE` | `40` | Requests to the API that may wait their turn, 60 at most, so that each starts within its 20-second timeout
|
|
158
|
-
| `TAOSWAP_MCP_CACHE_MB` | `64` | Megabytes of API answers kept in memory, 2,000 answers at most
|
|
163
|
+
| Setting | Default | What it sets |
|
|
164
|
+
| ------------------------------- | ----------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
165
|
+
| `--port`, `TAOSWAP_MCP_PORT` | `8080` | The port; `0` picks a free one |
|
|
166
|
+
| `--host`, `TAOSWAP_MCP_HOST` | `127.0.0.1`, and `0.0.0.0` in the image | The address to listen on |
|
|
167
|
+
| `TAOSWAP_MCP_TRUST_PROXY` | `0`, which ignores `X-Forwarded-For` | The reverse proxies in front of the server, each appending to `X-Forwarded-For`: the client's address is the entry that many places from the end, as the client writes the earlier ones |
|
|
168
|
+
| `TAOSWAP_MCP_ALLOWED_HOSTS` | `localhost`, `127.0.0.1` and `[::1]` on a loopback host, else any | The `Host` names accepted, comma-separated, or `*` for any: against DNS rebinding, list the server's public name |
|
|
169
|
+
| `TAOSWAP_MCP_ALLOWED_ORIGINS` | `localhost`, `127.0.0.1` and `[::1]` | The browser `Origin` names accepted; a request without `Origin`, as clients other than browsers send, passes |
|
|
170
|
+
| `TAOSWAP_MCP_RATE_PER_IP` | `120` | Requests a minute per client address, which may all come at once |
|
|
171
|
+
| `TAOSWAP_MCP_CONCURRENT_PER_IP` | `8` | Requests at once per client address |
|
|
172
|
+
| `TAOSWAP_MCP_CONCURRENT` | `64` | Requests at once in all |
|
|
173
|
+
| `TAOSWAP_MCP_TIMEOUT` | `60` | Seconds before a request still without an answer gets a `504` |
|
|
174
|
+
| `TAOSWAP_MCP_MAX_QUEUE` | `40` | Requests to the API that may wait their turn, 60 at most, so that each starts within its 20-second timeout |
|
|
175
|
+
| `TAOSWAP_MCP_CACHE_MB` | `64` | Megabytes of API answers kept in memory, 2,000 answers at most |
|
|
176
|
+
| `TAOSWAP_MCP_METRICS` | `0` | `1` serves Prometheus counters at `GET /metrics`: requests by method and status, conversations started (`initialize` or `server/discover`) by client name, tool calls by outcome and duration, and the API requests answered from the cache, joined, sent or refused as busy. Keep that path private: forward `/mcp` alone through the proxy |
|
|
159
177
|
|
|
160
178
|
`TAOSWAP_MCP_MAX_CHARS` applies too, and `taoswap-mcp --help` lists them all. A value out of range stops the server with a message and exit code 2. A platform such as claude.ai calls from addresses of its own, so one address may carry many of its users: raise the per-address limits for those.
|
|
161
179
|
|
package/dist/catalog.d.ts
CHANGED
package/dist/catalog.js
CHANGED
|
@@ -57,6 +57,7 @@ export function indexOperations(schema, manifest) {
|
|
|
57
57
|
const tags = Array.isArray(get.tags) ? get.tags : [];
|
|
58
58
|
operations.push({
|
|
59
59
|
path,
|
|
60
|
+
operationId: String(get.operationId ?? ""),
|
|
60
61
|
summary: oneLine(get.summary, 120),
|
|
61
62
|
description: String(get.description ?? ""),
|
|
62
63
|
tag: String(tags[0] ?? ""),
|
package/dist/cli.js
CHANGED
|
@@ -4,6 +4,7 @@ import { parseArgs } from "node:util";
|
|
|
4
4
|
import { localhostAllowedHostnames } from "@modelcontextprotocol/server";
|
|
5
5
|
import { serveStdio } from "@modelcontextprotocol/server/stdio";
|
|
6
6
|
import { createHttpServer, HTTP_DEFAULTS, MAX_BODY_BYTES } from "./http.js";
|
|
7
|
+
import { Metrics } from "./metrics.js";
|
|
7
8
|
import { createServer, defaultClient, MIN_MAX_CHARS, VERSION } from "./server.js";
|
|
8
9
|
import { UPSTREAM_DEFAULTS, Upstream, upstreamClient } from "./upstream.js";
|
|
9
10
|
/** At 4 requests a second, a request queued behind this many starts within the client's 20-second timeout. */
|
|
@@ -35,6 +36,7 @@ With --http:
|
|
|
35
36
|
TAOSWAP_MCP_TIMEOUT seconds a request may take, its answer included (${HTTP_DEFAULTS.timeoutSeconds})
|
|
36
37
|
TAOSWAP_MCP_MAX_QUEUE API requests that may wait their turn before a tool call fails as busy (${UPSTREAM_DEFAULTS.maxQueued}, ${MAX_QUEUE_LIMIT} at most)
|
|
37
38
|
TAOSWAP_MCP_CACHE_MB megabytes of API answers kept in memory (${UPSTREAM_DEFAULTS.maxBytes / 1024 / 1024})
|
|
39
|
+
TAOSWAP_MCP_METRICS 1 serves Prometheus counters at GET /metrics, which a proxy should keep private (0)
|
|
38
40
|
A request body is ${MAX_BODY_BYTES / 1024} KiB at most.`;
|
|
39
41
|
const flags = (() => {
|
|
40
42
|
try {
|
|
@@ -91,9 +93,10 @@ function serveHttp() {
|
|
|
91
93
|
const timeout = whole("TAOSWAP_MCP_TIMEOUT", env.TAOSWAP_MCP_TIMEOUT, HTTP_DEFAULTS.timeoutSeconds, 1, 3600);
|
|
92
94
|
const maxQueued = whole("TAOSWAP_MCP_MAX_QUEUE", env.TAOSWAP_MCP_MAX_QUEUE, UPSTREAM_DEFAULTS.maxQueued, 0, MAX_QUEUE_LIMIT);
|
|
93
95
|
const cacheMb = whole("TAOSWAP_MCP_CACHE_MB", env.TAOSWAP_MCP_CACHE_MB, UPSTREAM_DEFAULTS.maxBytes / 1024 / 1024, 0, 65_536);
|
|
94
|
-
const
|
|
96
|
+
const metrics = whole("TAOSWAP_MCP_METRICS", env.TAOSWAP_MCP_METRICS, 0, 0, 1) === 1 ? new Metrics(VERSION) : undefined;
|
|
97
|
+
const client = upstreamClient(new Upstream({ maxQueued, maxBytes: cacheMb * 1024 * 1024, ...(metrics ? { metrics } : {}) }));
|
|
95
98
|
const server = createHttpServer({
|
|
96
|
-
factory: () => createServer({ client, ...(maxChars ? { maxChars } : {}) }),
|
|
99
|
+
factory: () => createServer({ client, ...(maxChars ? { maxChars } : {}), ...(metrics ? { metrics } : {}) }),
|
|
97
100
|
trustProxy,
|
|
98
101
|
...(allowedHosts ? { allowedHosts } : {}),
|
|
99
102
|
...(allowedOrigins ? { allowedOrigins } : {}),
|
|
@@ -102,6 +105,7 @@ function serveHttp() {
|
|
|
102
105
|
concurrent,
|
|
103
106
|
timeoutMs: timeout * 1000,
|
|
104
107
|
onerror: (error) => console.error(`taoswap-mcp: ${error.message}`),
|
|
108
|
+
...(metrics ? { metrics } : {}),
|
|
105
109
|
});
|
|
106
110
|
server.on("error", (error) => {
|
|
107
111
|
console.error(`taoswap-mcp: cannot serve HTTP on ${host} port ${port}: ${error.message}`);
|
|
@@ -110,7 +114,7 @@ function serveHttp() {
|
|
|
110
114
|
server.listen(port, host, () => {
|
|
111
115
|
const bound = server.address();
|
|
112
116
|
const at = bound.family === "IPv6" ? `[${bound.address}]` : bound.address;
|
|
113
|
-
console.error(`taoswap-mcp ${VERSION}: MCP over Streamable HTTP at http://${at}:${bound.port}/mcp, health at /healthz`);
|
|
117
|
+
console.error(`taoswap-mcp ${VERSION}: MCP over Streamable HTTP at http://${at}:${bound.port}/mcp, health at /healthz${metrics ? ", metrics at /metrics" : ""}`);
|
|
114
118
|
});
|
|
115
119
|
const stop = () => {
|
|
116
120
|
server.close(() => process.exit(0));
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { QueryValue } from "taoswap";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import type { ShapeOptions } from "./shape.ts";
|
|
4
|
+
/** The pages that search results and fetched documents point to, which ChatGPT cites. */
|
|
5
|
+
export declare const SITE = "https://taoswap.org";
|
|
6
|
+
/** Hits kept from the API's search, and API calls one search makes at most. */
|
|
7
|
+
export declare const MAX_RESULTS = 10;
|
|
8
|
+
export declare const MAX_LOOKUPS = 4;
|
|
9
|
+
export interface SearchResult {
|
|
10
|
+
id: string;
|
|
11
|
+
title: string;
|
|
12
|
+
url: string;
|
|
13
|
+
}
|
|
14
|
+
/** What `fetch` reads for one document id, and how the answer gives its title and page. */
|
|
15
|
+
export interface DocumentSource {
|
|
16
|
+
path: string;
|
|
17
|
+
query: Record<string, QueryValue>;
|
|
18
|
+
shape?: ShapeOptions;
|
|
19
|
+
/** The part of the answer that is the document, undefined when the answer holds none. */
|
|
20
|
+
pick?(data: unknown): unknown;
|
|
21
|
+
title(item: unknown): string;
|
|
22
|
+
url(item: unknown): string;
|
|
23
|
+
}
|
|
24
|
+
export declare const searchInput: z.ZodObject<{
|
|
25
|
+
query: z.ZodString;
|
|
26
|
+
}, z.core.$strict>;
|
|
27
|
+
export declare const searchOutput: z.ZodObject<{
|
|
28
|
+
results: z.ZodArray<z.ZodObject<{
|
|
29
|
+
id: z.ZodString;
|
|
30
|
+
title: z.ZodString;
|
|
31
|
+
url: z.ZodString;
|
|
32
|
+
}, z.core.$strip>>;
|
|
33
|
+
}, z.core.$strip>;
|
|
34
|
+
export declare const fetchInput: z.ZodObject<{
|
|
35
|
+
id: z.ZodString;
|
|
36
|
+
}, z.core.$strict>;
|
|
37
|
+
export declare const fetchOutput: z.ZodObject<{
|
|
38
|
+
id: z.ZodString;
|
|
39
|
+
title: z.ZodString;
|
|
40
|
+
text: z.ZodString;
|
|
41
|
+
url: z.ZodString;
|
|
42
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
43
|
+
}, z.core.$strip>;
|
|
44
|
+
/** Text written on chain, made fit for a title: one line, without control characters, at most 60 characters. */
|
|
45
|
+
export declare function label(text: string | undefined): string | undefined;
|
|
46
|
+
export declare const SEARCH_KINDS: readonly ["address", "hash", "number", "words"];
|
|
47
|
+
export declare const SEARCH_FOUND: readonly ["entities", "collections", "none"];
|
|
48
|
+
export type SearchKind = (typeof SEARCH_KINDS)[number];
|
|
49
|
+
export type SearchFound = (typeof SEARCH_FOUND)[number];
|
|
50
|
+
/** The terms worth a search of their own, most specific first: addresses, hashes, numbers, then words. */
|
|
51
|
+
export declare function searchTerms(query: string): string[];
|
|
52
|
+
/** The kind of a query's most specific term: what the metrics count, since they never hold the query. */
|
|
53
|
+
export declare function searchKind(query: string): SearchKind;
|
|
54
|
+
/** One hit of GET /search/ as a search result, or undefined for a hit not worth a document. */
|
|
55
|
+
export declare function resultOf(hit: unknown, term: string): SearchResult | undefined;
|
|
56
|
+
/**
|
|
57
|
+
* Search results for a query, in the shape ChatGPT's deep research reads: the API's search on the whole query, then on its
|
|
58
|
+
* terms when the whole finds nothing, then the collections its words name, or all of them when nothing else matched;
|
|
59
|
+
* `found` says which of the three it came to.
|
|
60
|
+
*/
|
|
61
|
+
export declare function searchDocuments(query: string, lookup: (term: string) => Promise<unknown[]>): Promise<{
|
|
62
|
+
results: SearchResult[];
|
|
63
|
+
found: SearchFound;
|
|
64
|
+
}>;
|
|
65
|
+
/** The hits of a /search/ answer. */
|
|
66
|
+
export declare function hitsOf(data: unknown): unknown[];
|
|
67
|
+
/** What `fetch` reads for an id that `search` returns, or undefined for any other id. */
|
|
68
|
+
export declare function documentSource(id: string): DocumentSource | undefined;
|
|
69
|
+
/** The operations of openapi/manifest.json that each tool reads. */
|
|
70
|
+
export declare const DOCUMENT_OPERATIONS: {
|
|
71
|
+
readonly search: readonly ["/search/"];
|
|
72
|
+
readonly fetch: string[];
|
|
73
|
+
};
|
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { addressProblem } from "./ss58.js";
|
|
3
|
+
import { SUBNET_FIELDS, VALIDATOR_FIELDS } from "./tools.js";
|
|
4
|
+
/** The pages that search results and fetched documents point to, which ChatGPT cites. */
|
|
5
|
+
export const SITE = "https://taoswap.org";
|
|
6
|
+
/** Hits kept from the API's search, and API calls one search makes at most. */
|
|
7
|
+
export const MAX_RESULTS = 10;
|
|
8
|
+
export const MAX_LOOKUPS = 4;
|
|
9
|
+
export const searchInput = z.strictObject({
|
|
10
|
+
query: z.string().describe("Words, a subnet netuid or name, a validator name, an SS58 address, a block number or an extrinsic hash."),
|
|
11
|
+
});
|
|
12
|
+
export const searchOutput = z.object({
|
|
13
|
+
results: z.array(z.object({ id: z.string(), title: z.string(), url: z.string() })),
|
|
14
|
+
});
|
|
15
|
+
export const fetchInput = z.strictObject({
|
|
16
|
+
id: z
|
|
17
|
+
.string()
|
|
18
|
+
.describe("An id from search: subnet:64, validator:5F..., account:5F..., block:5000000, extrinsic:0x..., subnets, validators, tao-price or network."),
|
|
19
|
+
});
|
|
20
|
+
export const fetchOutput = z.object({
|
|
21
|
+
id: z.string(),
|
|
22
|
+
title: z.string(),
|
|
23
|
+
text: z.string(),
|
|
24
|
+
url: z.string(),
|
|
25
|
+
metadata: z.record(z.string(), z.string()).optional(),
|
|
26
|
+
});
|
|
27
|
+
const isRow = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
28
|
+
const str = (row, key) => (typeof row[key] === "string" ? row[key] : undefined);
|
|
29
|
+
const num = (row, key) => (Number.isInteger(row[key]) ? row[key] : undefined);
|
|
30
|
+
/** Text written on chain, made fit for a title: one line, without control characters, at most 60 characters. */
|
|
31
|
+
export function label(text) {
|
|
32
|
+
const flat = text
|
|
33
|
+
?.replace(/[\p{Cc}\p{Cf}]+/gu, " ")
|
|
34
|
+
.replace(/\s+/g, " ")
|
|
35
|
+
.trim();
|
|
36
|
+
if (!flat)
|
|
37
|
+
return undefined;
|
|
38
|
+
return flat.length > 60 ? `${flat.slice(0, 57)}...` : flat;
|
|
39
|
+
}
|
|
40
|
+
const short = (address) => `${address.slice(0, 6)}...${address.slice(-4)}`;
|
|
41
|
+
const isAddress = (text) => addressProblem(text) === undefined;
|
|
42
|
+
const HASH = /^0x[0-9a-f]{64}$/;
|
|
43
|
+
export const SEARCH_KINDS = ["address", "hash", "number", "words"];
|
|
44
|
+
export const SEARCH_FOUND = ["entities", "collections", "none"];
|
|
45
|
+
const COLLECTIONS = [
|
|
46
|
+
{
|
|
47
|
+
id: "subnets",
|
|
48
|
+
title: "Bittensor subnets: alpha prices, market caps, emissions and volume",
|
|
49
|
+
url: `${SITE}/subnets`,
|
|
50
|
+
match: /\b(subnets?|netuids?|alpha|dtao|market ?caps?|emissions?|sn\d+)\b/i,
|
|
51
|
+
source: {
|
|
52
|
+
path: "/v2/subnets/",
|
|
53
|
+
query: {},
|
|
54
|
+
shape: { listKey: "results", defaultFields: SUBNET_FIELDS, sortBy: "market_cap", sortDir: "desc" },
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
id: "validators",
|
|
59
|
+
title: "Bittensor validators: take, yields, stake and delegators",
|
|
60
|
+
url: `${SITE}/validators`,
|
|
61
|
+
match: /\b(validators?|delegat\w*|nominat\w*|stak\w*|ap[ry]s?|yields?|take)\b/i,
|
|
62
|
+
source: { path: "/v2/validators/", query: {}, shape: { listKey: "results", defaultFields: VALIDATOR_FIELDS, maxItems: 50 } },
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
id: "tao-price",
|
|
66
|
+
title: "TAO price in US dollars, daily, the last 30 days",
|
|
67
|
+
url: `${SITE}/price`,
|
|
68
|
+
match: /\b(tao|bittensor)\b.*\b(price|usd|dollars?|worth|value)\b|\b(price|usd|dollars?|worth|value)\b.*\b(tao|bittensor)\b/i,
|
|
69
|
+
source: { path: "/price-history/", query: { limit: 30 }, shape: { listKey: "results", keepLast: true } },
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
id: "network",
|
|
73
|
+
title: "Bittensor network stats: stake on root, TAO in pools, free TAO and accounts",
|
|
74
|
+
url: `${SITE}/metrics`,
|
|
75
|
+
match: /\b(network|supply|circulating|registration|accounts?|holders?|root)\b/i,
|
|
76
|
+
source: { path: "/network-stats/", query: {} },
|
|
77
|
+
},
|
|
78
|
+
];
|
|
79
|
+
const STOPWORDS = new Set(("about account address against all alpha also and any apr apy are best between bittensor block blocks can cap chain chart coin " +
|
|
80
|
+
"coins compare comparison crypto current daily data day days delegate delegation does dtao emission emissions explain extrinsic " +
|
|
81
|
+
"for from give has hash have history how info into its just know last latest like list many market miner miners mining month most " +
|
|
82
|
+
"much need netuid network next now only over overview past per please price prices show stake staking subnet subnets tao tell " +
|
|
83
|
+
"than that the their there this today token tokens top trend under validator validators value versus volume wallet want week what " +
|
|
84
|
+
"when where which who why with worth year yield yields").split(" "));
|
|
85
|
+
/** The terms worth a search of their own, most specific first: addresses, hashes, numbers, then words. */
|
|
86
|
+
export function searchTerms(query) {
|
|
87
|
+
const terms = new Set();
|
|
88
|
+
let rest = query;
|
|
89
|
+
// Each match leaves the text, so the letters of an address or a hash never come back as words.
|
|
90
|
+
const consume = (pattern, term) => {
|
|
91
|
+
rest = rest.replace(pattern, (match, group) => {
|
|
92
|
+
terms.add(term(match, typeof group === "string" ? group : undefined));
|
|
93
|
+
return " ";
|
|
94
|
+
});
|
|
95
|
+
};
|
|
96
|
+
consume(/\b5[1-9A-HJ-NP-Za-km-z]{47}\b/g, (address) => address);
|
|
97
|
+
consume(/\b0x[0-9a-fA-F]{64}\b/g, (hash) => hash.toLowerCase());
|
|
98
|
+
consume(/\b(?:sn|subnet|netuid)\s*#?\s*(\d{1,5})\b/gi, (match, netuid) => netuid ?? match);
|
|
99
|
+
consume(/(?<![\w.,])\d{1,10}(?![\w.,])/g, (number) => number);
|
|
100
|
+
for (const [word] of rest.matchAll(/\p{L}[\p{L}\p{N}_-]{2,}/gu))
|
|
101
|
+
if (!STOPWORDS.has(word.toLowerCase()))
|
|
102
|
+
terms.add(word);
|
|
103
|
+
return [...terms];
|
|
104
|
+
}
|
|
105
|
+
/** The kind of a query's most specific term: what the metrics count, since they never hold the query. */
|
|
106
|
+
export function searchKind(query) {
|
|
107
|
+
const [first = ""] = searchTerms(query.trim().slice(0, 200));
|
|
108
|
+
if (isAddress(first))
|
|
109
|
+
return "address";
|
|
110
|
+
if (HASH.test(first))
|
|
111
|
+
return "hash";
|
|
112
|
+
return /^\d+$/.test(first) ? "number" : "words";
|
|
113
|
+
}
|
|
114
|
+
/** A fragment of an address, not a word that happens to occur inside some addresses. */
|
|
115
|
+
const looksLikeAddress = (term) => /^[1-9A-HJ-NP-Za-km-z]{8,48}$/.test(term) && /\d/.test(term);
|
|
116
|
+
const RANK = ["subnet", "validator", "account", "extrinsic", "block"];
|
|
117
|
+
/** One hit of GET /search/ as a search result, or undefined for a hit not worth a document. */
|
|
118
|
+
export function resultOf(hit, term) {
|
|
119
|
+
if (!isRow(hit))
|
|
120
|
+
return undefined;
|
|
121
|
+
switch (hit.type) {
|
|
122
|
+
case "subnet": {
|
|
123
|
+
const netuid = num(hit, "subnet_id");
|
|
124
|
+
if (netuid === undefined)
|
|
125
|
+
return undefined;
|
|
126
|
+
const name = label(str(hit, "name"));
|
|
127
|
+
return { id: `subnet:${netuid}`, title: `Subnet ${netuid}${name ? `: ${name}` : ""}`, url: `${SITE}/subnets/${netuid}` };
|
|
128
|
+
}
|
|
129
|
+
case "validator": {
|
|
130
|
+
const hotkey = str(hit, "validator_hotkey");
|
|
131
|
+
if (!hotkey || !isAddress(hotkey))
|
|
132
|
+
return undefined;
|
|
133
|
+
return {
|
|
134
|
+
id: `validator:${hotkey}`,
|
|
135
|
+
title: `Validator ${label(str(hit, "name")) ?? short(hotkey)}`,
|
|
136
|
+
url: `${SITE}/validators/${hotkey}`,
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
case "account": {
|
|
140
|
+
const address = str(hit, "ss58_address");
|
|
141
|
+
if (!address || !isAddress(address) || hit.is_coldkey !== true || !looksLikeAddress(term))
|
|
142
|
+
return undefined;
|
|
143
|
+
return { id: `account:${address}`, title: `Account ${address}`, url: `${SITE}/portfolio/${address}` };
|
|
144
|
+
}
|
|
145
|
+
case "extrinsic": {
|
|
146
|
+
const [block, index, hash] = [num(hit, "block_number"), num(hit, "extrinsic_index"), str(hit, "hash")?.toLowerCase()];
|
|
147
|
+
if (block === undefined || index === undefined || !hash || !HASH.test(hash))
|
|
148
|
+
return undefined;
|
|
149
|
+
const call = [str(hit, "module"), str(hit, "call")].filter(Boolean).join(".");
|
|
150
|
+
return {
|
|
151
|
+
id: `extrinsic:${hash}`,
|
|
152
|
+
title: `Extrinsic ${block}-${index}${call ? `: ${call}` : ""}`,
|
|
153
|
+
url: `${SITE}/extrinsics/${block}-${index}`,
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
case "block": {
|
|
157
|
+
const block = num(hit, "block_number");
|
|
158
|
+
if (block === undefined)
|
|
159
|
+
return undefined;
|
|
160
|
+
return { id: `block:${block}`, title: `Block ${block}`, url: `${SITE}/blocks/${block}` };
|
|
161
|
+
}
|
|
162
|
+
default:
|
|
163
|
+
return undefined;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Search results for a query, in the shape ChatGPT's deep research reads: the API's search on the whole query, then on its
|
|
168
|
+
* terms when the whole finds nothing, then the collections its words name, or all of them when nothing else matched;
|
|
169
|
+
* `found` says which of the three it came to.
|
|
170
|
+
*/
|
|
171
|
+
export async function searchDocuments(query, lookup) {
|
|
172
|
+
const text = query.trim().slice(0, 200);
|
|
173
|
+
if (text === "")
|
|
174
|
+
return { results: [], found: "none" };
|
|
175
|
+
const byId = new Map();
|
|
176
|
+
const take = (hits, term) => {
|
|
177
|
+
for (const hit of hits) {
|
|
178
|
+
const result = resultOf(hit, term);
|
|
179
|
+
if (result && !byId.has(result.id))
|
|
180
|
+
byId.set(result.id, result);
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
take(await lookup(text), text);
|
|
184
|
+
if (byId.size === 0) {
|
|
185
|
+
for (const term of searchTerms(text).slice(0, MAX_LOOKUPS - 1))
|
|
186
|
+
if (term !== text)
|
|
187
|
+
take(await lookup(term), term);
|
|
188
|
+
}
|
|
189
|
+
const rank = (result) => RANK.indexOf(result.id.slice(0, result.id.indexOf(":")));
|
|
190
|
+
const entities = [...byId.values()].sort((a, b) => rank(a) - rank(b)).slice(0, MAX_RESULTS);
|
|
191
|
+
const named = COLLECTIONS.filter((collection) => collection.match.test(text));
|
|
192
|
+
const collections = entities.length === 0 && named.length === 0 ? COLLECTIONS : named;
|
|
193
|
+
return {
|
|
194
|
+
results: [...entities, ...collections.map(({ id, title, url }) => ({ id, title, url }))],
|
|
195
|
+
found: entities.length > 0 ? "entities" : named.length > 0 ? "collections" : "none",
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
/** The hits of a /search/ answer. */
|
|
199
|
+
export function hitsOf(data) {
|
|
200
|
+
return isRow(data) && Array.isArray(data.results) ? data.results : [];
|
|
201
|
+
}
|
|
202
|
+
/** What `fetch` reads for an id that `search` returns, or undefined for any other id. */
|
|
203
|
+
export function documentSource(id) {
|
|
204
|
+
const collection = COLLECTIONS.find((c) => c.id === id);
|
|
205
|
+
if (collection)
|
|
206
|
+
return { ...collection.source, title: () => collection.title, url: () => collection.url };
|
|
207
|
+
const colon = id.indexOf(":");
|
|
208
|
+
if (colon < 0)
|
|
209
|
+
return undefined;
|
|
210
|
+
const [kind, key] = [id.slice(0, colon), id.slice(colon + 1)];
|
|
211
|
+
switch (kind) {
|
|
212
|
+
case "subnet": {
|
|
213
|
+
if (!/^\d{1,5}$/.test(key) || Number(key) > 65535)
|
|
214
|
+
return undefined;
|
|
215
|
+
const netuid = Number(key);
|
|
216
|
+
return {
|
|
217
|
+
path: `/v2/subnets/${netuid}/`,
|
|
218
|
+
query: { omit: "neurons,conviction,hyperparameters" },
|
|
219
|
+
title: (item) => {
|
|
220
|
+
const name = isRow(item) ? label(str(item, "name")) : undefined;
|
|
221
|
+
return `Subnet ${netuid}${name ? `: ${name}` : ""}`;
|
|
222
|
+
},
|
|
223
|
+
url: () => `${SITE}/subnets/${netuid}`,
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
case "validator": {
|
|
227
|
+
if (!isAddress(key))
|
|
228
|
+
return undefined;
|
|
229
|
+
return {
|
|
230
|
+
path: `/v2/validators/${key}/`,
|
|
231
|
+
query: { omit: "history,delegators" },
|
|
232
|
+
title: (item) => {
|
|
233
|
+
const identity = isRow(item) && isRow(item.identity) ? item.identity : {};
|
|
234
|
+
return `Validator ${label(str(identity, "name")) ?? short(key)}`;
|
|
235
|
+
},
|
|
236
|
+
url: () => `${SITE}/validators/${key}`,
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
case "account": {
|
|
240
|
+
if (!isAddress(key))
|
|
241
|
+
return undefined;
|
|
242
|
+
return {
|
|
243
|
+
path: "/portfolio-balance/",
|
|
244
|
+
query: { account: key, days: 7, subnets: "all" },
|
|
245
|
+
shape: { listKey: "results", keepLast: true },
|
|
246
|
+
title: () => `Account ${key}`,
|
|
247
|
+
url: () => `${SITE}/portfolio/${key}`,
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
case "block": {
|
|
251
|
+
if (!/^\d{1,10}$/.test(key))
|
|
252
|
+
return undefined;
|
|
253
|
+
const block = Number(key);
|
|
254
|
+
return {
|
|
255
|
+
path: "/search/",
|
|
256
|
+
query: { q: key, type: "block", limit: 1 },
|
|
257
|
+
pick: (data) => hitsOf(data).find((hit) => isRow(hit) && hit.type === "block" && hit.block_number === block),
|
|
258
|
+
title: () => `Block ${block}`,
|
|
259
|
+
url: () => `${SITE}/blocks/${block}`,
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
case "extrinsic": {
|
|
263
|
+
const hash = key.toLowerCase();
|
|
264
|
+
if (!HASH.test(hash))
|
|
265
|
+
return undefined;
|
|
266
|
+
return {
|
|
267
|
+
path: "/search/",
|
|
268
|
+
query: { q: hash, type: "extrinsic", limit: 1 },
|
|
269
|
+
pick: (data) => hitsOf(data).find((hit) => isRow(hit) && hit.type === "extrinsic" && str(hit, "hash")?.toLowerCase() === hash),
|
|
270
|
+
title: (item) => resultOf(item, hash)?.title ?? `Extrinsic ${hash}`,
|
|
271
|
+
url: (item) => resultOf(item, hash)?.url ?? SITE,
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
default:
|
|
275
|
+
return undefined;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
/** The operations of openapi/manifest.json that each tool reads. */
|
|
279
|
+
export const DOCUMENT_OPERATIONS = {
|
|
280
|
+
search: ["/search/"],
|
|
281
|
+
fetch: [
|
|
282
|
+
...new Set([
|
|
283
|
+
...COLLECTIONS.map((c) => c.source.path),
|
|
284
|
+
"/v2/subnets/{netuid}/",
|
|
285
|
+
"/v2/validators/{hotkey}/",
|
|
286
|
+
"/portfolio-balance/",
|
|
287
|
+
"/search/",
|
|
288
|
+
]),
|
|
289
|
+
].sort(),
|
|
290
|
+
};
|
package/dist/http.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type Server } from "node:http";
|
|
2
2
|
import { type McpServer } from "@modelcontextprotocol/server";
|
|
3
|
+
import type { Metrics } from "./metrics.ts";
|
|
3
4
|
export declare const HTTP_DEFAULTS: {
|
|
4
5
|
readonly port: 8080;
|
|
5
6
|
readonly host: "127.0.0.1";
|
|
@@ -30,6 +31,8 @@ export interface HttpOptions {
|
|
|
30
31
|
onerror?: (error: Error) => void;
|
|
31
32
|
/** The clock of the per-address token buckets, in milliseconds. */
|
|
32
33
|
now?: () => number;
|
|
34
|
+
/** Counts requests and the clients that start a conversation, served at GET /metrics; without it, /metrics is not found. */
|
|
35
|
+
metrics?: Metrics;
|
|
33
36
|
}
|
|
34
37
|
/** A Node HTTP server, not yet listening, that serves MCP statelessly at /mcp and its health at /healthz. */
|
|
35
38
|
export declare function createHttpServer(options: HttpOptions): Server;
|