@descryy/mcp 0.4.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/descry-mcp.js +16 -2
- package/dist/bin/descry-mcp.js.map +1 -1
- package/dist/browser/driver.d.ts +105 -6
- package/dist/browser/driver.d.ts.map +1 -1
- package/dist/browser/driver.js +17 -3
- package/dist/browser/driver.js.map +1 -1
- package/dist/browser/evidence.d.ts +11 -0
- package/dist/browser/evidence.d.ts.map +1 -1
- package/dist/browser/evidence.js +64 -8
- package/dist/browser/evidence.js.map +1 -1
- package/dist/browser/fake-driver.d.ts +8 -0
- package/dist/browser/fake-driver.d.ts.map +1 -1
- package/dist/browser/fake-driver.js +26 -3
- package/dist/browser/fake-driver.js.map +1 -1
- package/dist/browser/playwright-driver.d.ts +68 -14
- package/dist/browser/playwright-driver.d.ts.map +1 -1
- package/dist/browser/playwright-driver.js +318 -38
- package/dist/browser/playwright-driver.js.map +1 -1
- package/dist/browser/provider.d.ts +10 -4
- package/dist/browser/provider.d.ts.map +1 -1
- package/dist/browser/provider.js +10 -4
- package/dist/browser/provider.js.map +1 -1
- package/dist/browser/scenario-runner.d.ts +9 -0
- package/dist/browser/scenario-runner.d.ts.map +1 -1
- package/dist/browser/scenario-runner.js +32 -2
- package/dist/browser/scenario-runner.js.map +1 -1
- package/dist/browser/tool-support.js +1 -1
- package/dist/browser/tool-support.js.map +1 -1
- package/dist/cancellation.d.ts +55 -0
- package/dist/cancellation.d.ts.map +1 -0
- package/dist/cancellation.js +76 -0
- package/dist/cancellation.js.map +1 -0
- package/dist/capped.d.ts +41 -0
- package/dist/capped.d.ts.map +1 -0
- package/dist/capped.js +35 -0
- package/dist/capped.js.map +1 -0
- package/dist/registry.d.ts +20 -1
- package/dist/registry.d.ts.map +1 -1
- package/dist/registry.js +71 -4
- package/dist/registry.js.map +1 -1
- package/dist/render.d.ts +92 -0
- package/dist/render.d.ts.map +1 -1
- package/dist/render.js +250 -5
- package/dist/render.js.map +1 -1
- package/dist/runtime-registry.d.ts +19 -1
- package/dist/runtime-registry.d.ts.map +1 -1
- package/dist/runtime-registry.js +88 -4
- package/dist/runtime-registry.js.map +1 -1
- package/dist/server.d.ts +19 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +135 -11
- package/dist/server.js.map +1 -1
- package/dist/session.d.ts +22 -0
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js +27 -1
- package/dist/session.js.map +1 -1
- package/dist/tools/analyze.d.ts +23 -3
- package/dist/tools/analyze.d.ts.map +1 -1
- package/dist/tools/analyze.js +35 -3
- package/dist/tools/analyze.js.map +1 -1
- package/dist/tools/browser-click.d.ts.map +1 -1
- package/dist/tools/browser-click.js +14 -0
- package/dist/tools/browser-click.js.map +1 -1
- package/dist/tools/browser-fill.d.ts.map +1 -1
- package/dist/tools/browser-fill.js +14 -0
- package/dist/tools/browser-fill.js.map +1 -1
- package/dist/tools/browser-navigate.d.ts.map +1 -1
- package/dist/tools/browser-navigate.js +14 -0
- package/dist/tools/browser-navigate.js.map +1 -1
- package/dist/tools/browser-run-scenario.d.ts.map +1 -1
- package/dist/tools/browser-run-scenario.js +12 -3
- package/dist/tools/browser-run-scenario.js.map +1 -1
- package/dist/tools/browser-save-scenario.d.ts.map +1 -1
- package/dist/tools/browser-save-scenario.js +109 -3
- package/dist/tools/browser-save-scenario.js.map +1 -1
- package/dist/tools/browser-start-session.d.ts.map +1 -1
- package/dist/tools/browser-start-session.js +43 -0
- package/dist/tools/browser-start-session.js.map +1 -1
- package/dist/tools/browser-type.d.ts.map +1 -1
- package/dist/tools/browser-type.js +14 -0
- package/dist/tools/browser-type.js.map +1 -1
- package/dist/tools/contracts.d.ts +41 -10
- package/dist/tools/contracts.d.ts.map +1 -1
- package/dist/tools/contracts.js +117 -17
- package/dist/tools/contracts.js.map +1 -1
- package/dist/tools/cross-pr.d.ts +39 -10
- package/dist/tools/cross-pr.d.ts.map +1 -1
- package/dist/tools/cross-pr.js +113 -29
- package/dist/tools/cross-pr.js.map +1 -1
- package/dist/tools/git-diff.d.ts.map +1 -1
- package/dist/tools/git-diff.js +30 -2
- package/dist/tools/git-diff.js.map +1 -1
- package/dist/tools/impact.d.ts.map +1 -1
- package/dist/tools/impact.js +50 -2
- package/dist/tools/impact.js.map +1 -1
- package/dist/tools/observe-runtime.d.ts.map +1 -1
- package/dist/tools/observe-runtime.js +84 -4
- package/dist/tools/observe-runtime.js.map +1 -1
- package/dist/tools/observe-tests.d.ts +12 -0
- package/dist/tools/observe-tests.d.ts.map +1 -1
- package/dist/tools/observe-tests.js +92 -8
- package/dist/tools/observe-tests.js.map +1 -1
- package/dist/tools/pre-push.d.ts +40 -7
- package/dist/tools/pre-push.d.ts.map +1 -1
- package/dist/tools/pre-push.js +65 -23
- package/dist/tools/pre-push.js.map +1 -1
- package/dist/tools/scope.d.ts.map +1 -1
- package/dist/tools/scope.js +20 -4
- package/dist/tools/scope.js.map +1 -1
- package/dist/tools/validate.d.ts +40 -1
- package/dist/tools/validate.d.ts.map +1 -1
- package/dist/tools/validate.js +150 -27
- package/dist/tools/validate.js.map +1 -1
- package/dist/tools/verification-status.d.ts.map +1 -1
- package/dist/tools/verification-status.js +3 -3
- package/dist/tools/verification-status.js.map +1 -1
- package/dist/transport.d.ts +12 -1
- package/dist/transport.d.ts.map +1 -1
- package/dist/transport.js +30 -16
- package/dist/transport.js.map +1 -1
- package/package.json +22 -13
package/dist/runtime-registry.js
CHANGED
|
@@ -40,6 +40,24 @@
|
|
|
40
40
|
* Every failure leaves here as a thrown `RuntimeAdapterLoadError` carrying the
|
|
41
41
|
* specifier and the reason, so the caller cannot take an adapter without also
|
|
42
42
|
* having to handle not getting one.
|
|
43
|
+
*
|
|
44
|
+
* ## B5: a bare specifier now resolves from the user's own repository first
|
|
45
|
+
*
|
|
46
|
+
* A bare specifier in a dynamic `import()` resolves against the IMPORTING
|
|
47
|
+
* MODULE's own location — this file's, unconditionally, before this fix. The
|
|
48
|
+
* documented launch (`npx -y @descryy/mcp <repo-path>`) puts this file inside
|
|
49
|
+
* an npx cache, so that root held only what npx installed; the user's
|
|
50
|
+
* repository, its `node_modules`, and the working directory were never
|
|
51
|
+
* consulted, which made the documented remedy ("install the adapter
|
|
52
|
+
* alongside this server") impossible under the documented configuration.
|
|
53
|
+
*
|
|
54
|
+
* `resolveAdapterModule` (below `loadRuntimeAdapter`) now tries three roots
|
|
55
|
+
* in order and names every one tried on failure: an already-resolved
|
|
56
|
+
* specifier is used directly; a bare specifier resolves from `repoPath` —
|
|
57
|
+
* the repository `observe_runtime` was pointed at — via `createRequire`
|
|
58
|
+
* anchored at that repo's own `package.json`; failing that, from this
|
|
59
|
+
* module's own closure, unchanged, so an adapter already declared as
|
|
60
|
+
* `@descryy/mcp`'s own dependency still resolves.
|
|
43
61
|
*/
|
|
44
62
|
var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
|
|
45
63
|
if (typeof path === "string" && /^\.\.?\//.test(path)) {
|
|
@@ -49,6 +67,9 @@ var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExte
|
|
|
49
67
|
}
|
|
50
68
|
return path;
|
|
51
69
|
};
|
|
70
|
+
import { createRequire } from "node:module";
|
|
71
|
+
import { isAbsolute, join } from "node:path";
|
|
72
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
52
73
|
/**
|
|
53
74
|
* Distinct from a generic `Error` so the tool can tell "the adapter would not
|
|
54
75
|
* load" (a refusal it must disclose) apart from "the run itself broke" (a
|
|
@@ -90,14 +111,77 @@ function isRuntimeAdapter(value) {
|
|
|
90
111
|
typeof candidate.stackTraceParser === "object" &&
|
|
91
112
|
typeof candidate.sourceLocationResolver === "object");
|
|
92
113
|
}
|
|
93
|
-
|
|
94
|
-
|
|
114
|
+
/**
|
|
115
|
+
* This module's own directory — the root a bare specifier resolves against
|
|
116
|
+
* TODAY, unchanged, and the one root that was reachable before this fix.
|
|
117
|
+
* Under the documented `npx -y @descryy/mcp <repo-path>` launch this is
|
|
118
|
+
* somewhere under an npx cache, which is never a directory the user
|
|
119
|
+
* installed anything into — the refusal below names it as exactly that,
|
|
120
|
+
* rather than presenting it as though it were installable.
|
|
121
|
+
*/
|
|
122
|
+
const SERVER_OWN_ROOT = fileURLToPath(new URL(".", import.meta.url));
|
|
123
|
+
/** An absolute filesystem path or a `file://` URL: already fully resolved, nothing left for repoPath or the server's own closure to add. */
|
|
124
|
+
function isAlreadyResolved(specifier) {
|
|
125
|
+
return isAbsolute(specifier) || specifier.startsWith("file://");
|
|
126
|
+
}
|
|
127
|
+
async function importSpecifier(specifier) {
|
|
128
|
+
return (await import(__rewriteRelativeImportExtension(specifier)));
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* B5's fix. A bare specifier in a dynamic `import()` resolves against the
|
|
132
|
+
* IMPORTING MODULE's own location — this file's, under the previous,
|
|
133
|
+
* single-root version of this function — never against `repoPath` or
|
|
134
|
+
* `process.cwd()`. Under the documented `npx -y @descryy/mcp <repo-path>`
|
|
135
|
+
* launch that resolution root is an npx cache holding only what npx
|
|
136
|
+
* installed, so the documented remedy ("install the adapter alongside this
|
|
137
|
+
* server") was impossible: there was no directory the user controls on that
|
|
138
|
+
* resolution path at all.
|
|
139
|
+
*
|
|
140
|
+
* Three roots, tried in this order, and a failure names every one tried —
|
|
141
|
+
* never only the one that happened to throw last:
|
|
142
|
+
*
|
|
143
|
+
* 1. An already-resolved specifier (`isAlreadyResolved`) is fully explicit;
|
|
144
|
+
* used directly, and no other root applies to it.
|
|
145
|
+
* 2. The repository the server was pointed at (`repoPath`) — resolved via
|
|
146
|
+
* `createRequire` anchored at that repo's own `package.json`, so
|
|
147
|
+
* `npm i -D <adapter>` in the user's project — the mental model the
|
|
148
|
+
* documentation already gives every reader — actually works.
|
|
149
|
+
* 3. This module's own closure (`SERVER_OWN_ROOT`, today's only root) —
|
|
150
|
+
* kept last rather than removed, so an adapter declared as a real
|
|
151
|
+
* dependency of `@descryy/mcp` itself still resolves (see this fix's
|
|
152
|
+
* own decisions-inbox entry on `optionalDependencies`).
|
|
153
|
+
*/
|
|
154
|
+
async function resolveAdapterModule(spec, repoPath) {
|
|
155
|
+
if (isAlreadyResolved(spec.module)) {
|
|
156
|
+
try {
|
|
157
|
+
return await importSpecifier(spec.module);
|
|
158
|
+
}
|
|
159
|
+
catch (error) {
|
|
160
|
+
throw new RuntimeAdapterLoadError(spec, describe(error));
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
const repoNodeModules = join(repoPath, "node_modules");
|
|
95
164
|
try {
|
|
96
|
-
|
|
165
|
+
const repoRequire = createRequire(pathToFileURL(join(repoPath, "package.json")));
|
|
166
|
+
const resolved = repoRequire.resolve(spec.module);
|
|
167
|
+
return await importSpecifier(pathToFileURL(resolved).href);
|
|
168
|
+
}
|
|
169
|
+
catch {
|
|
170
|
+
// Fall through to the server's own closure — recorded below only if
|
|
171
|
+
// that root also fails, so a successful fallback never mentions this
|
|
172
|
+
// attempt at all.
|
|
173
|
+
}
|
|
174
|
+
try {
|
|
175
|
+
return await importSpecifier(spec.module);
|
|
97
176
|
}
|
|
98
177
|
catch (error) {
|
|
99
|
-
throw new RuntimeAdapterLoadError(spec,
|
|
178
|
+
throw new RuntimeAdapterLoadError(spec, `looked in "${repoNodeModules}", then in the server's own dependencies at "${SERVER_OWN_ROOT}" -- neither ` +
|
|
179
|
+
`has ${JSON.stringify(spec.module)} (${describe(error)}). Install it in your project ` +
|
|
180
|
+
`(\`npm i -D ${spec.module}\`), or give an absolute path to its dist/index.js.`);
|
|
100
181
|
}
|
|
182
|
+
}
|
|
183
|
+
export async function loadRuntimeAdapter(spec, repoPath) {
|
|
184
|
+
const module = await resolveAdapterModule(spec, repoPath);
|
|
101
185
|
let factoryName = spec.export;
|
|
102
186
|
if (factoryName === undefined) {
|
|
103
187
|
const candidates = Object.keys(module).filter((key) => FACTORY_PATTERN.test(key) && typeof module[key] === "function");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-registry.js","sourceRoot":"","sources":["../src/runtime-registry.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"runtime-registry.js","sourceRoot":"","sources":["../src/runtime-registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4DG;;;;;;;;;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAaxD;;;;GAIG;AACH,MAAM,OAAO,uBAAwB,SAAQ,KAAK;IACvC,IAAI,CAAqB;IAElC,YAAY,IAAwB,EAAE,MAAc;QAClD,KAAK,CAAC,oBAAoB,IAAI,CAAC,MAAM,2BAA2B,MAAM,EAAE,CAAC,CAAC;QAC1E,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAC;QACtC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF;AAED,MAAM,eAAe,GAAG,oCAAoC,CAAC;AAE7D,SAAS,QAAQ,CAAC,KAAc;IAC9B,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;QAC3B,MAAM,IAAI,GAAI,KAA+B,CAAC,IAAI,CAAC;QACnD,OAAO,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,IAAI,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC;IAC1E,CAAC;IACD,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC;AAED;;;;;;;;;;GAUG;AACH,SAAS,gBAAgB,CAAC,KAAc;IACtC,MAAM,SAAS,GAAG,KAAuC,CAAC;IAC1D,OAAO,CACL,OAAO,SAAS,KAAK,QAAQ;QAC7B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C1B,MAAM,IAAI,uBAAuB,CAC/B,IAAI,EACJ,GAAG,UAAU,CAAC,MAAM,yCAAyC,UAAU,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK;gBAC5F,uFAAuF,CAC1F,CAAC;QACJ,CAAC;QACD,WAAW,GAAG,UAAU,CAAC,CAAC,CAAE,CAAC;IAC/B,CAAC;IAED,MAAM,OAAO,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC;IACpC,IAAI,OAAO,OAAO,KAAK,UAAU,EAAE,CAAC;QAClC,MAAM,IAAI,uBAAuB,CAAC,IAAI,EAAE,WAAW,WAAW,qBAAqB,CAAC,CAAC;IACvF,CAAC;IAED,IAAI,OAAgB,CAAC;IACrB,IAAI,CAAC;QACH,OAAO,GAAI,OAA0C,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACtE,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,uBAAuB,CAAC,IAAI,EAAE,IAAI,WAAW,aAAa,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IACzF,CAAC;IAED,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,EAAE,CAAC;QAC/B,MAAM,IAAI,uBAAuB,CAC/B,IAAI,EACJ,IAAI,WAAW,+EAA+E;YAC5F,yDAAyD,CAC5D,CAAC;IACJ,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
package/dist/server.d.ts
CHANGED
|
@@ -26,12 +26,31 @@
|
|
|
26
26
|
* broken protocol produces an error frame.
|
|
27
27
|
*/
|
|
28
28
|
import type { Session } from "./session.ts";
|
|
29
|
+
import { type ToolDefinition } from "./tools/index.ts";
|
|
29
30
|
import type { Transport } from "./transport.ts";
|
|
30
31
|
export interface McpServerOptions {
|
|
31
32
|
readonly session: Session;
|
|
32
33
|
readonly name?: string;
|
|
33
34
|
readonly version?: string;
|
|
35
|
+
/**
|
|
36
|
+
* Overrides the registry. Exists for tests of *this* layer: the cancellation
|
|
37
|
+
* path needs a call that is still running when the notification arrives, and
|
|
38
|
+
* of the thirty registered tools exactly one reads `ctx.signal` at all, so
|
|
39
|
+
* driving the mechanism through the real registry would test that one tool's
|
|
40
|
+
* plumbing rather than the server's dispatch.
|
|
41
|
+
*/
|
|
42
|
+
readonly tools?: readonly ToolDefinition[];
|
|
34
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* Does this frame have to jump the transport's ordering queue?
|
|
46
|
+
*
|
|
47
|
+
* True for `notifications/cancelled` and nothing else. Exported because the
|
|
48
|
+
* stdio runner needs the answer and the knowledge of what MCP methods mean
|
|
49
|
+
* belongs here, not in a module that otherwise only knows about bytes. Never
|
|
50
|
+
* throws — a line that will not parse is the dispatcher's to reject, with the
|
|
51
|
+
* error frame it already knows how to build.
|
|
52
|
+
*/
|
|
53
|
+
export declare function isOutOfBand(line: string): boolean;
|
|
35
54
|
export interface McpServer {
|
|
36
55
|
/** Handle one newline-delimited frame. Never throws; every failure becomes a frame. */
|
|
37
56
|
dispatch(line: string, transport: Transport): Promise<void>;
|
package/dist/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AA4BH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAKL,KAAK,cAAc,EACpB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAYhD,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B;;;;;;OAMG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,cAAc,EAAE,CAAC;CAC5C;AAED;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAYjD;AAED,MAAM,WAAW,SAAS;IACxB,uFAAuF;IACvF,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5D,wDAAwD;IACxD,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;CAC/B;AA4DD,wBAAgB,eAAe,CAAC,OAAO,EAAE,gBAAgB,GAAG,SAAS,CAyTpE"}
|
package/dist/server.js
CHANGED
|
@@ -25,17 +25,42 @@
|
|
|
25
25
|
* content with `isError`, which the model can read and act on. Only genuinely
|
|
26
26
|
* broken protocol produces an error frame.
|
|
27
27
|
*/
|
|
28
|
+
import { randomUUID } from "node:crypto";
|
|
28
29
|
import { resolveActionDispatch } from "./action-handshake.js";
|
|
29
30
|
import { fail, isRequest, negotiateVersion, ok, parseMessage, ProtocolError, RPC_INTERNAL_ERROR, RPC_INVALID_PARAMS, RPC_METHOD_NOT_FOUND, } from "./protocol.js";
|
|
30
|
-
import { renderAnswer, renderFailed, renderHandshake, renderTimedOut, renderToolError, } from "./render.js";
|
|
31
|
+
import { renderAnswer, renderFailed, renderHandshake, renderTimedOut, renderToolError, TOOL_OUTPUT_SCHEMA, } from "./render.js";
|
|
31
32
|
import { createDisclosureLedger } from "./disclosure-ledger.js";
|
|
32
|
-
import { TOOLS, TOOLS_BY_NAME, ToolInputError } from "./tools/index.js";
|
|
33
|
+
import { TOOLS, TOOLS_BY_NAME, ToolInputError, } from "./tools/index.js";
|
|
33
34
|
/** Every call's declared budget (§6). Fixed today; per-trigger budgets are P26/P28 work. */
|
|
34
35
|
const CALL_BUDGET_MS = 15 * 60 * 1000;
|
|
35
36
|
function isAbort(error) {
|
|
36
37
|
return ((error instanceof Error && error.name === "AbortError") ||
|
|
37
38
|
(typeof DOMException !== "undefined" && error instanceof DOMException && error.name === "TimeoutError"));
|
|
38
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* Does this frame have to jump the transport's ordering queue?
|
|
42
|
+
*
|
|
43
|
+
* True for `notifications/cancelled` and nothing else. Exported because the
|
|
44
|
+
* stdio runner needs the answer and the knowledge of what MCP methods mean
|
|
45
|
+
* belongs here, not in a module that otherwise only knows about bytes. Never
|
|
46
|
+
* throws — a line that will not parse is the dispatcher's to reject, with the
|
|
47
|
+
* error frame it already knows how to build.
|
|
48
|
+
*/
|
|
49
|
+
export function isOutOfBand(line) {
|
|
50
|
+
try {
|
|
51
|
+
const message = JSON.parse(line);
|
|
52
|
+
if (typeof message !== "object" || message === null || Array.isArray(message))
|
|
53
|
+
return false;
|
|
54
|
+
const frame = message;
|
|
55
|
+
// A *request* named `notifications/cancelled` is malformed, not a
|
|
56
|
+
// cancellation. Letting it jump the queue would answer it out of order,
|
|
57
|
+
// which is the exact hazard the ordering exists to prevent.
|
|
58
|
+
return frame["method"] === "notifications/cancelled" && frame["id"] === undefined;
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
39
64
|
const SERVER_INSTRUCTIONS = "Descry reads the repository's source into a code graph and answers questions about it.\n\n" +
|
|
40
65
|
"Call `analyze` first — every other tool queries the graph it builds, and a stale graph " +
|
|
41
66
|
"answers about code that has changed.\n\n" +
|
|
@@ -100,6 +125,17 @@ export function createMcpServer(options) {
|
|
|
100
125
|
// `disclosure-ledger.ts` for why it is not shared across connections.
|
|
101
126
|
const disclosureLedger = createDisclosureLedger();
|
|
102
127
|
let initialized = false;
|
|
128
|
+
const tools = options.tools ?? TOOLS;
|
|
129
|
+
const toolsByName = options.tools === undefined
|
|
130
|
+
? TOOLS_BY_NAME
|
|
131
|
+
: new Map(options.tools.map((tool) => [tool.name, tool]));
|
|
132
|
+
/**
|
|
133
|
+
* In-flight `tools/call`s, by request id, so `notifications/cancelled` has
|
|
134
|
+
* something to act on. Entries live exactly as long as the call: added
|
|
135
|
+
* before `tool.run`, removed in the `finally` that also drops the call's
|
|
136
|
+
* progress tick.
|
|
137
|
+
*/
|
|
138
|
+
const pending = new Map();
|
|
103
139
|
async function handleRequest(request, transport) {
|
|
104
140
|
const { id, method } = request;
|
|
105
141
|
const params = request.params ?? {};
|
|
@@ -122,7 +158,7 @@ export function createMcpServer(options) {
|
|
|
122
158
|
}
|
|
123
159
|
case "tools/list": {
|
|
124
160
|
transport.send(ok(id, {
|
|
125
|
-
tools:
|
|
161
|
+
tools: tools.map((tool) => ({
|
|
126
162
|
name: tool.name,
|
|
127
163
|
title: tool.title,
|
|
128
164
|
description: tool.description,
|
|
@@ -138,12 +174,22 @@ export function createMcpServer(options) {
|
|
|
138
174
|
// read it" reasoning as `class`, one line up.
|
|
139
175
|
tier: tool.tier,
|
|
140
176
|
toolVersion: tool.version,
|
|
177
|
+
// Every reply this server sends carries a `structuredContent`
|
|
178
|
+
// envelope, and without this a host has no way to validate one.
|
|
179
|
+
// Shared across all tools because the envelope is: see
|
|
180
|
+
// `TOOL_OUTPUT_SCHEMA`, including why `data` is left open.
|
|
181
|
+
outputSchema: TOOL_OUTPUT_SCHEMA,
|
|
141
182
|
})),
|
|
142
183
|
}));
|
|
143
184
|
return;
|
|
144
185
|
}
|
|
145
186
|
case "tools/call": {
|
|
146
|
-
|
|
187
|
+
const result = await callTool(id, params, transport);
|
|
188
|
+
// `null` means the call was cancelled while it ran. MCP forbids a
|
|
189
|
+
// response to a cancelled request, so the only correct frame here is
|
|
190
|
+
// no frame at all.
|
|
191
|
+
if (result !== null)
|
|
192
|
+
transport.send(ok(id, result));
|
|
147
193
|
return;
|
|
148
194
|
}
|
|
149
195
|
default:
|
|
@@ -155,9 +201,9 @@ export function createMcpServer(options) {
|
|
|
155
201
|
if (typeof name !== "string") {
|
|
156
202
|
return renderToolError("tools/call", '"name" must be a string');
|
|
157
203
|
}
|
|
158
|
-
const tool =
|
|
204
|
+
const tool = toolsByName.get(name);
|
|
159
205
|
if (tool === undefined) {
|
|
160
|
-
return renderToolError(name, `no such tool. Available: ${
|
|
206
|
+
return renderToolError(name, `no such tool. Available: ${tools.map((t) => t.name).join(", ")}.`);
|
|
161
207
|
}
|
|
162
208
|
const rawArgs = params["arguments"];
|
|
163
209
|
if (rawArgs !== undefined && (typeof rawArgs !== "object" || rawArgs === null || Array.isArray(rawArgs))) {
|
|
@@ -185,12 +231,43 @@ export function createMcpServer(options) {
|
|
|
185
231
|
});
|
|
186
232
|
}
|
|
187
233
|
: () => { };
|
|
234
|
+
// Two ways a call ends early, composed into the one signal the tool sees:
|
|
235
|
+
// its own budget running out, and the client asking for it to stop.
|
|
236
|
+
//
|
|
237
|
+
// **What this does and does not buy.** Aborting here stops the *server*
|
|
238
|
+
// waiting and suppresses the response the client is no longer listening
|
|
239
|
+
// for, which is the protocol's requirement and is met. It stops the actual
|
|
240
|
+
// work only in a tool that reads the signal it is handed, and today that is
|
|
241
|
+
// exactly one of thirty — `analyze`, which passes `ctx.signal` down. The
|
|
242
|
+
// other twenty-nine, `browser_run_scenario` and `observe_runtime` among
|
|
243
|
+
// them, take the signal and never look at it, so a cancelled call there
|
|
244
|
+
// leaves a real browser or a real application process running until it
|
|
245
|
+
// finishes on its own. That is a disclosed gap, filed as
|
|
246
|
+
// `DEC-NEXT-cancellation-reaches-one-tool-in-thirty.md`, not something this
|
|
247
|
+
// layer can fix from here — threading the signal is each tool's own work.
|
|
248
|
+
const controller = new AbortController();
|
|
249
|
+
pending.set(id, controller);
|
|
188
250
|
const ctx = {
|
|
189
251
|
session,
|
|
190
252
|
progress,
|
|
191
|
-
signal: AbortSignal.timeout(CALL_BUDGET_MS),
|
|
253
|
+
signal: AbortSignal.any([controller.signal, AbortSignal.timeout(CALL_BUDGET_MS)]),
|
|
192
254
|
};
|
|
193
255
|
const started = Date.now();
|
|
256
|
+
// B10: minted before any rendering happens, so every envelope this call
|
|
257
|
+
// can produce (handshake, failed, timed-out, or a real answer) carries
|
|
258
|
+
// the exact id `recordCallWithId` will file the record under below — a
|
|
259
|
+
// caller reading `callId` off the reply and citing it in `verify_claim`
|
|
260
|
+
// is citing the id that call is actually recorded as.
|
|
261
|
+
//
|
|
262
|
+
// `verify_claim` itself is the one exception, on the same reasoning as
|
|
263
|
+
// its exclusion from recording just below: it produces no fact for a
|
|
264
|
+
// later claim to cite, so its own `callId` is not drawn from the
|
|
265
|
+
// session's call-id sequence at all — `session.allocateCallId()` is
|
|
266
|
+
// reserved for calls that will actually be recorded under the id it
|
|
267
|
+
// returns. Reusing it here would consume a real id `verify_claim` never
|
|
268
|
+
// gets recorded under, opening a gap in the sequence a caller relies on
|
|
269
|
+
// corresponding exactly to recorded calls.
|
|
270
|
+
const callId = name === "verify_claim" ? randomUUID() : session.allocateCallId();
|
|
194
271
|
const renderOptions = () => ({
|
|
195
272
|
toolVersion: tool.version,
|
|
196
273
|
toolClass: tool.class,
|
|
@@ -198,6 +275,7 @@ export function createMcpServer(options) {
|
|
|
198
275
|
elapsedMs: Date.now() - started,
|
|
199
276
|
limitMs: CALL_BUDGET_MS,
|
|
200
277
|
disclosureLedger,
|
|
278
|
+
callId,
|
|
201
279
|
});
|
|
202
280
|
try {
|
|
203
281
|
// §7's two-call handshake. Decided before any real work starts — a mint
|
|
@@ -208,16 +286,33 @@ export function createMcpServer(options) {
|
|
|
208
286
|
return renderHandshake(name, dispatch.token, dispatch.willDo, renderOptions());
|
|
209
287
|
}
|
|
210
288
|
const outcome = await tool.run(dispatch.args, ctx);
|
|
289
|
+
// Cancelled while it was running, and it finished anyway — the client
|
|
290
|
+
// stopped listening for this id, so the answer is dropped rather than
|
|
291
|
+
// sent late. Not recorded on the session either: a fact the caller never
|
|
292
|
+
// received must not become one a later `verify_claim` can cite.
|
|
293
|
+
if (controller.signal.aborted)
|
|
294
|
+
return null;
|
|
211
295
|
const rendered = renderAnswer(name, outcome, renderOptions());
|
|
212
296
|
// MK-12: recorded after rendering, from the exact structuredContent the
|
|
213
297
|
// host receives — not the pre-render outcome, which the host never
|
|
214
298
|
// sees. `verify_claim` itself is excluded: it produces no fact for a
|
|
215
299
|
// later claim to cite, only a verdict about other calls' facts.
|
|
300
|
+
//
|
|
301
|
+
// Recorded under `callId` — the same id `rendered.structuredContent`
|
|
302
|
+
// already carries as `callId` — rather than a freshly minted one
|
|
303
|
+
// (B10): the two must be the same value for a citation read off this
|
|
304
|
+
// reply to resolve.
|
|
216
305
|
if (name !== "verify_claim")
|
|
217
|
-
session.
|
|
306
|
+
session.recordCallWithId(callId, name, args, rendered.structuredContent);
|
|
218
307
|
return rendered;
|
|
219
308
|
}
|
|
220
309
|
catch (error) {
|
|
310
|
+
// Cancellation is checked before anything else, including
|
|
311
|
+
// `ToolInputError`: whatever the tool threw on its way out, the client
|
|
312
|
+
// has told us it is not listening, and the spec is explicit that a
|
|
313
|
+
// cancelled request gets no response at all.
|
|
314
|
+
if (controller.signal.aborted)
|
|
315
|
+
return null;
|
|
221
316
|
if (error instanceof ToolInputError)
|
|
222
317
|
return renderToolError(name, error.message);
|
|
223
318
|
if (isAbort(error) || ctx.signal.aborted)
|
|
@@ -227,6 +322,31 @@ export function createMcpServer(options) {
|
|
|
227
322
|
// error just ends the call with nothing it can use.
|
|
228
323
|
return renderFailed(name, `${error instanceof Error ? error.message : String(error)}`, renderOptions());
|
|
229
324
|
}
|
|
325
|
+
finally {
|
|
326
|
+
pending.delete(id);
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* Act on `notifications/cancelled`: abort the named call if it is still ours
|
|
331
|
+
* and still running.
|
|
332
|
+
*
|
|
333
|
+
* Silence in every other case is deliberate and is what the spec asks for. A
|
|
334
|
+
* cancellation racing a call that has already returned is ordinary client
|
|
335
|
+
* behaviour, not an error — the client sent it before our response reached
|
|
336
|
+
* it — and a notification cannot be answered anyway, so there is nowhere to
|
|
337
|
+
* report a bad `requestId` even if one were worth reporting.
|
|
338
|
+
*/
|
|
339
|
+
function cancel(params) {
|
|
340
|
+
const requestId = params["requestId"];
|
|
341
|
+
if (typeof requestId !== "string" && typeof requestId !== "number")
|
|
342
|
+
return;
|
|
343
|
+
const controller = pending.get(requestId);
|
|
344
|
+
if (controller === undefined)
|
|
345
|
+
return;
|
|
346
|
+
const reason = params["reason"];
|
|
347
|
+
controller.abort(new Error(typeof reason === "string" && reason !== ""
|
|
348
|
+
? `cancelled by client: ${reason}`
|
|
349
|
+
: "cancelled by client"));
|
|
230
350
|
}
|
|
231
351
|
// Monotonic per-request tick for narration with no natural count.
|
|
232
352
|
const ticks = new Map();
|
|
@@ -258,9 +378,13 @@ export function createMcpServer(options) {
|
|
|
258
378
|
if (!isRequest(message)) {
|
|
259
379
|
if (message.method === "notifications/initialized")
|
|
260
380
|
initialized = true;
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
//
|
|
381
|
+
else if (message.method === "notifications/cancelled")
|
|
382
|
+
cancel(message.params ?? {});
|
|
383
|
+
// Anything else — roots changed, and every notification a future spec
|
|
384
|
+
// adds — is accepted and ignored. A notification must never be
|
|
385
|
+
// answered, so silence on the wire is the protocol; silence *in
|
|
386
|
+
// response* is what cancellation could not afford, which is why it is
|
|
387
|
+
// the one handled above.
|
|
264
388
|
return;
|
|
265
389
|
}
|
|
266
390
|
try {
|
package/dist/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EACL,IAAI,EACJ,SAAS,EACT,gBAAgB,EAChB,EAAE,EACF,YAAY,EACZ,aAAa,EACb,kBAAkB,EAClB,kBAAkB,EAClB,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AC,CAAC;gBACpF,sEAAsE;gBACtE,+DAA+D;gBAC/D,gEAAgE;gBAChE,sEAAsE;gBACtE,yBAAyB;gBACzB,OAAO;YACT,CAAC;YAED,IAAI,CAAC;gBACH,MAAM,aAAa,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;YAC1C,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,SAAS,CAAC,IAAI,CACZ,IAAI,CACF,OAAO,CAAC,EAAE,EACV,KAAK,YAAY,cAAc,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,kBAAkB,EACzE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CACvD,CACF,CAAC;YACJ,CAAC;oBAAS,CAAC;gBACT,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;YAC3B,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/session.d.ts
CHANGED
|
@@ -314,6 +314,19 @@ export declare class Session {
|
|
|
314
314
|
* live registry to record itself against.
|
|
315
315
|
*/
|
|
316
316
|
dispose(): Promise<void>;
|
|
317
|
+
/**
|
|
318
|
+
* B10 — mint the next call id without recording anything yet.
|
|
319
|
+
*
|
|
320
|
+
* `server.ts` calls this before `renderAnswer` so the envelope can carry
|
|
321
|
+
* the id as `callId` (`render.ts`'s own doc on that field), and records
|
|
322
|
+
* under the same value afterwards with `recordCallWithId` — one id, used
|
|
323
|
+
* for both, rather than one minted for the reply and a different one
|
|
324
|
+
* minted later for the record. Exposed as its own method (rather than
|
|
325
|
+
* folded into `recordCall`) because the id has to exist *before* the
|
|
326
|
+
* result it will be recorded with does; there is no result yet at the
|
|
327
|
+
* point this is called.
|
|
328
|
+
*/
|
|
329
|
+
allocateCallId(): string;
|
|
317
330
|
/**
|
|
318
331
|
* MK-12 — `verify_claim`'s fact boundary. Called once per completed tool
|
|
319
332
|
* call from `server.ts`, right after rendering, with the exact
|
|
@@ -328,6 +341,15 @@ export declare class Session {
|
|
|
328
341
|
* not a defect to guard against, the mechanism doing its job.
|
|
329
342
|
*/
|
|
330
343
|
recordCall(tool: string, args: Record<string, unknown>, result: Record<string, unknown>): RecordedToolCall;
|
|
344
|
+
/**
|
|
345
|
+
* `recordCall`, under an id minted earlier by `allocateCallId` rather than
|
|
346
|
+
* one minted here — B10's fix. The id a caller reads off a real reply's
|
|
347
|
+
* `callId` is this exact value, so `recordedCall(id)` finds it: the
|
|
348
|
+
* positive path that was previously unreachable because the id the
|
|
349
|
+
* envelope would need did not exist until one step after the envelope was
|
|
350
|
+
* already built.
|
|
351
|
+
*/
|
|
352
|
+
recordCallWithId(id: string, tool: string, args: Record<string, unknown>, result: Record<string, unknown>): RecordedToolCall;
|
|
331
353
|
/** All calls recorded this session, oldest first. */
|
|
332
354
|
recordedCalls(): readonly RecordedToolCall[];
|
|
333
355
|
recordedCall(id: string): RecordedToolCall | undefined;
|
package/dist/session.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../src/session.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAMH,OAAO,KAAK,EAAE,aAAa,EAAsB,iBAAiB,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAClG,OAAO,EAOL,KAAK,iBAAiB,EACtB,KAAK,KAAK,EACX,MAAM,eAAe,CAAC;AAEvB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAiC,KAAK,cAAc,EAAE,KAAK,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AACtH,OAAO,EAAgC,KAAK,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAClG,OAAO,EAAiB,KAAK,UAAU,EAAE,MAAM,eAAe,CAAC;AAE/D,MAAM,WAAW,YAAY;IAC3B,wEAAwE;IACxE,QAAQ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,YAAY,CAAC,EAAE,EAAE,MAAM,GAAG,gBAAgB,GAAG,SAAS;CAGvD"}
|
package/dist/session.js
CHANGED
|
@@ -562,6 +562,21 @@ export class Session {
|
|
|
562
562
|
await this.#browserSessions.reapAll("clientDisconnect");
|
|
563
563
|
this.close();
|
|
564
564
|
}
|
|
565
|
+
/**
|
|
566
|
+
* B10 — mint the next call id without recording anything yet.
|
|
567
|
+
*
|
|
568
|
+
* `server.ts` calls this before `renderAnswer` so the envelope can carry
|
|
569
|
+
* the id as `callId` (`render.ts`'s own doc on that field), and records
|
|
570
|
+
* under the same value afterwards with `recordCallWithId` — one id, used
|
|
571
|
+
* for both, rather than one minted for the reply and a different one
|
|
572
|
+
* minted later for the record. Exposed as its own method (rather than
|
|
573
|
+
* folded into `recordCall`) because the id has to exist *before* the
|
|
574
|
+
* result it will be recorded with does; there is no result yet at the
|
|
575
|
+
* point this is called.
|
|
576
|
+
*/
|
|
577
|
+
allocateCallId() {
|
|
578
|
+
return `call-${this.#nextCallId++}`;
|
|
579
|
+
}
|
|
565
580
|
/**
|
|
566
581
|
* MK-12 — `verify_claim`'s fact boundary. Called once per completed tool
|
|
567
582
|
* call from `server.ts`, right after rendering, with the exact
|
|
@@ -576,7 +591,18 @@ export class Session {
|
|
|
576
591
|
* not a defect to guard against, the mechanism doing its job.
|
|
577
592
|
*/
|
|
578
593
|
recordCall(tool, args, result) {
|
|
579
|
-
|
|
594
|
+
return this.recordCallWithId(this.allocateCallId(), tool, args, result);
|
|
595
|
+
}
|
|
596
|
+
/**
|
|
597
|
+
* `recordCall`, under an id minted earlier by `allocateCallId` rather than
|
|
598
|
+
* one minted here — B10's fix. The id a caller reads off a real reply's
|
|
599
|
+
* `callId` is this exact value, so `recordedCall(id)` finds it: the
|
|
600
|
+
* positive path that was previously unreachable because the id the
|
|
601
|
+
* envelope would need did not exist until one step after the envelope was
|
|
602
|
+
* already built.
|
|
603
|
+
*/
|
|
604
|
+
recordCallWithId(id, tool, args, result) {
|
|
605
|
+
const call = { id, tool, args, result, at: Date.now() };
|
|
580
606
|
this.#calls.push(call);
|
|
581
607
|
return call;
|
|
582
608
|
}
|