@parcha/agentrun-serve 0.0.0-stage → 0.1.0-beta.29
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 +560 -0
- package/LICENSE +202 -0
- package/NOTICE +5 -0
- package/README.md +1723 -2
- package/dist/adapters.d.ts +205 -0
- package/dist/adapters.js +459 -0
- package/dist/agents.d.ts +124 -0
- package/dist/agents.js +302 -0
- package/dist/app.d.ts +7 -0
- package/dist/app.js +324 -0
- package/dist/bound-files.d.ts +4 -0
- package/dist/bound-files.js +164 -0
- package/dist/box/record.d.ts +6 -0
- package/dist/box/record.js +41 -0
- package/dist/box/sweep.d.ts +53 -0
- package/dist/box/sweep.js +193 -0
- package/dist/box-image.d.ts +98 -0
- package/dist/box-image.js +283 -0
- package/dist/box-relay.d.ts +42 -0
- package/dist/box-relay.js +222 -0
- package/dist/boxes.d.ts +54 -0
- package/dist/boxes.js +182 -0
- package/dist/cap.d.ts +224 -0
- package/dist/cap.js +721 -0
- package/dist/catalog.d.ts +20 -0
- package/dist/catalog.js +53 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +167 -0
- package/dist/coding-tools.d.ts +31 -0
- package/dist/coding-tools.js +81 -0
- package/dist/console/THIRD-PARTY-NOTICES.txt +1141 -0
- package/dist/console/assets/index-BN7oVcO4.js +445 -0
- package/dist/console/assets/index-By-jkqki.css +1 -0
- package/dist/console/assets/jetbrains-mono-cyrillic-400-normal-BEIGL1Tu.woff2 +0 -0
- package/dist/console/assets/jetbrains-mono-cyrillic-400-normal-CIEtRijs.woff +0 -0
- package/dist/console/assets/jetbrains-mono-cyrillic-600-normal-BB5xRk30.woff +0 -0
- package/dist/console/assets/jetbrains-mono-cyrillic-600-normal-EVf6-Yzo.woff2 +0 -0
- package/dist/console/assets/jetbrains-mono-cyrillic-ext-400-normal-BHyURHCj.woff +0 -0
- package/dist/console/assets/jetbrains-mono-cyrillic-ext-400-normal-C_uLvvQ5.woff2 +0 -0
- package/dist/console/assets/jetbrains-mono-cyrillic-ext-600-normal-Dj6eZy5f.woff2 +0 -0
- package/dist/console/assets/jetbrains-mono-cyrillic-ext-600-normal-DpeVePZf.woff +0 -0
- package/dist/console/assets/jetbrains-mono-greek-400-normal-C190GLew.woff2 +0 -0
- package/dist/console/assets/jetbrains-mono-greek-400-normal-CNojz0t3.woff +0 -0
- package/dist/console/assets/jetbrains-mono-greek-600-normal-3KAm9r92.woff +0 -0
- package/dist/console/assets/jetbrains-mono-greek-600-normal-H7WoG9Et.woff2 +0 -0
- package/dist/console/assets/jetbrains-mono-latin-400-normal-B11XCQ5g.woff +0 -0
- package/dist/console/assets/jetbrains-mono-latin-400-normal-V6pRDFza.woff2 +0 -0
- package/dist/console/assets/jetbrains-mono-latin-600-normal-C8RAYTDA.woff2 +0 -0
- package/dist/console/assets/jetbrains-mono-latin-600-normal-DXv3JcnD.woff +0 -0
- package/dist/console/assets/jetbrains-mono-latin-ext-400-normal-Bc8Ftmh3.woff2 +0 -0
- package/dist/console/assets/jetbrains-mono-latin-ext-400-normal-DHMOLxAi.woff +0 -0
- package/dist/console/assets/jetbrains-mono-latin-ext-600-normal-BfB_LPfz.woff2 +0 -0
- package/dist/console/assets/jetbrains-mono-latin-ext-600-normal-DiQlUoE6.woff +0 -0
- package/dist/console/assets/jetbrains-mono-vietnamese-400-normal-BeU3T8wf.woff +0 -0
- package/dist/console/assets/jetbrains-mono-vietnamese-400-normal-ByoDsISC.woff2 +0 -0
- package/dist/console/assets/jetbrains-mono-vietnamese-600-normal-CSpzN4cI.woff +0 -0
- package/dist/console/assets/jetbrains-mono-vietnamese-600-normal-Dtizs43-.woff2 +0 -0
- package/dist/console/assets/schibsted-grotesk-latin-400-normal-Cph9ettZ.woff2 +0 -0
- package/dist/console/assets/schibsted-grotesk-latin-400-normal-DfGZKnlb.woff +0 -0
- package/dist/console/assets/schibsted-grotesk-latin-600-normal-BGBUNdzT.woff2 +0 -0
- package/dist/console/assets/schibsted-grotesk-latin-600-normal-COje25QW.woff +0 -0
- package/dist/console/assets/schibsted-grotesk-latin-ext-400-normal-4l4lq8zr.woff2 +0 -0
- package/dist/console/assets/schibsted-grotesk-latin-ext-400-normal-BGzXWJeR.woff +0 -0
- package/dist/console/assets/schibsted-grotesk-latin-ext-600-normal-8_E36CQj.woff2 +0 -0
- package/dist/console/assets/schibsted-grotesk-latin-ext-600-normal-C27an7Zc.woff +0 -0
- package/dist/console/index.html +15 -0
- package/dist/daytona-api.d.ts +21 -0
- package/dist/daytona-api.js +101 -0
- package/dist/decision-rows.d.ts +11 -0
- package/dist/decision-rows.js +116 -0
- package/dist/decisions.d.ts +94 -0
- package/dist/decisions.js +184 -0
- package/dist/effort-guidance.d.ts +5 -0
- package/dist/effort-guidance.js +14 -0
- package/dist/environment.d.ts +5 -0
- package/dist/environment.js +11 -0
- package/dist/errors.d.ts +72 -0
- package/dist/errors.js +66 -0
- package/dist/exa-keyless.d.ts +35 -0
- package/dist/exa-keyless.js +202 -0
- package/dist/fetch-page.d.ts +114 -0
- package/dist/fetch-page.js +182 -0
- package/dist/files.d.ts +60 -0
- package/dist/files.js +153 -0
- package/dist/grade.d.ts +96 -0
- package/dist/grade.js +348 -0
- package/dist/graph-view.d.ts +100 -0
- package/dist/graph-view.js +212 -0
- package/dist/harness-app.d.ts +38 -0
- package/dist/harness-app.js +626 -0
- package/dist/harness.d.ts +53 -0
- package/dist/harness.js +74 -0
- package/dist/home-path.d.ts +27 -0
- package/dist/home-path.js +78 -0
- package/dist/host-tools.d.ts +20 -0
- package/dist/host-tools.js +140 -0
- package/dist/host.d.ts +39 -0
- package/dist/host.js +81 -0
- package/dist/hosted-search.d.ts +27 -0
- package/dist/hosted-search.js +129 -0
- package/dist/import-sources.d.ts +104 -0
- package/dist/import-sources.js +629 -0
- package/dist/import-summary.d.ts +25 -0
- package/dist/import-summary.js +75 -0
- package/dist/import-worker.d.ts +26 -0
- package/dist/import-worker.js +41 -0
- package/dist/import.d.ts +145 -0
- package/dist/import.js +1221 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +6 -0
- package/dist/key-check.d.ts +36 -0
- package/dist/key-check.js +108 -0
- package/dist/key-refusal.d.ts +51 -0
- package/dist/key-refusal.js +187 -0
- package/dist/learn/check.d.ts +99 -0
- package/dist/learn/check.js +259 -0
- package/dist/learn/grade.d.ts +79 -0
- package/dist/learn/grade.js +433 -0
- package/dist/learn/index.d.ts +7 -0
- package/dist/learn/index.js +11 -0
- package/dist/learn/invisible.d.ts +5 -0
- package/dist/learn/invisible.js +42 -0
- package/dist/learn/notes.d.ts +59 -0
- package/dist/learn/notes.js +146 -0
- package/dist/learn/reflect.d.ts +49 -0
- package/dist/learn/reflect.js +167 -0
- package/dist/learn/secrets.d.ts +18 -0
- package/dist/learn/secrets.js +111 -0
- package/dist/learn/skills.d.ts +84 -0
- package/dist/learn/skills.js +198 -0
- package/dist/learning-routes.d.ts +196 -0
- package/dist/learning-routes.js +609 -0
- package/dist/learning-run.d.ts +304 -0
- package/dist/learning-run.js +797 -0
- package/dist/learning-words.d.ts +73 -0
- package/dist/learning-words.js +171 -0
- package/dist/learning.d.ts +377 -0
- package/dist/learning.js +801 -0
- package/dist/llm.d.ts +40 -0
- package/dist/llm.js +37 -0
- package/dist/llms.txt +37 -0
- package/dist/mcp-servers.d.ts +115 -0
- package/dist/mcp-servers.js +445 -0
- package/dist/mcp.d.ts +51 -0
- package/dist/mcp.js +392 -0
- package/dist/model.d.ts +184 -0
- package/dist/model.js +484 -0
- package/dist/monid.d.ts +74 -0
- package/dist/monid.js +277 -0
- package/dist/openapi/agentrun-v2.openapi.json +4805 -0
- package/dist/openapi.d.ts +10 -0
- package/dist/openapi.js +1417 -0
- package/dist/owner.d.ts +55 -0
- package/dist/owner.js +222 -0
- package/dist/packs.d.ts +71 -0
- package/dist/packs.js +180 -0
- package/dist/page.d.ts +32 -0
- package/dist/page.js +133 -0
- package/dist/paid-calls.d.ts +46 -0
- package/dist/paid-calls.js +110 -0
- package/dist/pause.d.ts +68 -0
- package/dist/pause.js +97 -0
- package/dist/pdf-pages.d.ts +44 -0
- package/dist/pdf-pages.js +147 -0
- package/dist/place.d.ts +46 -0
- package/dist/place.js +105 -0
- package/dist/print.d.ts +20 -0
- package/dist/print.js +29 -0
- package/dist/propose.d.ts +38 -0
- package/dist/propose.js +82 -0
- package/dist/quiet-sqlite-warning.d.ts +1 -0
- package/dist/quiet-sqlite-warning.js +14 -0
- package/dist/request-start.d.ts +14 -0
- package/dist/request-start.js +226 -0
- package/dist/result.d.ts +3 -0
- package/dist/result.js +5 -0
- package/dist/rows.d.ts +46 -0
- package/dist/rows.js +121 -0
- package/dist/run-box.d.ts +134 -0
- package/dist/run-box.js +440 -0
- package/dist/run-manifest.d.ts +27 -0
- package/dist/run-manifest.js +60 -0
- package/dist/runnable.d.ts +80 -0
- package/dist/runnable.js +162 -0
- package/dist/runs.d.ts +840 -0
- package/dist/runs.js +2279 -0
- package/dist/secret-cut.d.ts +27 -0
- package/dist/secret-cut.js +109 -0
- package/dist/secrets.d.ts +50 -0
- package/dist/secrets.js +140 -0
- package/dist/server-lock.d.ts +44 -0
- package/dist/server-lock.js +140 -0
- package/dist/server.d.ts +626 -0
- package/dist/server.js +1756 -0
- package/dist/sessions.d.ts +4 -0
- package/dist/sessions.js +105 -0
- package/dist/skills.d.ts +31 -0
- package/dist/skills.js +68 -0
- package/dist/stats.d.ts +101 -0
- package/dist/stats.js +82 -0
- package/dist/tool-keys.d.ts +151 -0
- package/dist/tool-keys.js +273 -0
- package/dist/tool-plane.d.ts +143 -0
- package/dist/tool-plane.js +242 -0
- package/dist/tools.d.ts +147 -0
- package/dist/tools.js +253 -0
- package/dist/turn-end.d.ts +23 -0
- package/dist/turn-end.js +14 -0
- package/dist/turns.d.ts +34 -0
- package/dist/turns.js +202 -0
- package/dist/uploads.d.ts +104 -0
- package/dist/uploads.js +474 -0
- package/dist/usage.d.ts +29 -0
- package/dist/usage.js +58 -0
- package/dist/validate.d.ts +55 -0
- package/dist/validate.js +175 -0
- package/dist/web-fetch.d.ts +64 -0
- package/dist/web-fetch.js +262 -0
- package/dist/web-search.d.ts +54 -0
- package/dist/web-search.js +136 -0
- package/dist/webhooks.d.ts +182 -0
- package/dist/webhooks.js +487 -0
- package/dist/workspace-paths.d.ts +33 -0
- package/dist/workspace-paths.js +104 -0
- package/dist/workspace.d.ts +88 -0
- package/dist/workspace.js +369 -0
- package/launcher/agentrun-serve +109 -0
- package/package.json +94 -4
- package/skills/agentrun-serve/SKILL.md +128 -0
|
@@ -0,0 +1,445 @@
|
|
|
1
|
+
// Remote MCP servers a person adds through /v2/settings/mcp-servers. A preview connects with the official SDK client
|
|
2
|
+
// (@modelcontextprotocol/client: 2026-07-28 first, 2025-era servers by its fallback), lists every tool and stores
|
|
3
|
+
// nothing. A save previews, then keeps the URL, the tool snapshot the person saw and the credential in
|
|
4
|
+
// DIR/mcp-servers.json (0600, written whole, synced, renamed), each header value sealed (AES-256-GCM, tool-keys.ts' seal
|
|
5
|
+
// key) and bound to `mcp:<server>:<header>`, so a value moved to another server or header does not open. No read
|
|
6
|
+
// returns a credential. No redirect is followed: a credential goes only to the URL the person gave.
|
|
7
|
+
import { createHmac } from "node:crypto";
|
|
8
|
+
import { readFileSync } from "node:fs";
|
|
9
|
+
import { join } from "node:path";
|
|
10
|
+
import { seal, unseal } from "@parcha/pi-durable-agent";
|
|
11
|
+
import { ApiError, invalid } from "./errors.js";
|
|
12
|
+
import { writeDurableSync } from "./files.js";
|
|
13
|
+
import { SEAL_KEY_ENV, sealKeyOf } from "./tool-keys.js";
|
|
14
|
+
import { isObject, unknownFields } from "./validate.js";
|
|
15
|
+
export const MCP_SERVERS_FILE = "mcp-servers.json";
|
|
16
|
+
const FORMAT = "mcp-servers/1";
|
|
17
|
+
export const MCP_SERVER_NAME = /^[a-z][a-z0-9-]{0,31}$/;
|
|
18
|
+
export const MCP_AUTH_TYPES = ["none", "bearer", "headers"];
|
|
19
|
+
const REQUEST_MS = 15_000;
|
|
20
|
+
const PREVIEW_MS = 30_000;
|
|
21
|
+
const MAX_RESPONSE_BYTES = 4 * 2 ** 20;
|
|
22
|
+
const MAX_URL = 2048;
|
|
23
|
+
const MAX_VALUE_BYTES = 8192;
|
|
24
|
+
const MAX_HEADERS = 8;
|
|
25
|
+
/** What one server's snapshot may hold: every list and get reads it back whole. */
|
|
26
|
+
const MAX_TOOLS = 500;
|
|
27
|
+
const MAX_SNAPSHOT_BYTES = 2 ** 20;
|
|
28
|
+
const MAX_PAGES = 64;
|
|
29
|
+
const CONTROL = /[\u0000-\u001f\u007f-\u009f]/;
|
|
30
|
+
const HEADER_NAME = /^[A-Za-z0-9!#$%&'*+.^_`|~-]{1,64}$/;
|
|
31
|
+
/** Headers the transport sets itself, or that name the connection rather than the person. */
|
|
32
|
+
const RESERVED = new Set(["accept", "connection", "content-length", "content-type", "host", "last-event-id", "mcp-method", "mcp-name", "mcp-protocol-version", "mcp-session-id", "transfer-encoding"]);
|
|
33
|
+
const LOOPBACK_V4 = /^127(?:[.]\d{1,3}){3}$/;
|
|
34
|
+
const LOOPBACK_NAMES = ["localhost", "[::1]"]; // key-gate: loopback-rule plain http is allowed only to these hosts
|
|
35
|
+
const LOOPBACK = (host) => LOOPBACK_NAMES.includes(host) || LOOPBACK_V4.test(host);
|
|
36
|
+
export class McpServers {
|
|
37
|
+
version;
|
|
38
|
+
file;
|
|
39
|
+
key;
|
|
40
|
+
sealCheck;
|
|
41
|
+
constructor(data, env, version) {
|
|
42
|
+
this.version = version;
|
|
43
|
+
this.file = join(data, MCP_SERVERS_FILE);
|
|
44
|
+
this.key = sealKeyOf(env[SEAL_KEY_ENV]);
|
|
45
|
+
this.sealCheck = this.key && createHmac("sha256", this.key).update(`agentrun-serve ${FORMAT} key check`).digest("base64url");
|
|
46
|
+
}
|
|
47
|
+
get atRest() {
|
|
48
|
+
return this.key ? "sealed" : "unavailable";
|
|
49
|
+
}
|
|
50
|
+
list() {
|
|
51
|
+
const servers = this.kept();
|
|
52
|
+
if (servers === "unreadable")
|
|
53
|
+
return { servers: [], file_unreadable: true };
|
|
54
|
+
return { servers: Object.keys(servers).sort().map((name) => this.view(name, servers[name])) };
|
|
55
|
+
}
|
|
56
|
+
get(name) {
|
|
57
|
+
return this.view(name, this.need(name));
|
|
58
|
+
}
|
|
59
|
+
/** POST preview: `{url, auth}`, or `{name}` for a saved server with its sealed credential. Stores nothing. */
|
|
60
|
+
async preview(body, stop) {
|
|
61
|
+
if (body.name !== undefined && body.url === undefined) {
|
|
62
|
+
const issues = unknownFields(body, ["name"]);
|
|
63
|
+
if (issues.length)
|
|
64
|
+
throw invalid(issues);
|
|
65
|
+
const name = String(body.name);
|
|
66
|
+
const kept = this.need(name);
|
|
67
|
+
return listServer(new URL(kept.url), this.opened(name, kept, "name"), this.version, stop);
|
|
68
|
+
}
|
|
69
|
+
const { url, auth } = this.admit(body);
|
|
70
|
+
if (auth.type !== "none" && !auth.headers)
|
|
71
|
+
throw invalid([credentialMissing(auth.type, "A preview needs the credential it is to connect with.")]);
|
|
72
|
+
return listServer(url, auth.headers ?? {}, this.version, stop);
|
|
73
|
+
}
|
|
74
|
+
/** PUT: preview, then keep the server with the tools listed. A body with no credential keeps the sealed one, while
|
|
75
|
+
* the auth type and the URL's origin stay the same. */
|
|
76
|
+
async save(name, body, stop) {
|
|
77
|
+
if (!MCP_SERVER_NAME.test(name))
|
|
78
|
+
throw invalid([{ field: "name", reason: "invalid", message: "A server's name is 1 to 32 lowercase letters, digits and dashes, starting with a letter (no underscores, so mcp__<server>__<tool> splits one way)." }]);
|
|
79
|
+
const { url, auth } = this.admit(body);
|
|
80
|
+
if (auth.type !== "none" && !this.key)
|
|
81
|
+
throw new ApiError("no_sealing_key", `This server was handed no seal key (${SEAL_KEY_ENV}), so it keeps no MCP server credential: it never keeps one in the clear.`);
|
|
82
|
+
const was = this.servers()[name];
|
|
83
|
+
let headers = auth.headers;
|
|
84
|
+
if (auth.type !== "none" && !headers) {
|
|
85
|
+
if (!was || was.auth.type !== auth.type)
|
|
86
|
+
throw invalid([credentialMissing(auth.type, `The server ${name} has no saved ${auth.type} credential to keep.`)]);
|
|
87
|
+
if (new URL(was.url).origin !== url.origin)
|
|
88
|
+
throw invalid([credentialMissing(auth.type, `The address moved from ${new URL(was.url).origin} to ${url.origin}: send the credential again, so a saved one never goes to another origin.`)]);
|
|
89
|
+
headers = this.opened(name, was, auth.type === "bearer" ? "auth.token" : "auth.headers");
|
|
90
|
+
}
|
|
91
|
+
const listed = await listServer(url, headers ?? {}, this.version, stop);
|
|
92
|
+
const now = new Date().toISOString();
|
|
93
|
+
const sealed = headers && Object.fromEntries(Object.entries(headers).map(([header, value]) => [header, seal(this.key, Buffer.from(value, "utf8"), aad(name, header)).toString("base64")]));
|
|
94
|
+
const servers = this.servers();
|
|
95
|
+
servers[name] = { url: url.href, auth: { type: auth.type, ...(sealed ? { sealed, check: this.sealCheck } : {}) }, ...listed, listed_at: now, updated_at: now };
|
|
96
|
+
this.write(servers);
|
|
97
|
+
return this.view(name, servers[name]);
|
|
98
|
+
}
|
|
99
|
+
/** POST refresh: list the saved server's tools again, keep them, and say what was added, removed and changed. */
|
|
100
|
+
async refresh(name, stop) {
|
|
101
|
+
const was = this.need(name);
|
|
102
|
+
const listed = await listServer(new URL(was.url), this.opened(name, was, "name"), this.version, stop);
|
|
103
|
+
const servers = this.servers();
|
|
104
|
+
const now = servers[name];
|
|
105
|
+
if (!now)
|
|
106
|
+
throw notFound(name);
|
|
107
|
+
// A PUT while listing (another URL, another account's credential) makes this listing stale: never kept.
|
|
108
|
+
if (canonical([now.url, now.auth, now.updated_at]) !== canonical([was.url, was.auth, was.updated_at]))
|
|
109
|
+
throw new ApiError("unavailable", `The server ${name} was changed while its tools were listed: refresh it again.`);
|
|
110
|
+
const before = new Map(now.tools.map((tool) => [tool.name, canonical(tool)]));
|
|
111
|
+
const after = new Map(listed.tools.map((tool) => [tool.name, canonical(tool)]));
|
|
112
|
+
servers[name] = { ...now, ...listed, listed_at: new Date().toISOString() };
|
|
113
|
+
this.write(servers);
|
|
114
|
+
return {
|
|
115
|
+
added: [...after.keys()].filter((tool) => !before.has(tool)),
|
|
116
|
+
removed: [...before.keys()].filter((tool) => !after.has(tool)),
|
|
117
|
+
changed: [...after.keys()].filter((tool) => before.has(tool) && before.get(tool) !== after.get(tool)),
|
|
118
|
+
server: this.view(name, servers[name]),
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
remove(name) {
|
|
122
|
+
const servers = this.servers();
|
|
123
|
+
if (!servers[name])
|
|
124
|
+
throw notFound(name);
|
|
125
|
+
delete servers[name];
|
|
126
|
+
this.write(servers);
|
|
127
|
+
}
|
|
128
|
+
need(name) {
|
|
129
|
+
const kept = this.servers()[name];
|
|
130
|
+
if (!kept)
|
|
131
|
+
throw notFound(name);
|
|
132
|
+
return kept;
|
|
133
|
+
}
|
|
134
|
+
view(name, kept) {
|
|
135
|
+
const { auth, ...rest } = kept;
|
|
136
|
+
const opened = auth.type === "none" ? null : this.open(name, kept);
|
|
137
|
+
return {
|
|
138
|
+
name,
|
|
139
|
+
...rest,
|
|
140
|
+
auth: { type: auth.type, ...(auth.type === "headers" ? { headers: Object.keys(auth.sealed ?? {}) } : {}) },
|
|
141
|
+
credential: opened === null ? null : "headers" in opened ? "sealed" : opened.unreadable,
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
open(name, kept) {
|
|
145
|
+
if (!this.key)
|
|
146
|
+
return { unreadable: "seal_key_missing" };
|
|
147
|
+
if (kept.auth.check !== this.sealCheck || !isObject(kept.auth.sealed))
|
|
148
|
+
return { unreadable: "unreadable" };
|
|
149
|
+
try {
|
|
150
|
+
return { headers: Object.fromEntries(Object.entries(kept.auth.sealed).map(([header, value]) => [header, unseal(this.key, Buffer.from(value, "base64"), aad(name, header)).toString("utf8")])) };
|
|
151
|
+
}
|
|
152
|
+
catch {
|
|
153
|
+
return { unreadable: "unreadable" };
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
/** The saved credential, opened, or the refusal that asks for it again. */
|
|
157
|
+
opened(name, kept, field) {
|
|
158
|
+
if (kept.auth.type === "none")
|
|
159
|
+
return {};
|
|
160
|
+
const opened = this.open(name, kept);
|
|
161
|
+
if ("headers" in opened)
|
|
162
|
+
return opened.headers;
|
|
163
|
+
if (opened.unreadable === "seal_key_missing")
|
|
164
|
+
throw new ApiError("no_sealing_key", `This server was handed no seal key (${SEAL_KEY_ENV}), so the saved credential of ${name} does not open.`);
|
|
165
|
+
throw invalid([{ field, reason: "missing", message: `The saved credential of ${name} does not open here (sealed under another seal key, or damaged): send it again.` }]);
|
|
166
|
+
}
|
|
167
|
+
/** A body's URL and auth, or 422. */
|
|
168
|
+
admit(body) {
|
|
169
|
+
const issues = unknownFields(body, ["url", "auth"]);
|
|
170
|
+
const url = urlOf(body.url, issues);
|
|
171
|
+
const auth = authOf(body.auth, issues);
|
|
172
|
+
if (issues.length)
|
|
173
|
+
throw invalid(issues);
|
|
174
|
+
return { url: url, auth: auth };
|
|
175
|
+
}
|
|
176
|
+
/** The saved servers: none with no file, "unreadable" when the file does not read as this format. */
|
|
177
|
+
kept() {
|
|
178
|
+
try {
|
|
179
|
+
const doc = JSON.parse(readFileSync(this.file, "utf8"));
|
|
180
|
+
return isObject(doc) && doc.format === FORMAT && isObject(doc.servers) ? Object.assign(Object.create(null), doc.servers) : "unreadable";
|
|
181
|
+
}
|
|
182
|
+
catch (error) {
|
|
183
|
+
return error.code === "ENOENT" ? Object.create(null) : "unreadable";
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
/** The saved servers, or 409: a file that does not read is never written over, so no saved server is lost to it. */
|
|
187
|
+
servers() {
|
|
188
|
+
const kept = this.kept();
|
|
189
|
+
if (kept === "unreadable")
|
|
190
|
+
throw new ApiError("store_unreadable", `${MCP_SERVERS_FILE} in the data directory does not read as ${FORMAT}: nothing is read from it or written to it until it is restored or removed.`);
|
|
191
|
+
return kept;
|
|
192
|
+
}
|
|
193
|
+
write(servers) {
|
|
194
|
+
writeDurableSync(this.file, `${JSON.stringify({ format: FORMAT, servers }, null, 2)}\n`);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
const aad = (name, header) => `mcp:${name}:${header}`;
|
|
198
|
+
/** `text` with every credential value cut out: each header's value, and a bearer's token alone, which a server may
|
|
199
|
+
* echo without its scheme. */
|
|
200
|
+
const scrub = (text, headers) => Object.values(headers).flatMap((value) => [value, /^Bearer\s+(.+)$/i.exec(value)?.[1]]).filter((value) => !!value).sort((a, b) => b.length - a.length).reduce((cut, value) => cut.split(value).join("[credential]"), text);
|
|
201
|
+
const notFound = (name) => new ApiError("not_found", `No MCP server ${name}: GET /v2/settings/mcp-servers lists them.`);
|
|
202
|
+
const credentialMissing = (type, message) => ({ field: type === "bearer" ? "auth.token" : "auth.headers", reason: "missing", message });
|
|
203
|
+
/** JSON with sorted keys, so two listings of one tool compare equal whatever order the server sends its fields in. */
|
|
204
|
+
const canonical = (value) => Array.isArray(value) ? `[${value.map(canonical).join(",")}]`
|
|
205
|
+
: isObject(value) ? `{${Object.keys(value).sort().map((key) => `${JSON.stringify(key)}:${canonical(value[key])}`).join(",")}}`
|
|
206
|
+
: JSON.stringify(value) ?? "null";
|
|
207
|
+
function urlOf(value, issues) {
|
|
208
|
+
if (typeof value !== "string" || value === "")
|
|
209
|
+
return void issues.push({ field: "url", reason: value === undefined ? "missing" : "wrong_type", message: "url is the MCP server's Streamable HTTP endpoint, as text." });
|
|
210
|
+
let url;
|
|
211
|
+
try {
|
|
212
|
+
url = new URL(value);
|
|
213
|
+
}
|
|
214
|
+
catch {
|
|
215
|
+
return void issues.push({ field: "url", reason: "invalid", message: "url is not a URL." });
|
|
216
|
+
}
|
|
217
|
+
if (value.length > MAX_URL)
|
|
218
|
+
issues.push({ field: "url", reason: "too_long", message: `url is at most ${MAX_URL} characters.` });
|
|
219
|
+
else if (url.username || url.password)
|
|
220
|
+
issues.push({ field: "url", reason: "invalid", message: "url holds a user or password: send a credential as auth instead." });
|
|
221
|
+
else if (url.protocol === "http:" && !LOOPBACK(url.hostname))
|
|
222
|
+
issues.push({ field: "url", reason: "not_https", message: "url is https, or http on this machine's loopback." });
|
|
223
|
+
else if (url.protocol !== "https:" && url.protocol !== "http:")
|
|
224
|
+
issues.push({ field: "url", reason: "invalid", message: "url is https, or http on loopback." });
|
|
225
|
+
url.hash = "";
|
|
226
|
+
return url;
|
|
227
|
+
}
|
|
228
|
+
/** The body's auth: its type and, when it sends one, its credential as the headers it becomes. */
|
|
229
|
+
function authOf(value, issues) {
|
|
230
|
+
if (value === undefined)
|
|
231
|
+
return { type: "none" };
|
|
232
|
+
if (!isObject(value))
|
|
233
|
+
return void issues.push({ field: "auth", reason: "wrong_type", message: "auth is {type: none|bearer|headers, token?, headers?}." });
|
|
234
|
+
const before = issues.length;
|
|
235
|
+
issues.push(...unknownFields(value, ["type", "token", "headers"]).map((issue) => ({ ...issue, field: `auth.${issue.field}` })));
|
|
236
|
+
const type = value.type;
|
|
237
|
+
if (type === "oauth")
|
|
238
|
+
return void issues.push({ field: "auth.type", reason: "not_yet", message: "OAuth sign-in to an MCP server is not here yet: use a bearer token or named headers the server accepts." });
|
|
239
|
+
if (!MCP_AUTH_TYPES.includes(type))
|
|
240
|
+
return void issues.push({ field: "auth.type", reason: "not_an_option", message: `auth.type is one of ${MCP_AUTH_TYPES.join(", ")}.` });
|
|
241
|
+
const check = (field, text) => {
|
|
242
|
+
if (typeof text !== "string" || text === "")
|
|
243
|
+
issues.push({ field, reason: "wrong_type", message: `${field} is text, not empty.` });
|
|
244
|
+
else if (CONTROL.test(text))
|
|
245
|
+
issues.push({ field, reason: "invalid", message: `${field} holds a control character.` });
|
|
246
|
+
else if (Buffer.byteLength(text) > MAX_VALUE_BYTES)
|
|
247
|
+
issues.push({ field, reason: "too_long", message: `${field} is at most ${MAX_VALUE_BYTES} bytes.` });
|
|
248
|
+
};
|
|
249
|
+
let headers;
|
|
250
|
+
if (type === "none" && (value.token !== undefined || value.headers !== undefined))
|
|
251
|
+
issues.push({ field: "auth", reason: "not_allowed", message: "auth.type none sends no credential." });
|
|
252
|
+
if (type === "bearer") {
|
|
253
|
+
if (value.headers !== undefined)
|
|
254
|
+
issues.push({ field: "auth.headers", reason: "not_allowed", message: "A bearer credential is auth.token." });
|
|
255
|
+
if (value.token !== undefined) {
|
|
256
|
+
check("auth.token", value.token);
|
|
257
|
+
headers = { authorization: `Bearer ${String(value.token)}` };
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
if (type === "headers") {
|
|
261
|
+
if (value.token !== undefined)
|
|
262
|
+
issues.push({ field: "auth.token", reason: "not_allowed", message: "Named headers are auth.headers." });
|
|
263
|
+
if (value.headers !== undefined) {
|
|
264
|
+
const entries = isObject(value.headers) ? Object.entries(value.headers) : [];
|
|
265
|
+
if (!entries.length || entries.length > MAX_HEADERS)
|
|
266
|
+
issues.push({ field: "auth.headers", reason: "invalid", message: `auth.headers names 1 to ${MAX_HEADERS} headers and their values.` });
|
|
267
|
+
headers = Object.create(null);
|
|
268
|
+
for (const [name, text] of entries) {
|
|
269
|
+
const lower = name.toLowerCase();
|
|
270
|
+
if (!HEADER_NAME.test(name) || RESERVED.has(lower))
|
|
271
|
+
issues.push({ field: `auth.headers.${name}`, reason: "invalid", message: `${name} is not a header a credential may be sent in.` });
|
|
272
|
+
else if (lower in headers)
|
|
273
|
+
issues.push({ field: `auth.headers.${name}`, reason: "duplicate", message: `${name} is named twice.` });
|
|
274
|
+
check(`auth.headers.${name}`, text);
|
|
275
|
+
headers[lower] = String(text);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
return issues.length > before ? undefined : { type: type, ...(headers ? { headers } : {}) };
|
|
280
|
+
}
|
|
281
|
+
/** Connect to `url`, agree a protocol revision, and list every tool (all pages), each request held to REQUEST_MS and
|
|
282
|
+
* MAX_RESPONSE_BYTES and the whole to PREVIEW_MS. A failure is an ApiError: 422 auth_required (with the auth the
|
|
283
|
+
* server asks for), 422 not_mcp, 422 input_invalid for a redirect, else 424 upstream_failed. */
|
|
284
|
+
async function listServer(url, headers, version, stop) {
|
|
285
|
+
const sdk = await import("@modelcontextprotocol/client");
|
|
286
|
+
const deadline = AbortSignal.any([AbortSignal.timeout(PREVIEW_MS), ...(stop ? [stop] : [])]);
|
|
287
|
+
const seen = [];
|
|
288
|
+
let overflow = false;
|
|
289
|
+
const watched = async (input, init) => {
|
|
290
|
+
const signal = AbortSignal.any([deadline, AbortSignal.timeout(REQUEST_MS), ...(init?.signal ? [init.signal] : [])]);
|
|
291
|
+
const res = await fetch(input, { ...init, redirect: "manual", signal });
|
|
292
|
+
const type = res.headers.get("content-type") ?? "";
|
|
293
|
+
seen.push({ status: res.status, headers: res.headers, rpc: type.startsWith("text/event-stream") ? Promise.resolve(true) : type.includes("json") ? speaksJsonRpc(res.clone()) : Promise.resolve(false) });
|
|
294
|
+
return capped(res, () => (overflow = true));
|
|
295
|
+
};
|
|
296
|
+
const transport = new sdk.StreamableHTTPClientTransport(url, { fetch: watched, requestInit: { headers, redirect: "manual" } });
|
|
297
|
+
const client = new sdk.Client({ name: "agentrun-serve", version }, { versionNegotiation: { mode: "auto" } });
|
|
298
|
+
try {
|
|
299
|
+
await client.connect(transport, { timeout: REQUEST_MS, signal: deadline });
|
|
300
|
+
// Paged here rather than by listTools(), which reads every page before answering: a snapshot past its caps
|
|
301
|
+
// stops at the page that crosses them.
|
|
302
|
+
const tools = [];
|
|
303
|
+
let bytes = 0;
|
|
304
|
+
if (client.getServerCapabilities()?.tools) {
|
|
305
|
+
for (let cursor, pages = 0;;) {
|
|
306
|
+
const page = await client.request({ method: "tools/list", ...(cursor !== undefined ? { params: { cursor } } : {}) }, { timeout: PREVIEW_MS, signal: deadline });
|
|
307
|
+
for (const tool of page.tools) {
|
|
308
|
+
const kept = {
|
|
309
|
+
name: tool.name,
|
|
310
|
+
...(tool.title ? { title: tool.title } : {}),
|
|
311
|
+
...(tool.description !== undefined ? { description: tool.description } : {}),
|
|
312
|
+
input_schema: tool.inputSchema,
|
|
313
|
+
...(tool.outputSchema ? { output_schema: tool.outputSchema } : {}),
|
|
314
|
+
...(tool.annotations ? { annotations: tool.annotations } : {}),
|
|
315
|
+
};
|
|
316
|
+
tools.push(kept);
|
|
317
|
+
bytes += Buffer.byteLength(JSON.stringify(kept));
|
|
318
|
+
if (tools.length > MAX_TOOLS)
|
|
319
|
+
throw invalid([{ field: "url", reason: "too_many_tools", message: `This server lists more than ${MAX_TOOLS} tools (${tools.length} so far, listing stopped): a server is kept with at most ${MAX_TOOLS}.` }]);
|
|
320
|
+
if (bytes > MAX_SNAPSHOT_BYTES)
|
|
321
|
+
throw invalid([{ field: "url", reason: "tools_too_large", message: `This server's tools come to more than ${MAX_SNAPSHOT_BYTES / 2 ** 20} MiB of names, descriptions and schemas (${tools.length} tools so far, listing stopped): a server is kept with at most ${MAX_SNAPSHOT_BYTES / 2 ** 20} MiB.` }]);
|
|
322
|
+
}
|
|
323
|
+
if (page.nextCursor === undefined || page.nextCursor === cursor)
|
|
324
|
+
break;
|
|
325
|
+
if (++pages >= MAX_PAGES)
|
|
326
|
+
throw new ApiError("upstream_failed", `The MCP server's tool list did not end within ${MAX_PAGES} pages.`);
|
|
327
|
+
cursor = page.nextCursor;
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
const instructions = client.getInstructions();
|
|
331
|
+
return {
|
|
332
|
+
protocol: client.getNegotiatedProtocolVersion() ?? "unknown",
|
|
333
|
+
server_info: client.getServerVersion() ?? null,
|
|
334
|
+
...(instructions ? { instructions } : {}),
|
|
335
|
+
tools,
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
catch (error) {
|
|
339
|
+
if (error instanceof ApiError)
|
|
340
|
+
throw error;
|
|
341
|
+
throw await refusal(error, seen, overflow, url, headers, deadline, sdk);
|
|
342
|
+
}
|
|
343
|
+
finally {
|
|
344
|
+
await client.close().catch(() => { });
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
async function refusal(error, seen, overflow, url, headers, deadline, sdk) {
|
|
348
|
+
const upstream = (message, status) => new ApiError("upstream_failed", message, status ? { details: { status } } : {});
|
|
349
|
+
if (overflow)
|
|
350
|
+
return upstream(`The MCP server answered more than ${MAX_RESPONSE_BYTES / 2 ** 20} MiB in one response.`);
|
|
351
|
+
const redirect = seen.find((one) => one.status >= 300 && one.status < 400);
|
|
352
|
+
if (redirect) {
|
|
353
|
+
const to = redirect.headers.get("location");
|
|
354
|
+
let where = to?.slice(0, 200);
|
|
355
|
+
try {
|
|
356
|
+
if (to)
|
|
357
|
+
where = new URL(to, url).href;
|
|
358
|
+
}
|
|
359
|
+
catch { }
|
|
360
|
+
return invalid([{ field: "url", reason: "redirect", message: scrub(`The MCP server answered ${redirect.status}${where ? `, pointing to ${where}` : ""}. Redirects are not followed, so a credential goes only where you send it: use the address it points to.`, headers) }]);
|
|
361
|
+
}
|
|
362
|
+
const denied = seen.find((one) => one.status === 401 || one.status === 403);
|
|
363
|
+
if (denied) {
|
|
364
|
+
const auth = await authAsked(url, denied.headers, deadline, sdk);
|
|
365
|
+
const sent = Object.keys(headers).length > 0;
|
|
366
|
+
const asks = auth === "oauth" ? "It signs in with OAuth, which is not here yet; a bearer token or headers it accepts work." : "Send a bearer token or the headers it takes.";
|
|
367
|
+
return new ApiError("auth_required", `The MCP server ${sent ? "refused the credential sent" : "asks for a credential"} (HTTP ${denied.status}). ${asks}`, { details: { auth, status: denied.status } });
|
|
368
|
+
}
|
|
369
|
+
const failed = seen.find((one) => one.status >= 500);
|
|
370
|
+
if (failed)
|
|
371
|
+
return upstream(`The MCP server answered HTTP ${failed.status}.`, failed.status);
|
|
372
|
+
if (!seen.length) {
|
|
373
|
+
if (deadline.aborted || timedOut(error))
|
|
374
|
+
return upstream(`The MCP server did not answer within ${REQUEST_MS / 1000} s.`);
|
|
375
|
+
return upstream(`Could not reach the MCP server at ${url.origin}${causeCode(error) ? ` (${causeCode(error)})` : ""}.`);
|
|
376
|
+
}
|
|
377
|
+
if (!(await Promise.all(seen.map((one) => one.rpc))).some(Boolean))
|
|
378
|
+
return new ApiError("not_mcp", `${url.href} does not speak MCP over Streamable HTTP: it answered HTTP ${seen.at(-1).status} with no JSON-RPC reply.`);
|
|
379
|
+
// The listing's own limit when it was the one that ran out, else one request's.
|
|
380
|
+
if (deadline.aborted || timedOut(error))
|
|
381
|
+
return upstream(deadline.aborted ? `The MCP server did not finish listing its tools within ${PREVIEW_MS / 1000} s.` : `The MCP server did not answer a request within ${REQUEST_MS / 1000} s.`);
|
|
382
|
+
// Cut every credential value from the SDK's words: a server may echo what it was sent.
|
|
383
|
+
const said = scrub(error instanceof Error ? error.message : String(error), headers);
|
|
384
|
+
return upstream(`The MCP server failed to list its tools: ${said.slice(0, 300)}`);
|
|
385
|
+
}
|
|
386
|
+
/** What a 401 or 403 asks for: `oauth` when the server names protected-resource metadata (its WWW-Authenticate, or a
|
|
387
|
+
* well-known document naming an authorization server), else `bearer`. The probe sends no credential. */
|
|
388
|
+
async function authAsked(url, headers, deadline, sdk) {
|
|
389
|
+
if (sdk.extractWWWAuthenticateParams(new Response(null, { headers })).resourceMetadataUrl)
|
|
390
|
+
return "oauth";
|
|
391
|
+
try {
|
|
392
|
+
const probe = async (input, init) => capped(await fetch(input, { ...init, redirect: "manual", signal: AbortSignal.any([deadline, AbortSignal.timeout(5_000)]) }), () => { });
|
|
393
|
+
const metadata = await sdk.discoverOAuthProtectedResourceMetadata(url, undefined, probe);
|
|
394
|
+
return metadata.authorization_servers?.length ? "oauth" : "bearer";
|
|
395
|
+
}
|
|
396
|
+
catch {
|
|
397
|
+
return "bearer";
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
/** Whether a JSON body is a JSON-RPC message, read no further than its first 64 KiB. */
|
|
401
|
+
async function speaksJsonRpc(res) {
|
|
402
|
+
try {
|
|
403
|
+
const reader = res.body?.getReader();
|
|
404
|
+
if (!reader)
|
|
405
|
+
return false;
|
|
406
|
+
let text = "";
|
|
407
|
+
for (let chunk = await reader.read(); !chunk.done && text.length < 65_536; chunk = await reader.read())
|
|
408
|
+
text += Buffer.from(chunk.value).toString("utf8");
|
|
409
|
+
await reader.cancel().catch(() => { });
|
|
410
|
+
return /"jsonrpc"\s*:\s*"2\.0"/.test(text);
|
|
411
|
+
}
|
|
412
|
+
catch {
|
|
413
|
+
return false;
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
/** `res` with its body cut off at MAX_RESPONSE_BYTES, `over` told when it is. */
|
|
417
|
+
function capped(res, over) {
|
|
418
|
+
if (!res.body || [101, 204, 205, 304].includes(res.status))
|
|
419
|
+
return res;
|
|
420
|
+
let bytes = 0;
|
|
421
|
+
const body = res.body.pipeThrough(new TransformStream({
|
|
422
|
+
transform(chunk, out) {
|
|
423
|
+
bytes += chunk.byteLength;
|
|
424
|
+
if (bytes > MAX_RESPONSE_BYTES) {
|
|
425
|
+
over();
|
|
426
|
+
out.error(new Error(`response over ${MAX_RESPONSE_BYTES} bytes`));
|
|
427
|
+
}
|
|
428
|
+
else
|
|
429
|
+
out.enqueue(chunk);
|
|
430
|
+
},
|
|
431
|
+
}));
|
|
432
|
+
return new Response(body, { status: res.status, statusText: res.statusText, headers: res.headers });
|
|
433
|
+
}
|
|
434
|
+
const timedOut = (error) => {
|
|
435
|
+
for (let at = error; at instanceof Error; at = at.cause)
|
|
436
|
+
if (at.name === "TimeoutError" || at.name === "AbortError" || /timed? ?out/i.test(at.message))
|
|
437
|
+
return true;
|
|
438
|
+
return false;
|
|
439
|
+
};
|
|
440
|
+
const causeCode = (error) => {
|
|
441
|
+
for (let at = error; isObject(at); at = at.cause)
|
|
442
|
+
if (typeof at.code === "string" && /^E[A-Z]+$/.test(at.code))
|
|
443
|
+
return at.code;
|
|
444
|
+
return undefined;
|
|
445
|
+
};
|
package/dist/mcp.d.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { IncomingMessage, ServerResponse } from "node:http";
|
|
2
|
+
import { type Json } from "./validate.js";
|
|
3
|
+
export declare const MCP_PATH = "/v2/mcp";
|
|
4
|
+
/** The protocol versions this endpoint speaks, newest first. `initialize` answers the client's when it is one of them,
|
|
5
|
+
* else the newest, as the protocol's negotiation says. */
|
|
6
|
+
export declare const PROTOCOL_VERSIONS: string[];
|
|
7
|
+
/** The most of a file `runs_files` returns as text: a client's tool output is short (Claude Code's is about 25k tokens). */
|
|
8
|
+
export declare const MAX_TEXT: number;
|
|
9
|
+
/** A route of this server: server.ts's `route`, which throws ApiError for a refusal. */
|
|
10
|
+
export type Route = (req: IncomingMessage, res: ServerResponse, url: URL, path: string) => Promise<void>;
|
|
11
|
+
type Call = {
|
|
12
|
+
method: "GET" | "POST" | "PUT";
|
|
13
|
+
path: string;
|
|
14
|
+
query?: Json;
|
|
15
|
+
body?: Json;
|
|
16
|
+
headers?: Record<string, string>;
|
|
17
|
+
};
|
|
18
|
+
/** A route's answer as it would have gone out. `tooBig`: cut off at the limit, `bytes` holding what came before. */
|
|
19
|
+
type Answered = {
|
|
20
|
+
status: number;
|
|
21
|
+
headers: Record<string, string>;
|
|
22
|
+
bytes: Buffer;
|
|
23
|
+
tooBig: boolean;
|
|
24
|
+
};
|
|
25
|
+
type Context = {
|
|
26
|
+
call: (call: Call, limit?: number) => Promise<Answered>;
|
|
27
|
+
origin: string;
|
|
28
|
+
version: string;
|
|
29
|
+
requestId: string;
|
|
30
|
+
};
|
|
31
|
+
type Tool = {
|
|
32
|
+
name: string;
|
|
33
|
+
title: string;
|
|
34
|
+
description: string;
|
|
35
|
+
inputSchema: Json;
|
|
36
|
+
annotations: Json;
|
|
37
|
+
run: (args: Json, context: Context) => Promise<Json>;
|
|
38
|
+
};
|
|
39
|
+
/** Each tool, by the /v2 routes it calls. Field names are the routes'. */
|
|
40
|
+
export declare const TOOLS: Tool[];
|
|
41
|
+
/** GET /llms.txt: what this server is, for a coding agent, without a credential. The text is the repository's
|
|
42
|
+
* `src/llms.txt`, copied beside the server by the build; it holds no data of this server's. */
|
|
43
|
+
export declare function answerLlms(req: IncomingMessage, res: ServerResponse): Promise<void>;
|
|
44
|
+
/** The endpoint: `route` serves each tool, `authorized` checks an Authorization header against the token. */
|
|
45
|
+
export declare function mcpEndpoint({ route, authorized, authFailed, version }: {
|
|
46
|
+
route: Route;
|
|
47
|
+
authorized: (header: string) => boolean;
|
|
48
|
+
authFailed: (route: string, reason: string) => void;
|
|
49
|
+
version: string;
|
|
50
|
+
}): (req: IncomingMessage, res: ServerResponse) => Promise<void>;
|
|
51
|
+
export {};
|