@b3os/mcp 0.0.1 → 0.1.3
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 +129 -43
- package/bin/b3os-mcp.js +14 -3
- package/dist/compact.d.ts +27 -0
- package/dist/compact.js +138 -0
- package/dist/compact.js.map +1 -0
- package/dist/handlers/_common.d.ts +150 -0
- package/dist/handlers/_common.js +329 -0
- package/dist/handlers/_common.js.map +1 -0
- package/dist/handlers/actions.d.ts +19 -0
- package/dist/handlers/actions.js +110 -0
- package/dist/handlers/actions.js.map +1 -0
- package/dist/handlers/render.d.ts +7 -0
- package/dist/handlers/render.js +72 -0
- package/dist/handlers/render.js.map +1 -0
- package/dist/handlers/routines.d.ts +20 -0
- package/dist/handlers/routines.js +128 -0
- package/dist/handlers/routines.js.map +1 -0
- package/dist/handlers/sandboxes.d.ts +2 -0
- package/dist/handlers/sandboxes.js +100 -0
- package/dist/handlers/sandboxes.js.map +1 -0
- package/dist/handlers/vision.d.ts +7 -0
- package/dist/handlers/vision.js +186 -0
- package/dist/handlers/vision.js.map +1 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/main.js +88 -7
- package/dist/main.js.map +1 -1
- package/dist/server.d.ts +68 -1
- package/dist/server.js +175 -18
- package/dist/server.js.map +1 -1
- package/dist/stdio.d.ts +24 -1
- package/dist/stdio.js +89 -12
- package/dist/stdio.js.map +1 -1
- package/dist/table-types.d.ts +84 -0
- package/dist/table-types.js +4 -0
- package/dist/table-types.js.map +1 -0
- package/dist/table.d.ts +54 -0
- package/dist/table.gen.d.ts +7 -0
- package/dist/table.gen.js +3755 -0
- package/dist/table.gen.js.map +1 -0
- package/dist/table.js +240 -0
- package/dist/table.js.map +1 -0
- package/dist/tools.d.ts +61 -47
- package/dist/tools.js +231 -705
- package/dist/tools.js.map +1 -1
- package/package.json +20 -10
- package/src/compact.ts +127 -0
- package/src/handlers/_common.ts +433 -0
- package/src/handlers/actions.ts +144 -0
- package/src/handlers/render.ts +90 -0
- package/src/handlers/routines.ts +152 -0
- package/src/handlers/sandboxes.ts +110 -0
- package/src/handlers/vision.ts +213 -0
- package/src/index.ts +36 -0
- package/src/main.ts +79 -7
- package/src/server.ts +225 -19
- package/src/stdio.ts +107 -10
- package/src/table-types.ts +88 -0
- package/src/table.gen.ts +3812 -0
- package/src/table.ts +304 -0
- package/src/tools.ts +310 -785
- package/table/core.mjs +73 -0
- package/table/requests.json +1151 -0
- package/table/table.json +3764 -0
- package/table/tools/actions.mjs +55 -0
- package/table/tools/infer.mjs +52 -0
- package/table/tools/platform.mjs +76 -0
- package/table/tools/render.mjs +126 -0
- package/table/tools/routines.mjs +70 -0
- package/table/tools/sandboxes.mjs +269 -0
- package/table/tools/vision.mjs +316 -0
- package/table/tools.mjs +92 -0
package/dist/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAAA,gHAAgH;AAChH,iBAAiB;AAEjB,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,QAAQ,IAAI,YAAY,EAAE,MAAM,YAAY,CAAC;AAGtD,MAAM,OAAO,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,CAAU,CAAC;AAEnE,MAAM,IAAI,GAAG,CAAC,CAAqB,EAAE,EAAE,CACrC,CAAC,CAAC,IAAI,EAAE,CAAC;KACN,KAAK,CAAC,GAAG,CAAC;KACV,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;KACpB,MAAM,CAAC,OAAO,CAAC,CAAC;AAErB,MAAM,C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
import { type PackToolFilter, type ToolDef } from "./tools.ts";
|
|
3
3
|
export declare const MODERN_VERSIONS: readonly ["2026-07-28"];
|
|
4
4
|
export declare const LEGACY_VERSIONS: readonly ["2025-11-25", "2025-06-18", "2025-03-26", "2024-11-05"];
|
|
5
5
|
export declare const SERVER_INFO: {
|
|
@@ -7,6 +7,7 @@ export declare const SERVER_INFO: {
|
|
|
7
7
|
title: string;
|
|
8
8
|
version: string;
|
|
9
9
|
};
|
|
10
|
+
/** The server-level instruction (the shared table's, the same text the edge's /mcp sends). */
|
|
10
11
|
export declare const INSTRUCTIONS: string;
|
|
11
12
|
type Id = string | number;
|
|
12
13
|
export interface JsonRpcRequest {
|
|
@@ -36,21 +37,87 @@ export interface McpServerOptions {
|
|
|
36
37
|
client: B3OS;
|
|
37
38
|
/** Packs whose actions become direct tools (`github`, `io.b3os/slack`). */
|
|
38
39
|
packs?: readonly string[];
|
|
40
|
+
/** Published routines that become direct tools `routine_<name>` (names, or `all`). */
|
|
41
|
+
routines?: readonly string[];
|
|
42
|
+
/** Opt-in toolsets of the shared table beside the core tools (`sandboxes`, `vision`, `routines`, `infer`, `platform`). */
|
|
43
|
+
toolsets?: readonly string[];
|
|
44
|
+
/**
|
|
45
|
+
* Feature flags on for the caller's organization (`x-b3os-flag`). A table tool of a preview operation is listed,
|
|
46
|
+
* and callable, only when its flag is here; by default none is (W3-0b-8).
|
|
47
|
+
*/
|
|
48
|
+
flags?: readonly string[];
|
|
39
49
|
/** Replace the tool set (tests, custom servers). */
|
|
40
50
|
tools?: readonly ToolDef[];
|
|
41
51
|
/** How long clients may cache tools/list (modern protocol). Default 5 minutes. */
|
|
42
52
|
ttlMs?: number;
|
|
53
|
+
/** Which of the packs' tools to serve (`effects`, `actions`). */
|
|
54
|
+
packFilter?: PackToolFilter;
|
|
55
|
+
/**
|
|
56
|
+
* Told about each pack that serves no tools and each pack or routine tool left out because its name is taken
|
|
57
|
+
* (the stdio server writes them to stderr). The same lines go to the client as `notifications/message`, in
|
|
58
|
+
* `tools/list` as `_meta.warnings`, and unresolved packs are named in the instructions.
|
|
59
|
+
*/
|
|
60
|
+
onWarning?: (message: string) => void;
|
|
61
|
+
/**
|
|
62
|
+
* Warnings about a `tools` set built by the caller (the edge loads pack tools itself and caches them), and the
|
|
63
|
+
* requested packs that serve nothing, for the instructions.
|
|
64
|
+
*/
|
|
65
|
+
warnings?: readonly string[];
|
|
66
|
+
unresolvedPacks?: readonly string[];
|
|
67
|
+
/**
|
|
68
|
+
* How tools/list writes input schemas (platform-dx.7, compact.ts): `compact` (the default) keeps names, types,
|
|
69
|
+
* enums, requiredness and object arguments' first sentence; `full` lists the table's schemas as they are. Calls
|
|
70
|
+
* are always checked against the full schema.
|
|
71
|
+
*/
|
|
72
|
+
detail?: "compact" | "full";
|
|
73
|
+
/** List and serve only these tools, by name (`?tools=` on /mcp, `--tools` on stdio); unknown names are warned about. */
|
|
74
|
+
only?: readonly string[];
|
|
75
|
+
/**
|
|
76
|
+
* The text of an `unauthorized` tool error, in place of the API's: what the agent should ask the user to do. The
|
|
77
|
+
* stdio server sets it (an agent cannot send an Authorization header, but the user can run `b3os login`); the
|
|
78
|
+
* edge's /mcp does not, so its errors stay the API's.
|
|
79
|
+
*/
|
|
80
|
+
authHelp?: (apiDetail: string) => string;
|
|
43
81
|
}
|
|
82
|
+
/** The instructions, plus a line naming the requested packs this session cannot serve. */
|
|
83
|
+
export declare function instructionsWith(unresolved: readonly string[]): string;
|
|
44
84
|
export declare class McpServer {
|
|
45
85
|
private readonly client;
|
|
46
86
|
private readonly packs;
|
|
87
|
+
private readonly routines;
|
|
88
|
+
private readonly toolsets;
|
|
89
|
+
private readonly flags;
|
|
90
|
+
private readonly onWarning;
|
|
91
|
+
private readonly packFilter;
|
|
92
|
+
private readonly warnings;
|
|
93
|
+
private readonly unresolved;
|
|
94
|
+
/** How many warnings went to the client as notifications/message already. */
|
|
95
|
+
private notified;
|
|
96
|
+
/** The level a legacy client set with `logging/setLevel` (none: no log notifications). */
|
|
97
|
+
private logLevel;
|
|
47
98
|
private tools;
|
|
48
99
|
private toolsLoading;
|
|
49
100
|
private readonly ttlMs;
|
|
101
|
+
private readonly detail;
|
|
102
|
+
private readonly only;
|
|
103
|
+
private onlyChecked;
|
|
104
|
+
private readonly authHelp;
|
|
50
105
|
/** The version a legacy `initialize` negotiated, for this process (stdio) or session. */
|
|
51
106
|
legacyVersion: string | undefined;
|
|
52
107
|
private readonly inflight;
|
|
53
108
|
constructor(opts: McpServerOptions);
|
|
109
|
+
/** The tools this server lists and serves: every tool, or the ones `only` names. */
|
|
110
|
+
private listed;
|
|
111
|
+
private warn;
|
|
112
|
+
/**
|
|
113
|
+
* Sends the warnings the client has not seen yet as `notifications/message` (level warning), only when the client
|
|
114
|
+
* asked for log messages at warning or below: a legacy session that set a level with `logging/setLevel`, or a
|
|
115
|
+
* request that carries `logLevel` (MCP 2026-07-28 forbids unsolicited log notifications; PD7). Otherwise the
|
|
116
|
+
* warnings reach the client only through `_meta.warnings` and the instructions (and stderr on stdio).
|
|
117
|
+
*/
|
|
118
|
+
private flushWarnings;
|
|
119
|
+
/** Whether this server can have anything to warn about (it then declares the logging capability). */
|
|
120
|
+
private get mayWarn();
|
|
54
121
|
private toolList;
|
|
55
122
|
/** Handles one message. `send` receives the response (requests only) and any notifications (progress). */
|
|
56
123
|
handle(msg: unknown, send: (m: Outgoing) => void): Promise<void>;
|
package/dist/server.js
CHANGED
|
@@ -2,17 +2,25 @@
|
|
|
2
2
|
// with `initialize`; modern ones (2026-07-28, stateless) put the protocol version in each request's `_meta`, may
|
|
3
3
|
// call `server/discover`, and get `resultType` plus cache hints on list results. Tool calls run concurrently;
|
|
4
4
|
// `notifications/cancelled` aborts one.
|
|
5
|
-
import { SDK_VERSION } from "@b3os/sdk";
|
|
6
|
-
import {
|
|
5
|
+
import { SDK_VERSION, TRACEPARENT_RE } from "@b3os/sdk";
|
|
6
|
+
import { compactSchema, detailFor } from "./compact.js";
|
|
7
|
+
import { MCP_INSTRUCTIONS } from "./table.js";
|
|
8
|
+
import { errorResult, loadPackTools, routineTools, tableTools, } from "./tools.js";
|
|
7
9
|
export const MODERN_VERSIONS = ["2026-07-28"];
|
|
8
10
|
export const LEGACY_VERSIONS = ["2025-11-25", "2025-06-18", "2025-03-26", "2024-11-05"];
|
|
9
11
|
const META_VERSION = "io.modelcontextprotocol/protocolVersion";
|
|
10
12
|
const META_SERVER_INFO = "io.modelcontextprotocol/serverInfo";
|
|
11
|
-
export const SERVER_INFO = { name: "b3os", title: "B3OS", version: "0.
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
export const SERVER_INFO = { name: "b3os", title: "B3OS", version: "0.1.3" };
|
|
14
|
+
/** MCP log levels, most verbose first (RFC 5424 severities). */
|
|
15
|
+
const LOG_LEVELS = ["debug", "info", "notice", "warning", "error", "critical", "alert", "emergency"];
|
|
16
|
+
/** The server-level instruction (the shared table's, the same text the edge's /mcp sends). */
|
|
17
|
+
export const INSTRUCTIONS = MCP_INSTRUCTIONS;
|
|
18
|
+
/** The instructions, plus a line naming the requested packs this session cannot serve. */
|
|
19
|
+
export function instructionsWith(unresolved) {
|
|
20
|
+
if (!unresolved.length)
|
|
21
|
+
return INSTRUCTIONS;
|
|
22
|
+
return `${INSTRUCTIONS}\n\nNot available in this session: the tools of ${unresolved.join(", ")} (see the warnings in tools/list). Their actions can still be found with actions_search and run with actions_call.`;
|
|
23
|
+
}
|
|
16
24
|
const ERR = {
|
|
17
25
|
parse: -32700,
|
|
18
26
|
invalidRequest: -32600,
|
|
@@ -24,25 +32,116 @@ const ERR = {
|
|
|
24
32
|
export class McpServer {
|
|
25
33
|
client;
|
|
26
34
|
packs;
|
|
35
|
+
routines;
|
|
36
|
+
toolsets;
|
|
37
|
+
flags;
|
|
38
|
+
onWarning;
|
|
39
|
+
packFilter;
|
|
40
|
+
warnings;
|
|
41
|
+
unresolved;
|
|
42
|
+
/** How many warnings went to the client as notifications/message already. */
|
|
43
|
+
notified = 0;
|
|
44
|
+
/** The level a legacy client set with `logging/setLevel` (none: no log notifications). */
|
|
45
|
+
logLevel;
|
|
27
46
|
tools;
|
|
28
47
|
toolsLoading;
|
|
29
48
|
ttlMs;
|
|
49
|
+
detail;
|
|
50
|
+
only;
|
|
51
|
+
onlyChecked = false;
|
|
52
|
+
authHelp;
|
|
30
53
|
/** The version a legacy `initialize` negotiated, for this process (stdio) or session. */
|
|
31
54
|
legacyVersion;
|
|
32
55
|
inflight = new Map();
|
|
33
56
|
constructor(opts) {
|
|
34
57
|
this.client = opts.client;
|
|
35
58
|
this.packs = opts.packs ?? [];
|
|
59
|
+
this.routines = opts.routines ?? [];
|
|
60
|
+
this.toolsets = opts.toolsets ?? [];
|
|
61
|
+
this.flags = opts.flags ?? [];
|
|
36
62
|
this.tools = opts.tools;
|
|
37
63
|
this.ttlMs = opts.ttlMs ?? 300_000;
|
|
64
|
+
this.onWarning = opts.onWarning;
|
|
65
|
+
this.packFilter = opts.packFilter ?? {};
|
|
66
|
+
this.warnings = [...(opts.warnings ?? [])];
|
|
67
|
+
this.unresolved = [...(opts.unresolvedPacks ?? [])];
|
|
68
|
+
this.detail = opts.detail ?? "compact";
|
|
69
|
+
this.only = opts.only?.length ? new Set(opts.only) : null;
|
|
70
|
+
this.authHelp = opts.authHelp;
|
|
71
|
+
}
|
|
72
|
+
/** The tools this server lists and serves: every tool, or the ones `only` names. */
|
|
73
|
+
async listed() {
|
|
74
|
+
const all = await this.toolList();
|
|
75
|
+
if (!this.only)
|
|
76
|
+
return all;
|
|
77
|
+
if (!this.onlyChecked) {
|
|
78
|
+
this.onlyChecked = true;
|
|
79
|
+
const names = new Set(all.map((t) => t.name));
|
|
80
|
+
const unknown = [...this.only].filter((n) => !names.has(n));
|
|
81
|
+
if (unknown.length)
|
|
82
|
+
this.warn(`tools= names no tool here: ${unknown.slice(0, 10).join(", ")}`);
|
|
83
|
+
}
|
|
84
|
+
return all.filter((t) => this.only?.has(t.name));
|
|
85
|
+
}
|
|
86
|
+
warn(message) {
|
|
87
|
+
this.warnings.push(message);
|
|
88
|
+
this.onWarning?.(message);
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Sends the warnings the client has not seen yet as `notifications/message` (level warning), only when the client
|
|
92
|
+
* asked for log messages at warning or below: a legacy session that set a level with `logging/setLevel`, or a
|
|
93
|
+
* request that carries `logLevel` (MCP 2026-07-28 forbids unsolicited log notifications; PD7). Otherwise the
|
|
94
|
+
* warnings reach the client only through `_meta.warnings` and the instructions (and stderr on stdio).
|
|
95
|
+
*/
|
|
96
|
+
flushWarnings(send, requestLevel) {
|
|
97
|
+
const level = typeof requestLevel === "string" ? requestLevel : this.logLevel;
|
|
98
|
+
if (!level || !LOG_LEVELS.includes(level) || LOG_LEVELS.indexOf(level) > LOG_LEVELS.indexOf("warning"))
|
|
99
|
+
return;
|
|
100
|
+
for (; this.notified < this.warnings.length; this.notified++) {
|
|
101
|
+
send({
|
|
102
|
+
jsonrpc: "2.0",
|
|
103
|
+
method: "notifications/message",
|
|
104
|
+
params: { level: "warning", logger: "b3os", data: this.warnings[this.notified] },
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
/** Whether this server can have anything to warn about (it then declares the logging capability). */
|
|
109
|
+
get mayWarn() {
|
|
110
|
+
return this.packs.length > 0 || this.routines.length > 0 || this.warnings.length > 0;
|
|
38
111
|
}
|
|
39
112
|
async toolList() {
|
|
40
113
|
if (this.tools)
|
|
41
114
|
return this.tools;
|
|
42
115
|
this.toolsLoading ??= (async () => {
|
|
43
|
-
const
|
|
44
|
-
const
|
|
45
|
-
|
|
116
|
+
const base = tableTools(this.toolsets, this.flags);
|
|
117
|
+
const [packs, routines] = await Promise.all([
|
|
118
|
+
this.packs.length ? loadPackTools(this.client, this.packs, this.packFilter) : undefined,
|
|
119
|
+
this.routines.length
|
|
120
|
+
? routineTools(this.client, this.routines).catch((e) => {
|
|
121
|
+
this.warn(`routines serve no tools: ${e?.message ?? String(e)}`);
|
|
122
|
+
return [];
|
|
123
|
+
})
|
|
124
|
+
: [],
|
|
125
|
+
]);
|
|
126
|
+
for (const w of packs?.warnings ?? [])
|
|
127
|
+
this.warn(w);
|
|
128
|
+
this.unresolved.push(...(packs?.unresolved ?? []));
|
|
129
|
+
const extra = [...(packs?.tools ?? []), ...routines];
|
|
130
|
+
const seen = new Set(base.map((t) => t.name));
|
|
131
|
+
const tools = [...base];
|
|
132
|
+
for (const t of extra) {
|
|
133
|
+
if (!seen.has(t.name)) {
|
|
134
|
+
seen.add(t.name);
|
|
135
|
+
tools.push(t);
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
// routine_<name> of a routine called run, get-run or signal is a table tool's name, and two long names can
|
|
139
|
+
// share their first 64 characters: say so instead of dropping the tool silently.
|
|
140
|
+
const src = t.source;
|
|
141
|
+
this.warn(src?.kind === "routine"
|
|
142
|
+
? `not serving routine ${src.name} as a tool: the name ${t.name} is taken; run it with routine_run (routine: "${src.name}")`
|
|
143
|
+
: `not serving ${src?.kind === "action" ? `action ${src.ref}` : t.title} as a tool: the name ${t.name} is taken; call it with actions_call`);
|
|
144
|
+
}
|
|
46
145
|
this.tools = tools;
|
|
47
146
|
return tools;
|
|
48
147
|
})();
|
|
@@ -120,43 +219,60 @@ export class McpServer {
|
|
|
120
219
|
const asked = typeof p.protocolVersion === "string" ? p.protocolVersion : undefined;
|
|
121
220
|
const version = asked && LEGACY_VERSIONS.includes(asked) ? asked : LEGACY_VERSIONS[0];
|
|
122
221
|
this.legacyVersion = version;
|
|
222
|
+
// Pack and routine tools load first, so the instructions can name the packs that serve nothing.
|
|
223
|
+
if (this.mayWarn)
|
|
224
|
+
await this.toolList();
|
|
123
225
|
return {
|
|
124
226
|
protocolVersion: version,
|
|
125
|
-
capabilities: { tools: { listChanged: false } },
|
|
227
|
+
capabilities: { tools: { listChanged: false }, ...(this.mayWarn ? { logging: {} } : {}) },
|
|
126
228
|
serverInfo: version >= "2025-06-18" ? SERVER_INFO : { name: SERVER_INFO.name, version: SERVER_INFO.version },
|
|
127
|
-
instructions:
|
|
229
|
+
instructions: instructionsWith(this.unresolved),
|
|
128
230
|
};
|
|
129
231
|
}
|
|
130
232
|
case "server/discover":
|
|
233
|
+
if (this.mayWarn)
|
|
234
|
+
await this.toolList();
|
|
131
235
|
return {
|
|
132
236
|
resultType: "complete",
|
|
133
237
|
supportedVersions: [...MODERN_VERSIONS, ...LEGACY_VERSIONS],
|
|
238
|
+
// Logging is deprecated in 2026-07-28; a modern request asks for log messages with `logLevel`.
|
|
134
239
|
capabilities: { tools: {} },
|
|
135
240
|
_meta: { [META_SERVER_INFO]: SERVER_INFO },
|
|
136
|
-
instructions:
|
|
241
|
+
instructions: instructionsWith(this.unresolved),
|
|
137
242
|
ttlMs: this.ttlMs,
|
|
138
|
-
cacheScope: "public",
|
|
243
|
+
cacheScope: this.mayWarn ? "private" : "public",
|
|
139
244
|
};
|
|
140
245
|
case "ping":
|
|
141
246
|
return {};
|
|
247
|
+
case "logging/setLevel": {
|
|
248
|
+
const level = p.level;
|
|
249
|
+
if (typeof level !== "string" || !LOG_LEVELS.includes(level))
|
|
250
|
+
throw new RpcError(ERR.invalidParams, `level must be one of ${LOG_LEVELS.join(", ")}`);
|
|
251
|
+
this.logLevel = level;
|
|
252
|
+
return {};
|
|
253
|
+
}
|
|
142
254
|
case "tools/list": {
|
|
143
|
-
const tools = await this.
|
|
255
|
+
const tools = await this.listed();
|
|
256
|
+
this.flushWarnings(send, p.logLevel ?? p._meta?.["io.modelcontextprotocol/logLevel"]);
|
|
144
257
|
const newer = modern || (this.legacyVersion ?? LEGACY_VERSIONS[0]) >= "2025-06-18";
|
|
145
258
|
return this.withMeta(modern, {
|
|
146
259
|
tools: tools.map((t) => ({
|
|
147
260
|
name: t.name,
|
|
148
261
|
...(newer ? { title: t.title } : {}),
|
|
149
262
|
description: t.description,
|
|
150
|
-
inputSchema: t.inputSchema,
|
|
151
|
-
annotations
|
|
263
|
+
inputSchema: this.detail === "full" ? t.inputSchema : compactSchema(t.inputSchema),
|
|
264
|
+
// A client that reads the tool's own title (2025-06-18 on) gets no second copy in the annotations.
|
|
265
|
+
annotations: newer && this.detail !== "full" ? withoutTitle(t.annotations) : t.annotations,
|
|
266
|
+
...(t.meta ? { _meta: t.meta } : {}),
|
|
152
267
|
})),
|
|
268
|
+
...(this.warnings.length ? { _meta: { warnings: [...this.warnings] } } : {}),
|
|
153
269
|
}, true);
|
|
154
270
|
}
|
|
155
271
|
case "tools/call": {
|
|
156
272
|
const name = p.name;
|
|
157
273
|
if (typeof name !== "string")
|
|
158
274
|
throw new RpcError(ERR.invalidParams, "tools/call needs a tool name");
|
|
159
|
-
const tool = (await this.
|
|
275
|
+
const tool = (await this.listed()).find((t) => t.name === name);
|
|
160
276
|
if (!tool)
|
|
161
277
|
throw new RpcError(ERR.invalidParams, `Unknown tool: ${name}`);
|
|
162
278
|
const args = (p.arguments ?? {});
|
|
@@ -165,10 +281,14 @@ export class McpServer {
|
|
|
165
281
|
const ac = new AbortController();
|
|
166
282
|
this.inflight.set(id, ac);
|
|
167
283
|
const token = p._meta?.progressToken;
|
|
284
|
+
// Trace context per message (PD27): it wins over the transport's (the HTTP header the edge's client carries).
|
|
285
|
+
const tp = p._meta?.traceparent;
|
|
286
|
+
const traceparent = typeof tp === "string" && TRACEPARENT_RE.test(tp.trim()) ? tp.trim() : undefined;
|
|
168
287
|
let result;
|
|
169
288
|
try {
|
|
170
289
|
result = await tool.call(this.client, args, {
|
|
171
290
|
signal: ac.signal,
|
|
291
|
+
...(traceparent ? { traceparent } : {}),
|
|
172
292
|
progress: token === undefined
|
|
173
293
|
? undefined
|
|
174
294
|
: (completed, total, message) => send({
|
|
@@ -189,6 +309,10 @@ export class McpServer {
|
|
|
189
309
|
finally {
|
|
190
310
|
this.inflight.delete(id);
|
|
191
311
|
}
|
|
312
|
+
if (result.isError && this.authHelp)
|
|
313
|
+
result = withAuthHelp(result, this.authHelp);
|
|
314
|
+
if (result.isError && this.detail !== "full")
|
|
315
|
+
result = withArgumentDetail(result, tool.inputSchema);
|
|
192
316
|
const newer = modern || (this.legacyVersion ?? LEGACY_VERSIONS[0]) >= "2025-06-18";
|
|
193
317
|
const out = { content: result.content };
|
|
194
318
|
if (result.isError)
|
|
@@ -210,6 +334,39 @@ export class McpServer {
|
|
|
210
334
|
}
|
|
211
335
|
}
|
|
212
336
|
}
|
|
337
|
+
function withoutTitle(annotations) {
|
|
338
|
+
const { title: _title, ...rest } = annotations;
|
|
339
|
+
return rest;
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* A refused call's answer from the compact listing (platform-dx.7): the full description of every argument the
|
|
343
|
+
* errors name, after the error lines, so the detail tools/list left out arrives when a call needs it.
|
|
344
|
+
*/
|
|
345
|
+
function withArgumentDetail(result, schema) {
|
|
346
|
+
const errors = result.structuredContent?.error?.errors;
|
|
347
|
+
if (!Array.isArray(errors) || !errors.length)
|
|
348
|
+
return result;
|
|
349
|
+
const lines = detailFor(schema, errors.filter((e) => typeof e?.pointer === "string"));
|
|
350
|
+
if (!lines.length)
|
|
351
|
+
return result;
|
|
352
|
+
return {
|
|
353
|
+
...result,
|
|
354
|
+
content: [...result.content, { type: "text", text: `About those arguments:\n${lines.join("\n")}` }],
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
/** An `unauthorized` tool error with the server's `authHelp` text in place of the API's detail. */
|
|
358
|
+
function withAuthHelp(result, help) {
|
|
359
|
+
const error = result.structuredContent?.error;
|
|
360
|
+
if (!error || error.code !== "unauthorized")
|
|
361
|
+
return result;
|
|
362
|
+
const detail = help(typeof error.detail === "string" ? error.detail : "");
|
|
363
|
+
const rid = typeof error.request_id === "string" && error.request_id ? `\n(request ${error.request_id})` : "";
|
|
364
|
+
return {
|
|
365
|
+
...result,
|
|
366
|
+
content: [{ type: "text", text: `unauthorized: ${detail}${rid}` }],
|
|
367
|
+
structuredContent: { ...result.structuredContent, error: { ...error, detail } },
|
|
368
|
+
};
|
|
369
|
+
}
|
|
213
370
|
class RpcError extends Error {
|
|
214
371
|
code;
|
|
215
372
|
data;
|
package/dist/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,iHAAiH;AACjH,iHAAiH;AACjH,8GAA8G;AAC9G,wCAAwC;AAExC,OAAO,EAAa,WAAW,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,SAAS,EAAiC,MAAM,YAAY,CAAC;AAE9F,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,YAAY,CAAU,CAAC;AACvD,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,CAAU,CAAC;AACjG,MAAM,YAAY,GAAG,yCAAyC,CAAC;AAC/D,MAAM,gBAAgB,GAAG,oCAAoC,CAAC;AAE9D,MAAM,CAAC,MAAM,WAAW,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;AAE7E,MAAM,CAAC,MAAM,YAAY,GACvB,+GAA+G;IAC/G,kHAAkH;IAClH,6GAA6G;IAC7G,yEAAyE,CAAC;AA8B5E,MAAM,GAAG,GAAG;IACV,KAAK,EAAE,CAAC,KAAK;IACb,cAAc,EAAE,CAAC,KAAK;IACtB,cAAc,EAAE,CAAC,KAAK;IACtB,aAAa,EAAE,CAAC,KAAK;IACrB,QAAQ,EAAE,CAAC,KAAK;IAChB,kBAAkB,EAAE,CAAC,KAAK;CAClB,CAAC;AAEX,MAAM,OAAO,SAAS;IACH,MAAM,CAAO;IACb,KAAK,CAAoB;IAClC,KAAK,CAAiC;IACtC,YAAY,CAA0C;IAC7C,KAAK,CAAS;IAC/B,yFAAyF;IACzF,aAAa,CAAqB;IACjB,QAAQ,GAAG,IAAI,GAAG,EAA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,CAAC"}
|
package/dist/stdio.d.ts
CHANGED
|
@@ -5,13 +5,36 @@ export interface StdioOptions extends Partial<McpServerOptions> {
|
|
|
5
5
|
output?: {
|
|
6
6
|
write(s: string): unknown;
|
|
7
7
|
};
|
|
8
|
+
/**
|
|
9
|
+
* Appends one JSON line per received message (time, method, protocol revision, tool name; never arguments or
|
|
10
|
+
* results) to this file: how to see what a client speaks. Default: $B3OS_MCP_TRACE.
|
|
11
|
+
*/
|
|
12
|
+
traceFile?: string;
|
|
8
13
|
}
|
|
9
14
|
/** The `b3os login` token, when there is one (same file as the CLI: $XDG_CONFIG_HOME/b3os/credentials.json). */
|
|
10
15
|
export declare function storedLogin(): {
|
|
11
16
|
token: string;
|
|
12
17
|
base_url?: string;
|
|
13
18
|
} | undefined;
|
|
14
|
-
/**
|
|
19
|
+
/**
|
|
20
|
+
* Drops B3OS_* variables whose value is an unexpanded client reference (`${env:B3OS_API_KEY}`,
|
|
21
|
+
* `${B3OS_BASE_URL}`): Cursor passes the reference itself when the variable is unset in its environment, and such
|
|
22
|
+
* a value is never a key or URL. The stored login (or the defaults) then apply. Returns the names dropped.
|
|
23
|
+
*/
|
|
24
|
+
export declare function dropUnexpandedReferences(env?: NodeJS.ProcessEnv): string[];
|
|
25
|
+
/**
|
|
26
|
+
* A client from B3OS_API_KEY (or the node socket / sandbox URL), else the stored CLI login under the SDK's rules
|
|
27
|
+
* (core/login.ts): only on a developer's machine, never in CI, on GitHub Actions or in a B3OS sandbox, and only
|
|
28
|
+
* for the API host the login was issued by, so B3OS_BASE_URL naming another host gets no key.
|
|
29
|
+
*/
|
|
15
30
|
export declare function defaultClient(): B3OS;
|
|
31
|
+
/** Where a client's key came from, found by comparing values (never printed). */
|
|
32
|
+
export type CredentialSource = "B3OS_API_KEY" | "b3os login" | "a key" | "none";
|
|
33
|
+
export declare function credentialSource(client: B3OS): CredentialSource;
|
|
34
|
+
/**
|
|
35
|
+
* What an `unauthorized` tool error tells the agent, by where the server's credential came from. An agent cannot
|
|
36
|
+
* sign in or send headers; the person it works for can run `b3os login`.
|
|
37
|
+
*/
|
|
38
|
+
export declare function authHelpFor(source: CredentialSource): (apiDetail: string) => string;
|
|
16
39
|
/** Serves MCP over stdin/stdout until stdin ends. */
|
|
17
40
|
export declare function serveStdio(opts?: StdioOptions): Promise<void>;
|
package/dist/stdio.js
CHANGED
|
@@ -1,9 +1,22 @@
|
|
|
1
1
|
// The stdio transport: newline-delimited JSON-RPC on stdin/stdout, logs on stderr only (MCP stdio rules).
|
|
2
|
-
import { readFileSync } from "node:fs";
|
|
2
|
+
import { appendFileSync, readFileSync } from "node:fs";
|
|
3
3
|
import { homedir } from "node:os";
|
|
4
4
|
import { join } from "node:path";
|
|
5
5
|
import { B3OS, DEFAULT_BASE_URL } from "@b3os/sdk";
|
|
6
6
|
import { McpServer } from "./server.js";
|
|
7
|
+
/** What a trace line records about one message: no parameters, so no argument or credential ever lands in it. */
|
|
8
|
+
function traceLine(m) {
|
|
9
|
+
const o = (m && typeof m === "object" ? m : {});
|
|
10
|
+
const meta = (o.params?._meta ?? {});
|
|
11
|
+
const rev = meta["io.modelcontextprotocol/protocolVersion"] ?? o.params?.protocolVersion;
|
|
12
|
+
return `${JSON.stringify({
|
|
13
|
+
ts: new Date().toISOString(),
|
|
14
|
+
method: typeof o.method === "string" ? o.method : null,
|
|
15
|
+
request: o.id !== undefined && o.id !== null,
|
|
16
|
+
protocol: typeof rev === "string" ? rev : null,
|
|
17
|
+
...(o.method === "tools/call" && typeof o.params?.name === "string" ? { tool: o.params.name } : {}),
|
|
18
|
+
})}\n`;
|
|
19
|
+
}
|
|
7
20
|
/** The `b3os login` token, when there is one (same file as the CLI: $XDG_CONFIG_HOME/b3os/credentials.json). */
|
|
8
21
|
export function storedLogin() {
|
|
9
22
|
const file = process.env.B3OS_CREDENTIALS_FILE ||
|
|
@@ -18,28 +31,84 @@ export function storedLogin() {
|
|
|
18
31
|
return undefined;
|
|
19
32
|
}
|
|
20
33
|
}
|
|
21
|
-
/**
|
|
34
|
+
/**
|
|
35
|
+
* Drops B3OS_* variables whose value is an unexpanded client reference (`${env:B3OS_API_KEY}`,
|
|
36
|
+
* `${B3OS_BASE_URL}`): Cursor passes the reference itself when the variable is unset in its environment, and such
|
|
37
|
+
* a value is never a key or URL. The stored login (or the defaults) then apply. Returns the names dropped.
|
|
38
|
+
*/
|
|
39
|
+
export function dropUnexpandedReferences(env = process.env) {
|
|
40
|
+
const dropped = [];
|
|
41
|
+
for (const [k, v] of Object.entries(env)) {
|
|
42
|
+
if (k.startsWith("B3OS_") && typeof v === "string" && /^\$\{[^}]*\}$/.test(v.trim())) {
|
|
43
|
+
delete env[k];
|
|
44
|
+
dropped.push(k);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return dropped;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* A client from B3OS_API_KEY (or the node socket / sandbox URL), else the stored CLI login under the SDK's rules
|
|
51
|
+
* (core/login.ts): only on a developer's machine, never in CI, on GitHub Actions or in a B3OS sandbox, and only
|
|
52
|
+
* for the API host the login was issued by, so B3OS_BASE_URL naming another host gets no key.
|
|
53
|
+
*/
|
|
22
54
|
export function defaultClient() {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
55
|
+
return new B3OS();
|
|
56
|
+
}
|
|
57
|
+
export function credentialSource(client) {
|
|
58
|
+
const key = client.apiKey;
|
|
59
|
+
if (!key)
|
|
60
|
+
return "none";
|
|
61
|
+
if (process.env.B3OS_API_KEY === key)
|
|
62
|
+
return "B3OS_API_KEY";
|
|
63
|
+
if (storedLogin()?.token === key)
|
|
64
|
+
return "b3os login";
|
|
65
|
+
return "a key";
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* What an `unauthorized` tool error tells the agent, by where the server's credential came from. An agent cannot
|
|
69
|
+
* sign in or send headers; the person it works for can run `b3os login`.
|
|
70
|
+
*/
|
|
71
|
+
export function authHelpFor(source) {
|
|
72
|
+
return (apiDetail) => {
|
|
73
|
+
const why = apiDetail.replace(/[.\s]+$/, "");
|
|
74
|
+
switch (source) {
|
|
75
|
+
case "none":
|
|
76
|
+
return ("Not signed in to B3OS. Ask the user to run `b3os login` in a terminal (or to set B3OS_API_KEY in this " +
|
|
77
|
+
"MCP server's settings), then call the tool again.");
|
|
78
|
+
case "b3os login":
|
|
79
|
+
return `B3OS refused the user's b3os login (${why}). Ask the user to run \`b3os login\` again, then call the tool again.`;
|
|
80
|
+
case "B3OS_API_KEY":
|
|
81
|
+
return (`B3OS refused the key in B3OS_API_KEY (${why}). Ask the user to put a working key in this MCP server's ` +
|
|
82
|
+
"settings, or to remove it and run `b3os login`.");
|
|
83
|
+
default:
|
|
84
|
+
return `B3OS refused this server's API key (${why}). Ask the user for a working key.`;
|
|
85
|
+
}
|
|
86
|
+
};
|
|
32
87
|
}
|
|
33
88
|
/** Serves MCP over stdin/stdout until stdin ends. */
|
|
34
89
|
export async function serveStdio(opts = {}) {
|
|
90
|
+
if (!opts.client) {
|
|
91
|
+
const dropped = dropUnexpandedReferences();
|
|
92
|
+
if (dropped.length)
|
|
93
|
+
process.stderr.write(`b3os-mcp: ignoring ${dropped.join(", ")}: the MCP client passed an unexpanded reference\n`);
|
|
94
|
+
}
|
|
35
95
|
const client = opts.client ?? defaultClient();
|
|
36
|
-
const
|
|
96
|
+
const source = credentialSource(client);
|
|
97
|
+
if (source === "none" && client.routes.nodeKind === "edge")
|
|
98
|
+
process.stderr.write("b3os-mcp: not signed in, so each tool call will ask the user to run b3os login (or to set B3OS_API_KEY)\n");
|
|
99
|
+
const server = new McpServer({
|
|
100
|
+
onWarning: (m) => process.stderr.write(`b3os-mcp: ${m}\n`),
|
|
101
|
+
authHelp: authHelpFor(source),
|
|
102
|
+
...opts,
|
|
103
|
+
client,
|
|
104
|
+
});
|
|
37
105
|
const input = opts.input ?? process.stdin;
|
|
38
106
|
const output = opts.output ?? process.stdout;
|
|
39
107
|
const send = (m) => {
|
|
40
108
|
output.write(`${JSON.stringify(m)}\n`);
|
|
41
109
|
};
|
|
42
110
|
const pending = new Set();
|
|
111
|
+
const trace = opts.traceFile ?? process.env.B3OS_MCP_TRACE;
|
|
43
112
|
let buf = "";
|
|
44
113
|
const dispatch = (line) => {
|
|
45
114
|
const t = line.trim();
|
|
@@ -55,6 +124,14 @@ export async function serveStdio(opts = {}) {
|
|
|
55
124
|
}
|
|
56
125
|
const items = Array.isArray(msg) ? msg : [msg];
|
|
57
126
|
for (const item of items) {
|
|
127
|
+
if (trace) {
|
|
128
|
+
try {
|
|
129
|
+
appendFileSync(trace, traceLine(item));
|
|
130
|
+
}
|
|
131
|
+
catch {
|
|
132
|
+
// tracing never breaks the server
|
|
133
|
+
}
|
|
134
|
+
}
|
|
58
135
|
const p = server.handle(item, send).catch((e) => {
|
|
59
136
|
process.stderr.write(`b3os-mcp: ${e?.stack ?? e}\n`);
|
|
60
137
|
});
|