agentfootprint 12.0.1 → 12.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.
Files changed (45) hide show
  1. package/CAPABILITIES.md +1 -0
  2. package/dist/esm/mcp/callChecks.d.ts +160 -0
  3. package/dist/esm/mcp/callChecks.js +237 -0
  4. package/dist/esm/mcp/callChecks.js.map +1 -0
  5. package/dist/esm/mcp/index.d.ts +3 -1
  6. package/dist/esm/mcp/index.js +7 -0
  7. package/dist/esm/mcp/index.js.map +1 -1
  8. package/dist/esm/mcp/listingGenerations.d.ts +54 -0
  9. package/dist/esm/mcp/listingGenerations.js +75 -0
  10. package/dist/esm/mcp/listingGenerations.js.map +1 -0
  11. package/dist/esm/mcp/mcpClient.js +108 -23
  12. package/dist/esm/mcp/mcpClient.js.map +1 -1
  13. package/dist/esm/mcp/toolList.d.ts +90 -0
  14. package/dist/esm/mcp/toolList.js +123 -0
  15. package/dist/esm/mcp/toolList.js.map +1 -0
  16. package/dist/esm/mcp/types.d.ts +118 -2
  17. package/dist/esm/tool-providers/index.d.ts +2 -2
  18. package/dist/esm/tool-providers/index.js +8 -0
  19. package/dist/esm/tool-providers/index.js.map +1 -1
  20. package/dist/mcp/callChecks.js +247 -0
  21. package/dist/mcp/callChecks.js.map +1 -0
  22. package/dist/mcp/index.js +10 -1
  23. package/dist/mcp/index.js.map +1 -1
  24. package/dist/mcp/listingGenerations.js +80 -0
  25. package/dist/mcp/listingGenerations.js.map +1 -0
  26. package/dist/mcp/mcpClient.js +108 -23
  27. package/dist/mcp/mcpClient.js.map +1 -1
  28. package/dist/mcp/toolList.js +128 -0
  29. package/dist/mcp/toolList.js.map +1 -0
  30. package/dist/tool-providers/index.js +9 -1
  31. package/dist/tool-providers/index.js.map +1 -1
  32. package/dist/types/mcp/callChecks.d.ts +161 -0
  33. package/dist/types/mcp/callChecks.d.ts.map +1 -0
  34. package/dist/types/mcp/index.d.ts +3 -1
  35. package/dist/types/mcp/index.d.ts.map +1 -1
  36. package/dist/types/mcp/listingGenerations.d.ts +55 -0
  37. package/dist/types/mcp/listingGenerations.d.ts.map +1 -0
  38. package/dist/types/mcp/mcpClient.d.ts.map +1 -1
  39. package/dist/types/mcp/toolList.d.ts +91 -0
  40. package/dist/types/mcp/toolList.d.ts.map +1 -0
  41. package/dist/types/mcp/types.d.ts +118 -2
  42. package/dist/types/mcp/types.d.ts.map +1 -1
  43. package/dist/types/tool-providers/index.d.ts +2 -2
  44. package/dist/types/tool-providers/index.d.ts.map +1 -1
  45. package/package.json +1 -1
@@ -45,6 +45,9 @@
45
45
  import { isDevMode } from 'footprintjs';
46
46
  import { callMetaOf, readToolExtras } from './toolExtras.js';
47
47
  import { isToolError, readToolResult, resultModeOf } from './toolResult.js';
48
+ import { listEveryPage, McpToolListIncompleteError } from './toolList.js';
49
+ import { listingsOf } from './listingGenerations.js';
50
+ import { callCheckKit, checkOutput, checksFor, McpOutputUncheckedError, outputUnchecked, refuseRequiredTask, validatorOption, } from './callChecks.js';
48
51
  import { createVendingFetch } from './gatewayTransport.js';
49
52
  import { ledgeredFetch, retryingFetch, seriesWithoutThrottle, } from './throttleRetry.js';
50
53
  import { RequestLedger } from './requestLedger.js';
@@ -94,7 +97,10 @@ export async function mcpClient(opts) {
94
97
  // checked once, here, before anything connects (`replay.ts`).
95
98
  const replay = replayDeclarationOf(opts.replay, `mcpClient[${name}]`);
96
99
  const strict = replay.policy === 'app-authorized';
97
- const { connection, ledger } = await openConnection(opts, replay, name);
100
+ // The validator a tool's own output checks use (`callChecks.ts`), refused by
101
+ // name now when it is not one.
102
+ const validator = validatorOption(opts.jsonSchemaValidator, `mcpClient[${name}]`);
103
+ const { connection, ledger, kit } = await openConnection(opts, replay, name, validator);
98
104
  const unlisted = new Set();
99
105
  // Tool cache so consumers calling `.tools()` more than once don't
100
106
  // hammer the server. `.refresh()` invalidates it.
@@ -106,13 +112,24 @@ export async function mcpClient(opts) {
106
112
  }
107
113
  };
