@mcp-index/sdk 0.1.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/LICENSE +133 -0
- package/README.md +49 -0
- package/dist/src/canonical.d.ts +42 -0
- package/dist/src/canonical.d.ts.map +1 -0
- package/dist/src/canonical.js +231 -0
- package/dist/src/canonical.js.map +1 -0
- package/dist/src/errors.d.ts +39 -0
- package/dist/src/errors.d.ts.map +1 -0
- package/dist/src/errors.js +79 -0
- package/dist/src/errors.js.map +1 -0
- package/dist/src/gate.d.ts +128 -0
- package/dist/src/gate.d.ts.map +1 -0
- package/dist/src/gate.js +626 -0
- package/dist/src/gate.js.map +1 -0
- package/dist/src/index.d.ts +26 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +20 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/lexicon.d.ts +15 -0
- package/dist/src/lexicon.d.ts.map +1 -0
- package/dist/src/lexicon.js +70 -0
- package/dist/src/lexicon.js.map +1 -0
- package/dist/src/outcomes.d.ts +67 -0
- package/dist/src/outcomes.d.ts.map +1 -0
- package/dist/src/outcomes.js +159 -0
- package/dist/src/outcomes.js.map +1 -0
- package/dist/src/preflight.d.ts +54 -0
- package/dist/src/preflight.d.ts.map +1 -0
- package/dist/src/preflight.js +0 -0
- package/dist/src/preflight.js.map +1 -0
- package/dist/src/provenance.d.ts +95 -0
- package/dist/src/provenance.d.ts.map +1 -0
- package/dist/src/provenance.js +221 -0
- package/dist/src/provenance.js.map +1 -0
- package/dist/src/render.d.ts +10 -0
- package/dist/src/render.d.ts.map +1 -0
- package/dist/src/render.js +38 -0
- package/dist/src/render.js.map +1 -0
- package/dist/src/risk.d.ts +32 -0
- package/dist/src/risk.d.ts.map +1 -0
- package/dist/src/risk.js +179 -0
- package/dist/src/risk.js.map +1 -0
- package/dist/src/scan.d.ts +15 -0
- package/dist/src/scan.d.ts.map +1 -0
- package/dist/src/scan.js +88 -0
- package/dist/src/scan.js.map +1 -0
- package/dist/src/schemaDiff.d.ts +36 -0
- package/dist/src/schemaDiff.d.ts.map +1 -0
- package/dist/src/schemaDiff.js +448 -0
- package/dist/src/schemaDiff.js.map +1 -0
- package/dist/src/wrap.d.ts +77 -0
- package/dist/src/wrap.d.ts.map +1 -0
- package/dist/src/wrap.js +554 -0
- package/dist/src/wrap.js.map +1 -0
- package/package.json +44 -0
package/dist/src/wrap.js
ADDED
|
@@ -0,0 +1,554 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pre-flight drift INTERCEPTOR — the TypeScript SDK-wrapper surface, at parity
|
|
3
|
+
* with Python `tooling/cse/preflight_intercept.py`.
|
|
4
|
+
*
|
|
5
|
+
* `wrap(session)` returns a transparent JS `Proxy` over the real
|
|
6
|
+
* `@modelcontextprotocol/sdk` `Client`: every method/prop passes through the
|
|
7
|
+
* get-trap UNTOUCHED, EXCEPT the three gated seams:
|
|
8
|
+
* - `listTools` — TOFU-pin every observed tool's PUBLIC contract.
|
|
9
|
+
* - `callTool` — run the shared Gate before delegating; HOLD on drift.
|
|
10
|
+
* - `request` — the low-level RPC chokepoint (the TS analog of Python's
|
|
11
|
+
* `send_request`). `callTool` is sugar over `request({method:'tools/call'})`,
|
|
12
|
+
* so a caller can invoke any tool straight through `request`; we gate a
|
|
13
|
+
* `tools/call` there too, or the pre-flight check is a paper wall.
|
|
14
|
+
* - `requestStream` — the EXPERIMENTAL streaming chokepoint. The SDK's task
|
|
15
|
+
* surface (`client.experimental.tasks.callToolStream`) invokes a tool via
|
|
16
|
+
* `requestStream({method:'tools/call'})`, a SECOND RPC path that does NOT go
|
|
17
|
+
* through `request`. `requestStream` is also reachable directly on the
|
|
18
|
+
* session. We gate a `tools/call` on BOTH the session-level `requestStream`
|
|
19
|
+
* AND a wrapped `experimental` accessor (whose `tasks.callToolStream` /
|
|
20
|
+
* `tasks.requestStream` desugar to it), or the streaming surface is a hole
|
|
21
|
+
* in the wall. The gate runs PRE-FLIGHT: a HELD verdict yields a throwing
|
|
22
|
+
* async generator that NEVER touches the upstream stream (fail-closed).
|
|
23
|
+
*
|
|
24
|
+
* NO CREDENTIAL (structural): the wrapper holds NO token, NO auth, opens NO
|
|
25
|
+
* connection. It reuses the wrapped session's own authenticated transport. The
|
|
26
|
+
* shared Gate reads only the PUBLIC contract.
|
|
27
|
+
*/
|
|
28
|
+
import { Gate, HELD_PROVENANCE_UNAVAILABLE_BANNER, INTERNAL_ERROR_HELD_MESSAGE, isInternalErrorVerdict, renderHoldBanner, behaviourObserved, } from "./gate.js";
|
|
29
|
+
import { Decision, utcNowIso } from "./preflight.js";
|
|
30
|
+
import { ChangeKind } from "./schemaDiff.js";
|
|
31
|
+
import { Operation } from "./errors.js";
|
|
32
|
+
import { Action } from "./outcomes.js";
|
|
33
|
+
import { surfaceProvenance } from "./provenance.js";
|
|
34
|
+
const DEFAULT_BEHAVIORAL_MANDATED_KINDS = new Set([
|
|
35
|
+
ChangeKind.OUTPUT_SCHEMA_CHANGED,
|
|
36
|
+
ChangeKind.ANNOTATION_FLIP_TO_DESTRUCTIVE,
|
|
37
|
+
]);
|
|
38
|
+
/** A HOLD raised before delegating to the wrapped session. Carries the structured
|
|
39
|
+
* verdict + (when a complete provenance backs the finding) the provenance. Honest
|
|
40
|
+
* voice: a HOLD is a CONTRACT DIFF, not a safety verdict. */
|
|
41
|
+
export class PreflightHold extends Error {
|
|
42
|
+
verdict;
|
|
43
|
+
provenance;
|
|
44
|
+
constructor(verdict, provenance, message) {
|
|
45
|
+
super(message);
|
|
46
|
+
this.name = "PreflightHold";
|
|
47
|
+
this.verdict = verdict;
|
|
48
|
+
this.provenance = provenance;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
// Raw transport seams we REFUSE to delegate (defense-in-depth) — so a caller
|
|
52
|
+
// cannot hand-assemble a tools/call frame straight to the socket, bypassing the
|
|
53
|
+
// gated `callTool` / `request` / `requestStream` chokepoints. Mirrors the Python
|
|
54
|
+
// `_DENY_DELEGATION` set, but adapted to the TS SDK's ACTUAL seams.
|
|
55
|
+
//
|
|
56
|
+
// CRITICAL (audit H1): the TS SDK `Protocol` base exposes a PUBLIC `get transport()`
|
|
57
|
+
// returning the live `Transport`, whose `.send(message)` accepts ANY JSONRPCMessage.
|
|
58
|
+
// Left delegated, a caller could do `wrapped.transport.send({...tools/call...})` and
|
|
59
|
+
// invoke a DRIFTED tool straight to the socket — a real bypass of the STATED defense
|
|
60
|
+
// in this file's docstring. So `transport` MUST be denied through the wrapper (returns
|
|
61
|
+
// undefined). This is SAFE: transport lifecycle (connect/close) is owned by whoever
|
|
62
|
+
// created the session — `Protocol.connect()` takes the transport as an ARGUMENT and
|
|
63
|
+
// writes the private `_transport`; `close()` reads `_transport` directly — neither
|
|
64
|
+
// reaches the wrapper's `transport` accessor. No legitimate tool-operation path in the
|
|
65
|
+
// integration tests or the documented public API needs `wrapped.transport`.
|
|
66
|
+
//
|
|
67
|
+
// `_transport` is denied for the same reason; `send` is denied defensively in case a
|
|
68
|
+
// future SDK surfaces a raw send on the session itself (no public `send` exists on the
|
|
69
|
+
// Protocol/Client today — it lives only on the `Transport` reached via `transport`).
|
|
70
|
+
// The Python SDK names (`_read_stream`/`_write_stream`/anyio readers) do NOT exist on
|
|
71
|
+
// the TS SDK — they were vestigial copies and are DROPPED (audit L1: keep the list
|
|
72
|
+
// honest, only real seams).
|
|
73
|
+
const DENY_DELEGATION = new Set([
|
|
74
|
+
"transport",
|
|
75
|
+
"_transport",
|
|
76
|
+
"send",
|
|
77
|
+
]);
|
|
78
|
+
/** Pull PUBLIC tool definitions out of whatever `listTools()` returned. Tolerant
|
|
79
|
+
* (the listing is attacker-derived): a `{tools: [...]}` object, a bare list, each
|
|
80
|
+
* entry a dict or an SDK Tool object. Normalizes to the PUBLIC-contract dict. */
|
|
81
|
+
function toolsFromResult(result) {
|
|
82
|
+
let raw;
|
|
83
|
+
if (result !== null && typeof result === "object" && !Array.isArray(result)) {
|
|
84
|
+
raw = result["tools"];
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
raw = result;
|
|
88
|
+
}
|
|
89
|
+
if (!Array.isArray(raw))
|
|
90
|
+
return [];
|
|
91
|
+
const out = [];
|
|
92
|
+
for (const entry of raw) {
|
|
93
|
+
const defn = toolToDict(entry);
|
|
94
|
+
if (defn !== null)
|
|
95
|
+
out.push(defn);
|
|
96
|
+
}
|
|
97
|
+
return out;
|
|
98
|
+
}
|
|
99
|
+
function attrOrKey(entry, key) {
|
|
100
|
+
if (entry !== null && typeof entry === "object") {
|
|
101
|
+
return entry[key];
|
|
102
|
+
}
|
|
103
|
+
return undefined;
|
|
104
|
+
}
|
|
105
|
+
function toolToDict(entry) {
|
|
106
|
+
const name = attrOrKey(entry, "name");
|
|
107
|
+
if (typeof name !== "string" || !name)
|
|
108
|
+
return null;
|
|
109
|
+
const desc = attrOrKey(entry, "description");
|
|
110
|
+
const schema = attrOrKey(entry, "inputSchema");
|
|
111
|
+
const inSch = schema !== null && typeof schema === "object" && !Array.isArray(schema) ? schema : {};
|
|
112
|
+
const record = {
|
|
113
|
+
name,
|
|
114
|
+
description: desc !== undefined && desc !== null ? String(desc) : "",
|
|
115
|
+
inputSchema: inSch,
|
|
116
|
+
};
|
|
117
|
+
const ann = attrOrKey(entry, "annotations");
|
|
118
|
+
if (ann !== null && typeof ann === "object" && !Array.isArray(ann))
|
|
119
|
+
record["annotations"] = ann;
|
|
120
|
+
const outp = attrOrKey(entry, "outputSchema");
|
|
121
|
+
if (outp !== null && typeof outp === "object" && !Array.isArray(outp))
|
|
122
|
+
record["outputSchema"] = outp;
|
|
123
|
+
return record;
|
|
124
|
+
}
|
|
125
|
+
/** DUCK-TYPE a `request` argument -> (method, toolName). The TS SDK passes a
|
|
126
|
+
* `{method, params}` request object. FAIL-CLOSED: a `tools/call` whose name
|
|
127
|
+
* cannot be read runs under "" -> the no-pin path fail-closes. */
|
|
128
|
+
function requestMethodAndTool(request) {
|
|
129
|
+
try {
|
|
130
|
+
const root = request;
|
|
131
|
+
const method = root?.["method"];
|
|
132
|
+
const methodStr = typeof method === "string" ? method : null;
|
|
133
|
+
if (methodStr !== "tools/call")
|
|
134
|
+
return [methodStr, ""];
|
|
135
|
+
const params = root["params"];
|
|
136
|
+
const name = params?.["name"];
|
|
137
|
+
return ["tools/call", typeof name === "string" ? name : ""];
|
|
138
|
+
}
|
|
139
|
+
catch {
|
|
140
|
+
return ["tools/call", ""];
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
function isThenable(v) {
|
|
144
|
+
return v !== null && typeof v === "object" && typeof v.then === "function";
|
|
145
|
+
}
|
|
146
|
+
/** The intercepting core. Holds the shared Gate + the last-observed PUBLIC
|
|
147
|
+
* contracts (so the Gate re-derives the live hash with no second round-trip) +
|
|
148
|
+
* the optional on-device stores. NO token, NO transport. */
|
|
149
|
+
class Interceptor {
|
|
150
|
+
session;
|
|
151
|
+
gate;
|
|
152
|
+
onHold;
|
|
153
|
+
autoValidateBehavior;
|
|
154
|
+
stats;
|
|
155
|
+
outcomes;
|
|
156
|
+
observed = new Map();
|
|
157
|
+
lastSurface = new Map();
|
|
158
|
+
// The tier the LAST gated call for a tool ACTUALLY reached, for its provenance (mirrors the
|
|
159
|
+
// Python wrapper's `_last_tier_reached`). AUDIT-LOW FLOOR FIX: tier_reached reflects what
|
|
160
|
+
// RAN — an INCONCLUSIVE only OFFERED a behavioral check floors to 0 (→ STRUCTURAL_ONLY),
|
|
161
|
+
// never a false BEHAVIORAL/3 stamp; 3 only when a behavioral verifier actually ran.
|
|
162
|
+
lastTierReached = new Map();
|
|
163
|
+
constructor(session, opts) {
|
|
164
|
+
this.session = session;
|
|
165
|
+
this.gate = new Gate({
|
|
166
|
+
pin: opts.pin,
|
|
167
|
+
serverId: opts.serverId,
|
|
168
|
+
failOpen: opts.failOpen,
|
|
169
|
+
autoAcceptBenign: opts.autoAcceptBenign,
|
|
170
|
+
now: opts.now ?? utcNowIso,
|
|
171
|
+
ownership: opts.ownership,
|
|
172
|
+
behavioralMandatedKinds: opts.behavioralMandatedKinds ?? DEFAULT_BEHAVIORAL_MANDATED_KINDS,
|
|
173
|
+
verifier: opts.verifier ?? null,
|
|
174
|
+
posture: opts.posture,
|
|
175
|
+
errors: opts.errors ?? null,
|
|
176
|
+
});
|
|
177
|
+
this.onHold = opts.onHold ?? null;
|
|
178
|
+
this.autoValidateBehavior = opts.autoValidateBehavior ?? false;
|
|
179
|
+
this.stats = opts.stats ?? null;
|
|
180
|
+
this.outcomes = opts.outcomes ?? null;
|
|
181
|
+
}
|
|
182
|
+
// ------------------------------------------------------------- list_tools
|
|
183
|
+
listTools(target, args) {
|
|
184
|
+
const result = target.listTools.apply(target, args);
|
|
185
|
+
if (isThenable(result)) {
|
|
186
|
+
return result.then((r) => {
|
|
187
|
+
this.observe(r);
|
|
188
|
+
return r;
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
this.observe(result);
|
|
192
|
+
return result;
|
|
193
|
+
}
|
|
194
|
+
observe(result) {
|
|
195
|
+
try {
|
|
196
|
+
const tools = toolsFromResult(result);
|
|
197
|
+
for (const defn of tools) {
|
|
198
|
+
const name = defn["name"];
|
|
199
|
+
this.observed.set(name, defn);
|
|
200
|
+
this.gate.observe(name, defn);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
catch (exc) {
|
|
204
|
+
this.gate.captureError(exc, Operation.LIST_TOOLS, "wrap.observe");
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
// -------------------------------------------------------------- call_tool
|
|
208
|
+
callTool(target, args) {
|
|
209
|
+
// SDK: callTool(params, resultSchema?, options?), params = {name, arguments}.
|
|
210
|
+
const params = (args[0] ?? {});
|
|
211
|
+
const name = typeof params["name"] === "string" ? params["name"] : "";
|
|
212
|
+
const verdict = this.decideOrInternalHold(name, Operation.CALL_TOOL);
|
|
213
|
+
if (verdict.decision === Decision.PROCEED) {
|
|
214
|
+
if (verdict.failOpenWarning)
|
|
215
|
+
warn(verdict);
|
|
216
|
+
return target.callTool.apply(target, args);
|
|
217
|
+
}
|
|
218
|
+
return this.refuseAsync(name, verdict);
|
|
219
|
+
}
|
|
220
|
+
// ------------------------------------------------------------ request
|
|
221
|
+
request(target, args) {
|
|
222
|
+
const reqFn = target.request;
|
|
223
|
+
if (typeof reqFn !== "function") {
|
|
224
|
+
throw new TypeError("wrapped session has no request() method");
|
|
225
|
+
}
|
|
226
|
+
const [method, toolName] = requestMethodAndTool(args[0]);
|
|
227
|
+
if (method !== "tools/call") {
|
|
228
|
+
return reqFn.apply(target, args);
|
|
229
|
+
}
|
|
230
|
+
const verdict = this.decideOrInternalHold(toolName, Operation.SEND_REQUEST);
|
|
231
|
+
if (verdict.decision === Decision.PROCEED) {
|
|
232
|
+
if (verdict.failOpenWarning)
|
|
233
|
+
warn(verdict);
|
|
234
|
+
return reqFn.apply(target, args);
|
|
235
|
+
}
|
|
236
|
+
// The SDK `request()` is async (returns a Promise<SchemaOutput>), so — like
|
|
237
|
+
// `callTool` — a HOLD must surface as a REJECTED Promise, not a sync throw,
|
|
238
|
+
// or the wrapper is not a transparent drop-in (a caller's `await`/`.catch`
|
|
239
|
+
// would miss the hold). Refusal goes through the SAME `refuseAsync` as
|
|
240
|
+
// `callTool` (one shared block, mirroring Python's shared refusal): same
|
|
241
|
+
// onHold dispatch, same provenance/banner, same PreflightHold; the wrapped
|
|
242
|
+
// session is NEVER touched on this path.
|
|
243
|
+
return this.refuseAsync(toolName, verdict);
|
|
244
|
+
}
|
|
245
|
+
// ------------------------------------------------------- requestStream
|
|
246
|
+
/** Gate the EXPERIMENTAL streaming RPC chokepoint. `requestStream` takes the
|
|
247
|
+
* same `{method, params}` request shape as `request`, so we parse + gate a
|
|
248
|
+
* `tools/call` identically. The SDK signature returns an AsyncGenerator, so
|
|
249
|
+
* the gate must surface PRE-FLIGHT: a HELD verdict returns a generator that
|
|
250
|
+
* THROWS on first iteration WITHOUT ever delegating to the upstream stream
|
|
251
|
+
* (the real `requestStream` is never called -> upstream touched 0 times,
|
|
252
|
+
* fail-closed). A non-`tools/call` (or PROCEED) delegates the real generator
|
|
253
|
+
* untouched. `streamFn` is the upstream `requestStream` bound to the right
|
|
254
|
+
* receiver (the raw session for the session-level seam; the SDK's own
|
|
255
|
+
* `_client` for the experimental seam, which it captured itself). */
|
|
256
|
+
requestStream(streamFn, receiver, args) {
|
|
257
|
+
const [method, toolName] = requestMethodAndTool(args[0]);
|
|
258
|
+
if (method !== "tools/call") {
|
|
259
|
+
return streamFn.apply(receiver, args);
|
|
260
|
+
}
|
|
261
|
+
const verdict = this.decideOrInternalHold(toolName, Operation.SEND_REQUEST);
|
|
262
|
+
if (verdict.decision === Decision.PROCEED) {
|
|
263
|
+
if (verdict.failOpenWarning)
|
|
264
|
+
warn(verdict);
|
|
265
|
+
return streamFn.apply(receiver, args);
|
|
266
|
+
}
|
|
267
|
+
return this.refuseStream(toolName, verdict);
|
|
268
|
+
}
|
|
269
|
+
/** A HELD streaming seam: an async generator that raises the SAME
|
|
270
|
+
* `PreflightHold` (or onHold result) as `refuseAsync`, on first iteration,
|
|
271
|
+
* before the upstream stream is ever opened. Shares `heldSurface` / `onHold`
|
|
272
|
+
* with the async refusal block so streaming and non-streaming holds are
|
|
273
|
+
* byte-for-byte identical (same provenance, banner, PreflightHold). */
|
|
274
|
+
async *refuseStream(name, verdict) {
|
|
275
|
+
if (this.onHold !== null) {
|
|
276
|
+
yield await Promise.resolve(this.onHold(verdict));
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
279
|
+
const [prov, banner] = this.heldSurface(name, verdict);
|
|
280
|
+
throw new PreflightHold(verdict, prov, banner);
|
|
281
|
+
}
|
|
282
|
+
/** Build a gated mirror of the SDK's `experimental` accessor. The SDK's
|
|
283
|
+
* `experimental.tasks` holds the UNWRAPPED client, so its `callToolStream` /
|
|
284
|
+
* `requestStream` bypass the proxy and hit `_client.requestStream` directly.
|
|
285
|
+
* We re-route BOTH tool-invoking stream surfaces through `this.requestStream`
|
|
286
|
+
* (the same gate as the session-level seam) by calling the SDK's own methods
|
|
287
|
+
* — preserving their task-augmentation / output-schema-validation behaviour —
|
|
288
|
+
* but only AFTER a PROCEED verdict; a HELD verdict throws before any upstream
|
|
289
|
+
* stream is opened. Every non-stream member of `tasks` (getTask, listTasks,
|
|
290
|
+
* cancelTask, …) and the rest of `experimental` delegate UNTOUCHED. */
|
|
291
|
+
wrapExperimental(real) {
|
|
292
|
+
const self = this;
|
|
293
|
+
const realTasks = real.tasks;
|
|
294
|
+
const tasksProxy = new Proxy(realTasks, {
|
|
295
|
+
get(t, prop, _recv) {
|
|
296
|
+
if (prop === "callToolStream") {
|
|
297
|
+
// callToolStream(params, resultSchema?, options?) desugars to
|
|
298
|
+
// requestStream({method:'tools/call', params}, ...). Gate on params.name
|
|
299
|
+
// PRE-FLIGHT; only on PROCEED do we invoke the SDK's real
|
|
300
|
+
// callToolStream (so its task/output-schema logic is preserved).
|
|
301
|
+
return (...a) => {
|
|
302
|
+
const params = (a[0] ?? {});
|
|
303
|
+
const toolName = typeof params["name"] === "string" ? params["name"] : "";
|
|
304
|
+
const verdict = self.decideOrInternalHold(toolName, Operation.SEND_REQUEST);
|
|
305
|
+
if (verdict.decision === Decision.PROCEED) {
|
|
306
|
+
if (verdict.failOpenWarning)
|
|
307
|
+
warn(verdict);
|
|
308
|
+
return realTasks.callToolStream.apply(realTasks, a);
|
|
309
|
+
}
|
|
310
|
+
return self.refuseStream(toolName, verdict);
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
if (prop === "requestStream") {
|
|
314
|
+
// tasks.requestStream(request, ...) takes the raw {method,params} shape —
|
|
315
|
+
// route it through the SAME gate as the session-level seam, delegating
|
|
316
|
+
// the real method (bound to realTasks) on PROCEED.
|
|
317
|
+
return (...a) => self.requestStream(realTasks.requestStream, realTasks, a);
|
|
318
|
+
}
|
|
319
|
+
const v = Reflect.get(t, prop, t);
|
|
320
|
+
return typeof v === "function" ? v.bind(t) : v;
|
|
321
|
+
},
|
|
322
|
+
});
|
|
323
|
+
return new Proxy(real, {
|
|
324
|
+
get(t, prop, _recv) {
|
|
325
|
+
if (prop === "tasks")
|
|
326
|
+
return tasksProxy;
|
|
327
|
+
const v = Reflect.get(t, prop, t);
|
|
328
|
+
return typeof v === "function" ? v.bind(t) : v;
|
|
329
|
+
},
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
/** The SINGLE refusal path for BOTH gated async seams (`callTool` and the
|
|
333
|
+
* low-level `request` chokepoint) — the TS analog of the one refusal block
|
|
334
|
+
* Python's `call_tool` / `send_request` share. Both SDK seams return a Promise,
|
|
335
|
+
* so a HOLD surfaces as a REJECTED Promise (never a sync throw), so the wrapper
|
|
336
|
+
* stays a transparent drop-in: a caller's `await` / `.catch` sees the hold. The
|
|
337
|
+
* wrapped session is NEVER touched on this path (fail-closed). When an `onHold`
|
|
338
|
+
* callback is set we return its result resolved to a Promise, so a caller that
|
|
339
|
+
* suppresses the throw still gets a thenable like the upstream would yield. */
|
|
340
|
+
refuseAsync(name, verdict) {
|
|
341
|
+
if (this.onHold !== null)
|
|
342
|
+
return Promise.resolve(this.onHold(verdict));
|
|
343
|
+
const [prov, banner] = this.heldSurface(name, verdict);
|
|
344
|
+
return Promise.reject(new PreflightHold(verdict, prov, banner));
|
|
345
|
+
}
|
|
346
|
+
decideOrInternalHold(name, operation) {
|
|
347
|
+
try {
|
|
348
|
+
let stat = this.gate.evaluate(name, this.observed.get(name) ?? null);
|
|
349
|
+
stat = this.maybeAutoValidate(name, stat);
|
|
350
|
+
const verdict = this.gate.applyPosture(stat);
|
|
351
|
+
this.recordCall(name, stat, verdict);
|
|
352
|
+
return verdict;
|
|
353
|
+
}
|
|
354
|
+
catch (exc) {
|
|
355
|
+
this.gate.captureError(exc, operation, "wrap.decideOrInternalHold");
|
|
356
|
+
return this.gate.internalErrorVerdict(name);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
maybeAutoValidate(name, stat) {
|
|
360
|
+
if (stat.decision === Decision.INCONCLUSIVE && this.autoValidateBehavior && this.gate.verifier !== null) {
|
|
361
|
+
const [resolved, outcome] = this.gate.runBehavioralOutcome(name, this.observed.get(name) ?? null, stat, this.gate.verifier);
|
|
362
|
+
// Behaviour ACTUALLY ran. Record tier 3 ONLY for an OBSERVED result — CLEARED or FAILED.
|
|
363
|
+
// UNAVAILABLE / DECLINED / never-consulted observed nothing → floor to 0. The tier is
|
|
364
|
+
// keyed on the STRUCTURED outcome enum, NEVER on the verifier-controlled reason string (a
|
|
365
|
+
// substring check there would let an UNAVAILABLE whose reason contains "behavioral
|
|
366
|
+
// validation FAILED" forge a tier-3 stamp on evidence that never ran).
|
|
367
|
+
this.lastTierReached.set(name, behaviourObserved(outcome) ? 3 : 0);
|
|
368
|
+
return resolved;
|
|
369
|
+
}
|
|
370
|
+
// INCONCLUSIVE only OFFERED a behavioral check (no auto-validate / no verifier) → nothing
|
|
371
|
+
// ran → floor to 0 (the audit-LOW floor fix). Any other static verdict is tier 0 too.
|
|
372
|
+
this.lastTierReached.set(name, 0);
|
|
373
|
+
return stat;
|
|
374
|
+
}
|
|
375
|
+
// ------------------------------------------------------------- stats record
|
|
376
|
+
recordCall(name, stat, effective) {
|
|
377
|
+
if (this.stats !== null) {
|
|
378
|
+
if (effective.decision === Decision.HOLD || effective.decision === Decision.INCONCLUSIVE) {
|
|
379
|
+
this.stats.recordHold();
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
this.captureOutcome(name, stat, effective);
|
|
383
|
+
}
|
|
384
|
+
captureOutcome(name, stat, effective) {
|
|
385
|
+
if (this.outcomes === null)
|
|
386
|
+
return;
|
|
387
|
+
if (isInternalErrorVerdict(effective) || isInternalErrorVerdict(stat))
|
|
388
|
+
return;
|
|
389
|
+
if (effective.decision === Decision.HOLD || effective.decision === Decision.INCONCLUSIVE) {
|
|
390
|
+
const prov = this.provenanceFor(name, effective);
|
|
391
|
+
if (prov === null)
|
|
392
|
+
return;
|
|
393
|
+
this.lastSurface.set(name, this.outcomes.recordSurface(prov, this.gate.posture));
|
|
394
|
+
}
|
|
395
|
+
else if (effective.decision === Decision.PROCEED &&
|
|
396
|
+
(stat.decision === Decision.HOLD || stat.decision === Decision.INCONCLUSIVE) &&
|
|
397
|
+
stat.drift.length > 0) {
|
|
398
|
+
const prov = this.provenanceFor(name, stat);
|
|
399
|
+
if (prov === null)
|
|
400
|
+
return;
|
|
401
|
+
const sid = this.outcomes.recordSurface(prov, this.gate.posture);
|
|
402
|
+
this.lastSurface.set(name, sid);
|
|
403
|
+
this.outcomes.recordResponse(sid, Action.OVERRIDE);
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
provenanceFor(name, verdict) {
|
|
407
|
+
const pinned = this.gate.pinFor(name);
|
|
408
|
+
return surfaceProvenance(verdict, {
|
|
409
|
+
serverId: this.gate.serverId,
|
|
410
|
+
tool: name,
|
|
411
|
+
oldSchema: pinned !== null ? pinned.schema : null,
|
|
412
|
+
newSchema: this.observed.get(name) ?? null,
|
|
413
|
+
tierReached: this.lastTierReached.get(name) ?? 0,
|
|
414
|
+
source: "wrapper",
|
|
415
|
+
});
|
|
416
|
+
}
|
|
417
|
+
heldSurface(name, verdict) {
|
|
418
|
+
if (isInternalErrorVerdict(verdict))
|
|
419
|
+
return [null, INTERNAL_ERROR_HELD_MESSAGE];
|
|
420
|
+
const prov = this.provenanceFor(name, verdict);
|
|
421
|
+
if (prov === null)
|
|
422
|
+
return [null, HELD_PROVENANCE_UNAVAILABLE_BANNER];
|
|
423
|
+
const tally = this.stats !== null ? this.stats.holdsThisMonth() : null;
|
|
424
|
+
return [prov, renderHoldBanner(verdict, tally)];
|
|
425
|
+
}
|
|
426
|
+
holdBanner(verdict) {
|
|
427
|
+
const [, banner] = this.heldSurface(verdict.toolName, verdict);
|
|
428
|
+
return banner;
|
|
429
|
+
}
|
|
430
|
+
// ----------------------------------------------------- behavioral validation
|
|
431
|
+
validateBehaviorNow(toolName, verifier) {
|
|
432
|
+
const observed = this.observed.get(toolName) ?? null;
|
|
433
|
+
const verdict = this.gate.evaluate(toolName, observed);
|
|
434
|
+
if (verdict.decision === Decision.PROCEED)
|
|
435
|
+
return verdict;
|
|
436
|
+
const chosen = verifier ?? this.gate.verifier;
|
|
437
|
+
if (chosen === null || chosen === undefined)
|
|
438
|
+
return verdict;
|
|
439
|
+
this.recordOutcomeResponse(toolName, Action.ESCALATE);
|
|
440
|
+
const [resolved, outcome] = this.gate.runBehavioralOutcome(toolName, observed, verdict, chosen);
|
|
441
|
+
// Behaviour ACTUALLY ran on demand (the third door) — record tier 3 ONLY for an OBSERVED
|
|
442
|
+
// result (CLEARED or FAILED). UNAVAILABLE / DECLINED / never-consulted floor to 0. Keyed on
|
|
443
|
+
// the STRUCTURED outcome enum, NEVER on the verifier-controlled reason string (mirrors the
|
|
444
|
+
// Python wrapper).
|
|
445
|
+
if (behaviourObserved(outcome)) {
|
|
446
|
+
this.lastTierReached.set(toolName, 3);
|
|
447
|
+
}
|
|
448
|
+
return resolved;
|
|
449
|
+
}
|
|
450
|
+
// ------------------------------------------------------------------- repin
|
|
451
|
+
repin(tool) {
|
|
452
|
+
const written = [];
|
|
453
|
+
const names = tool !== undefined ? [tool] : [...this.observed.keys()].sort();
|
|
454
|
+
for (const name of names) {
|
|
455
|
+
const observed = this.observed.get(name);
|
|
456
|
+
if (observed === undefined)
|
|
457
|
+
continue;
|
|
458
|
+
written.push(this.gate.repinOne(name, observed));
|
|
459
|
+
if (this.stats !== null)
|
|
460
|
+
this.stats.recordRepin();
|
|
461
|
+
this.recordOutcomeResponse(name, Action.REPIN);
|
|
462
|
+
}
|
|
463
|
+
return written;
|
|
464
|
+
}
|
|
465
|
+
recordOutcomeResponse(name, action) {
|
|
466
|
+
if (this.outcomes === null)
|
|
467
|
+
return;
|
|
468
|
+
const sid = this.lastSurface.get(name);
|
|
469
|
+
if (sid === undefined)
|
|
470
|
+
return;
|
|
471
|
+
this.outcomes.recordResponse(sid, action);
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
function warn(verdict) {
|
|
475
|
+
process.stderr.write(`preflight WARNING fail-open: PROCEED on un-checkable tool ` +
|
|
476
|
+
`${verdict.serverId}/${verdict.toolName} — ${verdict.reason}\n`);
|
|
477
|
+
}
|
|
478
|
+
// The wrapper's OWN management methods — names that shadow delegation.
|
|
479
|
+
const OWN_METHODS = new Set(["repin", "validateBehaviorNow", "holdBanner", "__interceptor__"]);
|
|
480
|
+
export function wrap(session, opts) {
|
|
481
|
+
const sess = session;
|
|
482
|
+
const interceptor = new Interceptor(sess, opts);
|
|
483
|
+
const handler = {
|
|
484
|
+
get(target, prop, _receiver) {
|
|
485
|
+
if (typeof prop !== "string") {
|
|
486
|
+
return Reflect.get(target, prop, target);
|
|
487
|
+
}
|
|
488
|
+
if (prop === "__interceptor__")
|
|
489
|
+
return interceptor;
|
|
490
|
+
if (prop === "listTools") {
|
|
491
|
+
return (...args) => interceptor.listTools(target, args);
|
|
492
|
+
}
|
|
493
|
+
if (prop === "callTool") {
|
|
494
|
+
return (...args) => interceptor.callTool(target, args);
|
|
495
|
+
}
|
|
496
|
+
if (prop === "request") {
|
|
497
|
+
return (...args) => interceptor.request(target, args);
|
|
498
|
+
}
|
|
499
|
+
if (prop === "requestStream") {
|
|
500
|
+
// The experimental streaming RPC chokepoint, reachable directly on the
|
|
501
|
+
// session. Gate a tools/call here too (parity with `request`), binding
|
|
502
|
+
// the real upstream `requestStream` to the raw target.
|
|
503
|
+
return (...args) => {
|
|
504
|
+
const fn = Reflect.get(target, "requestStream", target);
|
|
505
|
+
if (typeof fn !== "function") {
|
|
506
|
+
throw new TypeError("wrapped session has no requestStream() method");
|
|
507
|
+
}
|
|
508
|
+
return interceptor.requestStream(fn, target, args);
|
|
509
|
+
};
|
|
510
|
+
}
|
|
511
|
+
if (prop === "experimental") {
|
|
512
|
+
// The SDK `experimental` accessor returns an object whose `tasks` holds
|
|
513
|
+
// the UNWRAPPED client; left untouched it bypasses the gate. Return a
|
|
514
|
+
// gated mirror so `tasks.callToolStream` / `tasks.requestStream` run
|
|
515
|
+
// through the SAME gate as the session seams.
|
|
516
|
+
const real = Reflect.get(target, "experimental", target);
|
|
517
|
+
if (real === null || typeof real !== "object")
|
|
518
|
+
return real;
|
|
519
|
+
return interceptor.wrapExperimental(real);
|
|
520
|
+
}
|
|
521
|
+
if (prop === "repin") {
|
|
522
|
+
return (tool) => interceptor.repin(tool);
|
|
523
|
+
}
|
|
524
|
+
if (prop === "validateBehaviorNow") {
|
|
525
|
+
return (toolName, verifier) => interceptor.validateBehaviorNow(toolName, verifier);
|
|
526
|
+
}
|
|
527
|
+
if (prop === "holdBanner") {
|
|
528
|
+
return (verdict) => interceptor.holdBanner(verdict);
|
|
529
|
+
}
|
|
530
|
+
if (DENY_DELEGATION.has(prop)) {
|
|
531
|
+
// Defense-in-depth: refuse to delegate the raw transport seams.
|
|
532
|
+
return undefined;
|
|
533
|
+
}
|
|
534
|
+
// Delegate everything else UNTOUCHED. Bind methods to the real target so
|
|
535
|
+
// `this` inside the SDK points at the real session, never the proxy.
|
|
536
|
+
const value = Reflect.get(target, prop, target);
|
|
537
|
+
if (typeof value === "function") {
|
|
538
|
+
return value.bind(target);
|
|
539
|
+
}
|
|
540
|
+
return value;
|
|
541
|
+
},
|
|
542
|
+
has(target, prop) {
|
|
543
|
+
if (typeof prop === "string" && OWN_METHODS.has(prop))
|
|
544
|
+
return true;
|
|
545
|
+
return Reflect.has(target, prop);
|
|
546
|
+
},
|
|
547
|
+
};
|
|
548
|
+
return new Proxy(sess, handler);
|
|
549
|
+
}
|
|
550
|
+
/** Module-level convenience: re-pin observed contracts on a wrapped session. */
|
|
551
|
+
export function repin(wrapped, tool) {
|
|
552
|
+
return wrapped.repin(tool);
|
|
553
|
+
}
|
|
554
|
+
//# sourceMappingURL=wrap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wrap.js","sourceRoot":"","sources":["../../src/wrap.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;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AK,CAAC,IAAI,CAAC,CAAC;AAC7B,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@mcp-index/sdk",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Pre-flight MCP tool-contract drift interceptor — one-line wrap() over an MCP client session that HOLDs a tool call before your agent runs it when the contract drifted from your pin. No credential handling.",
|
|
5
|
+
"license": "PolyForm-Noncommercial-1.0.0",
|
|
6
|
+
"author": "Bhartis LLC",
|
|
7
|
+
"homepage": "https://mcpindex.ai",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/mcpindex-ai/mcpindex-trust.git",
|
|
11
|
+
"directory": "clients/ts"
|
|
12
|
+
},
|
|
13
|
+
"type": "module",
|
|
14
|
+
"main": "./dist/src/index.js",
|
|
15
|
+
"types": "./dist/src/index.d.ts",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./dist/src/index.d.ts",
|
|
19
|
+
"import": "./dist/src/index.js"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"files": ["dist/src", "README.md", "LICENSE"],
|
|
23
|
+
"publishConfig": {
|
|
24
|
+
"access": "public"
|
|
25
|
+
},
|
|
26
|
+
"engines": {
|
|
27
|
+
"node": ">=20"
|
|
28
|
+
},
|
|
29
|
+
"scripts": {
|
|
30
|
+
"build": "tsc -p tsconfig.json",
|
|
31
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
32
|
+
"test": "tsc -p tsconfig.json && node --test \"dist/test/**/*.test.js\"",
|
|
33
|
+
"prepublishOnly": "npm run build"
|
|
34
|
+
},
|
|
35
|
+
"keywords": ["mcp", "model-context-protocol", "drift", "security", "tofu", "agent"],
|
|
36
|
+
"peerDependencies": {
|
|
37
|
+
"@modelcontextprotocol/sdk": ">=1.0.0"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
41
|
+
"@types/node": "^25.9.1",
|
|
42
|
+
"typescript": "^6.0.3"
|
|
43
|
+
}
|
|
44
|
+
}
|