108
114
  const buildTools = async () => {
109
- // `signal` rides in the SDK's THIRD argument (RequestOptions), not in
110
- // the request params — see `wrapMcpTool`.
111
- const listed = opts.signal
112
- ? await connection.listTools(undefined, { signal: opts.signal })
113
- : await connection.listTools();
114
- noteUnlisted(replay, listed.tools, name, unlisted);
115
- return listed.tools.map((t) => wrapMcpTool(name, connection, t, opts.signal, resultMode, ledger, strict));
115
+ // Every page of the server's list (`toolList.ts`). `signal` rides each
116
+ // page in the SDK's trailing options argument, never in the params — see
117
+ // `wrapMcpTool`.
118
+ // Each page request is counted in this connection's listings, whatever it
119
+ // settles to (`listingGenerations.ts`).
120
+ const listing = await listEveryPage(connection, opts.signal, kit.listings);
121
+ // A list that did not end cannot say which entries name nothing.
122
+ if (listing.incomplete === undefined)
123
+ noteUnlisted(replay, listing.tools, name, unlisted);
124
+ // Every tool carries the checks of the list it came from (`callChecks.ts`):
125
+ // the SDK's `Client` holds them only while a one-page list's answer is its
126
+ // latest, and only then are they left to it.
127
+ const tools = listing.tools.map((t) => wrapMcpTool(name, connection, t, opts.signal, resultMode, ledger, strict, checksFor(t, kit, listing.generation)));
128
+ // Never a list cut short: what was listed travels on the refusal instead.
129
+ if (listing.incomplete !== undefined) {
130
+ throw new McpToolListIncompleteError(listing.incomplete, name, listing.pages, tools);
131
+ }
132
+ return tools;
116
133
  };
117
134
  return {
118
135
  name,
@@ -151,31 +168,79 @@ export async function mcpClient(opts) {
151
168
  * A call with neither `connection` nor `sdk` reaches `resolveClient` with two
152
169
  * `undefined` arguments and takes the identical path it always took.
153
170
  */
154
- async function openConnection(opts, replay, name) {
155
- if (opts.connection !== undefined)
156
- return { connection: opts.connection };
157
- if (opts._client !== undefined)
158
- return { connection: opts._client };
171
+ async function openConnection(opts, replay, name, validator) {
172
+ // A client built elsewhere: the library loads nothing, so only the caller's
173
+ // validator can check a tool's output itself, and errors take the SDK's shape.
174
+ // Its list requests are counted per client: every mcpClient over it shares one
175
+ // count, as they share the SDK's one set of checks (`listingGenerations.ts`).
176
+ if (opts.connection !== undefined) {
177
+ const kit = callCheckKit(name, listingsOf(opts.connection), validator);
178
+ return { connection: opts.connection, kit };
179
+ }
180
+ if (opts._client !== undefined) {
181
+ return {
182
+ connection: opts._client,
183
+ kit: callCheckKit(name, listingsOf(opts._client), validator),
184
+ };
185
+ }
159
186
  // `refuseConflictingOptions` has already refused the case where this is
160
187
  // absent, so the assertion documents that guarantee rather than assuming it.
161
188
  const transport = opts.transport;
162
- return resolveClient(transport, opts.clientInfo, opts.signal, opts.retryOnThrottle, opts.sdk, replay, name);
189
+ return resolveClient(transport, opts.clientInfo, opts.signal, opts.retryOnThrottle, opts.sdk, replay, name, validator);
163
190
  }
164
191
  // ─── SDK construction (lazy require, unless the caller supplied it) ─
165
- async function resolveClient(transport, clientInfo, signal, retryOnThrottle, sdk, replay, name = 'mcp') {
192
+ async function resolveClient(transport, clientInfo, signal, retryOnThrottle, sdk, replay, name = 'mcp', validator) {
166
193
  if (sdk !== undefined)
167
194
  assertSdk(sdk, transport.transport);
168
195
  const mod = sdk ?? loadClientModule();
169
- const client = new mod.Client(clientInfo ?? DEFAULT_CLIENT_INFO, {
170
- capabilities: {},
171
- });
196
+ // A caller's validator is the client's too, so one validator checks every
197
+ // page; without one, the options are exactly what they always were.
198
+ const options = validator === undefined
199
+ ? { capabilities: {} }
200
+ : { capabilities: {}, jsonSchemaValidator: validator };
201
+ const client = new mod.Client(clientInfo ?? DEFAULT_CLIENT_INFO, options);
172
202
  const built = await buildTransport(transport, retryOnThrottle, sdk, replay, name);
203
+ // With the SDK loaded here, so is what a tool's own checks run with: its
204
+ // default validator and its own error class. With `sdk`, the loader is never
205
+ // touched (`callChecks.ts`).
206
+ const kit = sdk === undefined
207
+ ? callCheckKit(name, listingsOf(client), validator, loadCheckModules(validator))
208
+ : callCheckKit(name, listingsOf(client), validator);
173
209
  // Same rule as callTool: options ride beside the transport, never inside it.
174
210
  if (signal)
175
211
  await client.connect(built.transport, { signal });
176
212
  else
177
213
  await client.connect(built.transport);
178
- return { connection: client, ...(built.ledger !== undefined && { ledger: built.ledger }) };
214
+ return {
215
+ connection: client,
216
+ kit,
217
+ ...(built.ledger !== undefined && { ledger: built.ledger }),
218
+ };
219
+ }
220
+ /**
221
+ * What the SDK's `Client` checks a tool's call with, loaded with the SDK on the
222
+ * Node loader path (the bundling law: when the client is built, never at a
223
+ * later tool call): its own `McpError`, and — unless the caller gave a
224
+ * validator — its default validator, `AjvJsonSchemaValidator`. Both modules are
225
+ * the ones `client/index.js` already loaded. An SDK without one of them (older
226
+ * than its public validator subpath) leaves that slot empty: errors then take
227
+ * the SDK's shape, and an output no validator here can check is never returned.
228
+ */
229
+ function loadCheckModules(validator) {
230
+ const McpError = loadOptional(() => lazyRequire('@modelcontextprotocol/sdk/types.js'))?.McpError;
231
+ const Validator = validator === undefined
232
+ ? loadOptional(() => lazyRequire('@modelcontextprotocol/sdk/validation/ajv'))?.AjvJsonSchemaValidator
233
+ : undefined;
234
+ return { McpError, Validator };
235
+ }
236
+ /** A module this SDK may not have: `undefined` when it cannot be loaded. */
237
+ function loadOptional(load) {
238
+ try {
239
+ return load();
240
+ }
241
+ catch {
242
+ return undefined;
243
+ }
179
244
  }
180
245
  /**
181
246
  * An injected `sdk` is checked before anything is built, so a wrong import (a
@@ -354,7 +419,7 @@ function noteUnlisted(replay, listed, server, noted) {
354
419
  }
355
420
  }
356
421
  // ─── Tool wrapping ─────────────────────────────────────────────────
357
- function wrapMcpTool(serverName, connection, mcp, signal, resultMode, ledger, strict = false) {
422
+ function wrapMcpTool(serverName, connection, mcp, signal, resultMode, ledger, strict = false, checks) {
358
423
  const tool = {
359
424
  schema: {
360
425
  name: mcp.name,
@@ -416,12 +481,32 @@ function wrapMcpTool(serverName, connection, mcp, signal, resultMode, ledger, st
416
481
  if (unavailable !== undefined) {
417
482
  throw new McpReplayUnavailableError(unavailable, serverName, mcp.name);
418
483
  }
484
+ // Whose checks this call runs under, decided before anything is sent
485
+ // (`callChecks.ts`): the SDK's `Client` holds them while this tool's
486
+ // one-page list is still its latest answer and no list request is out;
487
+ // otherwise the tool's own checks run. An output they cannot check is
488
+ // refused here, unsent.
489
+ const own = checks !== undefined && !checks.heldBySdk();
490
+ if (own && outputUnchecked(checks)) {
491
+ throw new McpOutputUncheckedError(serverName, mcp.name, false);
492
+ }
419
493
  const call = openCall(params, ctx, signal, ledger, serverName);
420
494
  let verdict = 'failed';
421
495
  try {
422
- const result = call.signal
423
- ? await connection.callTool(call.params, undefined, { signal: call.signal })
424
- : await connection.callTool(call.params);
496
+ const send = () => call.signal
497
+ ? connection.callTool(call.params, undefined, { signal: call.signal })
498
+ : connection.callTool(call.params);
499
+ // The tool's own checks run where the SDK's `callTool` runs them, so a
500
+ // call fails as it would with the SDK holding them: the task refusal
501
+ // before sending, the output checks once the answer is in.
502
+ if (own)
503
+ refuseRequiredTask(checks);
504
+ const result = await send();
505
+ // A list request that went out while the call was out may have replaced
506
+ // the SDK's checks before it read the answer, so the tool's own checks
507
+ // read it too.
508
+ if (checks !== undefined && (own || !checks.heldBySdk()))
509
+ checkOutput(checks, result);
425
510
  verdict = isToolError(result) ? 'tool-error' : 'completed';
426
511
  return readToolResult(result, mcp.name, serverName, resultMode);
427
512
  }
@@ -1 +1 @@
1
- {"version":3,"file":"mcpClient.js","sourceRoot":"","sources":["../../../src/mcp/mcpClient.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAaxC,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EACL,aAAa,EACb,aAAa,EACb,qBAAqB,GAGtB,MAAM,oBAAoB,CAAC;AAC5B,O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BAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;gBACtF,OAAO,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,WAAW,CAAC;gBAC3D,OAAO,cAAc,CAAC,MAAM,EAAE,GAAG,CAAC,IAAI,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC;YAClE,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;YACpC,CAAC;oBAAS,CAAC;gBACT,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YACtB,CAAC;QACH,CAAC;KACF,CAAC;IACF,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,90 @@
1
+ /**
2
+ * toolList — every page of a server's `tools/list` answer, or a typed refusal
3
+ * that says the list is incomplete.
4
+ *
5
+ * Pattern: one bounded loop + one typed refusal.
6
+ * Role: MCP pages a tool list: a page carries `nextCursor` while the server
7
+ * has more, and the next page is asked for with `{ cursor }`. Reading
8
+ * only the first page cut a paginating server's catalogue short in
9
+ * silence — the agent saw part of it and nothing said so. This reads
10
+ * until the server sends no cursor, within a bound, and when it cannot
11
+ * finish the list it says why:
12
+ *
13
+ * - `'page-limit'` — the list did not end within {@link MAX_TOOL_LIST_PAGES}
14
+ * pages;
15
+ * - `'cursor-repeated'` — a page named a cursor this listing already sent, so
16
+ * following it would loop.
17
+ *
18
+ * The first page is asked exactly as before pagination was followed: no params
19
+ * (and, with no signal, no arguments at all). The client's signal rides every
20
+ * page in the SDK's trailing options, and it is checked immediately before each
21
+ * page is asked for and again when each answer arrives (`lib/abort.ts`): once
22
+ * it has fired, nothing more is asked for and no page is accepted, the last one
23
+ * included. An abort is the caller's word, so it wins over an incomplete list.
24
+ * What it cannot do is settle a page a connection that ignores the signal is
25
+ * still holding: that promise settles when the connection says.
26
+ *
27
+ * Every page request is counted from the moment it is sent until it settles
28
+ * (`listingGenerations.ts`): the MCP SDK's `Client` replaces its per-tool call
29
+ * checks with each answer, so a tool's checks depend on which answer is the
30
+ * latest (`callChecks.ts`).
31
+ */
32
+ import type { Tool } from '../tools/tools.js';
33
+ import type { ListingGenerations } from './listingGenerations.js';
34
+ import type { McpConnection, McpListedTool } from './types.js';
35
+ /**
36
+ * The most `tools/list` requests one listing sends. A bound on REQUESTS, not on
37
+ * the catalogue's size: a page may hold any number of tools. A server that
38
+ * keeps paging past it is reported as incomplete rather than read without end.
39
+ */
40
+ export declare const MAX_TOOL_LIST_PAGES = 100;
41
+ /** Why a server's tool list could not be read to its end. */
42
+ export type McpToolListIncompleteReason = 'page-limit' | 'cursor-repeated';
43
+ /** What a listing read: every tool its pages held, how many pages, and whether it ended. */
44
+ export interface ToolListing {
45
+ readonly tools: readonly McpListedTool[];
46
+ readonly pages: number;
47
+ /**
48
+ * For a list read in ONE answer, the generation that answer settled at: the
49
+ * MCP SDK's `Client` holds its tools' checks while it stays the latest
50
+ * (`listingGenerations.ts`). Absent for a paged list: no one answer holds all
51
+ * of its tools.
52
+ */
53
+ readonly generation?: number;
54
+ /** Absent when the server's list ended: the last page carried no cursor. */
55
+ readonly incomplete?: McpToolListIncompleteReason;
56
+ }
57
+ /**
58
+ * Read the server's tool list, page by page, until a page carries no cursor —
59
+ * or until it cannot be finished, which the result says (`incomplete`).
60
+ *
61
+ * @param listings the connection's count of list requests, which every page
62
+ * request joins (`listingGenerations.ts`)
63
+ * @throws the abort, when `signal` has fired before a page is asked for or by
64
+ * the time its answer arrives; and whatever the connection rejects a page
65
+ * with, as it always did
66
+ */
67
+ export declare function listEveryPage(connection: McpConnection, signal: AbortSignal | undefined, listings: ListingGenerations): Promise<ToolListing>;
68
+ /**
69
+ * A server's tool list that could not be read to its end. `tools()` and
70
+ * `refresh()` reject with it rather than return a list cut short: an agent
71
+ * handed part of a catalogue cannot know what it was not offered.
72
+ *
73
+ * `tools` holds what WAS listed — wrapped and callable, exactly as `tools()`
74
+ * would have returned them — for a caller that decides to use an incomplete
75
+ * list knowingly. Names the server, the reason and the count, never a cursor.
76
+ */
77
+ export declare class McpToolListIncompleteError extends Error {
78
+ readonly reason: McpToolListIncompleteReason;
79
+ readonly server: string;
80
+ /** The pages read before the listing stopped. */
81
+ readonly pages: number;
82
+ /** The tools those pages listed, in page order. */
83
+ readonly tools: readonly Tool[];
84
+ readonly code: "ERR_MCP_TOOL_LIST_INCOMPLETE";
85
+ constructor(reason: McpToolListIncompleteReason, server: string,
86
+ /** The pages read before the listing stopped. */
87
+ pages: number,
88
+ /** The tools those pages listed, in page order. */
89
+ tools: readonly Tool[]);
90
+ }
@@ -0,0 +1,123 @@
1
+ /**
2
+ * toolList — every page of a server's `tools/list` answer, or a typed refusal
3
+ * that says the list is incomplete.
4
+ *
5
+ * Pattern: one bounded loop + one typed refusal.
6
+ * Role: MCP pages a tool list: a page carries `nextCursor` while the server
7
+ * has more, and the next page is asked for with `{ cursor }`. Reading
8
+ * only the first page cut a paginating server's catalogue short in
9
+ * silence — the agent saw part of it and nothing said so. This reads
10
+ * until the server sends no cursor, within a bound, and when it cannot
11
+ * finish the list it says why:
12
+ *
13
+ * - `'page-limit'` — the list did not end within {@link MAX_TOOL_LIST_PAGES}
14
+ * pages;
15
+ * - `'cursor-repeated'` — a page named a cursor this listing already sent, so
16
+ * following it would loop.
17
+ *
18
+ * The first page is asked exactly as before pagination was followed: no params
19
+ * (and, with no signal, no arguments at all). The client's signal rides every
20
+ * page in the SDK's trailing options, and it is checked immediately before each
21
+ * page is asked for and again when each answer arrives (`lib/abort.ts`): once
22
+ * it has fired, nothing more is asked for and no page is accepted, the last one
23
+ * included. An abort is the caller's word, so it wins over an incomplete list.
24
+ * What it cannot do is settle a page a connection that ignores the signal is
25
+ * still holding: that promise settles when the connection says.
26
+ *
27
+ * Every page request is counted from the moment it is sent until it settles
28
+ * (`listingGenerations.ts`): the MCP SDK's `Client` replaces its per-tool call
29
+ * checks with each answer, so a tool's checks depend on which answer is the
30
+ * latest (`callChecks.ts`).
31
+ */
32
+ import { throwIfAborted } from '../lib/abort.js';
33
+ /**
34
+ * The most `tools/list` requests one listing sends. A bound on REQUESTS, not on
35
+ * the catalogue's size: a page may hold any number of tools. A server that
36
+ * keeps paging past it is reported as incomplete rather than read without end.
37
+ */
38
+ export const MAX_TOOL_LIST_PAGES = 100;
39
+ /**
40
+ * Read the server's tool list, page by page, until a page carries no cursor —
41
+ * or until it cannot be finished, which the result says (`incomplete`).
42
+ *
43
+ * @param listings the connection's count of list requests, which every page
44
+ * request joins (`listingGenerations.ts`)
45
+ * @throws the abort, when `signal` has fired before a page is asked for or by
46
+ * the time its answer arrives; and whatever the connection rejects a page
47
+ * with, as it always did
48
+ */
49
+ export async function listEveryPage(connection, signal, listings) {
50
+ const tools = [];
51
+ const sent = new Set();
52
+ let cursor;
53
+ for (let pages = 1;; pages++) {
54
+ // Immediately before EVERY request, the first included: an aborted listing
55
+ // asks for nothing more (`lib/abort.ts`).
56
+ throwIfAborted(signal);
57
+ const { answer: page, generation } = await listings.ask(() => askPage(connection, cursor, signal));
58
+ // And after EVERY answer, before it is accepted: a page that lands after
59
+ // the abort — the last page too — is never part of a listing, so nothing
60
+ // incomplete is returned and nothing complete is cached.
61
+ throwIfAborted(signal);
62
+ // One push per tool: spreading a very large page into `push` can overflow the stack.
63
+ for (const tool of page.tools)
64
+ tools.push(tool);
65
+ const next = page.nextCursor;
66
+ if (next === undefined || next === null) {
67
+ return pages === 1 ? { tools, pages, generation } : { tools, pages };
68
+ }
69
+ if (sent.has(next))
70
+ return { tools, pages, incomplete: 'cursor-repeated' };
71
+ if (pages >= MAX_TOOL_LIST_PAGES)
72
+ return { tools, pages, incomplete: 'page-limit' };
73
+ sent.add(next);
74
+ cursor = next;
75
+ }
76
+ }
77
+ /**
78
+ * One page. The first carries no params — with no signal, no arguments at all —
79
+ * which is the request a one-page server always got; a later page carries
80
+ * `{ cursor }`. The signal rides the trailing options, never the params.
81
+ */
82
+ function askPage(connection, cursor, signal) {
83
+ const params = cursor === undefined ? undefined : { cursor };
84
+ if (signal !== undefined)
85
+ return connection.listTools(params, { signal });
86
+ return params === undefined ? connection.listTools() : connection.listTools(params);
87
+ }
88
+ /** The fixed sentence each reason reads as. Never a cursor: that is the server's data. */
89
+ const BECAUSE = {
90
+ 'page-limit': (pages) => `the list did not end within ${pages} pages`,
91
+ 'cursor-repeated': (pages) => `page ${pages} named a cursor this listing had already sent, so following it would loop`,
92
+ };
93
+ /**
94
+ * A server's tool list that could not be read to its end. `tools()` and
95
+ * `refresh()` reject with it rather than return a list cut short: an agent
96
+ * handed part of a catalogue cannot know what it was not offered.
97
+ *
98
+ * `tools` holds what WAS listed — wrapped and callable, exactly as `tools()`
99
+ * would have returned them — for a caller that decides to use an incomplete
100
+ * list knowingly. Names the server, the reason and the count, never a cursor.
101
+ */
102
+ export class McpToolListIncompleteError extends Error {
103
+ reason;
104
+ server;
105
+ pages;
106
+ tools;
107
+ code = 'ERR_MCP_TOOL_LIST_INCOMPLETE';
108
+ constructor(reason, server,
109
+ /** The pages read before the listing stopped. */
110
+ pages,
111
+ /** The tools those pages listed, in page order. */
112
+ tools) {
113
+ super(`mcpClient[${server}]: the server's tool list is incomplete — ${BECAUSE[reason](pages)}. ` +
114
+ `No tools were returned; the ${tools.length} listed before it stopped are on this ` +
115
+ "error's `tools`, for a caller that chooses to use an incomplete list.");
116
+ this.reason = reason;
117
+ this.server = server;
118
+ this.pages = pages;
119
+ this.tools = tools;
120
+ this.name = 'McpToolListIncompleteError';
121
+ }
122
+ }
123
+ //# sourceMappingURL=toolList.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toolList.js","sourceRoot":"","sources":["../../../src/mcp/toolList.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAKjD;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBA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I,GAAG,4BAA4B,CAAC;IAC3C,CAAC;CACF"}
@@ -307,6 +307,25 @@ export interface McpClientOptions {
307
307
  * @see McpSdk for the two static imports that produce it.
308
308
  */
309
309
  readonly sdk?: McpSdk;
310
+ /**
311
+ * The JSON Schema validator a tool's `outputSchema` is checked with — the MCP
312
+ * SDK's own validator interface (`new AjvJsonSchemaValidator()` from
313
+ * `@modelcontextprotocol/sdk/validation/ajv`, `new CfWorkerJsonSchemaValidator()`,
314
+ * or your own).
315
+ *
316
+ * Why it exists: the SDK's `Client` checks a tool's output only for the tools
317
+ * of its most recent `tools/list` answer, so every tool the library hands out
318
+ * carries its own checks, and runs them whenever the SDK no longer holds its
319
+ * list: a paged list, a list a later answer replaced, a call made while a list
320
+ * is read — of the lists `tools()` and `refresh()` read (see
321
+ * `McpClient.tools()`; the client the library builds here never lists by
322
+ * itself). The client the library builds is handed this same validator, so
323
+ * one validator checks every call. Omit it and the library uses the SDK's
324
+ * default, loaded with the SDK itself; with `sdk`, where the library never
325
+ * touches its Node loader, such a call to a tool that declares an
326
+ * `outputSchema` is refused (`McpOutputUncheckedError`) unless you pass one.
327
+ */
328
+ readonly jsonSchemaValidator?: McpJsonSchemaValidator;
310
329
  /** @see McpConnectionOptions — never set on this arm. */
311
330
  readonly connection?: undefined;
312
331
  /**
@@ -346,10 +365,35 @@ export interface McpConnectionOptions {
346
365
  /**
347
366
  * A connection you already opened. The library never calls `connect()` on it;
348
367
  * `close()` on the returned client closes it exactly once.
368
+ *
369
+ * Leave its tool discovery to `mcpClient`: the per-tool checks hold only for
370
+ * the lists `tools()` and `refresh()` read (see `McpClient.tools()`). Do not
371
+ * let the SDK client refresh itself (`listChanged.tools` with `autoRefresh`,
372
+ * which is on by default once `listChanged.tools` is given): set
373
+ * `autoRefresh: false` and call `refresh()` from `onChanged`, or give
374
+ * `mcpClient` a connection of its own.
349
375
  */
350
376
  readonly connection: McpConnection;
351
377
  /** Abort the list / call paths. Rides the SDK's request options. */
352
378
  readonly signal?: AbortSignal;
379
+ /**
380
+ * The JSON Schema validator your client checks tool output with — pass the
381
+ * SAME one you gave its constructor (`jsonSchemaValidator`), or the SDK's
382
+ * default, `new AjvJsonSchemaValidator()`.
383
+ *
384
+ * The SDK's `Client` checks a tool's output only for the tools of its most
385
+ * recent `tools/list` answer, so the library checks a tool itself, with this,
386
+ * whenever the SDK no longer holds its list: a paged list, a list a later
387
+ * answer replaced, a call made while a list is read. Without it, such a call
388
+ * to a tool that declares an `outputSchema` is refused
389
+ * (`McpOutputUncheckedError`); a one-page catalogue that is still the latest
390
+ * answer never needs it. It covers only the lists `tools()` and `refresh()`
391
+ * read: when the SDK client's cache is replaced some other way (its own
392
+ * automatic refresh, a `listTools` call of yours), the library still leaves
393
+ * the call to the SDK, and this validator is never asked (see
394
+ * `McpClient.tools()`).
395
+ */
396
+ readonly jsonSchemaValidator?: McpJsonSchemaValidator;
353
397
  /** @see McpClientOptions — never set on this arm. */
354
398
  readonly transport?: undefined;
355
399
  /** @see McpClientOptions — never set on this arm. */
@@ -376,12 +420,52 @@ export interface McpClient {
376
420
  * after `mcpClient(...)` is the snapshot used to register on the
377
421
  * agent; subsequent calls re-fetch (cheap, in-memory cached by the
378
422
  * SDK between fetches).
423
+ *
424
+ * Every page of the server's `tools/list` answer is read: the client
425
+ * follows `nextCursor` until a page carries none, sending at most 100
426
+ * `tools/list` requests (a bound on requests, not on the catalogue's size).
427
+ * A list that does not end within them, or that names a cursor it already
428
+ * sent (a loop), is never returned cut short: the call rejects with
429
+ * `McpToolListIncompleteError`, whose `reason` says which and whose `tools`
430
+ * holds what was listed. `signal` rides every page and is checked before
431
+ * each page is asked for and when each answer arrives: once it has fired,
432
+ * nothing more is asked for and no page is accepted.
433
+ *
434
+ * Every tool keeps its checks, whatever `tools()` and `refresh()` list later —
435
+ * those of any `mcpClient` over the same client included. That holds only
436
+ * while all tool discovery on the client runs through them; see below. The
437
+ * SDK's `Client` checks a tool's call (a required task refused before
438
+ * sending; `structuredContent` required by an `outputSchema`, and matched
439
+ * against it) only for the tools of its most recent `tools/list` answer, so
440
+ * every tool returned here carries those checks itself. They are left to the
441
+ * SDK only for a tool of a one-page list whose answer is still the latest,
442
+ * with no list request out. Every other call runs the tool's own and fails
443
+ * with the same error: a paged list's tools, a tool held across a later
444
+ * `refresh()` (failed or not), a call made while a list is read. Where no JSON
445
+ * Schema validator is reachable (`jsonSchemaValidator` on the `sdk` and
446
+ * `connection` arms), such a call to a tool that declares an `outputSchema` is
447
+ * refused with `McpOutputUncheckedError`: before it is sent, or, when a list
448
+ * was read while it was out, once its answer is in, unread.
449
+ *
450
+ * What it does not cover: a listing the library does not send. Your own
451
+ * `listTools` calls, the SDK client's automatic discovery (`listChanged.tools`
452
+ * with `autoRefresh`, on by default once `listChanged.tools` is given), or any
453
+ * other replacement of the SDK client's cache leave a tool handed out here
454
+ * believing the SDK still holds its checks — so neither its output checks nor
455
+ * its required-task refusal run, even with `jsonSchemaValidator`. The client
456
+ * the library builds (the `transport` and `sdk` arms) never lists by itself;
457
+ * on a client you pass as `connection`, set `autoRefresh: false` and call
458
+ * `refresh()` from `onChanged`, or give `mcpClient` a connection of its own.
379
459
  */
380
460
  tools(): Promise<readonly Tool[]>;
381
461
  /**
382
462
  * Force a refresh from the server. Use when you suspect the server
383
463
  * has dynamically added/removed tools mid-session (e.g., after the
384
- * server processes a config update).
464
+ * server processes a config update). Reads every page, as `tools()` does.
465
+ * When it fails it rejects, and `tools()` keeps serving the catalogue it
466
+ * had: those tools keep their own checks (see `tools()`). Route the server's
467
+ * list-changed notice here, rather than letting the SDK client refresh
468
+ * itself: a listing the library does not send is not covered.
385
469
  */
386
470
  refresh(): Promise<readonly Tool[]>;
387
471
  /** Close the underlying transport. After `close()` the client is unusable. */
@@ -412,8 +496,17 @@ export interface McpClient {
412
496
  * convenience version of it.
413
497
  */
414
498
  export interface McpConnection {
415
- listTools(params?: undefined, options?: McpRequestOptions): Promise<{
499
+ /**
500
+ * One page of the server's tool list. The first page is asked with no params;
501
+ * each later page with the `nextCursor` the page before it returned, as
502
+ * `{ cursor }`. A connection that never pages returns no `nextCursor`.
503
+ */
504
+ listTools(params?: {
505
+ readonly cursor?: string;
506
+ }, options?: McpRequestOptions): Promise<{
416
507
  readonly tools: ReadonlyArray<McpListedTool>;
508
+ /** Present while the server has more tools: what to ask for the next page with. */
509
+ readonly nextCursor?: string;
417
510
  }>;
418
511
  callTool(params: {
419
512
  readonly name: string;
@@ -510,6 +603,29 @@ export interface McpListedTool {
510
603
  readonly inputSchema: Readonly<Record<string, unknown>>;
511
604
  /** MCP's extensibility bag. Absent from most servers' tools. */
512
605
  readonly _meta?: Readonly<Record<string, unknown>>;
606
+ /**
607
+ * What the tool's `structuredContent` must match. Read for the one reason the
608
+ * SDK's `Client` reads it: a tool that declares one must answer with
609
+ * matching `structuredContent` (see `McpClient.tools()` for a paged list).
610
+ */
611
+ readonly outputSchema?: Readonly<Record<string, unknown>>;
612
+ /** How the tool may run: `taskSupport: 'required'` means only as a task, never a plain `tools/call`. */
613
+ readonly execution?: {
614
+ readonly taskSupport?: string;
615
+ };
616
+ }
617
+ /**
618
+ * A JSON Schema validator, as the MCP SDK's `Client` takes one
619
+ * (`jsonSchemaValidator`): `getValidator(schema)` compiles a schema once and
620
+ * returns a function that checks one value against it. Typed STRUCTURALLY so
621
+ * this declaration never references the optional peer; the SDK's own
622
+ * `AjvJsonSchemaValidator` and `CfWorkerJsonSchemaValidator` satisfy it.
623
+ */
624
+ export interface McpJsonSchemaValidator {
625
+ getValidator(schema: object): (input: unknown) => {
626
+ readonly valid: boolean;
627
+ readonly errorMessage?: string;
628
+ };
513
629
  }
514
630
  /**
515
631
  * What `tools/call` can answer with — **a union, because the protocol is one.**