@orkestrel/mcp 0.0.26 → 0.0.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/src/browser/index.d.ts +146 -275
- package/dist/src/browser/index.js +143 -393
- package/dist/src/browser/index.js.map +1 -1
- package/dist/src/core/index.cjs +1350 -247
- package/dist/src/core/index.cjs.map +1 -1
- package/dist/src/core/index.d.cts +1498 -551
- package/dist/src/core/index.d.ts +1498 -551
- package/dist/src/core/index.js +1318 -247
- package/dist/src/core/index.js.map +1 -1
- package/dist/src/server/index.cjs +425 -562
- package/dist/src/server/index.cjs.map +1 -1
- package/dist/src/server/index.d.cts +331 -357
- package/dist/src/server/index.d.ts +331 -357
- package/dist/src/server/index.js +417 -547
- package/dist/src/server/index.js.map +1 -1
- package/package.json +21 -20
|
@@ -16,7 +16,7 @@ import { ToolResult } from '@orkestrel/tool';
|
|
|
16
16
|
* @remarks
|
|
17
17
|
* The client's outbound writes flow through `client.transport.send` — its existing,
|
|
18
18
|
* unmodified request/response correlation — so `client` must have been constructed
|
|
19
|
-
* with a {@link import('./types.js').
|
|
19
|
+
* with a {@link import('./types.js').MCPMessageTransportInterface} that itself carries
|
|
20
20
|
* the SAME `transport` (see {@link import('./factories.js').createDuplexClientTransport},
|
|
21
21
|
* the additive factory that adapts an {@link MCPTransportInterface} into that shape);
|
|
22
22
|
* this binder then completes the inbound half by decoding each message and pushing it
|
|
@@ -155,7 +155,7 @@ export declare function buildCallOutcome(name: string, result: unknown): MCPCall
|
|
|
155
155
|
* rather than as a violation.
|
|
156
156
|
*
|
|
157
157
|
* Only write one on a carrier that accepts a client-initiated notification — see
|
|
158
|
-
* {@link import('./types.js').
|
|
158
|
+
* {@link import('./types.js').MCPMessageTransportInterface.duplex}. On Streamable HTTP the
|
|
159
159
|
* dated revision defines no such frame, and closing the response stream is the
|
|
160
160
|
* cancellation signal instead.
|
|
161
161
|
*
|
|
@@ -189,6 +189,60 @@ export declare function buildCancelledNotification(id: JSONRPCId, reason?: strin
|
|
|
189
189
|
*/
|
|
190
190
|
export declare function buildDiscoverResult(options: MCPServerOptions): MCPDiscoverResult;
|
|
191
191
|
|
|
192
|
+
/**
|
|
193
|
+
* Builds the `x-mcp-header` projections one tool's `inputSchema` declares.
|
|
194
|
+
*
|
|
195
|
+
* @remarks
|
|
196
|
+
* The single decision both sides of the protocol make about an annotated tool: an HTTP
|
|
197
|
+
* CLIENT excludes a definition this refuses from the `tools/list` result it delivers, and a
|
|
198
|
+
* SERVER recognizes exactly the `Mcp-Param-*` names this returns for its own definitions.
|
|
199
|
+
*
|
|
200
|
+
* `undefined` means the definition is invalid, and every rule the protocol states produces
|
|
201
|
+
* it: a value that is not an RFC 9110 token, a non-primitive or untyped annotated leaf, a
|
|
202
|
+
* name repeated case-insensitively within the schema, an annotation the `properties` chain
|
|
203
|
+
* does not reach, and a schema that is not a record at all. An empty list is the valid answer
|
|
204
|
+
* for a schema carrying no annotation.
|
|
205
|
+
*
|
|
206
|
+
* Total — never throws, and a cyclic or stack-hostile schema is refused rather than followed.
|
|
207
|
+
*
|
|
208
|
+
* @param schema - The tool's advertised `inputSchema`
|
|
209
|
+
* @returns The declared projections, or `undefined` when the definition is invalid
|
|
210
|
+
*
|
|
211
|
+
* @example
|
|
212
|
+
* ```ts
|
|
213
|
+
* buildHeaderParameters({
|
|
214
|
+
* type: 'object',
|
|
215
|
+
* properties: { region: { type: 'string', 'x-mcp-header': 'Region' } },
|
|
216
|
+
* }) // → [{ name: 'Region', path: ['region'], primitive: 'string' }]
|
|
217
|
+
* ```
|
|
218
|
+
*/
|
|
219
|
+
export declare function buildHeaderParameters(schema: unknown): readonly MCPHeaderParameter[] | undefined;
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Builds the `Mcp-Param-*` request headers one `tools/call` carries.
|
|
223
|
+
*
|
|
224
|
+
* @remarks
|
|
225
|
+
* The projection SEP-2243 requires of an HTTP client, and the same derivation a server runs
|
|
226
|
+
* to know what the request must carry. Each parameter's value is read at its exact
|
|
227
|
+
* property path in the call's own `arguments`; an absent or `null` value omits its header
|
|
228
|
+
* entirely, which is the protocol's distinction between "not supplied" and "supplied empty".
|
|
229
|
+
* The rendered text then travels through {@link encodeSentinel}, so a value carrying
|
|
230
|
+
* non-ASCII, control, or edge whitespace characters reaches the peer intact.
|
|
231
|
+
*
|
|
232
|
+
* @param parameters - The projections the tool's `inputSchema` declares
|
|
233
|
+
* @param values - The call's `arguments` record
|
|
234
|
+
* @returns The header field names and values, empty when nothing projects
|
|
235
|
+
*
|
|
236
|
+
* @example
|
|
237
|
+
* ```ts
|
|
238
|
+
* buildHeaderProjection(
|
|
239
|
+
* [{ name: 'Region', path: ['region'], primitive: 'string' }],
|
|
240
|
+
* { region: 'us-west1' },
|
|
241
|
+
* ) // → { 'Mcp-Param-Region': 'us-west1' }
|
|
242
|
+
* ```
|
|
243
|
+
*/
|
|
244
|
+
export declare function buildHeaderProjection(parameters: readonly MCPHeaderParameter[], values: unknown): Readonly<Record<string, string>>;
|
|
245
|
+
|
|
192
246
|
/**
|
|
193
247
|
* Builds the MCP `initialize` result — the negotiated protocol version, the
|
|
194
248
|
* advertised capabilities, and the server identity.
|
|
@@ -304,6 +358,20 @@ export declare function buildModernResult<T extends object>(result: T, identity:
|
|
|
304
358
|
*/
|
|
305
359
|
export declare function buildProgressNotification(token: string | number, progress: MCPProgress): JSONRPCNotification;
|
|
306
360
|
|
|
361
|
+
/**
|
|
362
|
+
* Builds the error for a non-success HTTP response that carried no JSON-RPC message.
|
|
363
|
+
*
|
|
364
|
+
* @param response - The response whose status is reported
|
|
365
|
+
* @param type - The response's content type, or an empty string when absent
|
|
366
|
+
* @returns An error naming the HTTP status and unsupported response shape
|
|
367
|
+
*
|
|
368
|
+
* @example
|
|
369
|
+
* ```ts
|
|
370
|
+
* const error = buildResponseError(new Response('', { status: 500 }), '')
|
|
371
|
+
* ```
|
|
372
|
+
*/
|
|
373
|
+
export declare function buildResponseError(response: Response, type: string): Error;
|
|
374
|
+
|
|
307
375
|
/**
|
|
308
376
|
* Builds the first notification carrying a subscription id for a listen request.
|
|
309
377
|
*
|
|
@@ -358,9 +426,68 @@ export declare function buildToolCall(request: JSONRPCRequest, caller?: unknown,
|
|
|
358
426
|
*/
|
|
359
427
|
export declare function buildToolDescriptors(manager: ToolManagerInterface): readonly MCPToolDescriptor[];
|
|
360
428
|
|
|
429
|
+
/**
|
|
430
|
+
* Computes the capabilities one round of input requests needs and the client did not declare.
|
|
431
|
+
*
|
|
432
|
+
* @remarks
|
|
433
|
+
* The protocol's rule is about SENDING: a server never issues a request kind the client's
|
|
434
|
+
* declared capabilities exclude. So this reads the round rather than the method, and it
|
|
435
|
+
* answers with the refusal's own payload — the `requiredCapabilities` record a
|
|
436
|
+
* `MissingRequiredClientCapability` error carries, keyed by each missing capability, in the
|
|
437
|
+
* `ClientCapabilities` shape the schema defines rather than as a list of names.
|
|
438
|
+
*
|
|
439
|
+
* Each kind maps to one declaration: `sampling/createMessage` to `sampling`, `roots/list` to
|
|
440
|
+
* `roots`, a form elicitation to what {@link supportsFormElicitation} accepts, and a
|
|
441
|
+
* URL-mode elicitation to a record-valued `elicitation.url`. A request this package cannot
|
|
442
|
+
* recognize needs nothing, because {@link import('./validators.js').isMCPInputRequestMap}
|
|
443
|
+
* has already refused the round it would have travelled in. Total over hostile input.
|
|
444
|
+
*
|
|
445
|
+
* The `elicitation` value names the ARM the round needs, so a client can act on the refusal
|
|
446
|
+
* by declaring exactly what the payload asks for. A missing URL arm answers `{ url: {} }`, a
|
|
447
|
+
* missing form arm answers the empty record this package reads as form-only, and a round
|
|
448
|
+
* needing both answers `{ form: {}, url: {} }`. An empty record for a URL round would name
|
|
449
|
+
* the declaration a URL-capable client already sent, and refuse the identical round again.
|
|
450
|
+
*
|
|
451
|
+
* @param requests - The round the server is about to issue
|
|
452
|
+
* @param capabilities - The client capability record the request declared
|
|
453
|
+
* @returns The missing capabilities, or `undefined` when the client declared every one
|
|
454
|
+
*
|
|
455
|
+
* @example
|
|
456
|
+
* ```ts
|
|
457
|
+
* computeMissingCapabilities({ answer: { method: 'roots/list' } }, {}) // { roots: {} }
|
|
458
|
+
* computeMissingCapabilities({ answer: { method: 'roots/list' } }, { roots: {} }) // undefined
|
|
459
|
+
* ```
|
|
460
|
+
*/
|
|
461
|
+
export declare function computeMissingCapabilities(requests: MCPInputRequestMap, capabilities: unknown): MCPClientCapabilities | undefined;
|
|
462
|
+
|
|
463
|
+
/**
|
|
464
|
+
* Counts every {@link MCP_HEADER_ANNOTATION} key one JSON value carries, at any position.
|
|
465
|
+
*
|
|
466
|
+
* @remarks
|
|
467
|
+
* The companion of {@link extractHeaderAnnotations}, which reads only the annotations a
|
|
468
|
+
* `properties` chain reaches. Comparing the two answers is how
|
|
469
|
+
* {@link buildHeaderParameters} decides reachability without a second walk that would have
|
|
470
|
+
* to re-state which JSON Schema keywords are traversable: an annotation the reachable walk
|
|
471
|
+
* did not read is one sitting under `items`, a composition or conditional keyword, a `$ref`
|
|
472
|
+
* target, or any other position, and the protocol makes the whole tool definition invalid for
|
|
473
|
+
* it.
|
|
474
|
+
*
|
|
475
|
+
* Iterative and ancestor-tracked, so a deeply nested or self-referential value terminates
|
|
476
|
+
* rather than exhausting the stack. Total — never throws, whatever the input.
|
|
477
|
+
*
|
|
478
|
+
* @param value - The value to scan, normally a tool's `inputSchema`
|
|
479
|
+
* @returns How many annotation keys the value carries
|
|
480
|
+
*
|
|
481
|
+
* @example
|
|
482
|
+
* ```ts
|
|
483
|
+
* countHeaderAnnotations({ properties: { region: { 'x-mcp-header': 'Region' } } }) // 1
|
|
484
|
+
* ```
|
|
485
|
+
*/
|
|
486
|
+
export declare function countHeaderAnnotations(value: unknown): number;
|
|
487
|
+
|
|
361
488
|
/**
|
|
362
489
|
* Adapts an {@link MCPTransportInterface} (the environment-agnostic duplex message
|
|
363
|
-
* channel) into a {@link
|
|
490
|
+
* channel) into a {@link MCPMessageTransportInterface} — the additive bridge that lets
|
|
364
491
|
* `createMCPClient` run over the new port without any change to `MCPClient`'s
|
|
365
492
|
* existing shape.
|
|
366
493
|
*
|
|
@@ -383,7 +510,7 @@ export declare function buildToolDescriptors(manager: ToolManagerInterface): rea
|
|
|
383
510
|
* capable emitter for `bindClient` to push onto.
|
|
384
511
|
*
|
|
385
512
|
* @param transport - The duplex channel to adapt
|
|
386
|
-
* @returns A {@link
|
|
513
|
+
* @returns A {@link MCPMessageTransportInterface} `createMCPClient` can drive
|
|
387
514
|
*
|
|
388
515
|
* @example
|
|
389
516
|
* ```ts
|
|
@@ -392,11 +519,11 @@ export declare function buildToolDescriptors(manager: ToolManagerInterface): rea
|
|
|
392
519
|
* await client.connect()
|
|
393
520
|
* ```
|
|
394
521
|
*/
|
|
395
|
-
export declare function createDuplexClientTransport(transport: MCPTransportInterface):
|
|
522
|
+
export declare function createDuplexClientTransport(transport: MCPTransportInterface): MCPMessageTransportInterface;
|
|
396
523
|
|
|
397
524
|
/**
|
|
398
525
|
* Creates a transport-agnostic Model Context Protocol CLIENT — connects to a REMOTE
|
|
399
|
-
* MCP server over an injected {@link import('./types.js').
|
|
526
|
+
* MCP server over an injected {@link import('./types.js').MCPMessageTransportInterface},
|
|
400
527
|
* negotiates the modern revision through `server/discover`, and exposes the server's tools as local
|
|
401
528
|
* {@link import('@orkestrel/tool').ToolInterface}s an agent can run.
|
|
402
529
|
*
|
|
@@ -427,7 +554,7 @@ export declare function createDuplexClientTransport(transport: MCPTransportInter
|
|
|
427
554
|
* })
|
|
428
555
|
* await client.connect()
|
|
429
556
|
* agent.context.tools.add(await client.tools()) // give the agent the remote tools
|
|
430
|
-
* const
|
|
557
|
+
* const outcome = await client.call('search', { query: 'mcp' })
|
|
431
558
|
* ```
|
|
432
559
|
*/
|
|
433
560
|
export declare function createMCPClient(options: MCPClientOptions): MCPClientInterface;
|
|
@@ -455,14 +582,14 @@ export declare function createMCPLegacy(server: MCPServerInterface): MCPDispatch
|
|
|
455
582
|
* client.version // '2026-07-28'
|
|
456
583
|
* ```
|
|
457
584
|
*/
|
|
458
|
-
export declare function createMCPLegacyClientTransport(transport:
|
|
585
|
+
export declare function createMCPLegacyClientTransport(transport: MCPMessageTransportInterface, options?: MCPLegacyClientTransportOptions): MCPMessageTransportInterface;
|
|
459
586
|
|
|
460
587
|
/**
|
|
461
588
|
* Creates a transport-agnostic Model Context Protocol server — exposes a live
|
|
462
589
|
* {@link import('@orkestrel/tool').ToolManagerInterface} and an optional
|
|
463
590
|
* {@link import('./types.js').MCPResourceManagerInterface},
|
|
464
591
|
* {@link import('./types.js').MCPPromptManagerInterface}, and
|
|
465
|
-
* {@link import('./types.js').
|
|
592
|
+
* {@link import('./types.js').MCPCompletionInterface} over JSON-RPC 2.0.
|
|
466
593
|
*
|
|
467
594
|
* @remarks
|
|
468
595
|
* Pump raw message strings through `handle` (parse → dispatch → serialize) from a
|
|
@@ -505,7 +632,7 @@ export declare function createMCPServer(options: MCPServerOptions): MCPServerInt
|
|
|
505
632
|
*
|
|
506
633
|
* @remarks
|
|
507
634
|
* The bound is checked FIRST, against the raw string, so an oversized message is never
|
|
508
|
-
*
|
|
635
|
+
* parsed at all: a decoder that parses before it measures has already spent the work
|
|
509
636
|
* the bound exists to refuse. A message over the bound, malformed JSON, and a well-formed
|
|
510
637
|
* value that is not a JSON-RPC message are one answer — `undefined` — because a binder does
|
|
511
638
|
* exactly the same thing with each of them: nothing, and let
|
|
@@ -526,7 +653,76 @@ export declare function createMCPServer(options: MCPServerOptions): MCPServerInt
|
|
|
526
653
|
export declare function decodeBoundedMessage(message: string, limits: MCPJSONLimitOptions): JSONRPCMessage | undefined;
|
|
527
654
|
|
|
528
655
|
/**
|
|
529
|
-
*
|
|
656
|
+
* Decodes one SSE event's `data` string into a {@link JSONRPCMessage}, or `undefined`
|
|
657
|
+
* when it is not one — the per-event step {@link readEventStream} folds over.
|
|
658
|
+
*
|
|
659
|
+
* @remarks
|
|
660
|
+
* Parses the `data` (a peer serializes the JSON-RPC envelope as the event's `data`) with
|
|
661
|
+
* `@orkestrel/contract`'s `parseJSON` — the declared JSON boundary, which answers `undefined`
|
|
662
|
+
* instead of throwing — and narrows the parsed value with `parseJSONRPCMessage`. Total:
|
|
663
|
+
* malformed JSON or a non-message value yields `undefined`, never throws.
|
|
664
|
+
*
|
|
665
|
+
* @param data - One SSE event's `data` payload
|
|
666
|
+
* @returns The decoded {@link JSONRPCMessage}, or `undefined`
|
|
667
|
+
*
|
|
668
|
+
* @example
|
|
669
|
+
* ```ts
|
|
670
|
+
* decodeEvent('{"jsonrpc":"2.0","id":1,"result":{}}') // the decoded response
|
|
671
|
+
* ```
|
|
672
|
+
*/
|
|
673
|
+
export declare function decodeEvent(data: string): JSONRPCMessage | undefined;
|
|
674
|
+
|
|
675
|
+
/**
|
|
676
|
+
* Reads the value one standard MCP request header carries, decoding the Base64 sentinel.
|
|
677
|
+
*
|
|
678
|
+
* @remarks
|
|
679
|
+
* The sentinel format is `=?base64?{Base64OfUTF8}?=`, spelled once as
|
|
680
|
+
* {@link MCP_SENTINEL_PREFIX} and {@link MCP_SENTINEL_SUFFIX} and read from there by both
|
|
681
|
+
* directions of the codec.
|
|
682
|
+
* The markers alone decide whether a value is a sentinel: a value carrying the prefix and the
|
|
683
|
+
* suffix is one, and its payload is then held to `decodeBase64` from `@orkestrel/codec` — the
|
|
684
|
+
* canonical RFC 4648 § 4 grammar, which admits exactly one spelling per byte sequence — and to
|
|
685
|
+
* well-formed UTF-8. A payload leaving a non-zero bit in the sextet its padding discards is a
|
|
686
|
+
* second spelling of a byte, so it is refused: `=?base64?QR==?=` reaches for the byte
|
|
687
|
+
* `=?base64?QQ==?=` spells canonically, and only the canonical spelling decodes. A malformed
|
|
688
|
+
* payload answers `undefined` rather than falling back to the literal, because the protocol
|
|
689
|
+
* requires a server to REJECT invalid characters, and a fallback would admit the very value
|
|
690
|
+
* the rule exists to refuse. A value missing either marker is a literal and comes back
|
|
691
|
+
* unchanged.
|
|
692
|
+
*
|
|
693
|
+
* `decodeUTF8` from `@orkestrel/codec` reads the bytes back as text: strict RFC 3629, where an
|
|
694
|
+
* overlong, an encoded surrogate, a code point past U+10FFFF, and a truncated sequence each
|
|
695
|
+
* answer `undefined` rather than a replacement character, and total, so the refusal arrives as
|
|
696
|
+
* that value instead of as a throw. It also keeps a leading U+FEFF as a character of the
|
|
697
|
+
* value, where the platform decoder consumes it as a byte order mark — which is what lets a
|
|
698
|
+
* value leading with U+FEFF survive {@link encodeSentinel} and come back whole.
|
|
699
|
+
*
|
|
700
|
+
* {@link import('./validators.js').isStandardBase64} is a wider and separate rule: it names
|
|
701
|
+
* JSON Schema `byte` membership for the blob, image, and audio content a peer sends, where
|
|
702
|
+
* this package receives liberally. It does not govern this payload.
|
|
703
|
+
*
|
|
704
|
+
* Optional whitespace is excluded first, per RFC 9110 § 5.5: a recipient parses a field value
|
|
705
|
+
* with its surrounding spaces and horizontal tabs removed, so a peer that padded a plain value
|
|
706
|
+
* still matches the body. A value whose own leading or trailing whitespace is significant
|
|
707
|
+
* cannot survive that, which is what {@link encodeSentinel} encodes it for.
|
|
708
|
+
*
|
|
709
|
+
* Total — never throws, whatever the input.
|
|
710
|
+
*
|
|
711
|
+
* @param value - The raw header field value the peer sent
|
|
712
|
+
* @returns The carried value, or `undefined` when the sentinel's payload is invalid
|
|
713
|
+
*
|
|
714
|
+
* @example
|
|
715
|
+
* ```ts
|
|
716
|
+
* decodeSentinel('=?base64?Y2Fmw6k=?=') // 'café'
|
|
717
|
+
* decodeSentinel(' search ') // 'search' — optional whitespace excluded
|
|
718
|
+
* decodeSentinel('=?base64?SGVsbG8?=') // undefined — invalid padding
|
|
719
|
+
* decodeSentinel('=?base64?QR==?=') // undefined — a non-canonical spelling
|
|
720
|
+
* ```
|
|
721
|
+
*/
|
|
722
|
+
export declare function decodeSentinel(value: string): string | undefined;
|
|
723
|
+
|
|
724
|
+
/**
|
|
725
|
+
* Sets the default modern result freshness lifetime in milliseconds.
|
|
530
726
|
*
|
|
531
727
|
* @remarks
|
|
532
728
|
* `ttlMs` is required on cacheable results, while zero means immediately stale
|
|
@@ -534,23 +730,31 @@ export declare function decodeBoundedMessage(message: string, limits: MCPJSONLim
|
|
|
534
730
|
*/
|
|
535
731
|
export declare const DEFAULT_MCP_CACHE_TTL = 60000;
|
|
536
732
|
|
|
537
|
-
/**
|
|
538
|
-
|
|
733
|
+
/**
|
|
734
|
+
* Supplies the default client name reported in the MCP `initialize` handshake
|
|
735
|
+
* (`clientInfo.name`).
|
|
736
|
+
*/
|
|
737
|
+
export declare const DEFAULT_MCP_CLIENT_NAME = "@orkestrel/mcp";
|
|
539
738
|
|
|
540
|
-
/**
|
|
739
|
+
/**
|
|
740
|
+
* Supplies the default client version reported in the MCP `initialize` handshake
|
|
741
|
+
* (`clientInfo.version`).
|
|
742
|
+
*/
|
|
541
743
|
export declare const DEFAULT_MCP_CLIENT_VERSION = "1.0.0";
|
|
542
744
|
|
|
543
745
|
/**
|
|
544
|
-
*
|
|
746
|
+
* Sets the secure server bounds used when the matching `limit` option leaf is absent or
|
|
747
|
+
* malformed.
|
|
545
748
|
*
|
|
546
749
|
* @remarks
|
|
547
750
|
* One MiB admits ordinary JSON-RPC requests and substantial tool arguments; 16 KiB admits
|
|
548
751
|
* extension-rich modern metadata and signed multi-round state; four MiB admits substantial
|
|
549
752
|
* JSON tool output without allowing an unconfigured service to serialize arbitrary process
|
|
550
|
-
* memory; 64
|
|
551
|
-
*
|
|
552
|
-
*
|
|
553
|
-
* defaults observed by later
|
|
753
|
+
* memory; 64 keys admits `_meta`'s reserved keys plus many extensions, and bounds a produced
|
|
754
|
+
* result's breadth by the same leaf; 128 concurrent streams admits a busy service while
|
|
755
|
+
* bounding retained producers; depth 32 admits ordinary JSON documents while rejecting
|
|
756
|
+
* stack-hostile nesting. Frozen so callers cannot alter the defaults observed by later
|
|
757
|
+
* servers.
|
|
554
758
|
*/
|
|
555
759
|
export declare const DEFAULT_MCP_LIMITS: Readonly<{
|
|
556
760
|
message: 1048576;
|
|
@@ -563,14 +767,39 @@ export declare const DEFAULT_MCP_LIMITS: Readonly<{
|
|
|
563
767
|
}>;
|
|
564
768
|
|
|
565
769
|
/**
|
|
566
|
-
*
|
|
770
|
+
* Sets the default per-request deadline (ms) an `MCPClient` applies when `options.timeout`
|
|
567
771
|
* is unset — a request the remote server does not answer within it rejects.
|
|
568
772
|
*/
|
|
569
773
|
export declare const DEFAULT_MCP_REQUEST_TIMEOUT = 30000;
|
|
570
774
|
|
|
571
|
-
/**
|
|
775
|
+
/** Sets the default number of subscription frames retained while no client read is parked. */
|
|
572
776
|
export declare const DEFAULT_MCP_SUBSCRIPTION_CAPACITY = 64;
|
|
573
777
|
|
|
778
|
+
/**
|
|
779
|
+
* Decodes one inbound frame and delivers it onto a transport emitter as `message` or `error`.
|
|
780
|
+
*
|
|
781
|
+
* @remarks
|
|
782
|
+
* The ONE inbound fold every message-carrying transport in this package runs: parse the frame,
|
|
783
|
+
* narrow it with `parseJSONRPCMessage`, emit `message` for a well-formed
|
|
784
|
+
* {@link JSONRPCMessage}, and emit `error` for anything else. Total — an adversarial frame
|
|
785
|
+
* produces an `error` emission and never a throw.
|
|
786
|
+
*
|
|
787
|
+
* The two failures report differently on purpose. Unparsable text emits the CAUGHT parse
|
|
788
|
+
* error, which names the offending position; well-formed JSON that is not a JSON-RPC message
|
|
789
|
+
* has no caught value to report, so it emits `fault` — the carrier's own wording, passed in
|
|
790
|
+
* rather than forked into a second copy of this body.
|
|
791
|
+
*
|
|
792
|
+
* @param emitter - The transport's emitter to deliver onto
|
|
793
|
+
* @param text - One inbound frame's raw text
|
|
794
|
+
* @param fault - The message for the error emitted when the frame parses but is not JSON-RPC
|
|
795
|
+
*
|
|
796
|
+
* @example
|
|
797
|
+
* ```ts
|
|
798
|
+
* deliverMessage(transport.emitter, frame, 'non-JSON-RPC WebSocket frame')
|
|
799
|
+
* ```
|
|
800
|
+
*/
|
|
801
|
+
export declare function deliverMessage(emitter: EmitterInterface<MCPMessageTransportEventMap>, text: string, fault: string): void;
|
|
802
|
+
|
|
574
803
|
/**
|
|
575
804
|
* Computes a lowercase host-neutral SHA-256 digest of one bounded canonical JSON value.
|
|
576
805
|
*
|
|
@@ -581,7 +810,7 @@ export declare const DEFAULT_MCP_SUBSCRIPTION_CAPACITY = 64;
|
|
|
581
810
|
export declare function digestJSON(value: unknown, limits: MCPJSONLimitOptions): Promise<string | undefined>;
|
|
582
811
|
|
|
583
812
|
/**
|
|
584
|
-
*
|
|
813
|
+
* Holds the one empty argument record every argument-less modern `tools/call` runs with.
|
|
585
814
|
*
|
|
586
815
|
* @remarks
|
|
587
816
|
* Frozen and null-prototype, and SHARED: two calls that name no `arguments` receive the same
|
|
@@ -596,6 +825,44 @@ export declare function digestJSON(value: unknown, limits: MCPJSONLimitOptions):
|
|
|
596
825
|
*/
|
|
597
826
|
export declare const EMPTY_MCP_ARGUMENTS: Readonly<Record<string, unknown>>;
|
|
598
827
|
|
|
828
|
+
/**
|
|
829
|
+
* Builds the wire form one standard MCP request header value must travel as.
|
|
830
|
+
*
|
|
831
|
+
* @remarks
|
|
832
|
+
* The exact inverse of {@link decodeSentinel}, and its membership rule is stated as that
|
|
833
|
+
* inverse rather than as a second list that could drift: a value travels LITERALLY when it is
|
|
834
|
+
* plain printable ASCII — every code point in `U+0020`–`U+007E`, the RFC 9110 field-value
|
|
835
|
+
* range this package admits — and {@link decodeSentinel} gives it back unchanged. Every other
|
|
836
|
+
* value travels wrapped in {@link MCP_SENTINEL_PREFIX} and {@link MCP_SENTINEL_SUFFIX}, the
|
|
837
|
+
* same markers the decode recognizes a sentinel by. `encodeBase64` from `@orkestrel/codec`
|
|
838
|
+
* spells the payload, so the wire form carries the canonical spelling {@link decodeSentinel}
|
|
839
|
+
* accepts.
|
|
840
|
+
*
|
|
841
|
+
* That one rule covers each row of the protocol's encoding table. A non-ASCII value and a
|
|
842
|
+
* value carrying a control character fail the ASCII test. A value with leading or trailing
|
|
843
|
+
* whitespace comes back trimmed, so it fails the round trip. A value already wearing the
|
|
844
|
+
* sentinel markers decodes to something else, or to nothing, so it fails the round trip too
|
|
845
|
+
* and is encoded rather than read back as a sentinel it never was.
|
|
846
|
+
*
|
|
847
|
+
* The bytes come from the platform `TextEncoder`, not from codec's `encodeUTF8`, and that is a
|
|
848
|
+
* ruling rather than an oversight. `TextEncoder` is total: it spells ill-formed text — a lone
|
|
849
|
+
* surrogate, which has no UTF-8 spelling — with the replacement character, so this function
|
|
850
|
+
* answers a `string` for every input. `encodeUTF8` refuses that text with `undefined`, which
|
|
851
|
+
* would widen this return to `string | undefined` and oblige every header projection to handle
|
|
852
|
+
* a value it cannot send. The decode side carries no such tension, so it reads back through
|
|
853
|
+
* codec's strict `decodeUTF8`.
|
|
854
|
+
*
|
|
855
|
+
* @param value - The value the header must carry
|
|
856
|
+
* @returns The literal value, or its Base64 sentinel form
|
|
857
|
+
*
|
|
858
|
+
* @example
|
|
859
|
+
* ```ts
|
|
860
|
+
* encodeSentinel('search') // 'search'
|
|
861
|
+
* encodeSentinel('café') // '=?base64?Y2Fmw6k=?='
|
|
862
|
+
* ```
|
|
863
|
+
*/
|
|
864
|
+
export declare function encodeSentinel(value: string): string;
|
|
865
|
+
|
|
599
866
|
/**
|
|
600
867
|
* Concatenates an MCP tool-call result's text content blocks into one string.
|
|
601
868
|
*
|
|
@@ -616,6 +883,157 @@ export declare const EMPTY_MCP_ARGUMENTS: Readonly<Record<string, unknown>>;
|
|
|
616
883
|
*/
|
|
617
884
|
export declare function extractContentText(result: unknown): string;
|
|
618
885
|
|
|
886
|
+
/**
|
|
887
|
+
* Reads every `x-mcp-header` annotation reachable from a schema node through `properties`.
|
|
888
|
+
*
|
|
889
|
+
* @remarks
|
|
890
|
+
* Reachability is the protocol's own rule: an annotation counts only where a chain of
|
|
891
|
+
* `properties` keys leads to it from the `inputSchema` root, so `path` is both the schema
|
|
892
|
+
* position and the position the call's `arguments` carry the value at. A property named
|
|
893
|
+
* `items` is reachable like any other, because the chain is read by key POSITION rather than
|
|
894
|
+
* by key name.
|
|
895
|
+
*
|
|
896
|
+
* `undefined` means the definition is invalid rather than empty: a reachable annotation whose
|
|
897
|
+
* value is not an {@link import('./validators.js').isFieldToken} token, one sitting on the
|
|
898
|
+
* schema ROOT (which is no property), one on a leaf whose declared type is not an
|
|
899
|
+
* {@link import('./validators.js').isMCPHeaderPrimitive} primitive, or a chain deeper than
|
|
900
|
+
* `DEFAULT_MCP_LIMITS.depth` — which is also what makes a self-referential schema terminate.
|
|
901
|
+
* A node that is not a record carries nothing and answers an empty list, because a leaf the
|
|
902
|
+
* walk cannot read is not a violation.
|
|
903
|
+
*
|
|
904
|
+
* @param schema - The schema node to read
|
|
905
|
+
* @param path - The `properties` keys already traversed; the root is called with `[]`
|
|
906
|
+
* @returns The annotations reachable from this node, or `undefined` when one is invalid
|
|
907
|
+
*
|
|
908
|
+
* @example
|
|
909
|
+
* ```ts
|
|
910
|
+
* extractHeaderAnnotations({ properties: { region: { type: 'string', 'x-mcp-header': 'Region' } } }, [])
|
|
911
|
+
* // → [{ name: 'Region', path: ['region'], primitive: 'string' }]
|
|
912
|
+
* ```
|
|
913
|
+
*/
|
|
914
|
+
export declare function extractHeaderAnnotations(schema: unknown, path: readonly string[]): readonly MCPHeaderParameter[] | undefined;
|
|
915
|
+
|
|
916
|
+
/**
|
|
917
|
+
* Reads one named tool's advertised `inputSchema` out of a `tools/list` answer.
|
|
918
|
+
*
|
|
919
|
+
* @remarks
|
|
920
|
+
* The answer is read as foreign data end to end — a dispatched response, an error envelope,
|
|
921
|
+
* and a result whose `tools` member is absent or is not an array all read as "no schema"
|
|
922
|
+
* rather than as a fault. That is what lets the HTTP POST handler ask its own dispatcher
|
|
923
|
+
* which `Mcp-Param-*` names a `tools/call` may carry without narrowing anything first.
|
|
924
|
+
*
|
|
925
|
+
* @param response - The `tools/list` answer, normally a {@link JSONRPCResponse}
|
|
926
|
+
* @param name - The tool whose schema to read
|
|
927
|
+
* @returns The advertised `inputSchema`, or `undefined` when the answer carries none
|
|
928
|
+
*
|
|
929
|
+
* @example
|
|
930
|
+
* ```ts
|
|
931
|
+
* extractToolSchema(answer, 'search')?.['properties']
|
|
932
|
+
* ```
|
|
933
|
+
*/
|
|
934
|
+
export declare function extractToolSchema(response: unknown, name: string): Readonly<Record<string, unknown>> | undefined;
|
|
935
|
+
|
|
936
|
+
/**
|
|
937
|
+
* Drives a REMOTE Streamable-HTTP MCP server over `fetch` — a CLIENT
|
|
938
|
+
* {@link MCPMessageTransportInterface} for the Model Context Protocol, the egress mirror of
|
|
939
|
+
* the server's `createMCPRoutes`.
|
|
940
|
+
*
|
|
941
|
+
* @remarks
|
|
942
|
+
* - **One class, both faces.** It touches `fetch`, `Response`, `AbortController`,
|
|
943
|
+
* `AbortSignal`, and `WeakMap` alone, so it is host-independent and lives in core. Each
|
|
944
|
+
* environment face publishes its own `createHTTPClientTransport` over it —
|
|
945
|
+
* `@orkestrel/mcp/browser` and `@orkestrel/mcp/server` — and both factories return this
|
|
946
|
+
* class, so a reply reaches a page and a Node process through the same decode.
|
|
947
|
+
* - **Request/response over `fetch`.** `send(message)` POSTs the JSON-serialized
|
|
948
|
+
* message to `options.url` with `content-type: application/json` and an
|
|
949
|
+
* `Accept` of BOTH `application/json` and `text/event-stream` (so the server may
|
|
950
|
+
* answer with either framing) — plus any `options.headers` (for example, an `Authorization`
|
|
951
|
+
* bearer). It then decodes the reply and emits each decoded {@link JSONRPCMessage} on
|
|
952
|
+
* the `message` event the {@link import('@orkestrel/mcp').MCPClientInterface} subscribes
|
|
953
|
+
* to.
|
|
954
|
+
* - **Both reply framings.** A `200` with an `application/json` body is parsed with
|
|
955
|
+
* `parseJSONRPCMessage`; a `200` with a `text/event-stream` body is decoded with the
|
|
956
|
+
* `@orkestrel/sse` {@link import('@orkestrel/sse').SSEParserInterface} ({@link
|
|
957
|
+
* readEventStream}) — the inverse of the server's `createStream` seam, so the wire
|
|
958
|
+
* round-trips. A `202`
|
|
959
|
+
* Accepted (a notification) carries no body and emits nothing.
|
|
960
|
+
* - **Session and protocol headers.** `start()` is a no-op (a
|
|
961
|
+
* request/response transport opens no long-lived connection). The
|
|
962
|
+
* `mcp-session-id` response header, when a STATEFUL server sends one (on
|
|
963
|
+
* `initialize`), is captured into `session` and then ECHOED as the
|
|
964
|
+
* `mcp-session-id` request header on every SUBSEQUENT request — so an
|
|
965
|
+
* `MCPClient` passes a stateful server's session validation. The
|
|
966
|
+
* initialize result's `protocolVersion` is likewise captured, but only
|
|
967
|
+
* when it is a SUPPORTED value, and echoed as `mcp-protocol-version` alone on
|
|
968
|
+
* subsequent legacy requests. Modern requests instead derive protocol and method
|
|
969
|
+
* headers from the message, plus the name header only for `tools/call` — carried in the
|
|
970
|
+
* protocol's Base64 sentinel form whenever the tool name cannot ride as plain ASCII.
|
|
971
|
+
* Before initialize returns, neither captured legacy header is sent.
|
|
972
|
+
* `close()` clears the captured protocol so a reconnect's `initialize`
|
|
973
|
+
* POST is headerless; the captured `session` persists across `close()`.
|
|
974
|
+
* - **`close()` releases what is in flight.** Every `fetch` this transport still has open is
|
|
975
|
+
* ABORTED, which cancels the response body a `send` is reading — an SSE reply the server
|
|
976
|
+
* never ends would otherwise outlive the transport, with nothing left able to reach it. The
|
|
977
|
+
* aborted read surfaces on `error` and the `send` reporting it resolves. `close()` is
|
|
978
|
+
* idempotent (one `close` event per connected lifetime), and `start()` opens the next one.
|
|
979
|
+
* - **Total at the boundary, and a non-success reply REJECTS.** Every reply is narrowed
|
|
980
|
+
* (`parseJSONRPCMessage`, the SSE decoder). A non-message success reply is dropped, never
|
|
981
|
+
* asserted. A non-success reply that carries no valid JSON-RPC message rejects `send` with
|
|
982
|
+
* an error naming its HTTP status and body shape — the peer answered, and answering the
|
|
983
|
+
* caller's request with silence would leave it waiting out its own deadline for a failure
|
|
984
|
+
* the transport already read. A valid JSON-RPC error body is emitted at any HTTP status,
|
|
985
|
+
* because the protocol carries that outcome in band. A `fetch` or decode failure on a
|
|
986
|
+
* success response surfaces on the `error` event rather than escaping `send`.
|
|
987
|
+
* - **Observable.** Owns the `emitter` ({@link MCPMessageTransportEventMap}); fires
|
|
988
|
+
* `message` per decoded reply, `error` on a fault, and `close` on `close()`.
|
|
989
|
+
*
|
|
990
|
+
* @example
|
|
991
|
+
* ```ts
|
|
992
|
+
* const transport = new HTTPClientTransport({ url: 'http://localhost:3000/mcp' })
|
|
993
|
+
* const client = new MCPClient({ transport })
|
|
994
|
+
* await client.connect()
|
|
995
|
+
* ```
|
|
996
|
+
*/
|
|
997
|
+
export declare class HTTPClientTransport implements MCPMessageTransportInterface {
|
|
998
|
+
#private;
|
|
999
|
+
constructor(options: HTTPClientTransportOptions);
|
|
1000
|
+
get emitter(): EmitterInterface<MCPMessageTransportEventMap>;
|
|
1001
|
+
get session(): string | undefined;
|
|
1002
|
+
get duplex(): boolean;
|
|
1003
|
+
start(): Promise<void>;
|
|
1004
|
+
send(message: JSONRPCMessage): Promise<void>;
|
|
1005
|
+
close(): Promise<void>;
|
|
1006
|
+
}
|
|
1007
|
+
|
|
1008
|
+
/**
|
|
1009
|
+
* Options for `createHTTPClientTransport` — the remote MCP server's URL and any extra
|
|
1010
|
+
* request headers.
|
|
1011
|
+
*
|
|
1012
|
+
* @remarks
|
|
1013
|
+
* - `url` — the absolute URL of the remote server's Streamable-HTTP endpoint (the
|
|
1014
|
+
* `POST` target every JSON-RPC message is written to, for example,
|
|
1015
|
+
* `http://localhost:3000/mcp`). REQUIRED.
|
|
1016
|
+
* - `headers` — extra request headers merged onto every `POST` (for example, an
|
|
1017
|
+
* `Authorization` bearer for a guarded server). The transport always sets
|
|
1018
|
+
* `content-type: application/json` and an `Accept` of both `application/json` and
|
|
1019
|
+
* `text/event-stream` (so the server may answer with either framing); a key supplied
|
|
1020
|
+
* here is merged on top.
|
|
1021
|
+
* - `fetch` — the `fetch` implementation to issue each `POST` with; defaults to
|
|
1022
|
+
* `globalThis.fetch` bound to `globalThis`. Injectable for a test double or a non-global
|
|
1023
|
+
* `fetch`.
|
|
1024
|
+
* - `timeout` — an optional per-request timeout in milliseconds; when set, each
|
|
1025
|
+
* `fetch` call composes that deadline with the transport's own close through
|
|
1026
|
+
* `AbortSignal.any([close, AbortSignal.timeout(timeout)])`, so whichever fires first
|
|
1027
|
+
* ends the request. Omit for no transport-level deadline; the close signal is passed
|
|
1028
|
+
* either way.
|
|
1029
|
+
*/
|
|
1030
|
+
export declare interface HTTPClientTransportOptions {
|
|
1031
|
+
readonly url: string;
|
|
1032
|
+
readonly headers?: Readonly<Record<string, string>>;
|
|
1033
|
+
readonly fetch?: typeof fetch;
|
|
1034
|
+
readonly timeout?: number;
|
|
1035
|
+
}
|
|
1036
|
+
|
|
619
1037
|
/**
|
|
620
1038
|
* Infers the wire era for an MCP protocol revision.
|
|
621
1039
|
*
|
|
@@ -630,6 +1048,26 @@ export declare function extractContentText(result: unknown): string;
|
|
|
630
1048
|
*/
|
|
631
1049
|
export declare function inferEra(version: string): MCPEra | undefined;
|
|
632
1050
|
|
|
1051
|
+
/**
|
|
1052
|
+
* Infers the wire era one invocation's own structure selects.
|
|
1053
|
+
*
|
|
1054
|
+
* @remarks
|
|
1055
|
+
* The STRUCTURAL read, distinct from {@link inferEra}'s read of a revision string: era is fixed
|
|
1056
|
+
* by the reserved modern metadata a request carries, so this answers for a message whose
|
|
1057
|
+
* revision has not been read and cannot answer `undefined` — every invocation took one of the
|
|
1058
|
+
* two published wire shapes. It is what an observation surface reports and what an ingress
|
|
1059
|
+
* routes on, so both derive it here rather than each spelling the ternary out.
|
|
1060
|
+
*
|
|
1061
|
+
* @param invocation - The invocation whose structure selects the era
|
|
1062
|
+
* @returns `'modern'` when the invocation carries the modern request shape, `'legacy'` otherwise
|
|
1063
|
+
*
|
|
1064
|
+
* @example
|
|
1065
|
+
* ```ts
|
|
1066
|
+
* inferRequestEra({ jsonrpc: '2.0', id: 1, method: 'tools/list', params: { _meta: meta } })
|
|
1067
|
+
* ```
|
|
1068
|
+
*/
|
|
1069
|
+
export declare function inferRequestEra(invocation: JSONRPCInvocation): MCPEra;
|
|
1070
|
+
|
|
633
1071
|
/**
|
|
634
1072
|
* Infers the protocol version an outbound message announces itself with — the ONE
|
|
635
1073
|
* projection every HTTP client transport stamps `mcp-protocol-version` from.
|
|
@@ -677,7 +1115,7 @@ export declare function inferVersion(offered: readonly string[]): MCPModernVersi
|
|
|
677
1115
|
* scheme allowlist. Component scanning is bounded by the input length.
|
|
678
1116
|
*
|
|
679
1117
|
* @param value - The unknown value to inspect
|
|
680
|
-
* @returns
|
|
1118
|
+
* @returns True if the value is an RFC 3986 URI rather than a relative reference; false otherwise
|
|
681
1119
|
*/
|
|
682
1120
|
export declare function isAbsoluteURI(value: unknown): value is string;
|
|
683
1121
|
|
|
@@ -691,7 +1129,7 @@ export declare function isAbsoluteURI(value: unknown): value is string;
|
|
|
691
1129
|
*
|
|
692
1130
|
* @param value - The unknown value to inspect
|
|
693
1131
|
* @param limits - Serialized byte, optional key, and nesting-depth bounds
|
|
694
|
-
* @returns `
|
|
1132
|
+
* @returns True if `value` is safe JSON satisfying every bound; false otherwise
|
|
695
1133
|
*
|
|
696
1134
|
* @example
|
|
697
1135
|
* ```ts
|
|
@@ -705,7 +1143,7 @@ export declare function isBoundedJSON<T>(value: T, limits: MCPJSONLimitOptions):
|
|
|
705
1143
|
*
|
|
706
1144
|
* @param value - The unknown value to inspect
|
|
707
1145
|
* @param bytes - The maximum accepted encoded bytes
|
|
708
|
-
* @returns `
|
|
1146
|
+
* @returns True if `value` is a string whose UTF-8 representation fits the bound; false otherwise
|
|
709
1147
|
*
|
|
710
1148
|
* @example
|
|
711
1149
|
* ```ts
|
|
@@ -742,7 +1180,7 @@ export declare function isBoundedString(value: unknown, bytes: number): value is
|
|
|
742
1180
|
*
|
|
743
1181
|
* @param value - The accepted response content to check
|
|
744
1182
|
* @param schema - The exact {@link MCPElicitSchema} that was issued with the elicitation
|
|
745
|
-
* @returns
|
|
1183
|
+
* @returns True if every declared and undeclared value is legal under `schema`; false otherwise
|
|
746
1184
|
*
|
|
747
1185
|
* @example
|
|
748
1186
|
* ```ts
|
|
@@ -759,29 +1197,31 @@ export declare function isBoundedString(value: unknown, bytes: number): value is
|
|
|
759
1197
|
export declare function isElicitContent(value: unknown, schema: unknown): value is Readonly<Record<string, MCPElicitValue>>;
|
|
760
1198
|
|
|
761
1199
|
/**
|
|
762
|
-
* Determines whether a
|
|
1200
|
+
* Determines whether a value is one RFC 9110 field token.
|
|
763
1201
|
*
|
|
764
1202
|
* @remarks
|
|
765
|
-
*
|
|
766
|
-
*
|
|
767
|
-
*
|
|
1203
|
+
* A token is one or more `tchar`: the ASCII letters, the digits, and
|
|
1204
|
+
* ``!#$%&'*+-.^_`|~``. That set already excludes the empty string, whitespace, a colon, a
|
|
1205
|
+
* control character, and every non-ASCII code point, so it is the whole constraint an
|
|
1206
|
+
* `x-mcp-header` annotation's value must satisfy — the value is appended verbatim to
|
|
1207
|
+
* {@link MCP_PARAM_PREFIX} and must survive as an HTTP field name.
|
|
768
1208
|
*
|
|
769
|
-
* @param value - The
|
|
770
|
-
* @returns
|
|
1209
|
+
* @param value - The unknown value to inspect
|
|
1210
|
+
* @returns True if the value is a non-empty RFC 9110 token; false otherwise
|
|
771
1211
|
*
|
|
772
1212
|
* @example
|
|
773
1213
|
* ```ts
|
|
774
|
-
*
|
|
775
|
-
*
|
|
1214
|
+
* isFieldToken('Region') // true
|
|
1215
|
+
* isFieldToken('My Region') // false
|
|
776
1216
|
* ```
|
|
777
1217
|
*/
|
|
778
|
-
export declare function
|
|
1218
|
+
export declare function isFieldToken(value: unknown): value is string;
|
|
779
1219
|
|
|
780
1220
|
/**
|
|
781
1221
|
* Determines whether a parsed value is an MCP `initialize` invocation.
|
|
782
1222
|
*
|
|
783
1223
|
* @param value - The already-parsed value to test
|
|
784
|
-
* @returns
|
|
1224
|
+
* @returns True if `value` is a valid `initialize` request or notification; false otherwise
|
|
785
1225
|
*
|
|
786
1226
|
* @example
|
|
787
1227
|
* ```ts
|
|
@@ -813,7 +1253,7 @@ export declare function isJSONObject(value: unknown): value is Readonly<Record<s
|
|
|
813
1253
|
* itself the hostile step, and it is bounded here rather than allowed to escape. Total.
|
|
814
1254
|
*
|
|
815
1255
|
* @param value - The already-parsed value to test
|
|
816
|
-
* @returns
|
|
1256
|
+
* @returns True if `value` carries an integer `code` and a string `message`; false otherwise
|
|
817
1257
|
*
|
|
818
1258
|
* @example
|
|
819
1259
|
* ```ts
|
|
@@ -834,7 +1274,7 @@ export declare function isJSONRPCError(value: unknown): value is JSONRPCError;
|
|
|
834
1274
|
* `result`. `error` carries an integer `code` and a string `message`. Total.
|
|
835
1275
|
*
|
|
836
1276
|
* @param value - The already-parsed value to test
|
|
837
|
-
* @returns
|
|
1277
|
+
* @returns True if `value` is a valid JSON-RPC error response; false otherwise
|
|
838
1278
|
*
|
|
839
1279
|
* @example
|
|
840
1280
|
* ```ts
|
|
@@ -856,7 +1296,7 @@ export declare function isJSONRPCErrorResponse(value: unknown): value is JSONRPC
|
|
|
856
1296
|
* no minimum length. Total: any other input returns `false`.
|
|
857
1297
|
*
|
|
858
1298
|
* @param value - The already-parsed value to test
|
|
859
|
-
* @returns
|
|
1299
|
+
* @returns True if `value` is a string or a finite integer; false otherwise
|
|
860
1300
|
*
|
|
861
1301
|
* @example
|
|
862
1302
|
* ```ts
|
|
@@ -878,7 +1318,7 @@ export declare function isJSONRPCId(value: unknown): value is JSONRPCId;
|
|
|
878
1318
|
* mutually exclusive, so a positive answer names exactly one arm. Total.
|
|
879
1319
|
*
|
|
880
1320
|
* @param value - The already-parsed value to test
|
|
881
|
-
* @returns
|
|
1321
|
+
* @returns True if `value` is a valid JSON-RPC request or notification; false otherwise
|
|
882
1322
|
*/
|
|
883
1323
|
export declare function isJSONRPCInvocation(value: unknown): value is JSONRPCInvocation;
|
|
884
1324
|
|
|
@@ -890,7 +1330,7 @@ export declare function isJSONRPCInvocation(value: unknown): value is JSONRPCInv
|
|
|
890
1330
|
* The union of {@link isJSONRPCInvocation} and {@link isJSONRPCResponse}. Total.
|
|
891
1331
|
*
|
|
892
1332
|
* @param value - The already-parsed value to test
|
|
893
|
-
* @returns
|
|
1333
|
+
* @returns True if `value` is a valid JSON-RPC message; false otherwise
|
|
894
1334
|
*/
|
|
895
1335
|
export declare function isJSONRPCMessage(value: unknown): value is JSONRPCMessage;
|
|
896
1336
|
|
|
@@ -903,7 +1343,7 @@ export declare function isJSONRPCMessage(value: unknown): value is JSONRPCMessag
|
|
|
903
1343
|
* be a record. Total: any other input returns `false`.
|
|
904
1344
|
*
|
|
905
1345
|
* @param value - The already-parsed value to test
|
|
906
|
-
* @returns
|
|
1346
|
+
* @returns True if `value` is a valid JSON-RPC notification; false otherwise
|
|
907
1347
|
*
|
|
908
1348
|
* @example
|
|
909
1349
|
* ```ts
|
|
@@ -925,7 +1365,7 @@ export declare function isJSONRPCNotification(value: unknown): value is JSONRPCN
|
|
|
925
1365
|
* be a record. Total: any other input returns `false`.
|
|
926
1366
|
*
|
|
927
1367
|
* @param value - The already-parsed value to test
|
|
928
|
-
* @returns
|
|
1368
|
+
* @returns True if `value` is a valid JSON-RPC request; false otherwise
|
|
929
1369
|
*
|
|
930
1370
|
* @example
|
|
931
1371
|
* ```ts
|
|
@@ -943,7 +1383,7 @@ export declare function isJSONRPCRequest(value: unknown): value is JSONRPCReques
|
|
|
943
1383
|
* The union of the mutually exclusive arms. Total.
|
|
944
1384
|
*
|
|
945
1385
|
* @param value - The already-parsed value to test
|
|
946
|
-
* @returns
|
|
1386
|
+
* @returns True if `value` is a valid JSON-RPC response; false otherwise
|
|
947
1387
|
*/
|
|
948
1388
|
export declare function isJSONRPCResponse(value: unknown): value is JSONRPCResponse;
|
|
949
1389
|
|
|
@@ -960,7 +1400,7 @@ export declare function isJSONRPCResponse(value: unknown): value is JSONRPCRespo
|
|
|
960
1400
|
* Total.
|
|
961
1401
|
*
|
|
962
1402
|
* @param value - The already-parsed value to test
|
|
963
|
-
* @returns
|
|
1403
|
+
* @returns True if `value` is a valid JSON-RPC result response; false otherwise
|
|
964
1404
|
*
|
|
965
1405
|
* @example
|
|
966
1406
|
* ```ts
|
|
@@ -974,7 +1414,7 @@ export declare function isJSONRPCResultResponse(value: unknown): value is JSONRP
|
|
|
974
1414
|
* Determines whether a value carries valid dated-schema MCP content annotations.
|
|
975
1415
|
*
|
|
976
1416
|
* @param value - The unknown value to inspect
|
|
977
|
-
* @returns
|
|
1417
|
+
* @returns True if the value is valid MCP annotations; false otherwise
|
|
978
1418
|
*/
|
|
979
1419
|
export declare function isMCPAnnotations(value: unknown): value is MCPAnnotations;
|
|
980
1420
|
|
|
@@ -982,7 +1422,7 @@ export declare function isMCPAnnotations(value: unknown): value is MCPAnnotation
|
|
|
982
1422
|
* Determines whether a value is embedded blob MCP resource contents.
|
|
983
1423
|
*
|
|
984
1424
|
* @param value - The unknown value to inspect
|
|
985
|
-
* @returns
|
|
1425
|
+
* @returns True if the value is embedded blob resource contents; false otherwise
|
|
986
1426
|
*/
|
|
987
1427
|
export declare function isMCPBlobResource(value: unknown): value is MCPBlobResource;
|
|
988
1428
|
|
|
@@ -990,7 +1430,7 @@ export declare function isMCPBlobResource(value: unknown): value is MCPBlobResou
|
|
|
990
1430
|
* Determines whether a value is a complete modern MCP tool result.
|
|
991
1431
|
*
|
|
992
1432
|
* @param value - The unknown value to inspect
|
|
993
|
-
* @returns
|
|
1433
|
+
* @returns True if the value is a complete MCP call result; false otherwise
|
|
994
1434
|
*/
|
|
995
1435
|
export declare function isMCPCallResult(value: unknown): value is MCPCallResult;
|
|
996
1436
|
|
|
@@ -1001,7 +1441,7 @@ export declare function isMCPClientCapabilities(value: unknown): value is MCPCli
|
|
|
1001
1441
|
* Determines whether a value is one host-produced completion candidate set.
|
|
1002
1442
|
*
|
|
1003
1443
|
* @param value - The unknown value to inspect
|
|
1004
|
-
* @returns
|
|
1444
|
+
* @returns True if its candidates and optional result facts are valid; false otherwise
|
|
1005
1445
|
*/
|
|
1006
1446
|
export declare function isMCPCompletion(value: unknown): value is MCPCompletion;
|
|
1007
1447
|
|
|
@@ -1009,7 +1449,7 @@ export declare function isMCPCompletion(value: unknown): value is MCPCompletion;
|
|
|
1009
1449
|
* Determines whether a value is one `completion/complete` parameter object.
|
|
1010
1450
|
*
|
|
1011
1451
|
* @param value - The unknown value to inspect
|
|
1012
|
-
* @returns
|
|
1452
|
+
* @returns True if its reference, fragment, and optional string context are valid; false otherwise
|
|
1013
1453
|
*/
|
|
1014
1454
|
export declare function isMCPCompletionParams(value: unknown): value is MCPCompletionParams;
|
|
1015
1455
|
|
|
@@ -1017,7 +1457,7 @@ export declare function isMCPCompletionParams(value: unknown): value is MCPCompl
|
|
|
1017
1457
|
* Determines whether a value is a prompt or resource-template completion reference.
|
|
1018
1458
|
*
|
|
1019
1459
|
* @param value - The unknown value to inspect
|
|
1020
|
-
* @returns
|
|
1460
|
+
* @returns True if the discriminated reference is valid; false otherwise
|
|
1021
1461
|
*/
|
|
1022
1462
|
export declare function isMCPCompletionReference(value: unknown): value is MCPCompletionReference;
|
|
1023
1463
|
|
|
@@ -1025,7 +1465,7 @@ export declare function isMCPCompletionReference(value: unknown): value is MCPCo
|
|
|
1025
1465
|
* Determines whether a value is one complete, capped `completion/complete` result.
|
|
1026
1466
|
*
|
|
1027
1467
|
* @param value - The unknown value to inspect
|
|
1028
|
-
* @returns
|
|
1468
|
+
* @returns True if the result is complete and carries at most 100 candidates; false otherwise
|
|
1029
1469
|
*/
|
|
1030
1470
|
export declare function isMCPCompletionResult(value: unknown): value is MCPCompletionResult;
|
|
1031
1471
|
|
|
@@ -1033,7 +1473,7 @@ export declare function isMCPCompletionResult(value: unknown): value is MCPCompl
|
|
|
1033
1473
|
* Determines whether a value is one exact dated-schema MCP tool content block.
|
|
1034
1474
|
*
|
|
1035
1475
|
* @param value - The unknown value to inspect
|
|
1036
|
-
* @returns
|
|
1476
|
+
* @returns True if the value is valid MCP content; false otherwise
|
|
1037
1477
|
*/
|
|
1038
1478
|
export declare function isMCPContent(value: unknown): value is MCPContent;
|
|
1039
1479
|
|
|
@@ -1041,7 +1481,7 @@ export declare function isMCPContent(value: unknown): value is MCPContent;
|
|
|
1041
1481
|
* Determines whether a value is one restricted primitive form-elicitation schema.
|
|
1042
1482
|
*
|
|
1043
1483
|
* @param value - The unknown value to inspect
|
|
1044
|
-
* @returns `
|
|
1484
|
+
* @returns True if `value` is a supported boolean, numeric, string, or string-array schema; false otherwise
|
|
1045
1485
|
*
|
|
1046
1486
|
* @example
|
|
1047
1487
|
* ```ts
|
|
@@ -1055,7 +1495,7 @@ export declare function isMCPElicitFieldSchema(value: unknown): value is MCPElic
|
|
|
1055
1495
|
* Determines whether a value is a form-mode elicitation parameter object.
|
|
1056
1496
|
*
|
|
1057
1497
|
* @param value - The unknown value to inspect
|
|
1058
|
-
* @returns
|
|
1498
|
+
* @returns True if `value` has the restricted form elicitation shape; false otherwise
|
|
1059
1499
|
*
|
|
1060
1500
|
* @example
|
|
1061
1501
|
* ```ts
|
|
@@ -1071,7 +1511,7 @@ export declare function isMCPElicitForm(value: unknown): value is MCPElicitForm;
|
|
|
1071
1511
|
* Determines whether a value is an embedded `elicitation/create` request.
|
|
1072
1512
|
*
|
|
1073
1513
|
* @param value - The unknown value to inspect
|
|
1074
|
-
* @returns
|
|
1514
|
+
* @returns True if `value` is a form- or URL-mode elicitation request; false otherwise
|
|
1075
1515
|
*
|
|
1076
1516
|
* @example
|
|
1077
1517
|
* ```ts
|
|
@@ -1087,7 +1527,7 @@ export declare function isMCPElicitRequest(value: unknown): value is MCPElicitRe
|
|
|
1087
1527
|
* Determines whether a value is one elicitation response.
|
|
1088
1528
|
*
|
|
1089
1529
|
* @param value - The unknown value to inspect
|
|
1090
|
-
* @returns
|
|
1530
|
+
* @returns True if action/content have the protocol shape; false otherwise
|
|
1091
1531
|
*
|
|
1092
1532
|
* @example
|
|
1093
1533
|
* ```ts
|
|
@@ -1107,7 +1547,7 @@ export declare function isMCPElicitResult(value: unknown): value is MCPElicitRes
|
|
|
1107
1547
|
* an unrecognized top-level annotation is data rather than a rejection.
|
|
1108
1548
|
*
|
|
1109
1549
|
* @param value - The unknown value to inspect
|
|
1110
|
-
* @returns
|
|
1550
|
+
* @returns True if `value` is a restricted object schema of supported field schemas; false otherwise
|
|
1111
1551
|
*
|
|
1112
1552
|
* @example
|
|
1113
1553
|
* ```ts
|
|
@@ -1121,7 +1561,7 @@ export declare function isMCPElicitSchema(value: unknown): value is MCPElicitSch
|
|
|
1121
1561
|
* Determines whether a value is a URL-mode elicitation parameter object.
|
|
1122
1562
|
*
|
|
1123
1563
|
* @param value - The unknown value to inspect
|
|
1124
|
-
* @returns
|
|
1564
|
+
* @returns True if `value` has the URL elicitation shape; false otherwise
|
|
1125
1565
|
*
|
|
1126
1566
|
* @example
|
|
1127
1567
|
* ```ts
|
|
@@ -1134,7 +1574,7 @@ export declare function isMCPElicitURL(value: unknown): value is MCPElicitURL;
|
|
|
1134
1574
|
* Determines whether an unknown value is an {@link MCPError}.
|
|
1135
1575
|
*
|
|
1136
1576
|
* @param value - The unknown value to inspect
|
|
1137
|
-
* @returns
|
|
1577
|
+
* @returns True if the value is an `MCPError`; false otherwise
|
|
1138
1578
|
*
|
|
1139
1579
|
* @example
|
|
1140
1580
|
* ```ts
|
|
@@ -1144,11 +1584,30 @@ export declare function isMCPElicitURL(value: unknown): value is MCPElicitURL;
|
|
|
1144
1584
|
*/
|
|
1145
1585
|
export declare function isMCPError(value: unknown): value is MCPError;
|
|
1146
1586
|
|
|
1587
|
+
/**
|
|
1588
|
+
* Determines whether a value is a JSON Schema type an `x-mcp-header` annotation may sit on.
|
|
1589
|
+
*
|
|
1590
|
+
* @remarks
|
|
1591
|
+
* `number` is refused deliberately: a JSON number has no interoperable decimal text form, so
|
|
1592
|
+
* a header carrying one could not be compared with the body byte for byte. `integer` renders
|
|
1593
|
+
* exactly, and the server compares it numerically.
|
|
1594
|
+
*
|
|
1595
|
+
* @param value - The unknown value to inspect
|
|
1596
|
+
* @returns True if the value is one of `'string'`, `'integer'`, or `'boolean'`; false otherwise
|
|
1597
|
+
*
|
|
1598
|
+
* @example
|
|
1599
|
+
* ```ts
|
|
1600
|
+
* isMCPHeaderPrimitive('integer') // true
|
|
1601
|
+
* isMCPHeaderPrimitive('number') // false
|
|
1602
|
+
* ```
|
|
1603
|
+
*/
|
|
1604
|
+
export declare function isMCPHeaderPrimitive(value: unknown): value is MCPHeaderPrimitive;
|
|
1605
|
+
|
|
1147
1606
|
/**
|
|
1148
1607
|
* Determines whether a value is one exact dated-schema MCP icon.
|
|
1149
1608
|
*
|
|
1150
1609
|
* @param value - The unknown value to inspect
|
|
1151
|
-
* @returns
|
|
1610
|
+
* @returns True if the value is a valid MCP icon; false otherwise
|
|
1152
1611
|
*/
|
|
1153
1612
|
export declare function isMCPIcon(value: unknown): value is MCPIcon;
|
|
1154
1613
|
|
|
@@ -1159,7 +1618,7 @@ export declare function isMCPIdentity(value: unknown): value is MCPIdentity;
|
|
|
1159
1618
|
* Determines whether a value is one legal embedded multi-round-trip request.
|
|
1160
1619
|
*
|
|
1161
1620
|
* @param value - The unknown value to inspect
|
|
1162
|
-
* @returns `
|
|
1621
|
+
* @returns True if `value` is an embedded elicitation, sampling, or roots request; false otherwise
|
|
1163
1622
|
*
|
|
1164
1623
|
* @example
|
|
1165
1624
|
* ```ts
|
|
@@ -1169,10 +1628,10 @@ export declare function isMCPIdentity(value: unknown): value is MCPIdentity;
|
|
|
1169
1628
|
export declare function isMCPInputRequest(value: unknown): value is MCPInputRequest;
|
|
1170
1629
|
|
|
1171
1630
|
/**
|
|
1172
|
-
* Determines whether a value is a
|
|
1631
|
+
* Determines whether a value is a consumer-keyed map of embedded input requests.
|
|
1173
1632
|
*
|
|
1174
1633
|
* @param value - The unknown value to inspect
|
|
1175
|
-
* @returns
|
|
1634
|
+
* @returns True if every own value is a legal {@link MCPInputRequest}; false otherwise
|
|
1176
1635
|
*
|
|
1177
1636
|
* @example
|
|
1178
1637
|
* ```ts
|
|
@@ -1181,6 +1640,30 @@ export declare function isMCPInputRequest(value: unknown): value is MCPInputRequ
|
|
|
1181
1640
|
*/
|
|
1182
1641
|
export declare function isMCPInputRequestMap(value: unknown): value is MCPInputRequestMap;
|
|
1183
1642
|
|
|
1643
|
+
/**
|
|
1644
|
+
* Determines whether a response answers the exact embedded request that was issued.
|
|
1645
|
+
*
|
|
1646
|
+
* @remarks
|
|
1647
|
+
* A response carries no `method` of its own, so the ISSUED request selects which arm applies
|
|
1648
|
+
* — the same way {@link isElicitContent} takes the issued schema rather than trusting the
|
|
1649
|
+
* content to describe itself. A form elicitation is checked twice: once for the response
|
|
1650
|
+
* shape and once, on `accept`, for the content against the schema that round issued. A
|
|
1651
|
+
* URL-mode elicitation issues no schema, so only the shape is checked. A request this
|
|
1652
|
+
* package cannot recognize admits NOTHING, because an unrecognized question has no correct
|
|
1653
|
+
* answer. Total over hostile responses and hostile requests alike.
|
|
1654
|
+
*
|
|
1655
|
+
* @param value - The client's answer to check
|
|
1656
|
+
* @param request - The exact {@link MCPInputRequest} that was issued under the same key
|
|
1657
|
+
* @returns True if the answer is legal for that request; false otherwise
|
|
1658
|
+
*
|
|
1659
|
+
* @example
|
|
1660
|
+
* ```ts
|
|
1661
|
+
* isMCPInputResponse({ roots: [] }, { method: 'roots/list' }) // true
|
|
1662
|
+
* isMCPInputResponse({ roots: [] }, { method: 'sampling/createMessage', params: {} }) // false
|
|
1663
|
+
* ```
|
|
1664
|
+
*/
|
|
1665
|
+
export declare function isMCPInputResponse(value: unknown, request: unknown): value is MCPInputResponse;
|
|
1666
|
+
|
|
1184
1667
|
/**
|
|
1185
1668
|
* Determines whether a value is an MCP input-required result.
|
|
1186
1669
|
*
|
|
@@ -1189,7 +1672,7 @@ export declare function isMCPInputRequestMap(value: unknown): value is MCPInputR
|
|
|
1189
1672
|
* both must be present and valid. Total over hostile input.
|
|
1190
1673
|
*
|
|
1191
1674
|
* @param value - The unknown value to inspect
|
|
1192
|
-
* @returns
|
|
1675
|
+
* @returns True if `value` is a valid input-required result; false otherwise
|
|
1193
1676
|
*
|
|
1194
1677
|
* @example
|
|
1195
1678
|
* ```ts
|
|
@@ -1208,7 +1691,7 @@ export declare function isMCPInputResult(value: unknown): value is MCPInputResul
|
|
|
1208
1691
|
* hostile input.
|
|
1209
1692
|
*
|
|
1210
1693
|
* @param value - The unknown value to inspect
|
|
1211
|
-
* @returns
|
|
1694
|
+
* @returns True if the value is a legacy result; false otherwise
|
|
1212
1695
|
*
|
|
1213
1696
|
* @example
|
|
1214
1697
|
* ```ts
|
|
@@ -1222,7 +1705,7 @@ export declare function isMCPLegacyResult(value: unknown): value is MCPLegacyRes
|
|
|
1222
1705
|
* Determines whether a value is a revision accepted by the optional legacy decorator.
|
|
1223
1706
|
*
|
|
1224
1707
|
* @param value - The unknown value to inspect
|
|
1225
|
-
* @returns
|
|
1708
|
+
* @returns True if the value is one of {@link SUPPORTED_LEGACY_PROTOCOL_VERSIONS}; false otherwise
|
|
1226
1709
|
*/
|
|
1227
1710
|
export declare function isMCPLegacyVersion(value: unknown): value is MCPLegacyVersion;
|
|
1228
1711
|
|
|
@@ -1239,7 +1722,7 @@ export declare function isMCPMetaObject(value: unknown): value is MCPMetaObject;
|
|
|
1239
1722
|
* Determines whether a value is a modern protocol revision accepted by a bare server.
|
|
1240
1723
|
*
|
|
1241
1724
|
* @param value - The unknown value to inspect
|
|
1242
|
-
* @returns
|
|
1725
|
+
* @returns True if the value is one of {@link SUPPORTED_MODERN_PROTOCOL_VERSIONS}; false otherwise
|
|
1243
1726
|
*/
|
|
1244
1727
|
export declare function isMCPModernVersion(value: unknown): value is MCPModernVersion;
|
|
1245
1728
|
|
|
@@ -1253,7 +1736,7 @@ export declare function isMCPModernVersion(value: unknown): value is MCPModernVe
|
|
|
1253
1736
|
* {@link JSONRPCId}, because a stamp naming nothing addressable is worse than no stamp.
|
|
1254
1737
|
*
|
|
1255
1738
|
* @param value - The unknown value to inspect
|
|
1256
|
-
* @returns
|
|
1739
|
+
* @returns True if the value is exact metadata whose subscription stamp, if present, is valid; false otherwise
|
|
1257
1740
|
*
|
|
1258
1741
|
* @example
|
|
1259
1742
|
* ```ts
|
|
@@ -1268,7 +1751,7 @@ export declare function isMCPNotificationMetaObject(value: unknown): value is MC
|
|
|
1268
1751
|
* Determines whether a value carries the shared optional pagination cursor.
|
|
1269
1752
|
*
|
|
1270
1753
|
* @param value - The unknown value to inspect
|
|
1271
|
-
* @returns
|
|
1754
|
+
* @returns True if a present `cursor` is a string; false otherwise
|
|
1272
1755
|
*/
|
|
1273
1756
|
export declare function isMCPPaginationParams(value: unknown): value is MCPPaginationParams;
|
|
1274
1757
|
|
|
@@ -1276,7 +1759,7 @@ export declare function isMCPPaginationParams(value: unknown): value is MCPPagin
|
|
|
1276
1759
|
* Determines whether a value is one exact finite MCP progress payload.
|
|
1277
1760
|
*
|
|
1278
1761
|
* @param value - The unknown value to inspect
|
|
1279
|
-
* @returns
|
|
1762
|
+
* @returns True if required progress and optional total/message fields match the dated schema; false otherwise
|
|
1280
1763
|
*/
|
|
1281
1764
|
export declare function isMCPProgress(value: unknown): value is MCPProgress;
|
|
1282
1765
|
|
|
@@ -1284,7 +1767,7 @@ export declare function isMCPProgress(value: unknown): value is MCPProgress;
|
|
|
1284
1767
|
* Determines whether a value is one `prompts/list` descriptor.
|
|
1285
1768
|
*
|
|
1286
1769
|
* @param value - The unknown value to inspect
|
|
1287
|
-
* @returns
|
|
1770
|
+
* @returns True if the prompt descriptor is valid; false otherwise
|
|
1288
1771
|
*/
|
|
1289
1772
|
export declare function isMCPPrompt(value: unknown): value is MCPPrompt;
|
|
1290
1773
|
|
|
@@ -1292,7 +1775,7 @@ export declare function isMCPPrompt(value: unknown): value is MCPPrompt;
|
|
|
1292
1775
|
* Determines whether a value is one prompt argument descriptor.
|
|
1293
1776
|
*
|
|
1294
1777
|
* @param value - The unknown value to inspect
|
|
1295
|
-
* @returns
|
|
1778
|
+
* @returns True if the prompt argument descriptor is valid; false otherwise
|
|
1296
1779
|
*/
|
|
1297
1780
|
export declare function isMCPPromptArgument(value: unknown): value is MCPPromptArgument;
|
|
1298
1781
|
|
|
@@ -1300,7 +1783,7 @@ export declare function isMCPPromptArgument(value: unknown): value is MCPPromptA
|
|
|
1300
1783
|
* Determines whether a value is one complete `prompts/get` result.
|
|
1301
1784
|
*
|
|
1302
1785
|
* @param value - The unknown value to inspect
|
|
1303
|
-
* @returns
|
|
1786
|
+
* @returns True if the prompt result and all messages are valid; false otherwise
|
|
1304
1787
|
*/
|
|
1305
1788
|
export declare function isMCPPromptGetResult(value: unknown): value is MCPPromptGetResult;
|
|
1306
1789
|
|
|
@@ -1308,7 +1791,7 @@ export declare function isMCPPromptGetResult(value: unknown): value is MCPPrompt
|
|
|
1308
1791
|
* Determines whether a value is one prompt message with existing rich content.
|
|
1309
1792
|
*
|
|
1310
1793
|
* @param value - The unknown value to inspect
|
|
1311
|
-
* @returns
|
|
1794
|
+
* @returns True if the role and content are valid; false otherwise
|
|
1312
1795
|
*/
|
|
1313
1796
|
export declare function isMCPPromptMessage(value: unknown): value is MCPPromptMessage;
|
|
1314
1797
|
|
|
@@ -1316,7 +1799,7 @@ export declare function isMCPPromptMessage(value: unknown): value is MCPPromptMe
|
|
|
1316
1799
|
* Determines whether a value is one consumer-owned prompt page.
|
|
1317
1800
|
*
|
|
1318
1801
|
* @param value - The unknown value to inspect
|
|
1319
|
-
* @returns
|
|
1802
|
+
* @returns True if the prompts and optional following cursor are valid; false otherwise
|
|
1320
1803
|
*/
|
|
1321
1804
|
export declare function isMCPPromptPage(value: unknown): value is MCPPromptPage;
|
|
1322
1805
|
|
|
@@ -1324,7 +1807,7 @@ export declare function isMCPPromptPage(value: unknown): value is MCPPromptPage;
|
|
|
1324
1807
|
* Determines whether a value is one `resources/list` descriptor.
|
|
1325
1808
|
*
|
|
1326
1809
|
* @param value - The unknown value to inspect
|
|
1327
|
-
* @returns
|
|
1810
|
+
* @returns True if the value is a valid resource descriptor; false otherwise
|
|
1328
1811
|
*/
|
|
1329
1812
|
export declare function isMCPResource(value: unknown): value is MCPResource;
|
|
1330
1813
|
|
|
@@ -1332,7 +1815,7 @@ export declare function isMCPResource(value: unknown): value is MCPResource;
|
|
|
1332
1815
|
* Determines whether a value is structurally discriminated resource contents.
|
|
1333
1816
|
*
|
|
1334
1817
|
* @param value - The unknown value to inspect
|
|
1335
|
-
* @returns
|
|
1818
|
+
* @returns True if exactly one of `text` and `blob` is present and valid; false otherwise
|
|
1336
1819
|
*/
|
|
1337
1820
|
export declare function isMCPResourceContents(value: unknown): value is MCPResourceContents;
|
|
1338
1821
|
|
|
@@ -1340,7 +1823,7 @@ export declare function isMCPResourceContents(value: unknown): value is MCPResou
|
|
|
1340
1823
|
* Determines whether a value is one consumer-owned resource page.
|
|
1341
1824
|
*
|
|
1342
1825
|
* @param value - The unknown value to inspect
|
|
1343
|
-
* @returns
|
|
1826
|
+
* @returns True if the resources and optional following cursor are valid; false otherwise
|
|
1344
1827
|
*/
|
|
1345
1828
|
export declare function isMCPResourcePage(value: unknown): value is MCPResourcePage;
|
|
1346
1829
|
|
|
@@ -1352,7 +1835,7 @@ export declare function isMCPResourcePage(value: unknown): value is MCPResourceP
|
|
|
1352
1835
|
* level belong to the consumer-supplied resource manager; this package projects the string.
|
|
1353
1836
|
*
|
|
1354
1837
|
* @param value - The unknown value to inspect
|
|
1355
|
-
* @returns
|
|
1838
|
+
* @returns True if the value is a valid resource-template descriptor; false otherwise
|
|
1356
1839
|
*/
|
|
1357
1840
|
export declare function isMCPResourceTemplate(value: unknown): value is MCPResourceTemplate;
|
|
1358
1841
|
|
|
@@ -1360,7 +1843,7 @@ export declare function isMCPResourceTemplate(value: unknown): value is MCPResou
|
|
|
1360
1843
|
* Determines whether a value is one consumer-owned resource-template page.
|
|
1361
1844
|
*
|
|
1362
1845
|
* @param value - The unknown value to inspect
|
|
1363
|
-
* @returns
|
|
1846
|
+
* @returns True if the templates and optional following cursor are valid; false otherwise
|
|
1364
1847
|
*/
|
|
1365
1848
|
export declare function isMCPResourceTemplatePage(value: unknown): value is MCPResourceTemplatePage;
|
|
1366
1849
|
|
|
@@ -1377,7 +1860,7 @@ export declare function isMCPResourceTemplatePage(value: unknown): value is MCPR
|
|
|
1377
1860
|
* input.
|
|
1378
1861
|
*
|
|
1379
1862
|
* @param value - The unknown value to inspect
|
|
1380
|
-
* @returns
|
|
1863
|
+
* @returns True if the value is a modern result; false otherwise
|
|
1381
1864
|
*
|
|
1382
1865
|
* @example
|
|
1383
1866
|
* ```ts
|
|
@@ -1391,6 +1874,95 @@ export declare function isMCPResult(value: unknown): value is MCPResult;
|
|
|
1391
1874
|
/** Determines whether a value is exact result metadata with a valid reserved server identity. */
|
|
1392
1875
|
export declare function isMCPResultMetaObject(value: unknown): value is MCPResultMetaObject;
|
|
1393
1876
|
|
|
1877
|
+
/**
|
|
1878
|
+
* Determines whether a value is one filesystem root a client exposes.
|
|
1879
|
+
*
|
|
1880
|
+
* @remarks
|
|
1881
|
+
* The dated schema declares `uri` with `format: uri`, so this applies the same RFC 3986
|
|
1882
|
+
* check {@link isAbsoluteURI} gives every other `format: uri` field the package validates,
|
|
1883
|
+
* including a URL-mode elicitation's `url`. Total over hostile input.
|
|
1884
|
+
*
|
|
1885
|
+
* @param value - The unknown value to inspect
|
|
1886
|
+
* @returns True if `value` carries an absolute `uri` and an optional string `name`; false otherwise
|
|
1887
|
+
*
|
|
1888
|
+
* @example
|
|
1889
|
+
* ```ts
|
|
1890
|
+
* isMCPRoot({ uri: 'file:///workspace', name: 'workspace' }) // true
|
|
1891
|
+
* isMCPRoot({ uri: 'workspace' }) // false — the schema declares `format: uri`
|
|
1892
|
+
* ```
|
|
1893
|
+
*/
|
|
1894
|
+
export declare function isMCPRoot(value: unknown): value is MCPRoot;
|
|
1895
|
+
|
|
1896
|
+
/**
|
|
1897
|
+
* Determines whether a value is one client answer to an embedded `roots/list` request.
|
|
1898
|
+
*
|
|
1899
|
+
* @remarks
|
|
1900
|
+
* The dated schema requires the `roots` array, and each root is checked by
|
|
1901
|
+
* {@link isMCPRoot}. Total over hostile input.
|
|
1902
|
+
*
|
|
1903
|
+
* @param value - The unknown value to inspect
|
|
1904
|
+
* @returns True if `value` carries an array of valid roots; false otherwise
|
|
1905
|
+
*
|
|
1906
|
+
* @example
|
|
1907
|
+
* ```ts
|
|
1908
|
+
* isMCPRootResult({ roots: [{ uri: 'file:///workspace' }] }) // true
|
|
1909
|
+
* isMCPRootResult({ roots: {} }) // false — the schema requires an array
|
|
1910
|
+
* ```
|
|
1911
|
+
*/
|
|
1912
|
+
export declare function isMCPRootResult(value: unknown): value is MCPRootResult;
|
|
1913
|
+
|
|
1914
|
+
/**
|
|
1915
|
+
* Determines whether a value is one block a sampling completion may carry.
|
|
1916
|
+
*
|
|
1917
|
+
* @remarks
|
|
1918
|
+
* The schema's `SamplingMessageContentBlock`: the text, image, and audio blocks
|
|
1919
|
+
* {@link isMCPContent} also admits, plus `tool_use` and `tool_result`. The resource arms of
|
|
1920
|
+
* {@link isMCPContent} are refused, because the schema leaves them out of a sampling
|
|
1921
|
+
* completion. A `tool_result` carries ordinary {@link isMCPContent} blocks and an open
|
|
1922
|
+
* `structuredContent`, which the schema constrains to no shape at all. Total over hostile
|
|
1923
|
+
* input.
|
|
1924
|
+
*
|
|
1925
|
+
* @param value - The unknown value to inspect
|
|
1926
|
+
* @returns True if `value` is one legal sampling content block; false otherwise
|
|
1927
|
+
*
|
|
1928
|
+
* @example
|
|
1929
|
+
* ```ts
|
|
1930
|
+
* isMCPSampleContent({ type: 'text', text: 'Paris' }) // true
|
|
1931
|
+
* isMCPSampleContent({ type: 'tool_use', id: 'c1', name: 'lookup', input: {} }) // true
|
|
1932
|
+
* isMCPSampleContent({ type: 'resource_link', name: 'doc', uri: 'file:///doc' }) // false
|
|
1933
|
+
* ```
|
|
1934
|
+
*/
|
|
1935
|
+
export declare function isMCPSampleContent(value: unknown): value is MCPSampleContent;
|
|
1936
|
+
|
|
1937
|
+
/**
|
|
1938
|
+
* Determines whether a value is one client answer to an embedded sampling request.
|
|
1939
|
+
*
|
|
1940
|
+
* @remarks
|
|
1941
|
+
* The schema's `CreateMessageResult` types `content` as an `anyOf` over one
|
|
1942
|
+
* {@link isMCPSampleContent} block or an ARRAY of them, so both are admitted here: a
|
|
1943
|
+
* tool-using model answers with `tool_use` and `tool_result` blocks, and a model answering in
|
|
1944
|
+
* several parts answers with the array. `stopReason` stays an open string because the schema
|
|
1945
|
+
* names four values and permits any other a provider reports. Total over hostile input.
|
|
1946
|
+
*
|
|
1947
|
+
* @param value - The unknown value to inspect
|
|
1948
|
+
* @returns True if `value` has the sampling-completion shape; false otherwise
|
|
1949
|
+
*
|
|
1950
|
+
* @example
|
|
1951
|
+
* ```ts
|
|
1952
|
+
* isMCPSampleResult({
|
|
1953
|
+
* role: 'assistant',
|
|
1954
|
+
* content: { type: 'text', text: 'Paris' },
|
|
1955
|
+
* model: 'test-model',
|
|
1956
|
+
* }) // true
|
|
1957
|
+
* isMCPSampleResult({
|
|
1958
|
+
* role: 'assistant',
|
|
1959
|
+
* content: [{ type: 'text', text: 'Paris' }],
|
|
1960
|
+
* model: 'test-model',
|
|
1961
|
+
* }) // true
|
|
1962
|
+
* ```
|
|
1963
|
+
*/
|
|
1964
|
+
export declare function isMCPSampleResult(value: unknown): value is MCPSampleResult;
|
|
1965
|
+
|
|
1394
1966
|
/** Determines whether a value is one exact open dated server-capability declaration. */
|
|
1395
1967
|
export declare function isMCPServerCapabilities(value: unknown): value is MCPServerCapabilities;
|
|
1396
1968
|
|
|
@@ -1398,7 +1970,7 @@ export declare function isMCPServerCapabilities(value: unknown): value is MCPSer
|
|
|
1398
1970
|
* Determines whether a value is a string-valued MCP argument record.
|
|
1399
1971
|
*
|
|
1400
1972
|
* @param value - The unknown value to inspect
|
|
1401
|
-
* @returns
|
|
1973
|
+
* @returns True if every own argument value is a string; false otherwise
|
|
1402
1974
|
*/
|
|
1403
1975
|
export declare function isMCPStringArguments(value: unknown): value is Readonly<Record<string, string>>;
|
|
1404
1976
|
|
|
@@ -1416,7 +1988,7 @@ export declare function isMCPStringArguments(value: unknown): value is Readonly<
|
|
|
1416
1988
|
* the caller asked for.
|
|
1417
1989
|
*
|
|
1418
1990
|
* @param value - The unknown value to inspect
|
|
1419
|
-
* @returns
|
|
1991
|
+
* @returns True if every recognized filter field has its protocol shape; false otherwise
|
|
1420
1992
|
*/
|
|
1421
1993
|
export declare function isMCPSubscriptionFilter(value: unknown): value is MCPSubscriptionFilter;
|
|
1422
1994
|
|
|
@@ -1424,7 +1996,7 @@ export declare function isMCPSubscriptionFilter(value: unknown): value is MCPSub
|
|
|
1424
1996
|
* Determines whether a value is a graceful `subscriptions/listen` result.
|
|
1425
1997
|
*
|
|
1426
1998
|
* @param value - The unknown value to inspect
|
|
1427
|
-
* @returns
|
|
1999
|
+
* @returns True if the result is complete and carries a valid subscription id; false otherwise
|
|
1428
2000
|
*/
|
|
1429
2001
|
export declare function isMCPSubscriptionResult(value: unknown): value is MCPSubscriptionResult;
|
|
1430
2002
|
|
|
@@ -1448,7 +2020,7 @@ export declare function isMCPSubscriptionResult(value: unknown): value is MCPSub
|
|
|
1448
2020
|
* What is checked is what this package publishes as the contract.
|
|
1449
2021
|
*
|
|
1450
2022
|
* @param value - The unknown value to inspect
|
|
1451
|
-
* @returns
|
|
2023
|
+
* @returns True if the value is a well-formed {@link MCPTaskDetail}; false otherwise
|
|
1452
2024
|
*
|
|
1453
2025
|
* @example
|
|
1454
2026
|
* ```ts
|
|
@@ -1475,7 +2047,7 @@ export declare function isMCPTaskDetail(value: unknown): value is MCPTaskDetail;
|
|
|
1475
2047
|
* peer stamps there is the peer's to write.
|
|
1476
2048
|
*
|
|
1477
2049
|
* @param value - The unknown value to inspect
|
|
1478
|
-
* @returns
|
|
2050
|
+
* @returns True if the value is a well-formed {@link MCPTaskDetailResult}; false otherwise
|
|
1479
2051
|
*
|
|
1480
2052
|
* @example
|
|
1481
2053
|
* ```ts
|
|
@@ -1502,7 +2074,7 @@ export declare function isMCPTaskDetailResult(value: unknown): value is MCPTaskD
|
|
|
1502
2074
|
* to it, so a guard that demanded the stamp would refuse every frame a producer emits.
|
|
1503
2075
|
*
|
|
1504
2076
|
* @param value - The unknown value to inspect
|
|
1505
|
-
* @returns
|
|
2077
|
+
* @returns True if the value is a well-formed `notifications/tasks` notification; false otherwise
|
|
1506
2078
|
*
|
|
1507
2079
|
* @example
|
|
1508
2080
|
* ```ts
|
|
@@ -1513,10 +2085,7 @@ export declare function isMCPTaskDetailResult(value: unknown): value is MCPTaskD
|
|
|
1513
2085
|
* params: { taskId: 'a' } }) // false — the params owe a whole snapshot
|
|
1514
2086
|
* ```
|
|
1515
2087
|
*/
|
|
1516
|
-
export declare function isMCPTaskNotification(value: unknown): value is
|
|
1517
|
-
readonly method: 'notifications/tasks';
|
|
1518
|
-
readonly params: MCPTaskNotificationParams;
|
|
1519
|
-
};
|
|
2088
|
+
export declare function isMCPTaskNotification(value: unknown): value is MCPTaskNotification;
|
|
1520
2089
|
|
|
1521
2090
|
/**
|
|
1522
2091
|
* Determines whether a value is a modern MCP task-creation result.
|
|
@@ -1530,7 +2099,7 @@ export declare function isMCPTaskNotification(value: unknown): value is JSONRPCN
|
|
|
1530
2099
|
* INTEGER milliseconds because the schema formats them `int`.
|
|
1531
2100
|
*
|
|
1532
2101
|
* @param value - The unknown value to inspect
|
|
1533
|
-
* @returns
|
|
2102
|
+
* @returns True if the value is a well-formed `resultType: 'task'` result; false otherwise
|
|
1534
2103
|
*
|
|
1535
2104
|
* @example
|
|
1536
2105
|
* ```ts
|
|
@@ -1544,7 +2113,7 @@ export declare function isMCPTaskResult(value: unknown): value is MCPTaskResult;
|
|
|
1544
2113
|
* Determines whether a value is one of the extension's task lifecycle states.
|
|
1545
2114
|
*
|
|
1546
2115
|
* @param value - The unknown value to inspect
|
|
1547
|
-
* @returns
|
|
2116
|
+
* @returns True if the value is an {@link MCPTaskStatus}; false otherwise
|
|
1548
2117
|
*
|
|
1549
2118
|
* @example
|
|
1550
2119
|
* ```ts
|
|
@@ -1558,7 +2127,7 @@ export declare function isMCPTaskStatus(value: unknown): value is MCPTaskStatus;
|
|
|
1558
2127
|
* Determines whether a value is embedded textual MCP resource contents.
|
|
1559
2128
|
*
|
|
1560
2129
|
* @param value - The unknown value to inspect
|
|
1561
|
-
* @returns
|
|
2130
|
+
* @returns True if the value is embedded textual resource contents; false otherwise
|
|
1562
2131
|
*/
|
|
1563
2132
|
export declare function isMCPTextResource(value: unknown): value is MCPTextResource;
|
|
1564
2133
|
|
|
@@ -1566,7 +2135,7 @@ export declare function isMCPTextResource(value: unknown): value is MCPTextResou
|
|
|
1566
2135
|
* Determines whether a value is a supported {@link MCPVersion}.
|
|
1567
2136
|
*
|
|
1568
2137
|
* @param value - The unknown value to inspect
|
|
1569
|
-
* @returns
|
|
2138
|
+
* @returns True if the value is one of {@link SUPPORTED_MCP_VERSIONS}; false otherwise
|
|
1570
2139
|
*/
|
|
1571
2140
|
export declare function isMCPVersion(value: unknown): value is MCPVersion;
|
|
1572
2141
|
|
|
@@ -1581,7 +2150,7 @@ export declare function isMCPVersion(value: unknown): value is MCPVersion;
|
|
|
1581
2150
|
* legacy dispatch. Total over hostile and malformed input.
|
|
1582
2151
|
*
|
|
1583
2152
|
* @param value - The already-parsed value to inspect
|
|
1584
|
-
* @returns
|
|
2153
|
+
* @returns True if the value is an invocation carrying the reserved version key; false otherwise
|
|
1585
2154
|
*/
|
|
1586
2155
|
export declare function isModernRequest(value: unknown): value is JSONRPCInvocation;
|
|
1587
2156
|
|
|
@@ -1600,7 +2169,7 @@ export declare function isModernRequest(value: unknown): value is JSONRPCInvocat
|
|
|
1600
2169
|
* refuse. It is a SYNTAX guard: no time zone, locale, calendar era, or leap second applies.
|
|
1601
2170
|
*
|
|
1602
2171
|
* @param value - The unknown value to inspect
|
|
1603
|
-
* @returns
|
|
2172
|
+
* @returns True if the value is an RFC 3339 `full-date` for a day that exists; false otherwise
|
|
1604
2173
|
*
|
|
1605
2174
|
* @example
|
|
1606
2175
|
* ```ts
|
|
@@ -1624,7 +2193,7 @@ export declare function isRFC3339Date(value: unknown): value is string;
|
|
|
1624
2193
|
* second.
|
|
1625
2194
|
*
|
|
1626
2195
|
* @param value - The unknown value to inspect
|
|
1627
|
-
* @returns
|
|
2196
|
+
* @returns True if the value is an RFC 3339 `date-time` for a day that exists; false otherwise
|
|
1628
2197
|
*
|
|
1629
2198
|
* @example
|
|
1630
2199
|
* ```ts
|
|
@@ -1639,40 +2208,13 @@ export declare function isRFC3339DateTime(value: unknown): value is string;
|
|
|
1639
2208
|
* Determines whether a value is standard padded base64 as required by JSON Schema `byte` format.
|
|
1640
2209
|
*
|
|
1641
2210
|
* @param value - The unknown value to inspect
|
|
1642
|
-
* @returns
|
|
2211
|
+
* @returns True if the value is an empty or completely padded standard base64 encoding; false otherwise
|
|
1643
2212
|
*/
|
|
1644
2213
|
export declare function isStandardBase64(value: unknown): value is string;
|
|
1645
2214
|
|
|
1646
2215
|
/**
|
|
1647
|
-
*
|
|
1648
|
-
*
|
|
1649
|
-
* @remarks
|
|
1650
|
-
* The declaration lives at `extensions['io.modelcontextprotocol/tasks']` and the schema
|
|
1651
|
-
* types its value EXACTLY EMPTY — `Record<string, never>`, an object with no additional
|
|
1652
|
-
* properties. So the key's presence is the whole declaration, and the value carries the
|
|
1653
|
-
* whole of the check: a `true` or a string there is a client speaking a different protocol
|
|
1654
|
-
* rather than a shorthand, and a member inside the object is a client declaring an option
|
|
1655
|
-
* this extension does not define. Both are refused, because a server that accepted either
|
|
1656
|
-
* would be reading a shape no peer can produce from the snapshot's own schema.
|
|
1657
|
-
*
|
|
1658
|
-
* A client declares this PER REQUEST. Nothing here consults a session, because the modern
|
|
1659
|
-
* revision is stateless and a capability declared once at connect time says nothing about
|
|
1660
|
-
* the request in hand. Total over hostile input.
|
|
1661
|
-
*
|
|
1662
|
-
* @param value - The client capability record to inspect
|
|
1663
|
-
* @returns `true` when the tasks extension is declared as the schema's empty object
|
|
1664
|
-
*
|
|
1665
|
-
* @example
|
|
1666
|
-
* ```ts
|
|
1667
|
-
* isTaskSupported({ extensions: { 'io.modelcontextprotocol/tasks': {} } }) // true
|
|
1668
|
-
* isTaskSupported({ extensions: {} }) // false — the key is the declaration
|
|
1669
|
-
* isTaskSupported({ extensions: { 'io.modelcontextprotocol/tasks': { on: true } } }) // false
|
|
1670
|
-
* ```
|
|
1671
|
-
*/
|
|
1672
|
-
export declare function isTaskSupported(value: unknown): boolean;
|
|
1673
|
-
|
|
1674
|
-
/**
|
|
1675
|
-
* JSON-RPC 2.0 reserved error: the server failed while handling an otherwise valid request.
|
|
2216
|
+
* Names the JSON-RPC 2.0 reserved error for a server that failed while handling an otherwise
|
|
2217
|
+
* valid request.
|
|
1676
2218
|
*
|
|
1677
2219
|
* @remarks
|
|
1678
2220
|
* The code every MODERN internal fault answers with — a provider, handler, continuation,
|
|
@@ -1682,20 +2224,20 @@ export declare function isTaskSupported(value: unknown): boolean;
|
|
|
1682
2224
|
*/
|
|
1683
2225
|
export declare const JSONRPC_INTERNAL_ERROR = -32603;
|
|
1684
2226
|
|
|
1685
|
-
/** JSON-RPC 2.0 reserved error
|
|
2227
|
+
/** Names the JSON-RPC 2.0 reserved error for a method's invalid parameters. */
|
|
1686
2228
|
export declare const JSONRPC_INVALID_PARAMS = -32602;
|
|
1687
2229
|
|
|
1688
|
-
/** JSON-RPC 2.0 reserved error
|
|
2230
|
+
/** Names the JSON-RPC 2.0 reserved error for a payload that was not a valid Request object. */
|
|
1689
2231
|
export declare const JSONRPC_INVALID_REQUEST = -32600;
|
|
1690
2232
|
|
|
1691
|
-
/** JSON-RPC 2.0 reserved error
|
|
2233
|
+
/** Names the JSON-RPC 2.0 reserved error for a requested method that does not exist. */
|
|
1692
2234
|
export declare const JSONRPC_METHOD_NOT_FOUND = -32601;
|
|
1693
2235
|
|
|
1694
|
-
/** JSON-RPC 2.0 reserved error
|
|
2236
|
+
/** Names the JSON-RPC 2.0 reserved error for invalid JSON received (the message did not parse). */
|
|
1695
2237
|
export declare const JSONRPC_PARSE_ERROR = -32700;
|
|
1696
2238
|
|
|
1697
2239
|
/**
|
|
1698
|
-
* JSON-RPC 2.0 implementation-defined server error (the `-32000` to `-32099` range).
|
|
2240
|
+
* Names the JSON-RPC 2.0 implementation-defined server error (the `-32000` to `-32099` range).
|
|
1699
2241
|
*
|
|
1700
2242
|
* @remarks
|
|
1701
2243
|
* Retained for the LEGACY branch alone. A modern fault answers
|
|
@@ -1705,7 +2247,7 @@ export declare const JSONRPC_PARSE_ERROR = -32700;
|
|
|
1705
2247
|
export declare const JSONRPC_SERVER_ERROR = -32000;
|
|
1706
2248
|
|
|
1707
2249
|
/**
|
|
1708
|
-
*
|
|
2250
|
+
* Represents a JSON-RPC 2.0 error object — the `error` member of a
|
|
1709
2251
|
* {@link JSONRPCErrorResponse}.
|
|
1710
2252
|
*
|
|
1711
2253
|
* @remarks
|
|
@@ -1720,8 +2262,8 @@ export declare interface JSONRPCError {
|
|
|
1720
2262
|
}
|
|
1721
2263
|
|
|
1722
2264
|
/**
|
|
1723
|
-
*
|
|
1724
|
-
* {@link JSONRPCError} that ended it.
|
|
2265
|
+
* Represents the failure arm of a JSON-RPC 2.0 response — the request's `id` echoed with
|
|
2266
|
+
* the {@link JSONRPCError} that ended it.
|
|
1725
2267
|
*
|
|
1726
2268
|
* @remarks
|
|
1727
2269
|
* `id` is OMITTED, never `null`, when the request could not be parsed or its id
|
|
@@ -1730,18 +2272,18 @@ export declare interface JSONRPCError {
|
|
|
1730
2272
|
*/
|
|
1731
2273
|
export declare interface JSONRPCErrorResponse {
|
|
1732
2274
|
readonly jsonrpc: '2.0';
|
|
1733
|
-
/**
|
|
2275
|
+
/** Holds the failed request's id; ABSENT when no id could be read. */
|
|
1734
2276
|
readonly id?: JSONRPCId;
|
|
1735
2277
|
readonly error: JSONRPCError;
|
|
1736
|
-
/**
|
|
2278
|
+
/** Forbids this member; an answer carries a result or an error, never both. */
|
|
1737
2279
|
readonly result?: never;
|
|
1738
2280
|
}
|
|
1739
2281
|
|
|
1740
|
-
/**
|
|
2282
|
+
/** Represents a JSON-RPC 2.0 correlation id — the value a request and its response share. */
|
|
1741
2283
|
export declare type JSONRPCId = string | number;
|
|
1742
2284
|
|
|
1743
2285
|
/**
|
|
1744
|
-
*
|
|
2286
|
+
* Represents one inbound JSON-RPC call — the common dispatch input.
|
|
1745
2287
|
*
|
|
1746
2288
|
* @remarks
|
|
1747
2289
|
* Narrow the arms apart on the id: `invocation.id === undefined` is the notification
|
|
@@ -1750,7 +2292,7 @@ export declare type JSONRPCId = string | number;
|
|
|
1750
2292
|
export declare type JSONRPCInvocation = JSONRPCRequest | JSONRPCNotification;
|
|
1751
2293
|
|
|
1752
2294
|
/**
|
|
1753
|
-
*
|
|
2295
|
+
* Represents a JSON-RPC 2.0 message on the wire — a {@link JSONRPCInvocation} or a
|
|
1754
2296
|
* {@link JSONRPCResponse}.
|
|
1755
2297
|
*
|
|
1756
2298
|
* @remarks
|
|
@@ -1760,8 +2302,8 @@ export declare type JSONRPCInvocation = JSONRPCRequest | JSONRPCNotification;
|
|
|
1760
2302
|
export declare type JSONRPCMessage = JSONRPCInvocation | JSONRPCResponse;
|
|
1761
2303
|
|
|
1762
2304
|
/**
|
|
1763
|
-
*
|
|
1764
|
-
* nothing (for example, `notifications/initialized`).
|
|
2305
|
+
* Represents a JSON-RPC 2.0 notification — a fire-and-forget `method` call that is answered
|
|
2306
|
+
* by nothing (for example, `notifications/initialized`).
|
|
1765
2307
|
*
|
|
1766
2308
|
* @remarks
|
|
1767
2309
|
* A notification MUST NOT carry an `id`, so `id` is declared `never`: a
|
|
@@ -1771,14 +2313,14 @@ export declare type JSONRPCMessage = JSONRPCInvocation | JSONRPCResponse;
|
|
|
1771
2313
|
export declare interface JSONRPCNotification {
|
|
1772
2314
|
readonly jsonrpc: '2.0';
|
|
1773
2315
|
readonly method: string;
|
|
1774
|
-
/**
|
|
2316
|
+
/** Forbids this member; an id is what makes a call a {@link JSONRPCRequest} instead. */
|
|
1775
2317
|
readonly id?: never;
|
|
1776
|
-
/**
|
|
2318
|
+
/** Holds the method's open argument record (narrowed by the handler). */
|
|
1777
2319
|
readonly params?: Readonly<Record<string, unknown>>;
|
|
1778
2320
|
}
|
|
1779
2321
|
|
|
1780
2322
|
/**
|
|
1781
|
-
*
|
|
2323
|
+
* Represents a JSON-RPC 2.0 request — a `method` call with optional `params`, correlated to
|
|
1782
2324
|
* its response by the `id` it REQUIRES.
|
|
1783
2325
|
*
|
|
1784
2326
|
* @remarks
|
|
@@ -1791,12 +2333,12 @@ export declare interface JSONRPCRequest {
|
|
|
1791
2333
|
readonly method: string;
|
|
1792
2334
|
/** Correlates the request with its response. */
|
|
1793
2335
|
readonly id: JSONRPCId;
|
|
1794
|
-
/**
|
|
2336
|
+
/** Holds the method's open argument record (narrowed by the handler). */
|
|
1795
2337
|
readonly params?: Readonly<Record<string, unknown>>;
|
|
1796
2338
|
}
|
|
1797
2339
|
|
|
1798
2340
|
/**
|
|
1799
|
-
*
|
|
2341
|
+
* Represents a JSON-RPC 2.0 response — the answer to one {@link JSONRPCRequest}.
|
|
1800
2342
|
*
|
|
1801
2343
|
* @remarks
|
|
1802
2344
|
* The arms are mutually exclusive in the type and in their guards. Narrow them
|
|
@@ -1805,8 +2347,8 @@ export declare interface JSONRPCRequest {
|
|
|
1805
2347
|
export declare type JSONRPCResponse = JSONRPCResultResponse | JSONRPCErrorResponse;
|
|
1806
2348
|
|
|
1807
2349
|
/**
|
|
1808
|
-
*
|
|
1809
|
-
* method's `result`.
|
|
2350
|
+
* Represents the success arm of a JSON-RPC 2.0 response — the request's `id` echoed with
|
|
2351
|
+
* the method's `result`.
|
|
1810
2352
|
*
|
|
1811
2353
|
* @remarks
|
|
1812
2354
|
* A result answers a request, and a request always has a readable `id`, so `id` is
|
|
@@ -1817,7 +2359,7 @@ export declare interface JSONRPCResultResponse {
|
|
|
1817
2359
|
readonly jsonrpc: '2.0';
|
|
1818
2360
|
readonly id: JSONRPCId;
|
|
1819
2361
|
readonly result: MCPResult | MCPLegacyResult;
|
|
1820
|
-
/**
|
|
2362
|
+
/** Forbids this member; an answer carries a result or an error, never both. */
|
|
1821
2363
|
readonly error?: never;
|
|
1822
2364
|
}
|
|
1823
2365
|
|
|
@@ -1858,7 +2400,7 @@ export declare function legacyResultToModern(result: MCPLegacyResult, method: st
|
|
|
1858
2400
|
*
|
|
1859
2401
|
* @param method - The method the pending request was issued for
|
|
1860
2402
|
* @param resultType - The unknown `resultType` the peer answered with
|
|
1861
|
-
* @returns
|
|
2403
|
+
* @returns True if that method may legally answer with that `resultType`; false otherwise
|
|
1862
2404
|
*
|
|
1863
2405
|
* @example
|
|
1864
2406
|
* ```ts
|
|
@@ -1874,12 +2416,12 @@ export declare function matchesResultType(method: string, resultType: unknown):
|
|
|
1874
2416
|
*
|
|
1875
2417
|
* @param notification - The server notification offered by the configured producer
|
|
1876
2418
|
* @param filter - The filter acknowledged to the client
|
|
1877
|
-
* @returns
|
|
2419
|
+
* @returns True if the notification belongs on this subscription stream; false otherwise
|
|
1878
2420
|
*/
|
|
1879
2421
|
export declare function matchesSubscriptionNotification(notification: JSONRPCNotification, filter: MCPSubscriptionFilter): boolean;
|
|
1880
2422
|
|
|
1881
2423
|
/**
|
|
1882
|
-
*
|
|
2424
|
+
* Names the reserved extension key identifying the stable Tasks extension.
|
|
1883
2425
|
*
|
|
1884
2426
|
* @remarks
|
|
1885
2427
|
* The ONE spelling of it in this package, and the identity of the immutable snapshot dated
|
|
@@ -1890,11 +2432,11 @@ export declare function matchesSubscriptionNotification(notification: JSONRPCNot
|
|
|
1890
2432
|
*/
|
|
1891
2433
|
export declare const MCP_EXTENSION_TASKS = "io.modelcontextprotocol/tasks";
|
|
1892
2434
|
|
|
1893
|
-
/**
|
|
2435
|
+
/** Names the older legacy revision the optional legacy decorator accepts and an adapter can pin. */
|
|
1894
2436
|
export declare const MCP_FALLBACK_VERSION: MCPLegacyVersion;
|
|
1895
2437
|
|
|
1896
2438
|
/**
|
|
1897
|
-
*
|
|
2439
|
+
* Names the revision offered and defaulted to in the legacy `initialize` handshake.
|
|
1898
2440
|
*
|
|
1899
2441
|
* @remarks
|
|
1900
2442
|
* This is deliberately a legacy revision, and the newest one supported. 2026-07-28 is stateless
|
|
@@ -1903,26 +2445,62 @@ export declare const MCP_FALLBACK_VERSION: MCPLegacyVersion;
|
|
|
1903
2445
|
*/
|
|
1904
2446
|
export declare const MCP_HANDSHAKE_VERSION: MCPLegacyVersion;
|
|
1905
2447
|
|
|
1906
|
-
/**
|
|
2448
|
+
/**
|
|
2449
|
+
* Identifies the tool-schema annotation key naming the header one parameter projects into.
|
|
2450
|
+
*
|
|
2451
|
+
* @remarks
|
|
2452
|
+
* It is valid ONLY on a primitive property schema statically reachable from the `inputSchema`
|
|
2453
|
+
* root through `properties` keys alone. An occurrence anywhere else — under `items`, a
|
|
2454
|
+
* composition or conditional keyword, or a `$ref` target — makes the whole tool definition
|
|
2455
|
+
* invalid, which is what {@link import('@orkestrel/mcp').buildHeaderParameters} decides.
|
|
2456
|
+
*/
|
|
2457
|
+
export declare const MCP_HEADER_ANNOTATION = "x-mcp-header";
|
|
2458
|
+
|
|
2459
|
+
/** Names the MCP reserved error for required HTTP metadata that does not match the request body. */
|
|
1907
2460
|
export declare const MCP_HEADER_MISMATCH = -32020;
|
|
1908
2461
|
|
|
1909
|
-
/**
|
|
2462
|
+
/**
|
|
2463
|
+
* Bounds the `tools/list` pages one modern `tools/call` walks to reach its own annotations.
|
|
2464
|
+
*
|
|
2465
|
+
* @remarks
|
|
2466
|
+
* The HTTP POST handler reads a called tool's {@link MCP_HEADER_ANNOTATION} annotations by
|
|
2467
|
+
* dispatching `tools/list` fresh on every `tools/call`, following `nextCursor` until the
|
|
2468
|
+
* named tool is found or the answer carries no cursor. The walk is bounded because its cost
|
|
2469
|
+
* is paid per call: at a page size of 100 this bound reaches 800 definitions, and a consumer
|
|
2470
|
+
* whose replacement `tools/list` pages more finely than that pays the extra dispatches on
|
|
2471
|
+
* every call it serves. The built-in listing answers the whole registry on one page and
|
|
2472
|
+
* never reaches the second. A definition further in than the walk reaches reads as no
|
|
2473
|
+
* definition, so its {@link MCP_PARAM_PREFIX} headers are forwarded untouched — the same
|
|
2474
|
+
* answer a name no served definition annotates receives.
|
|
2475
|
+
*/
|
|
2476
|
+
export declare const MCP_LOOKUP_PAGES = 8;
|
|
2477
|
+
|
|
2478
|
+
/** Names the reserved modern `_meta` key carrying the client's open capability record. */
|
|
1910
2479
|
export declare const MCP_META_CAPABILITIES = "io.modelcontextprotocol/clientCapabilities";
|
|
1911
2480
|
|
|
1912
|
-
/**
|
|
2481
|
+
/** Names the reserved modern `_meta` key carrying the optional client identity. */
|
|
1913
2482
|
export declare const MCP_META_CLIENT = "io.modelcontextprotocol/clientInfo";
|
|
1914
2483
|
|
|
1915
|
-
/**
|
|
2484
|
+
/** Names the reserved modern `_meta` key carrying the server identity on results. */
|
|
1916
2485
|
export declare const MCP_META_SERVER = "io.modelcontextprotocol/serverInfo";
|
|
1917
2486
|
|
|
1918
|
-
/**
|
|
2487
|
+
/** Names the reserved modern `_meta` key carrying a `subscriptions/listen` request id. */
|
|
1919
2488
|
export declare const MCP_META_SUBSCRIPTION = "io.modelcontextprotocol/subscriptionId";
|
|
1920
2489
|
|
|
1921
|
-
/**
|
|
2490
|
+
/** Names the reserved modern `_meta` key carrying the request's protocol revision. */
|
|
1922
2491
|
export declare const MCP_META_VERSION = "io.modelcontextprotocol/protocolVersion";
|
|
1923
2492
|
|
|
1924
2493
|
/**
|
|
1925
|
-
*
|
|
2494
|
+
* Names the modern Streamable-HTTP request header carrying the JSON-RPC method.
|
|
2495
|
+
*
|
|
2496
|
+
* @remarks
|
|
2497
|
+
* It is stamped on every modern request and on no legacy request.
|
|
2498
|
+
*/
|
|
2499
|
+
export declare const MCP_METHOD_HEADER = "mcp-method";
|
|
2500
|
+
|
|
2501
|
+
/**
|
|
2502
|
+
* Names the MCP reserved error for an operation needing a client capability that was not
|
|
2503
|
+
* declared.
|
|
1926
2504
|
*
|
|
1927
2505
|
* @remarks
|
|
1928
2506
|
* The GENERIC code for the whole condition, not one capability's code. This server answers
|
|
@@ -1936,20 +2514,91 @@ export declare const MCP_META_VERSION = "io.modelcontextprotocol/protocolVersion
|
|
|
1936
2514
|
*/
|
|
1937
2515
|
export declare const MCP_MISSING_CAPABILITY = -32021;
|
|
1938
2516
|
|
|
1939
|
-
/**
|
|
2517
|
+
/** Names the modern revision offered by an unpinned client during discovery. */
|
|
1940
2518
|
export declare const MCP_MODERN_VERSION: MCPModernVersion;
|
|
1941
2519
|
|
|
1942
|
-
/**
|
|
2520
|
+
/**
|
|
2521
|
+
* Names the modern Streamable-HTTP request header carrying a named target.
|
|
2522
|
+
*
|
|
2523
|
+
* @remarks
|
|
2524
|
+
* The HTTP client transport stamps it only for `tools/call`, from that request's `params.name`,
|
|
2525
|
+
* in the Base64 sentinel form whenever the name cannot ride as plain ASCII.
|
|
2526
|
+
*/
|
|
2527
|
+
export declare const MCP_NAME_HEADER = "mcp-name";
|
|
2528
|
+
|
|
2529
|
+
/**
|
|
2530
|
+
* Names the request-header prefix an `x-mcp-header` annotation projects a tool argument onto.
|
|
2531
|
+
*
|
|
2532
|
+
* @remarks
|
|
2533
|
+
* The full field name is this prefix followed by the annotation's own value verbatim, so
|
|
2534
|
+
* `x-mcp-header: 'Region'` becomes `Mcp-Param-Region`. HTTP field names are case-insensitive,
|
|
2535
|
+
* which is why {@link MCP_HEADER_ANNOTATION} values are unique case-insensitively within one
|
|
2536
|
+
* `inputSchema`.
|
|
2537
|
+
*/
|
|
2538
|
+
export declare const MCP_PARAM_PREFIX = "Mcp-Param-";
|
|
2539
|
+
|
|
2540
|
+
/**
|
|
2541
|
+
* Names the Streamable-HTTP transport header carrying the MCP protocol version.
|
|
2542
|
+
*
|
|
2543
|
+
* @remarks
|
|
2544
|
+
* A modern request derives it from its own `_meta`; a legacy request echoes the revision the
|
|
2545
|
+
* `initialize` result negotiated on each subsequent request.
|
|
2546
|
+
*/
|
|
2547
|
+
export declare const MCP_PROTOCOL_VERSION_HEADER = "mcp-protocol-version";
|
|
2548
|
+
|
|
2549
|
+
/**
|
|
2550
|
+
* Names the opening marker of the Base64 sentinel a standard MCP header value travels in.
|
|
2551
|
+
*
|
|
2552
|
+
* @remarks
|
|
2553
|
+
* The markers are LOWERCASE and exact, and this constant with {@link MCP_SENTINEL_SUFFIX} is
|
|
2554
|
+
* their ONE spelling in this package: {@link import('@orkestrel/mcp').encodeSentinel} builds a
|
|
2555
|
+
* sentinel from them and {@link import('@orkestrel/mcp').decodeSentinel} recognizes one by
|
|
2556
|
+
* them, so the two directions cannot drift apart.
|
|
2557
|
+
*/
|
|
2558
|
+
export declare const MCP_SENTINEL_PREFIX = "=?base64?";
|
|
2559
|
+
|
|
2560
|
+
/** Names the closing marker of the Base64 sentinel a standard MCP header value travels in. */
|
|
2561
|
+
export declare const MCP_SENTINEL_SUFFIX = "?=";
|
|
2562
|
+
|
|
2563
|
+
/**
|
|
2564
|
+
* Names the Streamable-HTTP transport header that carries the MCP session id.
|
|
2565
|
+
*
|
|
2566
|
+
* @remarks
|
|
2567
|
+
* A STATEFUL server sends it on the `initialize` reply, and
|
|
2568
|
+
* {@link import('./transports/HTTPClientTransport.js').HTTPClientTransport} echoes it as a
|
|
2569
|
+
* request header on every subsequent request, so a client passes that server's session
|
|
2570
|
+
* validation unchanged.
|
|
2571
|
+
*/
|
|
2572
|
+
export declare const MCP_SESSION_HEADER = "mcp-session-id";
|
|
2573
|
+
|
|
2574
|
+
/** Names the MCP reserved error for a request naming an unsupported protocol revision. */
|
|
1943
2575
|
export declare const MCP_UNSUPPORTED_VERSION = -32022;
|
|
1944
2576
|
|
|
1945
|
-
/**
|
|
2577
|
+
/**
|
|
2578
|
+
* Names the WebSocket subprotocol `createWebSocketClientTransport` requests by default —
|
|
2579
|
+
* `'mcp'`, which `createWebSocketServer` selects when the client offers it. Per RFC 6455
|
|
2580
|
+
* §4.1 a client MUST fail the connection if the server returns
|
|
2581
|
+
* a subprotocol it did not request; Node ≥ 22 (undici) enforces this strictly, so the
|
|
2582
|
+
* default bakes the correct value in. Override `WebSocketClientTransportOptions.protocols`
|
|
2583
|
+
* only when connecting to a foreign server that speaks a different subprotocol (or `[]`
|
|
2584
|
+
* for no subprotocol negotiation at all).
|
|
2585
|
+
*
|
|
2586
|
+
* @remarks
|
|
2587
|
+
* The client sends it in `Sec-WebSocket-Protocol` and the server echoes it in its `101`
|
|
2588
|
+
* handshake, so an MCP WebSocket endpoint is distinguishable from any other WebSocket on the
|
|
2589
|
+
* same path. The default WebSocket upgrade path is the same `'/mcp'` the HTTP transport mounts
|
|
2590
|
+
* at — the upgrade is selected by the `Upgrade: websocket` header, not a separate path.
|
|
2591
|
+
*/
|
|
2592
|
+
export declare const MCP_WEBSOCKET_SUBPROTOCOL = "mcp";
|
|
2593
|
+
|
|
2594
|
+
/** Represents the optional audience, importance, and modification hints on MCP content. */
|
|
1946
2595
|
export declare interface MCPAnnotations {
|
|
1947
2596
|
readonly audience?: readonly MCPRole[];
|
|
1948
2597
|
readonly priority?: number;
|
|
1949
2598
|
readonly lastModified?: string;
|
|
1950
2599
|
}
|
|
1951
2600
|
|
|
1952
|
-
/**
|
|
2601
|
+
/** Represents a base64-encoded audio MCP content block. */
|
|
1953
2602
|
export declare interface MCPAudioContent {
|
|
1954
2603
|
readonly type: 'audio';
|
|
1955
2604
|
readonly data: string;
|
|
@@ -1958,7 +2607,7 @@ export declare interface MCPAudioContent {
|
|
|
1958
2607
|
readonly _meta?: MCPMetaObject;
|
|
1959
2608
|
}
|
|
1960
2609
|
|
|
1961
|
-
/**
|
|
2610
|
+
/** Represents embedded base64-encoded resource contents. */
|
|
1962
2611
|
export declare interface MCPBlobResource {
|
|
1963
2612
|
readonly uri: string;
|
|
1964
2613
|
readonly mimeType?: string;
|
|
@@ -1980,10 +2629,11 @@ export declare interface MCPBlobResource {
|
|
|
1980
2629
|
* - `progress` receives each `notifications/progress` frame the peer publishes for this
|
|
1981
2630
|
* request. Supplying it is what stamps the request's progress token, so a peer only
|
|
1982
2631
|
* reports where a caller is listening.
|
|
1983
|
-
* - `input` carries one input-required retry.
|
|
1984
|
-
*
|
|
1985
|
-
* `
|
|
1986
|
-
* `
|
|
2632
|
+
* - `input` carries one input-required retry. `responses` is required; `state` is optional
|
|
2633
|
+
* because a peer may issue a round with no `requestState` to return, and the client sends
|
|
2634
|
+
* the `requestState` parameter exactly when a state is supplied. The retry must repeat the
|
|
2635
|
+
* original `name` and byte-identical `arguments`; the client maps the leaves to the
|
|
2636
|
+
* top-level `requestState` and `inputResponses` parameters.
|
|
1987
2637
|
*
|
|
1988
2638
|
* No option survives the call: the continuation data is placed only on that request, and when
|
|
1989
2639
|
* the request settles — answered, refused, timed out, aborted, or drained by a `disconnect` —
|
|
@@ -1994,15 +2644,15 @@ export declare interface MCPCallOptions {
|
|
|
1994
2644
|
readonly signal?: AbortSignal;
|
|
1995
2645
|
/** Receives this request's progress frames; supplying it stamps the progress token. */
|
|
1996
2646
|
readonly progress?: MCPProgressHandler;
|
|
1997
|
-
/** Carries the protected state
|
|
2647
|
+
/** Carries the responses, and any protected state, for one input-required retry. */
|
|
1998
2648
|
readonly input?: {
|
|
1999
|
-
readonly state
|
|
2649
|
+
readonly state?: string;
|
|
2000
2650
|
readonly responses: Readonly<Record<string, unknown>>;
|
|
2001
2651
|
};
|
|
2002
2652
|
}
|
|
2003
2653
|
|
|
2004
2654
|
/**
|
|
2005
|
-
*
|
|
2655
|
+
* Represents what one remote `tools/call` answered — the arms the dated protocol permits.
|
|
2006
2656
|
*
|
|
2007
2657
|
* @remarks
|
|
2008
2658
|
* The peer chooses the arm, so the caller narrows on `resultType`:
|
|
@@ -2021,19 +2671,19 @@ export declare interface MCPCallOptions {
|
|
|
2021
2671
|
*/
|
|
2022
2672
|
export declare type MCPCallOutcome = {
|
|
2023
2673
|
readonly resultType: 'complete';
|
|
2024
|
-
/**
|
|
2674
|
+
/** Holds the remote tool's value — its `structuredContent`, or its parsed text. */
|
|
2025
2675
|
readonly value: unknown;
|
|
2026
2676
|
} | MCPTaskResult | MCPInputResult;
|
|
2027
2677
|
|
|
2028
|
-
/**
|
|
2678
|
+
/** Represents a required complete modern `tools/call` result. */
|
|
2029
2679
|
export declare type MCPCallResult = MCPUnstampedCallResult & {
|
|
2030
2680
|
readonly resultType: 'complete';
|
|
2031
2681
|
};
|
|
2032
2682
|
|
|
2033
2683
|
/**
|
|
2034
|
-
*
|
|
2035
|
-
*
|
|
2036
|
-
*
|
|
2684
|
+
* Connects to a REMOTE MCP server over any injected {@link MCPMessageTransportInterface},
|
|
2685
|
+
* negotiates the modern revision, and exposes the server's tools as local
|
|
2686
|
+
* {@link ToolInterface}s an agent can run.
|
|
2037
2687
|
*
|
|
2038
2688
|
* @remarks
|
|
2039
2689
|
* - **The mirror of `MCPServer`.** The server DISPATCHES requests over a tool registry;
|
|
@@ -2097,7 +2747,7 @@ export declare class MCPClient implements MCPClientInterface {
|
|
|
2097
2747
|
get emitter(): EmitterInterface<MCPClientEventMap>;
|
|
2098
2748
|
get connected(): boolean;
|
|
2099
2749
|
get version(): MCPModernVersion | undefined;
|
|
2100
|
-
get transport():
|
|
2750
|
+
get transport(): MCPMessageTransportInterface;
|
|
2101
2751
|
get tasks(): MCPTaskClientInterface;
|
|
2102
2752
|
connect(): Promise<void>;
|
|
2103
2753
|
discover(): Promise<MCPDiscoverResult>;
|
|
@@ -2107,7 +2757,7 @@ export declare class MCPClient implements MCPClientInterface {
|
|
|
2107
2757
|
call(name: string, args: Readonly<Record<string, unknown>>, options?: MCPCallOptions): Promise<MCPCallOutcome>;
|
|
2108
2758
|
}
|
|
2109
2759
|
|
|
2110
|
-
/**
|
|
2760
|
+
/** Represents the open dated client-capability declaration carried by modern requests. */
|
|
2111
2761
|
export declare type MCPClientCapabilities = Readonly<Record<string, MCPMetaObject>> & {
|
|
2112
2762
|
readonly experimental?: Readonly<Record<string, MCPMetaObject>>;
|
|
2113
2763
|
readonly roots?: MCPMetaObject;
|
|
@@ -2123,7 +2773,7 @@ export declare type MCPClientCapabilities = Readonly<Record<string, MCPMetaObjec
|
|
|
2123
2773
|
};
|
|
2124
2774
|
|
|
2125
2775
|
/**
|
|
2126
|
-
*
|
|
2776
|
+
* Represents the push observation surface of an {@link MCPClientInterface} — the moments a
|
|
2127
2777
|
* fire-and-forget observer (logging, tracing) subscribes to through `client.emitter.on`.
|
|
2128
2778
|
*
|
|
2129
2779
|
* @remarks
|
|
@@ -2144,20 +2794,19 @@ export declare type MCPClientCapabilities = Readonly<Record<string, MCPMetaObjec
|
|
|
2144
2794
|
* Declared as a `type` alias so the literal satisfies `EventMap`.
|
|
2145
2795
|
*/
|
|
2146
2796
|
export declare type MCPClientEventMap = {
|
|
2147
|
-
/**
|
|
2797
|
+
/** Reports that era negotiation completed — the client is connected. */
|
|
2148
2798
|
readonly connect: readonly [];
|
|
2149
|
-
/**
|
|
2799
|
+
/** Reports that the client disconnected — pending requests rejected, the connection it owned closed or its close failed. */
|
|
2150
2800
|
readonly disconnect: readonly [];
|
|
2151
|
-
/**
|
|
2801
|
+
/** Reports that a server-initiated notification arrived (not a response to a pending request). */
|
|
2152
2802
|
readonly notification: readonly [message: JSONRPCMessage];
|
|
2153
|
-
/**
|
|
2803
|
+
/** Reports a client-level fault surfaced for observation (typed `unknown`). */
|
|
2154
2804
|
readonly error: readonly [error: unknown];
|
|
2155
2805
|
};
|
|
2156
2806
|
|
|
2157
2807
|
/**
|
|
2158
|
-
*
|
|
2159
|
-
*
|
|
2160
|
-
* modern wire revision, and exposes the server's tools as local
|
|
2808
|
+
* Connects to a REMOTE MCP server over any injected {@link MCPMessageTransportInterface},
|
|
2809
|
+
* negotiates the modern wire revision, and exposes the server's tools as local
|
|
2161
2810
|
* {@link ToolInterface}s an agent can run.
|
|
2162
2811
|
*
|
|
2163
2812
|
* @remarks
|
|
@@ -2176,7 +2825,7 @@ export declare type MCPClientEventMap = {
|
|
|
2176
2825
|
* non-`'complete'` arm throws there instead.
|
|
2177
2826
|
* - **Per-request cancellation.** `call`'s `options.signal` cancels ONE in-flight request:
|
|
2178
2827
|
* it rejects locally on every carrier, and additionally writes `notifications/cancelled`
|
|
2179
|
-
* where the transport declares itself {@link
|
|
2828
|
+
* where the transport declares itself {@link MCPMessageTransportInterface.duplex}. It
|
|
2180
2829
|
* never cancels the connection, and never a durable task — a call that already answered
|
|
2181
2830
|
* `resultType: 'task'` is a request that is over. Cancellation is advisory, so a
|
|
2182
2831
|
* response arriving after the abort is discarded rather than raised.
|
|
@@ -2209,14 +2858,15 @@ export declare type MCPClientEventMap = {
|
|
|
2209
2858
|
*/
|
|
2210
2859
|
export declare interface MCPClientInterface {
|
|
2211
2860
|
readonly emitter: EmitterInterface<MCPClientEventMap>;
|
|
2212
|
-
/**
|
|
2861
|
+
/** Reports whether modern revision negotiation has completed and the client is connected. */
|
|
2213
2862
|
readonly connected: boolean;
|
|
2214
|
-
/**
|
|
2863
|
+
/** Holds the negotiated protocol revision, or `undefined` while disconnected. */
|
|
2215
2864
|
readonly version: MCPModernVersion | undefined;
|
|
2216
|
-
/**
|
|
2217
|
-
readonly transport:
|
|
2865
|
+
/** Holds the injected transport the client drives the remote server over. */
|
|
2866
|
+
readonly transport: MCPMessageTransportInterface;
|
|
2218
2867
|
/**
|
|
2219
|
-
*
|
|
2868
|
+
* Holds the stable Tasks extension's client half — reading, answering, and stopping a durable
|
|
2869
|
+
* task.
|
|
2220
2870
|
*
|
|
2221
2871
|
* @remarks
|
|
2222
2872
|
* Always present, because the `tasks/*` methods are ordinary requests a client may
|
|
@@ -2338,7 +2988,7 @@ export declare interface MCPClientInterface {
|
|
|
2338
2988
|
*
|
|
2339
2989
|
* `options.signal` cancels THIS request only — the caller stops waiting, the pending
|
|
2340
2990
|
* request rejects, and the peer is TOLD on a carrier that can carry a client
|
|
2341
|
-
* notification (see {@link
|
|
2991
|
+
* notification (see {@link MCPMessageTransportInterface.duplex}). MCP cancellation is
|
|
2342
2992
|
* advisory: the peer may answer anyway, and that late answer is discarded rather than
|
|
2343
2993
|
* raised. `options.progress` receives this request's progress frames.
|
|
2344
2994
|
*
|
|
@@ -2351,7 +3001,7 @@ export declare interface MCPClientInterface {
|
|
|
2351
3001
|
}
|
|
2352
3002
|
|
|
2353
3003
|
/**
|
|
2354
|
-
* Options for `createMCPClient` — the {@link
|
|
3004
|
+
* Options for `createMCPClient` — the {@link MCPMessageTransportInterface} to drive, the
|
|
2355
3005
|
* optional client {@link MCPIdentity}, the per-request `timeout`, and the reserved
|
|
2356
3006
|
* `on` hooks.
|
|
2357
3007
|
*
|
|
@@ -2378,176 +3028,52 @@ export declare interface MCPClientInterface {
|
|
|
2378
3028
|
*/
|
|
2379
3029
|
export declare interface MCPClientOptions {
|
|
2380
3030
|
readonly on?: EmitterHooks<MCPClientEventMap>;
|
|
2381
|
-
/**
|
|
3031
|
+
/** Holds the emitter's listener-error handler — a listener throw routes here, not to a domain event. */
|
|
2382
3032
|
readonly error?: EmitterErrorHandler;
|
|
2383
|
-
readonly transport:
|
|
3033
|
+
readonly transport: MCPMessageTransportInterface;
|
|
2384
3034
|
readonly identity?: MCPIdentity;
|
|
2385
|
-
/**
|
|
3035
|
+
/** Holds the open client-capability record carried by modern requests. */
|
|
2386
3036
|
readonly capabilities?: MCPClientCapabilities;
|
|
2387
3037
|
/**
|
|
2388
|
-
*
|
|
3038
|
+
* Pins an optional exact modern protocol revision; absence permits modern negotiation. A defined
|
|
2389
3039
|
* pin must match the peer's discovery advertisement. An unsupported runtime value throws an
|
|
2390
3040
|
* {@link MCPError} synchronously during construction.
|
|
2391
3041
|
*/
|
|
2392
3042
|
readonly version?: MCPModernVersion;
|
|
2393
|
-
/**
|
|
3043
|
+
/** Sets the per-request deadline in milliseconds (default {@link import('./constants.js').DEFAULT_MCP_REQUEST_TIMEOUT}). */
|
|
2394
3044
|
readonly timeout?: number;
|
|
2395
3045
|
}
|
|
2396
3046
|
|
|
2397
|
-
/**
|
|
2398
|
-
* The observable events of a {@link MCPClientTransportInterface} — the moments the
|
|
2399
|
-
* {@link MCPClientInterface} (and any tracer) subscribes to through `transport.emitter.on`.
|
|
2400
|
-
*
|
|
2401
|
-
* @remarks
|
|
2402
|
-
* - `message` — a JSON-RPC message ARRIVED from the remote server (a response the
|
|
2403
|
-
* client correlates to a pending request by `id`, or a server-initiated
|
|
2404
|
-
* notification). The transport decodes the wire bytes (a JSON body or an SSE
|
|
2405
|
-
* `data:` event) and emits the parsed {@link JSONRPCMessage}.
|
|
2406
|
-
* - `close` — the transport's connection ended (a stream closed, `close()` ran).
|
|
2407
|
-
* - `error` — a transport-level fault (a malformed message, a network error); the
|
|
2408
|
-
* payload is typed `unknown`. This is a DOMAIN event, distinct from the emitter's
|
|
2409
|
-
* own listener-error channel: a listener throw is routed to the emitter's `error` handler
|
|
2410
|
-
* (the `error` option), never onto this map. Declared as a `type` alias so the
|
|
2411
|
-
* type-literal satisfies `EventMap` structurally.
|
|
2412
|
-
*/
|
|
2413
|
-
export declare type MCPClientTransportEventMap = {
|
|
2414
|
-
/** A JSON-RPC message arrived from the remote server (a response, or a notification). */
|
|
2415
|
-
readonly message: readonly [message: JSONRPCMessage];
|
|
2416
|
-
/** The transport's connection ended. */
|
|
2417
|
-
readonly close: readonly [];
|
|
2418
|
-
/** A transport-level fault — the caught error (typed `unknown`). */
|
|
2419
|
-
readonly error: readonly [error: unknown];
|
|
2420
|
-
};
|
|
2421
|
-
|
|
2422
|
-
/**
|
|
2423
|
-
* A transport-agnostic MCP message carrier — pumps JSON-RPC messages to a peer and
|
|
2424
|
-
* surfaces received messages on its `emitter`'s `message` event, with no knowledge
|
|
2425
|
-
* of the protocol role on either side.
|
|
2426
|
-
*
|
|
2427
|
-
* @remarks
|
|
2428
|
-
* A client hands the transport one {@link JSONRPCMessage} through `send`, and the
|
|
2429
|
-
* transport delivers each decoded reply through the `message` event. Server bridges
|
|
2430
|
-
* use the same carrier for bidirectional WebSocket and stdio channels. The minimal surface is a
|
|
2431
|
-
* `start` (open the connection / arm any reader), `send` (write one message),
|
|
2432
|
-
* and `close` (tear down). `session` exposes a server-assigned session id once a
|
|
2433
|
-
* stateful transport has one (`undefined` for the stateless v1) — reserved for the
|
|
2434
|
-
* later sessions tier. Concrete transports live in the browser and server environments;
|
|
2435
|
-
* the in-process loopback transport in the tests implements the same contract.
|
|
2436
|
-
*/
|
|
2437
|
-
export declare interface MCPClientTransportInterface {
|
|
2438
|
-
readonly emitter: EmitterInterface<MCPClientTransportEventMap>;
|
|
2439
|
-
/** A server-assigned session id once a stateful transport has one; `undefined` otherwise. */
|
|
2440
|
-
readonly session: string | undefined;
|
|
2441
|
-
/**
|
|
2442
|
-
* Whether this carrier accepts a CLIENT-INITIATED notification — one written with no
|
|
2443
|
-
* `id`, which no response will ever answer.
|
|
2444
|
-
*
|
|
2445
|
-
* @remarks
|
|
2446
|
-
* The transport states it because only the transport knows it, and getting it wrong is
|
|
2447
|
-
* invisible: `send` accepts any {@link JSONRPCMessage}, so a carrier with no
|
|
2448
|
-
* client→server notification channel will happily write one and drop it silently.
|
|
2449
|
-
*
|
|
2450
|
-
* `true` for a genuinely bidirectional channel — a WebSocket, a stdio pipe pair, an
|
|
2451
|
-
* in-process duplex port — where a frame the client writes at any moment reaches the
|
|
2452
|
-
* peer. `false` for a request/response carrier such as Streamable HTTP: the dated
|
|
2453
|
-
* revision defines NO client-to-server notification over it, and the cancellation
|
|
2454
|
-
* signal there is closing the response stream rather than a frame. A `false` carrier
|
|
2455
|
-
* is not a degraded one — it has its own signal — so the client withholds the frame
|
|
2456
|
-
* rather than writing one nothing will read.
|
|
2457
|
-
*/
|
|
2458
|
-
readonly duplex: boolean;
|
|
2459
|
-
/**
|
|
2460
|
-
* Opens the transport — establishes the connection and arms any reply reader.
|
|
2461
|
-
*
|
|
2462
|
-
* @remarks
|
|
2463
|
-
* A `start` that REJECTS must first release whatever it had already acquired. The
|
|
2464
|
-
* {@link MCPClientInterface} claims a connection only once `start` resolves, so a rejection
|
|
2465
|
-
* leaves it holding an error and no claim: a socket, session, or reader the transport opened
|
|
2466
|
-
* before failing is reachable by nothing the client can call, and no client-side mechanism can
|
|
2467
|
-
* be added that would reach it.
|
|
2468
|
-
*
|
|
2469
|
-
* @returns Resolves once the transport is ready to `send`
|
|
2470
|
-
*/
|
|
2471
|
-
start(): Promise<void>;
|
|
2472
|
-
/**
|
|
2473
|
-
* Sends one JSON-RPC message to the remote server.
|
|
2474
|
-
*
|
|
2475
|
-
* @remarks
|
|
2476
|
-
* Each decoded reply is surfaced on the `emitter`'s `message` event — `send`
|
|
2477
|
-
* itself resolves once the message has been written (and, for a request/response
|
|
2478
|
-
* transport, its synchronous reply emitted), not when a logical response arrives;
|
|
2479
|
-
* the {@link MCPClientInterface} awaits the response through its `id` correlation.
|
|
2480
|
-
*
|
|
2481
|
-
* A `send` that FAILS must fail by REJECTING, never by throwing synchronously. The
|
|
2482
|
-
* {@link MCPClientInterface} registers the write inside the same promise executor that
|
|
2483
|
-
* records the request's pending entry, so a synchronous throw leaves no promise for that
|
|
2484
|
-
* registration to attach to: the entry set one statement earlier is never settled, and a
|
|
2485
|
-
* later abort writes `notifications/cancelled` naming a request the write never delivered.
|
|
2486
|
-
* An `async send` satisfies this by construction, which is why every transport this package
|
|
2487
|
-
* ships declares one; a non-`async` implementation returns a rejected promise instead of
|
|
2488
|
-
* throwing. The client cannot enforce this from its side — the throw and the write are
|
|
2489
|
-
* indistinguishable to it — so it is stated here, on the contract that owns it.
|
|
2490
|
-
*
|
|
2491
|
-
* A transport whose channel confirms the write rejects on its failure. A transport whose
|
|
2492
|
-
* exchange reports through the emitter resolves. A transport whose channel cannot confirm a
|
|
2493
|
-
* write answers a closed channel from its own state, and each states which in its own
|
|
2494
|
-
* remarks.
|
|
2495
|
-
*
|
|
2496
|
-
* @param message - The message to write to the wire
|
|
2497
|
-
* @returns Resolves once the message has been sent, and rejects — never throws — when the
|
|
2498
|
-
* write fails
|
|
2499
|
-
*/
|
|
2500
|
-
send(message: JSONRPCMessage): Promise<void>;
|
|
2501
|
-
/**
|
|
2502
|
-
* Closes the transport — ends the connection and releases resources.
|
|
2503
|
-
*
|
|
2504
|
-
* @remarks
|
|
2505
|
-
* A `close` must SETTLE, and its settlements mean different things to its caller: resolving
|
|
2506
|
-
* says the connection ended, rejecting says it did not. The
|
|
2507
|
-
* {@link MCPClientInterface}'s only other bound is a deadline, which reports that the shutdown
|
|
2508
|
-
* did not ANSWER and never that it did not happen — so a `close` that resolves or rejects hours
|
|
2509
|
-
* late still decides the outcome, and one that never settles leaves the connection owed for the
|
|
2510
|
-
* client's life. `close` is never called twice concurrently for one connection: a caller that
|
|
2511
|
-
* gave up waiting JOINS the `close` still running rather than issuing another. It IS called
|
|
2512
|
-
* again after an earlier `close` REJECTED, because a rejected close ended nothing.
|
|
2513
|
-
*
|
|
2514
|
-
* `close` is IDEMPOTENT: a call on a transport an earlier `close` already ended resolves
|
|
2515
|
-
* without emitting `close` again and without releasing anything a second time. Idempotence
|
|
2516
|
-
* bounds ONE closed lifetime rather than the object — a transport that reopens on `start`
|
|
2517
|
-
* arms itself there, and its next `close` ends that connection and emits once for it.
|
|
2518
|
-
*
|
|
2519
|
-
* @returns Resolves once the transport is closed
|
|
2520
|
-
*/
|
|
2521
|
-
close(): Promise<void>;
|
|
2522
|
-
}
|
|
2523
|
-
|
|
2524
|
-
/** One completion candidate set before the protocol's 100-value projection cap. */
|
|
3047
|
+
/** Represents one completion candidate set before the protocol's 100-value projection cap. */
|
|
2525
3048
|
export declare interface MCPCompletion {
|
|
2526
3049
|
readonly values: readonly string[];
|
|
2527
3050
|
readonly total?: number;
|
|
2528
3051
|
readonly hasMore?: boolean;
|
|
2529
3052
|
}
|
|
2530
3053
|
|
|
2531
|
-
/**
|
|
3054
|
+
/** Represents the argument fragment being completed. */
|
|
2532
3055
|
export declare interface MCPCompletionArgument {
|
|
2533
3056
|
readonly name: string;
|
|
2534
3057
|
readonly value: string;
|
|
2535
3058
|
}
|
|
2536
3059
|
|
|
2537
|
-
/**
|
|
3060
|
+
/** Holds previously resolved string arguments supplied as completion context. */
|
|
2538
3061
|
export declare interface MCPCompletionContext {
|
|
2539
3062
|
readonly arguments?: Readonly<Record<string, string>>;
|
|
2540
3063
|
}
|
|
2541
3064
|
|
|
2542
3065
|
/**
|
|
2543
|
-
*
|
|
3066
|
+
* Represents the consumer-supplied completion port for prompt and resource-template arguments.
|
|
2544
3067
|
*
|
|
2545
3068
|
* @remarks
|
|
2546
3069
|
* The host owns reference lookup and template-variable knowledge. MCP forwards the reference
|
|
2547
3070
|
* verbatim and performs no template parsing or expansion. Returning `undefined` means the
|
|
2548
3071
|
* referenced prompt or resource template does not exist.
|
|
3072
|
+
*
|
|
3073
|
+
* This is the PORT that produces a {@link MCPCompletion}, not the behavioural face of one: the
|
|
3074
|
+
* candidate set is the data type, and this contract is the single method a host answers it from.
|
|
2549
3075
|
*/
|
|
2550
|
-
export declare interface
|
|
3076
|
+
export declare interface MCPCompletionInterface {
|
|
2551
3077
|
/**
|
|
2552
3078
|
* Completes one argument against its host-owned reference.
|
|
2553
3079
|
*
|
|
@@ -2565,20 +3091,20 @@ export declare interface MCPCompletionParams {
|
|
|
2565
3091
|
readonly context?: MCPCompletionContext;
|
|
2566
3092
|
}
|
|
2567
3093
|
|
|
2568
|
-
/**
|
|
3094
|
+
/** Represents the prompt or resource-template reference accepted by `completion/complete`. */
|
|
2569
3095
|
export declare type MCPCompletionReference = MCPPromptReference | MCPResourceTemplateReference;
|
|
2570
3096
|
|
|
2571
|
-
/**
|
|
3097
|
+
/** Represents the complete `completion/complete` result. */
|
|
2572
3098
|
export declare interface MCPCompletionResult {
|
|
2573
3099
|
readonly resultType: 'complete';
|
|
2574
3100
|
readonly completion: MCPCompletion;
|
|
2575
3101
|
readonly _meta?: MCPResultMetaObject;
|
|
2576
3102
|
}
|
|
2577
3103
|
|
|
2578
|
-
/**
|
|
3104
|
+
/** Represents one exact dated-schema tool content block. */
|
|
2579
3105
|
export declare type MCPContent = MCPTextContent | MCPImageContent | MCPAudioContent | MCPResourceLink | MCPEmbeddedResource;
|
|
2580
3106
|
|
|
2581
|
-
/**
|
|
3107
|
+
/** Represents the host-neutral integrity and storage port for opaque MRTR continuation state. */
|
|
2582
3108
|
export declare interface MCPContinuationInterface {
|
|
2583
3109
|
/** Protects a canonical state string and returns the opaque client carrier. */
|
|
2584
3110
|
seal(value: string): Promise<string>;
|
|
@@ -2586,7 +3112,7 @@ export declare interface MCPContinuationInterface {
|
|
|
2586
3112
|
open(value: string): Promise<string | undefined>;
|
|
2587
3113
|
}
|
|
2588
3114
|
|
|
2589
|
-
/**
|
|
3115
|
+
/** Represents the mandatory modern `server/discover` result. */
|
|
2590
3116
|
export declare type MCPDiscoverResult = {
|
|
2591
3117
|
readonly supportedVersions: readonly MCPModernVersion[];
|
|
2592
3118
|
readonly capabilities: MCPServerCapabilities;
|
|
@@ -2598,7 +3124,7 @@ export declare type MCPDiscoverResult = {
|
|
|
2598
3124
|
};
|
|
2599
3125
|
|
|
2600
3126
|
/**
|
|
2601
|
-
*
|
|
3127
|
+
* Represents the minimal transport-facing MCP dispatch surface.
|
|
2602
3128
|
*
|
|
2603
3129
|
* @remarks
|
|
2604
3130
|
* A transport-facing dispatcher needs the resolved message limit and the `dispatch` and
|
|
@@ -2606,9 +3132,9 @@ export declare type MCPDiscoverResult = {
|
|
|
2606
3132
|
* no response channel for a contained transport fault and must report that fault as an event.
|
|
2607
3133
|
*/
|
|
2608
3134
|
export declare interface MCPDispatcherInterface {
|
|
2609
|
-
/**
|
|
3135
|
+
/** Holds the shared server observation surface, including contained transport faults. */
|
|
2610
3136
|
readonly emitter: EmitterInterface<MCPServerEventMap>;
|
|
2611
|
-
/**
|
|
3137
|
+
/** Holds the resolved bounds the dispatcher enforces. */
|
|
2612
3138
|
readonly limit: Required<MCPLimitOptions>;
|
|
2613
3139
|
/**
|
|
2614
3140
|
* Dispatches a parsed JSON-RPC request.
|
|
@@ -2645,7 +3171,7 @@ export declare interface MCPDispatcherInterface {
|
|
|
2645
3171
|
}
|
|
2646
3172
|
|
|
2647
3173
|
/**
|
|
2648
|
-
*
|
|
3174
|
+
* Represents the per-request execution options every dispatched handler receives.
|
|
2649
3175
|
*
|
|
2650
3176
|
* @remarks
|
|
2651
3177
|
* `caller` is consumer-ASSERTED and NEVER VERIFIED. Sessions mint transport identity, not
|
|
@@ -2656,23 +3182,17 @@ export declare interface MCPDispatcherInterface {
|
|
|
2656
3182
|
export declare interface MCPDispatchOptions {
|
|
2657
3183
|
/** Aborts when the bound transport can observe that the caller's request has ended. */
|
|
2658
3184
|
readonly signal?: AbortSignal;
|
|
2659
|
-
/**
|
|
3185
|
+
/** Carries consumer-asserted caller context, forwarded opaquely and never protocol-verified. */
|
|
2660
3186
|
readonly caller?: unknown;
|
|
2661
3187
|
}
|
|
2662
3188
|
|
|
2663
|
-
/**
|
|
2664
|
-
export declare interface MCPElicitation {
|
|
2665
|
-
readonly request: MCPElicitForm;
|
|
2666
|
-
readonly state?: JSONValue;
|
|
2667
|
-
}
|
|
2668
|
-
|
|
2669
|
-
/** One titled value in a form elicitation's single- or multi-select schema. */
|
|
3189
|
+
/** Represents one titled value in a form elicitation's single- or multi-select schema. */
|
|
2670
3190
|
export declare interface MCPElicitChoice {
|
|
2671
3191
|
readonly const: string;
|
|
2672
3192
|
readonly title: string;
|
|
2673
3193
|
}
|
|
2674
3194
|
|
|
2675
|
-
/**
|
|
3195
|
+
/** Represents one restricted single-field schema accepted by MCP form-mode elicitation. */
|
|
2676
3196
|
export declare type MCPElicitFieldSchema = {
|
|
2677
3197
|
readonly type: 'boolean';
|
|
2678
3198
|
readonly title?: string;
|
|
@@ -2727,29 +3247,29 @@ export declare type MCPElicitFieldSchema = {
|
|
|
2727
3247
|
};
|
|
2728
3248
|
};
|
|
2729
3249
|
|
|
2730
|
-
/**
|
|
3250
|
+
/** Represents the parameters of a form-mode `elicitation/create` request. */
|
|
2731
3251
|
export declare interface MCPElicitForm {
|
|
2732
3252
|
readonly mode?: 'form';
|
|
2733
3253
|
readonly message: string;
|
|
2734
3254
|
readonly requestedSchema: MCPElicitSchema;
|
|
2735
3255
|
}
|
|
2736
3256
|
|
|
2737
|
-
/**
|
|
3257
|
+
/** Represents the mode-discriminated parameters of an `elicitation/create` request. */
|
|
2738
3258
|
export declare type MCPElicitParams = MCPElicitForm | MCPElicitURL;
|
|
2739
3259
|
|
|
2740
|
-
/**
|
|
3260
|
+
/** Represents an embedded MCP request asking the client to elicit input from its operator. */
|
|
2741
3261
|
export declare interface MCPElicitRequest {
|
|
2742
3262
|
readonly method: 'elicitation/create';
|
|
2743
3263
|
readonly params: MCPElicitParams;
|
|
2744
3264
|
}
|
|
2745
3265
|
|
|
2746
|
-
/**
|
|
3266
|
+
/** Represents the result supplied by a client for one embedded {@link MCPElicitRequest}. */
|
|
2747
3267
|
export declare interface MCPElicitResult {
|
|
2748
3268
|
readonly action: 'accept' | 'decline' | 'cancel';
|
|
2749
3269
|
readonly content?: Readonly<Record<string, MCPElicitValue>>;
|
|
2750
3270
|
}
|
|
2751
3271
|
|
|
2752
|
-
/**
|
|
3272
|
+
/** Represents the restricted top-level object schema in a form-mode elicitation request. */
|
|
2753
3273
|
export declare interface MCPElicitSchema extends Readonly<Record<string, unknown>> {
|
|
2754
3274
|
readonly $schema?: string;
|
|
2755
3275
|
readonly type: 'object';
|
|
@@ -2757,17 +3277,17 @@ export declare interface MCPElicitSchema extends Readonly<Record<string, unknown
|
|
|
2757
3277
|
readonly required?: readonly string[];
|
|
2758
3278
|
}
|
|
2759
3279
|
|
|
2760
|
-
/**
|
|
3280
|
+
/** Represents the parameters of a URL-mode `elicitation/create` request. */
|
|
2761
3281
|
export declare interface MCPElicitURL {
|
|
2762
3282
|
readonly mode: 'url';
|
|
2763
3283
|
readonly message: string;
|
|
2764
3284
|
readonly url: string;
|
|
2765
3285
|
}
|
|
2766
3286
|
|
|
2767
|
-
/**
|
|
3287
|
+
/** Names the primitive value shapes accepted in an MCP form elicitation response. */
|
|
2768
3288
|
export declare type MCPElicitValue = string | number | boolean | readonly string[];
|
|
2769
3289
|
|
|
2770
|
-
/**
|
|
3290
|
+
/** Represents an MCP content block carrying embedded text or blob resource contents. */
|
|
2771
3291
|
export declare interface MCPEmbeddedResource {
|
|
2772
3292
|
readonly type: 'resource';
|
|
2773
3293
|
readonly resource: MCPTextResource | MCPBlobResource;
|
|
@@ -2776,7 +3296,7 @@ export declare interface MCPEmbeddedResource {
|
|
|
2776
3296
|
}
|
|
2777
3297
|
|
|
2778
3298
|
/**
|
|
2779
|
-
*
|
|
3299
|
+
* Names the wire era selected by an MCP request's structure.
|
|
2780
3300
|
*
|
|
2781
3301
|
* @remarks
|
|
2782
3302
|
* `'modern'` and `'legacy'`, and not the boolean such a union would usually be: this is
|
|
@@ -2789,7 +3309,7 @@ export declare interface MCPEmbeddedResource {
|
|
|
2789
3309
|
export declare type MCPEra = 'modern' | 'legacy';
|
|
2790
3310
|
|
|
2791
3311
|
/**
|
|
2792
|
-
*
|
|
3312
|
+
* Preserves a Model Context Protocol error's machine-readable numeric code and
|
|
2793
3313
|
* optional structured context.
|
|
2794
3314
|
*
|
|
2795
3315
|
* @remarks
|
|
@@ -2825,7 +3345,7 @@ export declare class MCPError extends Error {
|
|
|
2825
3345
|
constructor(message: string, code: number, context?: unknown);
|
|
2826
3346
|
}
|
|
2827
3347
|
|
|
2828
|
-
/**
|
|
3348
|
+
/** Represents the explicit, host-neutral context for one modern tool execution. */
|
|
2829
3349
|
export declare interface MCPExecutionContext {
|
|
2830
3350
|
readonly request: JSONRPCRequest;
|
|
2831
3351
|
readonly call: ToolCall;
|
|
@@ -2834,10 +3354,38 @@ export declare interface MCPExecutionContext {
|
|
|
2834
3354
|
readonly progress?: MCPProgressInterface;
|
|
2835
3355
|
}
|
|
2836
3356
|
|
|
2837
|
-
/** Executes one canonical tool call or
|
|
3357
|
+
/** Executes one canonical tool call or returns a fully formed complete MCP result. */
|
|
2838
3358
|
export declare type MCPExecutionHandler = (context: MCPExecutionContext) => ToolResult | MCPCallResult | Promise<ToolResult | MCPCallResult>;
|
|
2839
3359
|
|
|
2840
|
-
/**
|
|
3360
|
+
/**
|
|
3361
|
+
* Represents one `x-mcp-header` projection a tool's `inputSchema` declares.
|
|
3362
|
+
*
|
|
3363
|
+
* @remarks
|
|
3364
|
+
* - `name` — the annotation's own value, appended verbatim to {@link MCP_PARAM_PREFIX} to
|
|
3365
|
+
* form the request field name.
|
|
3366
|
+
* - `path` — the `properties` keys leading from the `inputSchema` root to the annotated
|
|
3367
|
+
* leaf, which is also the path the call's `arguments` carry the value at.
|
|
3368
|
+
* - `primitive` — the leaf's declared type, which fixes the value's text rendering and, for
|
|
3369
|
+
* `integer`, makes the server's comparison numeric rather than textual.
|
|
3370
|
+
*/
|
|
3371
|
+
export declare interface MCPHeaderParameter {
|
|
3372
|
+
readonly name: string;
|
|
3373
|
+
readonly path: readonly string[];
|
|
3374
|
+
readonly primitive: MCPHeaderPrimitive;
|
|
3375
|
+
}
|
|
3376
|
+
|
|
3377
|
+
/**
|
|
3378
|
+
* Names the JSON Schema types an `x-mcp-header` annotation may sit on.
|
|
3379
|
+
*
|
|
3380
|
+
* @remarks
|
|
3381
|
+
* The protocol admits primitives alone, and it splits the JSON Schema number tower: `integer`
|
|
3382
|
+
* carries a decimal rendering an HTTP field can hold exactly, while `number` has no
|
|
3383
|
+
* interoperable text form and is refused. `object`, `array`, and `null` are refused for the
|
|
3384
|
+
* same reason — a header field carries text, not structure.
|
|
3385
|
+
*/
|
|
3386
|
+
export declare type MCPHeaderPrimitive = 'boolean' | 'integer' | 'string';
|
|
3387
|
+
|
|
3388
|
+
/** Represents one sized, themed icon associated with an MCP resource link. */
|
|
2841
3389
|
export declare type MCPIcon = MCPMetaObject & {
|
|
2842
3390
|
readonly src: string;
|
|
2843
3391
|
readonly mimeType?: string;
|
|
@@ -2845,7 +3393,7 @@ export declare type MCPIcon = MCPMetaObject & {
|
|
|
2845
3393
|
readonly theme?: 'light' | 'dark';
|
|
2846
3394
|
};
|
|
2847
3395
|
|
|
2848
|
-
/**
|
|
3396
|
+
/** Represents the complete dated identity of an MCP server or client. */
|
|
2849
3397
|
export declare type MCPIdentity = MCPMetaObject & {
|
|
2850
3398
|
readonly name: string;
|
|
2851
3399
|
readonly version: string;
|
|
@@ -2855,7 +3403,7 @@ export declare type MCPIdentity = MCPMetaObject & {
|
|
|
2855
3403
|
readonly icons?: readonly MCPIcon[];
|
|
2856
3404
|
};
|
|
2857
3405
|
|
|
2858
|
-
/**
|
|
3406
|
+
/** Represents a base64-encoded image MCP content block. */
|
|
2859
3407
|
export declare interface MCPImageContent {
|
|
2860
3408
|
readonly type: 'image';
|
|
2861
3409
|
readonly data: string;
|
|
@@ -2864,43 +3412,48 @@ export declare interface MCPImageContent {
|
|
|
2864
3412
|
readonly _meta?: MCPMetaObject;
|
|
2865
3413
|
}
|
|
2866
3414
|
|
|
2867
|
-
/**
|
|
3415
|
+
/** Represents the call-in-hand context supplied to an {@link MCPInputHandler}. */
|
|
2868
3416
|
export declare interface MCPInputContext {
|
|
2869
3417
|
readonly request: JSONRPCRequest;
|
|
2870
3418
|
readonly name: string;
|
|
2871
3419
|
readonly arguments: Readonly<Record<string, unknown>>;
|
|
2872
|
-
|
|
3420
|
+
/** Holds every verified answer to the previous round, under the keys that round assigned. */
|
|
3421
|
+
readonly responses?: MCPInputResponseMap;
|
|
2873
3422
|
readonly state?: JSONValue;
|
|
2874
3423
|
}
|
|
2875
3424
|
|
|
2876
3425
|
/**
|
|
2877
|
-
* Decides whether the current `tools/call` needs
|
|
3426
|
+
* Decides whether the current `tools/call` still needs input from the client.
|
|
2878
3427
|
*
|
|
2879
|
-
* @param context - The original call plus
|
|
3428
|
+
* @param context - The original call plus every verified answer and state on a retry
|
|
2880
3429
|
* @param options - The resolved per-request method options
|
|
2881
|
-
* @returns
|
|
3430
|
+
* @returns The next round to send, or `undefined` to continue into the tool registry
|
|
2882
3431
|
*/
|
|
2883
|
-
export declare type MCPInputHandler = (context: MCPInputContext, options: MCPMethodOptions) =>
|
|
3432
|
+
export declare type MCPInputHandler = (context: MCPInputContext, options: MCPMethodOptions) => MCPInputRound | undefined | Promise<MCPInputRound | undefined>;
|
|
2884
3433
|
|
|
2885
|
-
/**
|
|
3434
|
+
/** Configures the consumer policy for the server's multi-round-trip input mechanism. */
|
|
2886
3435
|
export declare interface MCPInputOptions {
|
|
2887
|
-
/**
|
|
3436
|
+
/** Holds the host-neutral integrity/storage port for the opaque continuation carrier. */
|
|
2888
3437
|
readonly continuation: MCPContinuationInterface;
|
|
2889
|
-
/**
|
|
3438
|
+
/**
|
|
3439
|
+
* Sets the continuation lifetime in milliseconds; required so MCP never invents an expiry policy.
|
|
3440
|
+
*/
|
|
2890
3441
|
readonly ttl: number;
|
|
2891
3442
|
/** Resolves the authenticated principal for the call in hand. */
|
|
2892
3443
|
readonly principal: MCPPrincipalHandler;
|
|
2893
|
-
/**
|
|
2894
|
-
readonly
|
|
3444
|
+
/** Composes the next round of input requests, including on verified retries. */
|
|
3445
|
+
readonly selector: MCPInputHandler;
|
|
2895
3446
|
}
|
|
2896
3447
|
|
|
2897
3448
|
/**
|
|
2898
|
-
*
|
|
3449
|
+
* Represents one embedded multi-round-trip request.
|
|
2899
3450
|
*
|
|
2900
3451
|
* @remarks
|
|
2901
|
-
*
|
|
2902
|
-
*
|
|
2903
|
-
*
|
|
3452
|
+
* A consumer composes any of the three arms into an {@link MCPInputRound}, and this server
|
|
3453
|
+
* issues whichever arms that round carries. The elicitation arm is fully typed because this
|
|
3454
|
+
* package issues its schema and enforces the answer against it. The sampling and roots arms
|
|
3455
|
+
* keep OPEN parameter records: the dated schema leaves their request bodies to the caller, and
|
|
3456
|
+
* narrowing them here would refuse parameters the protocol permits.
|
|
2904
3457
|
*/
|
|
2905
3458
|
export declare type MCPInputRequest = MCPElicitRequest | {
|
|
2906
3459
|
readonly method: 'sampling/createMessage';
|
|
@@ -2910,11 +3463,27 @@ export declare type MCPInputRequest = MCPElicitRequest | {
|
|
|
2910
3463
|
readonly params?: Readonly<Record<string, unknown>>;
|
|
2911
3464
|
};
|
|
2912
3465
|
|
|
2913
|
-
/**
|
|
3466
|
+
/** Represents a consumer-keyed map of embedded requests the client must fulfil. */
|
|
2914
3467
|
export declare type MCPInputRequestMap = Readonly<Record<string, MCPInputRequest>>;
|
|
2915
3468
|
|
|
2916
3469
|
/**
|
|
2917
|
-
*
|
|
3470
|
+
* Represents one client answer to one embedded input request.
|
|
3471
|
+
*
|
|
3472
|
+
* @remarks
|
|
3473
|
+
* The arms are discriminated by their own required members — `action` for an elicitation,
|
|
3474
|
+
* `roots` for a roots listing, and `model` beside `role` for a sampling completion — because
|
|
3475
|
+
* the protocol gives a response no `method` of its own. The server knows which arm applies
|
|
3476
|
+
* from the request it ISSUED under that key, so {@link MCPInputHandler} receives every answer
|
|
3477
|
+
* already checked against the question it answers.
|
|
3478
|
+
*/
|
|
3479
|
+
export declare type MCPInputResponse = MCPElicitResult | MCPSampleResult | MCPRootResult;
|
|
3480
|
+
|
|
3481
|
+
/** Represents a consumer-keyed map of the client's answers to one issued round. */
|
|
3482
|
+
export declare type MCPInputResponseMap = Readonly<Record<string, MCPInputResponse>>;
|
|
3483
|
+
|
|
3484
|
+
/**
|
|
3485
|
+
* Represents an incomplete modern result carrying input requests, protected request state,
|
|
3486
|
+
* or both.
|
|
2918
3487
|
*
|
|
2919
3488
|
* @remarks
|
|
2920
3489
|
* The union enforces the protocol's at-least-one-of rule at the type boundary:
|
|
@@ -2933,15 +3502,30 @@ export declare type MCPInputResult = {
|
|
|
2933
3502
|
};
|
|
2934
3503
|
|
|
2935
3504
|
/**
|
|
2936
|
-
*
|
|
3505
|
+
* Represents one consumer-composed round of embedded requests, before MCP seals its
|
|
3506
|
+
* continuation state.
|
|
3507
|
+
*
|
|
3508
|
+
* @remarks
|
|
3509
|
+
* The consumer owns the keys and the request kinds, because the keys are how it correlates
|
|
3510
|
+
* each answer and the kinds are what its own policy needs. MCP owns everything protective
|
|
3511
|
+
* around the round: the capability gate, the seal, the expiry, and the per-answer check on
|
|
3512
|
+
* the retry.
|
|
3513
|
+
*/
|
|
3514
|
+
export declare interface MCPInputRound {
|
|
3515
|
+
readonly requests: MCPInputRequestMap;
|
|
3516
|
+
readonly state?: JSONValue;
|
|
3517
|
+
}
|
|
3518
|
+
|
|
3519
|
+
/**
|
|
3520
|
+
* Represents the integrity-protected payload carried inside an opaque `requestState` token.
|
|
2937
3521
|
*
|
|
2938
3522
|
* @remarks
|
|
2939
3523
|
* `id` is the FIRST round's request id and stays bound across every later round, so a
|
|
2940
3524
|
* multi-round exchange remains one correlated call rather than a chain whose origin is lost
|
|
2941
|
-
* after the second hop. `
|
|
2942
|
-
*
|
|
2943
|
-
*
|
|
2944
|
-
* `
|
|
3525
|
+
* after the second hop. `requests` is the EXACT round that was issued: it carries the keys the
|
|
3526
|
+
* retry must answer and, for a form elicitation, the schema {@link isElicitContent} enforces
|
|
3527
|
+
* an accepted answer against — a round that is bound but never enforced buys nothing.
|
|
3528
|
+
* `requests` and `expiry` are re-minted every round; `principal`, `id`, `version`, `method`,
|
|
2945
3529
|
* `name`, and `digest` are the bindings that must not move.
|
|
2946
3530
|
*/
|
|
2947
3531
|
export declare interface MCPInputState {
|
|
@@ -2950,21 +3534,20 @@ export declare interface MCPInputState {
|
|
|
2950
3534
|
readonly id: JSONRPCId;
|
|
2951
3535
|
readonly version: string;
|
|
2952
3536
|
readonly method: string;
|
|
2953
|
-
|
|
3537
|
+
/** Holds the exact round issued under this state, enforced answer by answer on the retry. */
|
|
3538
|
+
readonly requests: MCPInputRequestMap;
|
|
2954
3539
|
readonly name: string;
|
|
2955
3540
|
readonly digest: string;
|
|
2956
|
-
/** The exact schema issued with this round, enforced on the accepted response. */
|
|
2957
|
-
readonly schema: MCPElicitSchema;
|
|
2958
3541
|
readonly state?: JSONValue;
|
|
2959
3542
|
}
|
|
2960
3543
|
|
|
2961
3544
|
/** Limits applied by {@link isBoundedJSON} to one JSON value. */
|
|
2962
3545
|
export declare interface MCPJSONLimitOptions {
|
|
2963
|
-
/**
|
|
3546
|
+
/** Bounds the serialized UTF-8 bytes. */
|
|
2964
3547
|
readonly bytes: number;
|
|
2965
|
-
/**
|
|
3548
|
+
/** Bounds the total enumerable keys; omitted when bytes alone bound breadth. */
|
|
2966
3549
|
readonly keys?: number;
|
|
2967
|
-
/**
|
|
3550
|
+
/** Bounds the array/object nesting depth. */
|
|
2968
3551
|
readonly depth: number;
|
|
2969
3552
|
}
|
|
2970
3553
|
|
|
@@ -3005,7 +3588,7 @@ export declare class MCPLegacy implements MCPDispatcherInterface {
|
|
|
3005
3588
|
* restores legacy results to modern complete-result shapes before delivery, and bounds retained
|
|
3006
3589
|
* request correlations with the configured deadline.
|
|
3007
3590
|
*/
|
|
3008
|
-
export declare class MCPLegacyClientTransport implements
|
|
3591
|
+
export declare class MCPLegacyClientTransport implements MCPMessageTransportInterface {
|
|
3009
3592
|
#private;
|
|
3010
3593
|
/**
|
|
3011
3594
|
* Creates a legacy client transport adapter.
|
|
@@ -3013,8 +3596,8 @@ export declare class MCPLegacyClientTransport implements MCPClientTransportInter
|
|
|
3013
3596
|
* @param transport - The legacy peer transport
|
|
3014
3597
|
* @param options - The legacy handshake identity, capabilities, revision, and deadline
|
|
3015
3598
|
*/
|
|
3016
|
-
constructor(transport:
|
|
3017
|
-
get emitter(): EmitterInterface<
|
|
3599
|
+
constructor(transport: MCPMessageTransportInterface, options?: MCPLegacyClientTransportOptions);
|
|
3600
|
+
get emitter(): EmitterInterface<MCPMessageTransportEventMap>;
|
|
3018
3601
|
get session(): string | undefined;
|
|
3019
3602
|
get duplex(): boolean;
|
|
3020
3603
|
start(): Promise<void>;
|
|
@@ -3050,26 +3633,26 @@ export declare class MCPLegacyClientTransport implements MCPClientTransportInter
|
|
|
3050
3633
|
* the peer. Do not send unrelated id-`0` traffic through the wrapped transport in that window.
|
|
3051
3634
|
*/
|
|
3052
3635
|
export declare interface MCPLegacyClientTransportOptions {
|
|
3053
|
-
/**
|
|
3636
|
+
/** Holds the client identity sent during the legacy handshake. */
|
|
3054
3637
|
readonly identity?: MCPIdentity;
|
|
3055
|
-
/**
|
|
3638
|
+
/** Holds the client capabilities sent during the legacy handshake. */
|
|
3056
3639
|
readonly capabilities?: MCPClientCapabilities;
|
|
3057
|
-
/**
|
|
3640
|
+
/** Names the exact legacy revision to request and require. */
|
|
3058
3641
|
readonly version?: MCPLegacyVersion;
|
|
3059
|
-
/**
|
|
3642
|
+
/** Sets the legacy handshake and forwarded-request deadline in milliseconds. */
|
|
3060
3643
|
readonly timeout?: number;
|
|
3061
3644
|
}
|
|
3062
3645
|
|
|
3063
|
-
/**
|
|
3646
|
+
/** Represents the construction options for the removable legacy protocol decorator. */
|
|
3064
3647
|
export declare interface MCPLegacyOptions {
|
|
3065
|
-
/**
|
|
3648
|
+
/** Holds the sole dispatcher and execution engine. */
|
|
3066
3649
|
readonly dispatcher: MCPDispatcherInterface;
|
|
3067
|
-
/**
|
|
3650
|
+
/** Holds the identity returned by the legacy `initialize` handshake. */
|
|
3068
3651
|
readonly identity: MCPIdentity;
|
|
3069
3652
|
}
|
|
3070
3653
|
|
|
3071
3654
|
/**
|
|
3072
|
-
*
|
|
3655
|
+
* Represents one legacy-era result — the payload of an answer produced by the fixed legacy
|
|
3073
3656
|
* method switch.
|
|
3074
3657
|
*
|
|
3075
3658
|
* @remarks
|
|
@@ -3083,42 +3666,45 @@ export declare interface MCPLegacyOptions {
|
|
|
3083
3666
|
* This arm exists only for the optional legacy server decorator and client transport adapter.
|
|
3084
3667
|
*/
|
|
3085
3668
|
export declare interface MCPLegacyResult {
|
|
3086
|
-
/**
|
|
3669
|
+
/** Forbids this member; the legacy revision has no result discriminator. */
|
|
3087
3670
|
readonly resultType?: never;
|
|
3088
3671
|
readonly [key: string]: unknown;
|
|
3089
3672
|
}
|
|
3090
3673
|
|
|
3091
|
-
/**
|
|
3674
|
+
/** Names a legacy protocol revision supported by the optional legacy decorators. */
|
|
3092
3675
|
export declare type MCPLegacyVersion = '2025-11-25' | '2025-06-18';
|
|
3093
3676
|
|
|
3094
|
-
/**
|
|
3677
|
+
/** Configures the hostile-input and live-resource bounds for an MCP server. */
|
|
3095
3678
|
export declare interface MCPLimitOptions {
|
|
3096
|
-
/**
|
|
3679
|
+
/** Bounds the UTF-8 bytes accepted by the raw string boundary. */
|
|
3097
3680
|
readonly message?: number;
|
|
3098
|
-
/**
|
|
3681
|
+
/** Bounds the serialized UTF-8 bytes accepted in one `_meta` value. */
|
|
3099
3682
|
readonly metadata?: number;
|
|
3100
|
-
/**
|
|
3683
|
+
/**
|
|
3684
|
+
* Bounds the total enumerable keys accepted in one bounded value: one `_meta` value under
|
|
3685
|
+
* `metadata`, and one produced tool-call result under `content`.
|
|
3686
|
+
*/
|
|
3101
3687
|
readonly keys?: number;
|
|
3102
|
-
/**
|
|
3688
|
+
/** Bounds the UTF-8 bytes accepted in one protected `requestState`. */
|
|
3103
3689
|
readonly state?: number;
|
|
3104
|
-
/**
|
|
3690
|
+
/** Bounds the serialized UTF-8 bytes accepted from one complete produced tool-call result. */
|
|
3105
3691
|
readonly content?: number;
|
|
3106
|
-
/**
|
|
3692
|
+
/** Bounds the simultaneously live built-in subscription streams. */
|
|
3107
3693
|
readonly subscriptions?: number;
|
|
3108
|
-
/**
|
|
3694
|
+
/** Bounds the nesting depth accepted by bounded JSON values. */
|
|
3109
3695
|
readonly depth?: number;
|
|
3110
3696
|
}
|
|
3111
3697
|
|
|
3112
|
-
/**
|
|
3698
|
+
/** Configures the per-subscription cancellation and bounded buffering policy. */
|
|
3113
3699
|
export declare interface MCPListenOptions {
|
|
3114
3700
|
/** Aborts the subscription and rejects its pending read with the signal reason. */
|
|
3115
3701
|
readonly signal: AbortSignal;
|
|
3116
|
-
/**
|
|
3702
|
+
/** Bounds the number of delivered frames retained while no read is parked. */
|
|
3117
3703
|
readonly capacity?: number;
|
|
3118
3704
|
}
|
|
3119
3705
|
|
|
3120
3706
|
/**
|
|
3121
|
-
*
|
|
3707
|
+
* Represents the MCP `tools/list` result — tool descriptors plus optional modern result
|
|
3122
3708
|
* stamps.
|
|
3123
3709
|
*
|
|
3124
3710
|
* @remarks
|
|
@@ -3134,11 +3720,138 @@ export declare type MCPListResult = {
|
|
|
3134
3720
|
readonly _meta?: MCPResultMetaObject;
|
|
3135
3721
|
};
|
|
3136
3722
|
|
|
3137
|
-
/**
|
|
3723
|
+
/** Names the dated logging levels accepted by MCP request metadata. */
|
|
3138
3724
|
export declare type MCPLoggingLevel = 'debug' | 'info' | 'notice' | 'warning' | 'error' | 'critical' | 'alert' | 'emergency';
|
|
3139
3725
|
|
|
3140
3726
|
/**
|
|
3141
|
-
*
|
|
3727
|
+
* Lists the observable events of a {@link MCPMessageTransportInterface} — the moments the
|
|
3728
|
+
* {@link MCPClientInterface} (and any tracer) subscribes to through `transport.emitter.on`.
|
|
3729
|
+
*
|
|
3730
|
+
* @remarks
|
|
3731
|
+
* - `message` — a JSON-RPC message ARRIVED from the remote server (a response the
|
|
3732
|
+
* client correlates to a pending request by `id`, or a server-initiated
|
|
3733
|
+
* notification). The transport decodes the wire bytes (a JSON body or an SSE
|
|
3734
|
+
* `data:` event) and emits the parsed {@link JSONRPCMessage}.
|
|
3735
|
+
* - `close` — the transport's connection ended (a stream closed, `close()` ran).
|
|
3736
|
+
* - `error` — a transport-level fault (a malformed message, a network error); the
|
|
3737
|
+
* payload is typed `unknown`. This is a DOMAIN event, distinct from the emitter's
|
|
3738
|
+
* own listener-error channel: a listener throw is routed to the emitter's `error` handler
|
|
3739
|
+
* (the `error` option), never onto this map. Declared as a `type` alias so the
|
|
3740
|
+
* type-literal satisfies `EventMap` structurally.
|
|
3741
|
+
*/
|
|
3742
|
+
export declare type MCPMessageTransportEventMap = {
|
|
3743
|
+
/** Reports that a JSON-RPC message arrived from the remote server (a response, or a notification). */
|
|
3744
|
+
readonly message: readonly [message: JSONRPCMessage];
|
|
3745
|
+
/** Reports that the transport's connection ended. */
|
|
3746
|
+
readonly close: readonly [];
|
|
3747
|
+
/** Reports a transport-level fault — the caught error (typed `unknown`). */
|
|
3748
|
+
readonly error: readonly [error: unknown];
|
|
3749
|
+
};
|
|
3750
|
+
|
|
3751
|
+
/**
|
|
3752
|
+
* Pumps JSON-RPC messages to a peer and surfaces received messages on its `emitter`'s
|
|
3753
|
+
* `message` event, with no knowledge of the protocol role on either side — a
|
|
3754
|
+
* transport-agnostic MCP message carrier.
|
|
3755
|
+
*
|
|
3756
|
+
* @remarks
|
|
3757
|
+
* A client hands the transport one {@link JSONRPCMessage} through `send`, and the
|
|
3758
|
+
* transport delivers each decoded reply through the `message` event. Server bridges
|
|
3759
|
+
* use the same carrier for bidirectional WebSocket and stdio channels. The minimal surface is a
|
|
3760
|
+
* `start` (open the connection / arm any reader), `send` (write one message),
|
|
3761
|
+
* and `close` (tear down). `session` exposes a server-assigned session id once a
|
|
3762
|
+
* stateful transport has one (`undefined` for the stateless v1) — reserved for the
|
|
3763
|
+
* later sessions tier. Concrete transports live in the browser and server environments;
|
|
3764
|
+
* the in-process loopback transport in the tests implements the same contract.
|
|
3765
|
+
*/
|
|
3766
|
+
export declare interface MCPMessageTransportInterface {
|
|
3767
|
+
readonly emitter: EmitterInterface<MCPMessageTransportEventMap>;
|
|
3768
|
+
/** Holds a server-assigned session id after a stateful transport has one; `undefined` otherwise. */
|
|
3769
|
+
readonly session: string | undefined;
|
|
3770
|
+
/**
|
|
3771
|
+
* Reports whether this carrier accepts a CLIENT-INITIATED notification — one written with
|
|
3772
|
+
* no `id`, which no response will ever answer.
|
|
3773
|
+
*
|
|
3774
|
+
* @remarks
|
|
3775
|
+
* The transport states it because only the transport knows it, and getting it wrong is
|
|
3776
|
+
* invisible: `send` accepts any {@link JSONRPCMessage}, so a carrier with no
|
|
3777
|
+
* client→server notification channel will happily write one and drop it silently.
|
|
3778
|
+
*
|
|
3779
|
+
* `true` for a genuinely bidirectional channel — a WebSocket, a stdio pipe pair, an
|
|
3780
|
+
* in-process duplex port — where a frame the client writes at any moment reaches the
|
|
3781
|
+
* peer. `false` for a request/response carrier such as Streamable HTTP: the dated
|
|
3782
|
+
* revision defines NO client-to-server notification over it, and the cancellation
|
|
3783
|
+
* signal there is closing the response stream rather than a frame. A `false` carrier
|
|
3784
|
+
* is not a degraded one — it has its own signal — so the client withholds the frame
|
|
3785
|
+
* rather than writing one nothing will read.
|
|
3786
|
+
*/
|
|
3787
|
+
readonly duplex: boolean;
|
|
3788
|
+
/**
|
|
3789
|
+
* Opens the transport — establishes the connection and arms any reply reader.
|
|
3790
|
+
*
|
|
3791
|
+
* @remarks
|
|
3792
|
+
* A `start` that REJECTS must first release whatever it had already acquired. The
|
|
3793
|
+
* {@link MCPClientInterface} claims a connection only once `start` resolves, so a rejection
|
|
3794
|
+
* leaves it holding an error and no claim: a socket, session, or reader the transport opened
|
|
3795
|
+
* before failing is reachable by nothing the client can call, and no client-side mechanism can
|
|
3796
|
+
* be added that would reach it.
|
|
3797
|
+
*
|
|
3798
|
+
* @returns Resolves once the transport is ready to `send`
|
|
3799
|
+
*/
|
|
3800
|
+
start(): Promise<void>;
|
|
3801
|
+
/**
|
|
3802
|
+
* Sends one JSON-RPC message to the remote server.
|
|
3803
|
+
*
|
|
3804
|
+
* @remarks
|
|
3805
|
+
* Each decoded reply is surfaced on the `emitter`'s `message` event — `send`
|
|
3806
|
+
* itself resolves once the message has been written (and, for a request/response
|
|
3807
|
+
* transport, its synchronous reply emitted), not when a logical response arrives;
|
|
3808
|
+
* the {@link MCPClientInterface} awaits the response through its `id` correlation.
|
|
3809
|
+
*
|
|
3810
|
+
* A `send` that FAILS must fail by REJECTING, never by throwing synchronously. The
|
|
3811
|
+
* {@link MCPClientInterface} registers the write inside the same promise executor that
|
|
3812
|
+
* records the request's pending entry, so a synchronous throw leaves no promise for that
|
|
3813
|
+
* registration to attach to: the entry set one statement earlier is never settled, and a
|
|
3814
|
+
* later abort writes `notifications/cancelled` naming a request the write never delivered.
|
|
3815
|
+
* An `async send` satisfies this by construction, which is why every transport this package
|
|
3816
|
+
* ships declares one; a non-`async` implementation returns a rejected promise instead of
|
|
3817
|
+
* throwing. The client cannot enforce this from its side — the throw and the write are
|
|
3818
|
+
* indistinguishable to it — so it is stated here, on the contract that owns it.
|
|
3819
|
+
*
|
|
3820
|
+
* A transport whose channel confirms the write rejects on its failure. A transport whose
|
|
3821
|
+
* exchange reports through the emitter resolves. A transport whose channel cannot confirm a
|
|
3822
|
+
* write answers a closed channel from its own state, and each states which in its own
|
|
3823
|
+
* remarks.
|
|
3824
|
+
*
|
|
3825
|
+
* @param message - The message to write to the wire
|
|
3826
|
+
* @returns Resolves once the message has been sent, and rejects — never throws — when the
|
|
3827
|
+
* write fails
|
|
3828
|
+
*/
|
|
3829
|
+
send(message: JSONRPCMessage): Promise<void>;
|
|
3830
|
+
/**
|
|
3831
|
+
* Closes the transport — ends the connection and releases resources.
|
|
3832
|
+
*
|
|
3833
|
+
* @remarks
|
|
3834
|
+
* A `close` must SETTLE, and its settlements mean different things to its caller: resolving
|
|
3835
|
+
* says the connection ended, rejecting says it did not. The
|
|
3836
|
+
* {@link MCPClientInterface}'s only other bound is a deadline, which reports that the shutdown
|
|
3837
|
+
* did not ANSWER and never that it did not happen — so a `close` that resolves or rejects hours
|
|
3838
|
+
* late still decides the outcome, and one that never settles leaves the connection owed for the
|
|
3839
|
+
* client's life. `close` is never called twice concurrently for one connection: a caller that
|
|
3840
|
+
* gave up waiting JOINS the `close` still running rather than issuing another. It IS called
|
|
3841
|
+
* again after an earlier `close` REJECTED, because a rejected close ended nothing.
|
|
3842
|
+
*
|
|
3843
|
+
* `close` is IDEMPOTENT: a call on a transport an earlier `close` already ended resolves
|
|
3844
|
+
* without emitting `close` again and without releasing anything a second time. Idempotence
|
|
3845
|
+
* bounds ONE closed lifetime rather than the object — a transport that reopens on `start`
|
|
3846
|
+
* arms itself there, and its next `close` ends that connection and emits once for it.
|
|
3847
|
+
*
|
|
3848
|
+
* @returns Resolves once the transport is closed
|
|
3849
|
+
*/
|
|
3850
|
+
close(): Promise<void>;
|
|
3851
|
+
}
|
|
3852
|
+
|
|
3853
|
+
/**
|
|
3854
|
+
* Represents the exact finite JSON metadata carried by MCP `_meta` envelopes.
|
|
3142
3855
|
*
|
|
3143
3856
|
* @remarks
|
|
3144
3857
|
* The `Object` suffix is not a role suffix from the type table — it NAMES THE SHAPE.
|
|
@@ -3150,7 +3863,7 @@ export declare type MCPLoggingLevel = 'debug' | 'info' | 'notice' | 'warning' |
|
|
|
3150
3863
|
export declare type MCPMetaObject = Readonly<Record<string, JSONValue>>;
|
|
3151
3864
|
|
|
3152
3865
|
/**
|
|
3153
|
-
*
|
|
3866
|
+
* Represents one modern method, registered on the seam that dispatches it.
|
|
3154
3867
|
*
|
|
3155
3868
|
* @remarks
|
|
3156
3869
|
* A registered method answers a {@link JSONRPCRequest} — with a terminating
|
|
@@ -3183,7 +3896,7 @@ export declare type MCPMetaObject = Readonly<Record<string, JSONValue>>;
|
|
|
3183
3896
|
export declare type MCPMethodHandler = (request: JSONRPCRequest, options: MCPMethodOptions) => Promise<JSONRPCResponse | MCPStream>;
|
|
3184
3897
|
|
|
3185
3898
|
/**
|
|
3186
|
-
*
|
|
3899
|
+
* Holds the modern methods an {@link import('./types.js').MCPServerInterface}
|
|
3187
3900
|
* dispatches through — a name-keyed store of {@link MCPMethodHandler}s that owns its
|
|
3188
3901
|
* map rather than exposing one.
|
|
3189
3902
|
*
|
|
@@ -3212,8 +3925,8 @@ export declare class MCPMethodManager implements MCPMethodManagerInterface {
|
|
|
3212
3925
|
}
|
|
3213
3926
|
|
|
3214
3927
|
/**
|
|
3215
|
-
*
|
|
3216
|
-
* seam carrying both the built-in methods and any method a consumer adds.
|
|
3928
|
+
* Represents the modern method registry an {@link MCPServerInterface} dispatches through —
|
|
3929
|
+
* the ONE seam carrying both the built-in methods and any method a consumer adds.
|
|
3217
3930
|
*
|
|
3218
3931
|
* @remarks
|
|
3219
3932
|
* `server/discover`, `tools/list`, `tools/call`, and `subscriptions/listen` are registered here at construction,
|
|
@@ -3241,13 +3954,13 @@ export declare interface MCPMethodManagerInterface {
|
|
|
3241
3954
|
}
|
|
3242
3955
|
|
|
3243
3956
|
/**
|
|
3244
|
-
*
|
|
3957
|
+
* Represents the RESOLVED per-request options one dispatched method receives.
|
|
3245
3958
|
*
|
|
3246
3959
|
* @remarks
|
|
3247
3960
|
* The mirror of {@link MCPDispatchOptions} on the far side of dispatch: a CALLER may
|
|
3248
3961
|
* have no signal to offer, but a dispatched method always has one to observe, so
|
|
3249
3962
|
* `signal` is REQUIRED here. Dispatch resolves it once, at the single ingress, and
|
|
3250
|
-
* supplies the same value to every handler,
|
|
3963
|
+
* supplies the same value to every handler, input, principal, and subscription
|
|
3251
3964
|
* producer the request reaches — none of them may reinvent a cancellation source or
|
|
3252
3965
|
* treat absence as a case.
|
|
3253
3966
|
*
|
|
@@ -3267,15 +3980,15 @@ export declare interface MCPMethodManagerInterface {
|
|
|
3267
3980
|
export declare interface MCPMethodOptions {
|
|
3268
3981
|
/** Aborts when the caller's request ends, or when the answer it produced is finished. */
|
|
3269
3982
|
readonly signal: AbortSignal;
|
|
3270
|
-
/**
|
|
3983
|
+
/** Carries consumer-asserted caller context, forwarded opaquely and never protocol-verified. */
|
|
3271
3984
|
readonly caller?: unknown;
|
|
3272
3985
|
}
|
|
3273
3986
|
|
|
3274
|
-
/**
|
|
3987
|
+
/** Names a modern protocol revision supported by the bare MCP server. */
|
|
3275
3988
|
export declare type MCPModernVersion = '2026-07-28';
|
|
3276
3989
|
|
|
3277
3990
|
/**
|
|
3278
|
-
*
|
|
3991
|
+
* Carries open notification metadata with the dated reserved subscription field.
|
|
3279
3992
|
*
|
|
3280
3993
|
* @remarks
|
|
3281
3994
|
* The subscription id is OPTIONAL here, and that is the schema's own split rather than
|
|
@@ -3288,19 +4001,21 @@ export declare type MCPModernVersion = '2026-07-28';
|
|
|
3288
4001
|
* sits on the terminating result of a stream, so a subscription always exists to name.
|
|
3289
4002
|
*/
|
|
3290
4003
|
export declare type MCPNotificationMetaObject = MCPMetaObject & {
|
|
3291
|
-
/**
|
|
4004
|
+
/**
|
|
4005
|
+
* Holds the JSON-RPC id of the `subscriptions/listen` request whose stream delivered the frame.
|
|
4006
|
+
*/
|
|
3292
4007
|
readonly 'io.modelcontextprotocol/subscriptionId'?: JSONRPCId;
|
|
3293
4008
|
};
|
|
3294
4009
|
|
|
3295
|
-
/**
|
|
4010
|
+
/** Represents the cursor parameters shared by every paginated modern list method. */
|
|
3296
4011
|
export declare interface MCPPaginationParams {
|
|
3297
|
-
/**
|
|
4012
|
+
/** Holds the opaque cursor returned by the preceding page. */
|
|
3298
4013
|
readonly cursor?: string;
|
|
3299
4014
|
}
|
|
3300
4015
|
|
|
3301
|
-
/**
|
|
4016
|
+
/** Represents the cursor result fields shared by every paginated modern list method. */
|
|
3302
4017
|
export declare interface MCPPaginationResult {
|
|
3303
|
-
/**
|
|
4018
|
+
/** Holds the opaque cursor for the following page; absent when this is the final page. */
|
|
3304
4019
|
readonly nextCursor?: string;
|
|
3305
4020
|
}
|
|
3306
4021
|
|
|
@@ -3313,7 +4028,7 @@ export declare interface MCPPaginationResult {
|
|
|
3313
4028
|
*/
|
|
3314
4029
|
export declare type MCPPrincipalHandler = (request: JSONRPCRequest, options: MCPMethodOptions) => string | Promise<string>;
|
|
3315
4030
|
|
|
3316
|
-
/**
|
|
4031
|
+
/** Represents one official request-scoped progress payload. */
|
|
3317
4032
|
export declare interface MCPProgress {
|
|
3318
4033
|
readonly progress: number;
|
|
3319
4034
|
readonly total?: number;
|
|
@@ -3338,14 +4053,43 @@ export declare interface MCPProgress {
|
|
|
3338
4053
|
*/
|
|
3339
4054
|
export declare type MCPProgressHandler = (progress: MCPProgress) => void;
|
|
3340
4055
|
|
|
3341
|
-
/**
|
|
4056
|
+
/**
|
|
4057
|
+
* Reports request-scoped progress under backpressure — the reporter supplied to an explicit
|
|
4058
|
+
* executor.
|
|
4059
|
+
*/
|
|
3342
4060
|
export declare interface MCPProgressInterface {
|
|
3343
4061
|
/** Reports one finite, strictly increasing progress value and awaits its consumption. */
|
|
3344
4062
|
report(progress: MCPProgress): Promise<void>;
|
|
3345
4063
|
}
|
|
3346
4064
|
|
|
3347
4065
|
/**
|
|
3348
|
-
*
|
|
4066
|
+
* Represents the OWNING half of one progress slot — {@link MCPProgressInterface} plus the
|
|
4067
|
+
* consuming and stopping the slot's owner performs.
|
|
4068
|
+
*
|
|
4069
|
+
* @remarks
|
|
4070
|
+
* Two interfaces over one entity because two parties hold it and they are owed different
|
|
4071
|
+
* powers. An executor receives the narrow {@link MCPProgressInterface} through
|
|
4072
|
+
* {@link MCPExecutionContext} and can publish and nothing else; the MCP-owned response stream
|
|
4073
|
+
* that created the slot holds this one and also drains it and shuts it down. Naming the owner's
|
|
4074
|
+
* half is what keeps `take` and `stop` documented as contract rather than as extra surface a
|
|
4075
|
+
* class happens to expose.
|
|
4076
|
+
*
|
|
4077
|
+
* @example
|
|
4078
|
+
* ```ts
|
|
4079
|
+
* const owner: MCPProgressOwnerInterface = new MCPProgressReporter(id, limits, signal)
|
|
4080
|
+
* const notification = await owner.take()
|
|
4081
|
+
* owner.stop()
|
|
4082
|
+
* ```
|
|
4083
|
+
*/
|
|
4084
|
+
export declare interface MCPProgressOwnerInterface extends MCPProgressInterface {
|
|
4085
|
+
/** Takes the next progress notification, waiting for the single producer slot when empty. */
|
|
4086
|
+
take(): Promise<JSONRPCNotification>;
|
|
4087
|
+
/** Stops the reporter permanently, rejects pending work, and detaches its abort listener. */
|
|
4088
|
+
stop(): void;
|
|
4089
|
+
}
|
|
4090
|
+
|
|
4091
|
+
/**
|
|
4092
|
+
* Hands bounded, request-scoped progress from one producer to one serial consumer.
|
|
3349
4093
|
*
|
|
3350
4094
|
* The reporter holds at most one owned progress item. {@link report} applies backpressure until
|
|
3351
4095
|
* {@link take} consumes that slot. It has no replay, queue, concurrent-consumer coordination,
|
|
@@ -3367,7 +4111,7 @@ export declare interface MCPProgressInterface {
|
|
|
3367
4111
|
* reporter.stop()
|
|
3368
4112
|
* ```
|
|
3369
4113
|
*/
|
|
3370
|
-
export declare class MCPProgressReporter implements
|
|
4114
|
+
export declare class MCPProgressReporter implements MCPProgressOwnerInterface {
|
|
3371
4115
|
#private;
|
|
3372
4116
|
/**
|
|
3373
4117
|
* Creates one non-durable progress slot for an active request.
|
|
@@ -3403,7 +4147,7 @@ export declare class MCPProgressReporter implements MCPProgressInterface {
|
|
|
3403
4147
|
stop(): void;
|
|
3404
4148
|
}
|
|
3405
4149
|
|
|
3406
|
-
/**
|
|
4150
|
+
/** Represents one prompt descriptor advertised by `prompts/list`. */
|
|
3407
4151
|
export declare interface MCPPrompt {
|
|
3408
4152
|
readonly name: string;
|
|
3409
4153
|
readonly title?: string;
|
|
@@ -3413,7 +4157,7 @@ export declare interface MCPPrompt {
|
|
|
3413
4157
|
readonly _meta?: MCPMetaObject;
|
|
3414
4158
|
}
|
|
3415
4159
|
|
|
3416
|
-
/**
|
|
4160
|
+
/** Represents one argument descriptor advertised with an MCP prompt. */
|
|
3417
4161
|
export declare interface MCPPromptArgument {
|
|
3418
4162
|
readonly name: string;
|
|
3419
4163
|
readonly title?: string;
|
|
@@ -3429,7 +4173,7 @@ export declare interface MCPPromptGetParams {
|
|
|
3429
4173
|
readonly requestState?: string;
|
|
3430
4174
|
}
|
|
3431
4175
|
|
|
3432
|
-
/**
|
|
4176
|
+
/** Represents the complete, non-cacheable `prompts/get` result. */
|
|
3433
4177
|
export declare interface MCPPromptGetResult {
|
|
3434
4178
|
readonly resultType: 'complete';
|
|
3435
4179
|
readonly description?: string;
|
|
@@ -3437,7 +4181,7 @@ export declare interface MCPPromptGetResult {
|
|
|
3437
4181
|
readonly _meta?: MCPResultMetaObject;
|
|
3438
4182
|
}
|
|
3439
4183
|
|
|
3440
|
-
/**
|
|
4184
|
+
/** Represents the complete cacheable `prompts/list` result. */
|
|
3441
4185
|
export declare type MCPPromptListResult = MCPPromptPage & {
|
|
3442
4186
|
readonly resultType: 'complete';
|
|
3443
4187
|
readonly ttlMs: number;
|
|
@@ -3446,7 +4190,7 @@ export declare type MCPPromptListResult = MCPPromptPage & {
|
|
|
3446
4190
|
};
|
|
3447
4191
|
|
|
3448
4192
|
/**
|
|
3449
|
-
*
|
|
4193
|
+
* Represents the consumer-supplied prompt registry port.
|
|
3450
4194
|
*
|
|
3451
4195
|
* @remarks
|
|
3452
4196
|
* MCP owns no prompt storage. The host projects one shared-cursor page at a time and resolves
|
|
@@ -3471,25 +4215,25 @@ export declare interface MCPPromptManagerInterface {
|
|
|
3471
4215
|
prompt(params: MCPPromptGetParams, options: MCPMethodOptions): MCPPromptGetResult | MCPInputResult | undefined | Promise<MCPPromptGetResult | MCPInputResult | undefined>;
|
|
3472
4216
|
}
|
|
3473
4217
|
|
|
3474
|
-
/**
|
|
4218
|
+
/** Represents one user or assistant message returned by `prompts/get`. */
|
|
3475
4219
|
export declare interface MCPPromptMessage {
|
|
3476
4220
|
readonly role: 'user' | 'assistant';
|
|
3477
4221
|
readonly content: MCPContent;
|
|
3478
4222
|
}
|
|
3479
4223
|
|
|
3480
|
-
/**
|
|
4224
|
+
/** Represents one consumer-owned page projected by `prompts/list`. */
|
|
3481
4225
|
export declare interface MCPPromptPage extends MCPPaginationResult {
|
|
3482
4226
|
readonly prompts: readonly MCPPrompt[];
|
|
3483
4227
|
}
|
|
3484
4228
|
|
|
3485
|
-
/**
|
|
4229
|
+
/** Represents a completion reference to one named prompt. */
|
|
3486
4230
|
export declare interface MCPPromptReference {
|
|
3487
4231
|
readonly type: 'ref/prompt';
|
|
3488
4232
|
readonly name: string;
|
|
3489
4233
|
}
|
|
3490
4234
|
|
|
3491
4235
|
/**
|
|
3492
|
-
*
|
|
4236
|
+
* Represents the validated per-request context projected from a modern request's reserved
|
|
3493
4237
|
* `_meta` keys.
|
|
3494
4238
|
*
|
|
3495
4239
|
* @remarks
|
|
@@ -3526,7 +4270,7 @@ export declare interface MCPRequestContext {
|
|
|
3526
4270
|
*/
|
|
3527
4271
|
export declare type MCPRequestFunction = (method: string, params: Readonly<Record<string, unknown>> | undefined, deadline: number | undefined) => Promise<unknown>;
|
|
3528
4272
|
|
|
3529
|
-
/**
|
|
4273
|
+
/** Represents one resource descriptor advertised by `resources/list`. */
|
|
3530
4274
|
export declare interface MCPResource {
|
|
3531
4275
|
readonly uri: string;
|
|
3532
4276
|
readonly name: string;
|
|
@@ -3540,7 +4284,7 @@ export declare interface MCPResource {
|
|
|
3540
4284
|
}
|
|
3541
4285
|
|
|
3542
4286
|
/**
|
|
3543
|
-
*
|
|
4287
|
+
* Represents the resource contents returned by `resources/read`.
|
|
3544
4288
|
*
|
|
3545
4289
|
* @remarks
|
|
3546
4290
|
* The wire has no tag field. Presence of `text` or `blob` is the structural
|
|
@@ -3552,7 +4296,7 @@ export declare type MCPResourceContents = (MCPTextResource & {
|
|
|
3552
4296
|
readonly text?: never;
|
|
3553
4297
|
});
|
|
3554
4298
|
|
|
3555
|
-
/**
|
|
4299
|
+
/** Represents a link to an MCP resource, including its exact dated-schema metadata. */
|
|
3556
4300
|
export declare interface MCPResourceLink {
|
|
3557
4301
|
readonly type: 'resource_link';
|
|
3558
4302
|
readonly name: string;
|
|
@@ -3566,7 +4310,7 @@ export declare interface MCPResourceLink {
|
|
|
3566
4310
|
readonly _meta?: MCPMetaObject;
|
|
3567
4311
|
}
|
|
3568
4312
|
|
|
3569
|
-
/**
|
|
4313
|
+
/** Represents the complete cacheable `resources/list` result. */
|
|
3570
4314
|
export declare type MCPResourceListResult = MCPResourcePage & {
|
|
3571
4315
|
readonly resultType: 'complete';
|
|
3572
4316
|
readonly ttlMs: number;
|
|
@@ -3575,7 +4319,7 @@ export declare type MCPResourceListResult = MCPResourcePage & {
|
|
|
3575
4319
|
};
|
|
3576
4320
|
|
|
3577
4321
|
/**
|
|
3578
|
-
*
|
|
4322
|
+
* Represents the consumer-supplied resource registry port.
|
|
3579
4323
|
*
|
|
3580
4324
|
* @remarks
|
|
3581
4325
|
* MCP owns no storage. The host may back this port with memory, a workspace, a database,
|
|
@@ -3614,7 +4358,7 @@ export declare interface MCPResourceManagerInterface {
|
|
|
3614
4358
|
templates(pagination: MCPPaginationParams, options: MCPMethodOptions): MCPResourceTemplatePage | Promise<MCPResourceTemplatePage>;
|
|
3615
4359
|
}
|
|
3616
4360
|
|
|
3617
|
-
/**
|
|
4361
|
+
/** Represents one consumer-owned page projected by `resources/list`. */
|
|
3618
4362
|
export declare interface MCPResourcePage extends MCPPaginationResult {
|
|
3619
4363
|
readonly resources: readonly MCPResource[];
|
|
3620
4364
|
}
|
|
@@ -3626,7 +4370,7 @@ export declare interface MCPResourceReadParams {
|
|
|
3626
4370
|
readonly requestState?: string;
|
|
3627
4371
|
}
|
|
3628
4372
|
|
|
3629
|
-
/**
|
|
4373
|
+
/** Represents the complete cacheable `resources/read` result. */
|
|
3630
4374
|
export declare type MCPResourceReadResult = {
|
|
3631
4375
|
readonly contents: readonly MCPResourceContents[];
|
|
3632
4376
|
readonly resultType: 'complete';
|
|
@@ -3635,7 +4379,7 @@ export declare type MCPResourceReadResult = {
|
|
|
3635
4379
|
readonly _meta?: MCPResultMetaObject;
|
|
3636
4380
|
};
|
|
3637
4381
|
|
|
3638
|
-
/**
|
|
4382
|
+
/** Represents one RFC 6570 resource-template descriptor advertised by `resources/templates/list`. */
|
|
3639
4383
|
export declare interface MCPResourceTemplate {
|
|
3640
4384
|
readonly uriTemplate: string;
|
|
3641
4385
|
readonly name: string;
|
|
@@ -3647,7 +4391,7 @@ export declare interface MCPResourceTemplate {
|
|
|
3647
4391
|
readonly _meta?: MCPMetaObject;
|
|
3648
4392
|
}
|
|
3649
4393
|
|
|
3650
|
-
/**
|
|
4394
|
+
/** Represents the complete cacheable `resources/templates/list` result. */
|
|
3651
4395
|
export declare type MCPResourceTemplateListResult = MCPResourceTemplatePage & {
|
|
3652
4396
|
readonly resultType: 'complete';
|
|
3653
4397
|
readonly ttlMs: number;
|
|
@@ -3655,19 +4399,19 @@ export declare type MCPResourceTemplateListResult = MCPResourceTemplatePage & {
|
|
|
3655
4399
|
readonly _meta?: MCPResultMetaObject;
|
|
3656
4400
|
};
|
|
3657
4401
|
|
|
3658
|
-
/**
|
|
4402
|
+
/** Represents one consumer-owned page projected by `resources/templates/list`. */
|
|
3659
4403
|
export declare interface MCPResourceTemplatePage extends MCPPaginationResult {
|
|
3660
4404
|
readonly resourceTemplates: readonly MCPResourceTemplate[];
|
|
3661
4405
|
}
|
|
3662
4406
|
|
|
3663
|
-
/**
|
|
4407
|
+
/** Represents a completion reference to one resource-template URI descriptor. */
|
|
3664
4408
|
export declare interface MCPResourceTemplateReference {
|
|
3665
4409
|
readonly type: 'ref/resource';
|
|
3666
4410
|
readonly uri: string;
|
|
3667
4411
|
}
|
|
3668
4412
|
|
|
3669
4413
|
/**
|
|
3670
|
-
*
|
|
4414
|
+
* Represents one modern MCP result — the open contract every dated-revision result satisfies.
|
|
3671
4415
|
*
|
|
3672
4416
|
* @remarks
|
|
3673
4417
|
* The dated schema requires a `resultType` on EVERY modern result and leaves the
|
|
@@ -3685,24 +4429,69 @@ export declare interface MCPResourceTemplateReference {
|
|
|
3685
4429
|
* answer any registered method through, and nowhere else.
|
|
3686
4430
|
*/
|
|
3687
4431
|
export declare interface MCPResult {
|
|
3688
|
-
/**
|
|
4432
|
+
/**
|
|
4433
|
+
* Names the result's protocol discriminator (`'complete'`, `'input_required'`, or a later value).
|
|
4434
|
+
*/
|
|
3689
4435
|
readonly resultType: string;
|
|
3690
|
-
/**
|
|
4436
|
+
/** Carries open modern protocol metadata, including reserved namespaced keys. */
|
|
3691
4437
|
readonly _meta?: MCPResultMetaObject;
|
|
3692
4438
|
readonly [key: string]: unknown;
|
|
3693
4439
|
}
|
|
3694
4440
|
|
|
3695
|
-
/**
|
|
4441
|
+
/** Carries open result metadata with the dated reserved server identity field. */
|
|
3696
4442
|
export declare type MCPResultMetaObject = MCPMetaObject & {
|
|
3697
4443
|
readonly 'io.modelcontextprotocol/serverInfo'?: MCPIdentity;
|
|
3698
4444
|
};
|
|
3699
4445
|
|
|
3700
|
-
/**
|
|
4446
|
+
/** Names the intended recipient of annotated MCP content. */
|
|
3701
4447
|
export declare type MCPRole = 'user' | 'assistant';
|
|
3702
4448
|
|
|
4449
|
+
/** Represents one filesystem root a client exposes to a server. */
|
|
4450
|
+
export declare interface MCPRoot {
|
|
4451
|
+
readonly uri: string;
|
|
4452
|
+
readonly name?: string;
|
|
4453
|
+
readonly _meta?: MCPMetaObject;
|
|
4454
|
+
}
|
|
4455
|
+
|
|
4456
|
+
/** Represents the client's answer to one embedded `roots/list` request. */
|
|
4457
|
+
export declare interface MCPRootResult {
|
|
4458
|
+
readonly roots: readonly MCPRoot[];
|
|
4459
|
+
readonly _meta?: MCPMetaObject;
|
|
4460
|
+
}
|
|
4461
|
+
|
|
4462
|
+
/**
|
|
4463
|
+
* Represents one block a sampling completion may carry.
|
|
4464
|
+
*
|
|
4465
|
+
* @remarks
|
|
4466
|
+
* The dated schema's `SamplingMessageContentBlock`: the text, image, and audio blocks
|
|
4467
|
+
* {@link MCPContent} also admits, plus the two tool blocks a tool-using model produces. The
|
|
4468
|
+
* resource arms of {@link MCPContent} are deliberately absent — the schema leaves them out of
|
|
4469
|
+
* a sampling completion.
|
|
4470
|
+
*/
|
|
4471
|
+
export declare type MCPSampleContent = MCPTextContent | MCPImageContent | MCPAudioContent | MCPToolUseContent | MCPToolResultContent;
|
|
4472
|
+
|
|
4473
|
+
/**
|
|
4474
|
+
* Represents the client's answer to one embedded `sampling/createMessage` request.
|
|
4475
|
+
*
|
|
4476
|
+
* @remarks
|
|
4477
|
+
* `content` is the dated schema's own `anyOf`: one {@link MCPSampleContent} block, or an array
|
|
4478
|
+
* of them. A tool-using model answers with `tool_use` and `tool_result` blocks, and a model
|
|
4479
|
+
* answering in several parts answers with the array, so narrowing this to a single text, image,
|
|
4480
|
+
* or audio block would refuse completions the schema permits. `stopReason` is an open string
|
|
4481
|
+
* because the schema names `endTurn`, `stopSequence`, `maxTokens`, and `toolUse` while
|
|
4482
|
+
* permitting any other value a provider reports.
|
|
4483
|
+
*/
|
|
4484
|
+
export declare interface MCPSampleResult {
|
|
4485
|
+
readonly role: 'user' | 'assistant';
|
|
4486
|
+
readonly content: MCPSampleContent | readonly MCPSampleContent[];
|
|
4487
|
+
readonly model: string;
|
|
4488
|
+
readonly stopReason?: string;
|
|
4489
|
+
readonly _meta?: MCPMetaObject;
|
|
4490
|
+
}
|
|
4491
|
+
|
|
3703
4492
|
/**
|
|
3704
|
-
*
|
|
3705
|
-
*
|
|
4493
|
+
* Dispatches JSON-RPC 2.0 requests over a live {@link ToolManagerInterface}, with NO
|
|
4494
|
+
* transport coupling.
|
|
3706
4495
|
*
|
|
3707
4496
|
* @remarks
|
|
3708
4497
|
* - **`dispatch` and `handle`.** `dispatch(invocation)` runs an already-parsed invocation and
|
|
@@ -3748,7 +4537,7 @@ export declare class MCPServer implements MCPServerInterface {
|
|
|
3748
4537
|
handle(message: string, options?: MCPDispatchOptions): Promise<string | MCPTextStreamControllerInterface | undefined>;
|
|
3749
4538
|
}
|
|
3750
4539
|
|
|
3751
|
-
/**
|
|
4540
|
+
/** Represents the open dated server-capability declaration returned by discovery. */
|
|
3752
4541
|
export declare type MCPServerCapabilities = Readonly<Record<string, MCPMetaObject>> & {
|
|
3753
4542
|
readonly experimental?: Readonly<Record<string, MCPMetaObject>>;
|
|
3754
4543
|
readonly logging?: MCPMetaObject;
|
|
@@ -3767,7 +4556,7 @@ export declare type MCPServerCapabilities = Readonly<Record<string, MCPMetaObjec
|
|
|
3767
4556
|
};
|
|
3768
4557
|
|
|
3769
4558
|
/**
|
|
3770
|
-
*
|
|
4559
|
+
* Represents the push observation surface of an {@link MCPServerInterface} — the
|
|
3771
4560
|
* dispatch moments a fire-and-forget observer (logging, tracing) subscribes to
|
|
3772
4561
|
* through `server.emitter.on`.
|
|
3773
4562
|
*
|
|
@@ -3781,7 +4570,7 @@ export declare type MCPServerCapabilities = Readonly<Record<string, MCPMetaObjec
|
|
|
3781
4570
|
*/
|
|
3782
4571
|
export declare type MCPServerEventMap = {
|
|
3783
4572
|
/**
|
|
3784
|
-
*
|
|
4573
|
+
* Reports that an invocation is being dispatched — its method, correlating id (absent for a
|
|
3785
4574
|
* notification), and structural wire era.
|
|
3786
4575
|
*
|
|
3787
4576
|
* @remarks
|
|
@@ -3791,10 +4580,20 @@ export declare type MCPServerEventMap = {
|
|
|
3791
4580
|
* inbound traffic. Only SCALARS are reported: nothing read out of the request graph
|
|
3792
4581
|
* escapes here, so a listener can never observe a value the ownership seam has not yet
|
|
3793
4582
|
* bounded.
|
|
4583
|
+
*
|
|
4584
|
+
* Not every reported invocation arrived from a peer. A modern `tools/call` reaching the
|
|
4585
|
+
* HTTP POST handler (`createMCPPostHandler`) reports the SYNTHETIC `tools/list` that
|
|
4586
|
+
* handler dispatches to read the called tool's `x-mcp-header` annotations, ahead of the
|
|
4587
|
+
* call itself. Each carries the RESERVED id `0`, and one fires per page the handler
|
|
4588
|
+
* walks, up to {@link MCP_LOOKUP_PAGES}. So an observer accounting for inbound traffic
|
|
4589
|
+
* subtracts a `('tools/list', 0, 'modern')` that precedes a `tools/call`, and one
|
|
4590
|
+
* tracing the server's own work keeps it. The id is reserved by convention rather than
|
|
4591
|
+
* enforced: a peer sending its own `tools/list` under id `0` is not told apart here.
|
|
3794
4592
|
*/
|
|
3795
4593
|
readonly request: readonly [method: string, id: JSONRPCId | undefined, era: MCPEra];
|
|
3796
4594
|
/**
|
|
3797
|
-
*
|
|
4595
|
+
* Reports an operational fault the server CONTAINED — the caught value, exactly once per
|
|
4596
|
+
* fault.
|
|
3798
4597
|
*
|
|
3799
4598
|
* @remarks
|
|
3800
4599
|
* Every fault this server answers with an internal-error response reports here first: a
|
|
@@ -3815,8 +4614,7 @@ export declare type MCPServerEventMap = {
|
|
|
3815
4614
|
};
|
|
3816
4615
|
|
|
3817
4616
|
/**
|
|
3818
|
-
*
|
|
3819
|
-
* modern requests over a live
|
|
4617
|
+
* Dispatches JSON-RPC 2.0 modern requests over a live
|
|
3820
4618
|
* {@link ToolManagerInterface}, with NO transport coupling (a transport layer
|
|
3821
4619
|
* pumps strings through `handle`).
|
|
3822
4620
|
*
|
|
@@ -3845,10 +4643,10 @@ export declare type MCPServerEventMap = {
|
|
|
3845
4643
|
*/
|
|
3846
4644
|
export declare interface MCPServerInterface extends MCPDispatcherInterface {
|
|
3847
4645
|
readonly identity: MCPIdentity;
|
|
3848
|
-
/**
|
|
4646
|
+
/** Holds the modern method registry this server dispatches through (built-ins included). */
|
|
3849
4647
|
readonly methods: MCPMethodManagerInterface;
|
|
3850
4648
|
/**
|
|
3851
|
-
*
|
|
4649
|
+
* Holds the bounds this server actually enforces — every leaf resolved, none optional.
|
|
3852
4650
|
*
|
|
3853
4651
|
* @remarks
|
|
3854
4652
|
* Derived from {@link MCPServerOptions.limit} at construction and stored nowhere else, so
|
|
@@ -3951,19 +4749,21 @@ export declare interface MCPServerInterface extends MCPDispatcherInterface {
|
|
|
3951
4749
|
*/
|
|
3952
4750
|
export declare interface MCPServerOptions {
|
|
3953
4751
|
readonly on?: EmitterHooks<MCPServerEventMap>;
|
|
3954
|
-
/**
|
|
4752
|
+
/** Holds the emitter's listener-error handler — a listener throw routes here, not to a domain event. */
|
|
3955
4753
|
readonly error?: EmitterErrorHandler;
|
|
3956
4754
|
readonly identity: MCPIdentity;
|
|
3957
|
-
/**
|
|
4755
|
+
/** Holds the live tool registry the server exposes over `tools/list` / `tools/call`. */
|
|
3958
4756
|
readonly tools: ToolManagerInterface;
|
|
3959
|
-
/**
|
|
4757
|
+
/**
|
|
4758
|
+
* Holds the optional consumer-owned resource registry exposed over the modern resource methods.
|
|
4759
|
+
*/
|
|
3960
4760
|
readonly resources?: MCPResourceManagerInterface;
|
|
3961
|
-
/**
|
|
4761
|
+
/** Holds the optional consumer-owned prompt registry exposed over the modern prompt methods. */
|
|
3962
4762
|
readonly prompts?: MCPPromptManagerInterface;
|
|
3963
|
-
/**
|
|
3964
|
-
readonly completion?:
|
|
4763
|
+
/** Holds the optional host-owned prompt and resource-template completion provider. */
|
|
4764
|
+
readonly completion?: MCPCompletionInterface;
|
|
3965
4765
|
/**
|
|
3966
|
-
*
|
|
4766
|
+
* Holds the optional explicit execution policy above the canonical live tool registry.
|
|
3967
4767
|
*
|
|
3968
4768
|
* @remarks
|
|
3969
4769
|
* This is also the ONLY way a tool observes cancellation. The default path calls
|
|
@@ -3972,21 +4772,30 @@ export declare interface MCPServerOptions {
|
|
|
3972
4772
|
* completion even after the request that asked for it has ended, and abandons the result.
|
|
3973
4773
|
* An {@link MCPExecutionHandler} receives `signal` on its {@link MCPExecutionContext} and
|
|
3974
4774
|
* can stop the work itself.
|
|
4775
|
+
*
|
|
4776
|
+
* A handler returning a complete {@link MCPCallResult} is taken at its word: the server
|
|
4777
|
+
* bounds it and re-proves its shape, then sends what the handler composed. Nothing stamps
|
|
4778
|
+
* the `_meta` server identity `buildModernResult` puts on a normalized result, so a handler
|
|
4779
|
+
* whose peer reads that key composes it through `buildModernResult` itself.
|
|
3975
4780
|
*/
|
|
3976
4781
|
readonly execution?: MCPExecutionHandler;
|
|
3977
|
-
/**
|
|
4782
|
+
/** Holds the optional human guidance exposed by `server/discover`. */
|
|
3978
4783
|
readonly instructions?: string;
|
|
3979
|
-
/**
|
|
4784
|
+
/** Holds the modern cache stamps; omitted values use the protocol-safe defaults. */
|
|
3980
4785
|
readonly cache?: {
|
|
3981
4786
|
readonly ttl?: number;
|
|
3982
4787
|
readonly scope?: 'public' | 'private';
|
|
3983
4788
|
};
|
|
3984
|
-
/**
|
|
4789
|
+
/**
|
|
4790
|
+
* Holds the optional multi-round-trip input mechanism; all continuation and expiry policy is
|
|
4791
|
+
* consumer-supplied.
|
|
4792
|
+
*/
|
|
3985
4793
|
readonly input?: MCPInputOptions;
|
|
3986
|
-
/**
|
|
4794
|
+
/** Holds the optional event-driven producer for the modern `subscriptions/listen` method. */
|
|
3987
4795
|
readonly subscription?: MCPSubscriptionOptions;
|
|
3988
4796
|
/**
|
|
3989
|
-
*
|
|
4797
|
+
* Holds the optional Tasks extension; the durable store and the deferral decision are
|
|
4798
|
+
* consumer-supplied.
|
|
3990
4799
|
*
|
|
3991
4800
|
* @remarks
|
|
3992
4801
|
* Omitting it leaves every existing path untouched — nothing is advertised, no call is
|
|
@@ -3994,12 +4803,12 @@ export declare interface MCPServerOptions {
|
|
|
3994
4803
|
* snapshot dated 2026-07-28, so the shape this option admits is fixed.
|
|
3995
4804
|
*/
|
|
3996
4805
|
readonly task?: MCPTaskOptions;
|
|
3997
|
-
/**
|
|
4806
|
+
/** Holds the hostile-input and live-resource bounds; omitted leaves use secure defaults. */
|
|
3998
4807
|
readonly limit?: MCPLimitOptions;
|
|
3999
4808
|
}
|
|
4000
4809
|
|
|
4001
4810
|
/**
|
|
4002
|
-
*
|
|
4811
|
+
* Represents a held-open modern result: each `yield` is a {@link JSONRPCNotification}; the
|
|
4003
4812
|
* `return` value is the terminating response.
|
|
4004
4813
|
*
|
|
4005
4814
|
* @remarks
|
|
@@ -4017,7 +4826,8 @@ export declare interface MCPServerOptions {
|
|
|
4017
4826
|
export declare type MCPStream = AsyncGenerator<JSONRPCNotification, JSONRPCResponse, unknown>;
|
|
4018
4827
|
|
|
4019
4828
|
/**
|
|
4020
|
-
*
|
|
4829
|
+
* Provides the one cancellation engine every modern held-open result leaves `MCPServer`
|
|
4830
|
+
* through.
|
|
4021
4831
|
*
|
|
4022
4832
|
* @remarks
|
|
4023
4833
|
* A native async generator decides cancellation with a QUEUE: `return()` and `throw()` wait
|
|
@@ -4123,8 +4933,8 @@ export declare class MCPStreamController implements MCPStreamControllerInterface
|
|
|
4123
4933
|
}
|
|
4124
4934
|
|
|
4125
4935
|
/**
|
|
4126
|
-
*
|
|
4127
|
-
* stream leaving `MCPServer.dispatch` takes.
|
|
4936
|
+
* Represents a held-open modern result whose cancellation ONE owner arbitrates — the arm
|
|
4937
|
+
* every stream leaving `MCPServer.dispatch` takes.
|
|
4128
4938
|
*
|
|
4129
4939
|
* @remarks
|
|
4130
4940
|
* The generator protocol states what a stream yields and says nothing about who ends one,
|
|
@@ -4213,7 +5023,7 @@ export declare interface MCPStreamControllerInterface extends MCPStream {
|
|
|
4213
5023
|
}
|
|
4214
5024
|
|
|
4215
5025
|
/**
|
|
4216
|
-
*
|
|
5026
|
+
* Names the notification families a client may opt in to on a `subscriptions/listen` stream.
|
|
4217
5027
|
*
|
|
4218
5028
|
* @remarks
|
|
4219
5029
|
* Every key here is a WIRE SPELLING, carried verbatim from the dated schema's
|
|
@@ -4267,31 +5077,35 @@ export declare interface MCPSubscriptionFilter {
|
|
|
4267
5077
|
*/
|
|
4268
5078
|
export declare type MCPSubscriptionHandler = (notifications: MCPSubscriptionFilter, options: MCPMethodOptions) => AsyncIterable<JSONRPCNotification> | Promise<AsyncIterable<JSONRPCNotification>>;
|
|
4269
5079
|
|
|
4270
|
-
/**
|
|
5080
|
+
/** Configures the server's built-in `subscriptions/listen` method. */
|
|
4271
5081
|
export declare interface MCPSubscriptionOptions {
|
|
4272
|
-
/**
|
|
5082
|
+
/** Holds the notification filter this server can actually honour. */
|
|
4273
5083
|
readonly notifications: MCPSubscriptionFilter;
|
|
4274
5084
|
/** Opens the producer for one honoured filter. */
|
|
4275
|
-
readonly
|
|
5085
|
+
readonly producer: MCPSubscriptionHandler;
|
|
4276
5086
|
}
|
|
4277
5087
|
|
|
4278
|
-
/**
|
|
5088
|
+
/**
|
|
5089
|
+
* Represents the terminating result returned when a `subscriptions/listen` stream closes
|
|
5090
|
+
* gracefully.
|
|
5091
|
+
*/
|
|
4279
5092
|
export declare type MCPSubscriptionResult = {
|
|
4280
5093
|
readonly resultType: 'complete';
|
|
4281
5094
|
readonly _meta: MCPSubscriptionResultMetaObject;
|
|
4282
5095
|
};
|
|
4283
5096
|
|
|
4284
|
-
/**
|
|
5097
|
+
/** Represents the required metadata on a graceful `subscriptions/listen` result. */
|
|
4285
5098
|
export declare type MCPSubscriptionResultMetaObject = MCPResultMetaObject & {
|
|
4286
|
-
/**
|
|
5099
|
+
/** Holds the JSON-RPC id of the `subscriptions/listen` request whose stream is closing. */
|
|
4287
5100
|
readonly 'io.modelcontextprotocol/subscriptionId': JSONRPCId;
|
|
4288
5101
|
};
|
|
4289
5102
|
|
|
4290
|
-
/**
|
|
5103
|
+
/** Represents a client subscription's owned notifications and graceful terminal result. */
|
|
4291
5104
|
export declare type MCPSubscriptionStream = AsyncGenerator<JSONRPCNotification, MCPSubscriptionResult, unknown>;
|
|
4292
5105
|
|
|
4293
5106
|
/**
|
|
4294
|
-
*
|
|
5107
|
+
* Represents one durable task's wire snapshot — the payload a deferred `tools/call` answers
|
|
5108
|
+
* with.
|
|
4295
5109
|
*
|
|
4296
5110
|
* @remarks
|
|
4297
5111
|
* Every field name here is a WIRE SPELLING carried verbatim from the extension's
|
|
@@ -4304,22 +5118,22 @@ export declare type MCPSubscriptionStream = AsyncGenerator<JSONRPCNotification,
|
|
|
4304
5118
|
* again; a manager that pushes notifications instead simply omits it.
|
|
4305
5119
|
*/
|
|
4306
5120
|
export declare type MCPTask = {
|
|
4307
|
-
/**
|
|
5121
|
+
/** Holds the durable handle a later `tasks/get` / `tasks/update` / `tasks/cancel` names. */
|
|
4308
5122
|
readonly taskId: string;
|
|
4309
5123
|
readonly status: MCPTaskStatus;
|
|
4310
|
-
/**
|
|
5124
|
+
/** Carries optional human-readable detail about the current status. */
|
|
4311
5125
|
readonly statusMessage?: string;
|
|
4312
5126
|
readonly createdAt: string;
|
|
4313
5127
|
readonly lastUpdatedAt: string;
|
|
4314
|
-
/**
|
|
5128
|
+
/** Reports the remaining lifetime in milliseconds, or `null` when the task does not expire. */
|
|
4315
5129
|
readonly ttlMs: number | null;
|
|
4316
|
-
/**
|
|
5130
|
+
/** Suggests the milliseconds between polls; absent when the manager suggests none. */
|
|
4317
5131
|
readonly pollIntervalMs?: number;
|
|
4318
5132
|
};
|
|
4319
5133
|
|
|
4320
5134
|
/**
|
|
4321
|
-
*
|
|
4322
|
-
*
|
|
5135
|
+
* Issues the `tasks/*` methods over one correlated-request door — the CLIENT half of the
|
|
5136
|
+
* stable Tasks extension, exposed as an {@link import('./types.js').MCPClientInterface}'s
|
|
4323
5137
|
* `tasks`.
|
|
4324
5138
|
*
|
|
4325
5139
|
* @remarks
|
|
@@ -4362,8 +5176,8 @@ export declare class MCPTaskClient implements MCPTaskClientInterface {
|
|
|
4362
5176
|
}
|
|
4363
5177
|
|
|
4364
5178
|
/**
|
|
4365
|
-
*
|
|
4366
|
-
*
|
|
5179
|
+
* Reads, answers, and stops a durable task the peer created — the CLIENT half of the stable
|
|
5180
|
+
* Tasks extension.
|
|
4367
5181
|
*
|
|
4368
5182
|
* @remarks
|
|
4369
5183
|
* The mirror of {@link MCPTaskManagerInterface} minus `start`, because creating a task is
|
|
@@ -4464,7 +5278,7 @@ export declare interface MCPTaskClientInterface {
|
|
|
4464
5278
|
}
|
|
4465
5279
|
|
|
4466
5280
|
/**
|
|
4467
|
-
*
|
|
5281
|
+
* Represents the construction options for an {@link MCPTaskClientInterface}.
|
|
4468
5282
|
*
|
|
4469
5283
|
* @remarks
|
|
4470
5284
|
* `request` is the correlated-request door (see {@link MCPRequestFunction}); an
|
|
@@ -4473,14 +5287,14 @@ export declare interface MCPTaskClientInterface {
|
|
|
4473
5287
|
* to its own calls, stated here because this client does not read the other one's options.
|
|
4474
5288
|
*/
|
|
4475
5289
|
export declare interface MCPTaskClientOptions {
|
|
4476
|
-
/**
|
|
5290
|
+
/** Holds the correlated-request door every task request is issued through. */
|
|
4477
5291
|
readonly request: MCPRequestFunction;
|
|
4478
|
-
/**
|
|
5292
|
+
/** Sets the deadline each task request carries; omitted waits on the peer indefinitely. */
|
|
4479
5293
|
readonly timeout?: number;
|
|
4480
5294
|
}
|
|
4481
5295
|
|
|
4482
5296
|
/**
|
|
4483
|
-
*
|
|
5297
|
+
* Represents the call-in-hand context supplied to an {@link MCPTaskHandler} and to
|
|
4484
5298
|
* {@link MCPTaskManagerInterface.start}.
|
|
4485
5299
|
*
|
|
4486
5300
|
* @remarks
|
|
@@ -4505,8 +5319,8 @@ export declare interface MCPTaskContext {
|
|
|
4505
5319
|
}
|
|
4506
5320
|
|
|
4507
5321
|
/**
|
|
4508
|
-
*
|
|
4509
|
-
* and a task notification report.
|
|
5322
|
+
* Represents one task snapshot together with whatever its status carries — the shape
|
|
5323
|
+
* `tasks/get` and a task notification report.
|
|
4510
5324
|
*
|
|
4511
5325
|
* @remarks
|
|
4512
5326
|
* The union is the schema's own: `input_required` carries the requests to answer,
|
|
@@ -4536,7 +5350,7 @@ export declare type MCPTaskDetail = (MCPTask & {
|
|
|
4536
5350
|
});
|
|
4537
5351
|
|
|
4538
5352
|
/**
|
|
4539
|
-
*
|
|
5353
|
+
* Represents the wire answer to `tasks/get` — one snapshot under the completed-result stamp.
|
|
4540
5354
|
*
|
|
4541
5355
|
* @remarks
|
|
4542
5356
|
* DISTINCT from {@link MCPTaskDetail}, and the distinction is the whole point. A detail is
|
|
@@ -4552,7 +5366,7 @@ export declare type MCPTaskDetail = (MCPTask & {
|
|
|
4552
5366
|
*/
|
|
4553
5367
|
export declare type MCPTaskDetailResult = MCPTaskDetail & {
|
|
4554
5368
|
readonly resultType: 'complete';
|
|
4555
|
-
/**
|
|
5369
|
+
/** Carries open modern protocol metadata, including reserved namespaced keys. */
|
|
4556
5370
|
readonly _meta?: MCPResultMetaObject;
|
|
4557
5371
|
};
|
|
4558
5372
|
|
|
@@ -4584,8 +5398,8 @@ export declare type MCPTaskDetailResult = MCPTaskDetail & {
|
|
|
4584
5398
|
export declare type MCPTaskHandler = (context: MCPTaskContext, options: MCPMethodOptions) => string | undefined | Promise<string | undefined>;
|
|
4585
5399
|
|
|
4586
5400
|
/**
|
|
4587
|
-
*
|
|
4588
|
-
* creates tasks through and reads them back from.
|
|
5401
|
+
* Represents the consumer-owned durable store behind the Tasks extension — the port this
|
|
5402
|
+
* package creates tasks through and reads them back from.
|
|
4589
5403
|
*
|
|
4590
5404
|
* @remarks
|
|
4591
5405
|
* There is deliberately NO plural accessor. The extension defines no `tasks/list`, and
|
|
@@ -4604,7 +5418,7 @@ export declare type MCPTaskHandler = (context: MCPTaskContext, options: MCPMetho
|
|
|
4604
5418
|
*/
|
|
4605
5419
|
export declare interface MCPTaskManagerInterface {
|
|
4606
5420
|
/**
|
|
4607
|
-
* Creates — or
|
|
5421
|
+
* Creates — or returns the existing — durable task for one stable operation key.
|
|
4608
5422
|
*
|
|
4609
5423
|
* @remarks
|
|
4610
5424
|
* The obligations this package cannot enforce, and one consequence that is easy
|
|
@@ -4656,7 +5470,7 @@ export declare interface MCPTaskManagerInterface {
|
|
|
4656
5470
|
* VERBATIM — it holds none of the task's keys, so the ignoring is this method's to do.
|
|
4657
5471
|
*
|
|
4658
5472
|
* This is the SECOND multi-round-trip mechanism in the package, and it is the weaker one.
|
|
4659
|
-
* The
|
|
5473
|
+
* The built-in input path binds each round with a sealed `requestState`, an argument digest,
|
|
4660
5474
|
* an absolute expiry, and the resolved principal; this path has none of them, because MCP
|
|
4661
5475
|
* neither issued the question nor owns the channel it is answered on. Anything equivalent
|
|
4662
5476
|
* has to live here: bind each published key to the principal that may answer it, expire
|
|
@@ -4682,8 +5496,22 @@ export declare interface MCPTaskManagerInterface {
|
|
|
4682
5496
|
}
|
|
4683
5497
|
|
|
4684
5498
|
/**
|
|
4685
|
-
*
|
|
4686
|
-
*
|
|
5499
|
+
* Represents one well-formed `notifications/tasks` frame — the notification
|
|
5500
|
+
* {@link import('./validators.js').isMCPTaskNotification} admits.
|
|
5501
|
+
*
|
|
5502
|
+
* @remarks
|
|
5503
|
+
* The name of what that guard proves. A consumer reading `notification.params.taskId` off an
|
|
5504
|
+
* admitted frame narrows to this type, so the narrowing has a name it can annotate, pass, and
|
|
5505
|
+
* return rather than an anonymous intersection re-spelled at each site.
|
|
5506
|
+
*/
|
|
5507
|
+
export declare type MCPTaskNotification = JSONRPCNotification & {
|
|
5508
|
+
readonly method: 'notifications/tasks';
|
|
5509
|
+
readonly params: MCPTaskNotificationParams;
|
|
5510
|
+
};
|
|
5511
|
+
|
|
5512
|
+
/**
|
|
5513
|
+
* Represents the parameters of a `notifications/tasks` frame — one snapshot, flat, optionally
|
|
5514
|
+
* stamped with the subscription that delivered it.
|
|
4687
5515
|
*
|
|
4688
5516
|
* @remarks
|
|
4689
5517
|
* FLAT, and that is the schema's shape rather than a choice: the extension types these
|
|
@@ -4697,13 +5525,13 @@ export declare interface MCPTaskManagerInterface {
|
|
|
4697
5525
|
* {@link MCPNotificationMetaObject}.
|
|
4698
5526
|
*/
|
|
4699
5527
|
export declare type MCPTaskNotificationParams = MCPTaskDetail & {
|
|
4700
|
-
/**
|
|
5528
|
+
/** Carries open notification metadata, including the reserved subscription stamp. */
|
|
4701
5529
|
readonly _meta?: MCPNotificationMetaObject;
|
|
4702
5530
|
readonly [key: string]: unknown;
|
|
4703
5531
|
};
|
|
4704
5532
|
|
|
4705
5533
|
/**
|
|
4706
|
-
*
|
|
5534
|
+
* Configures the consumer policy for the server's stable Tasks extension.
|
|
4707
5535
|
*
|
|
4708
5536
|
* @remarks
|
|
4709
5537
|
* Supplying this is what turns the extension on: an unconfigured server advertises
|
|
@@ -4711,14 +5539,14 @@ export declare type MCPTaskNotificationParams = MCPTaskDetail & {
|
|
|
4711
5539
|
* reply from a server that does not implement an optional extension.
|
|
4712
5540
|
*/
|
|
4713
5541
|
export declare interface MCPTaskOptions {
|
|
4714
|
-
/**
|
|
5542
|
+
/** Holds the durable store the server creates tasks in and reads them back from. */
|
|
4715
5543
|
readonly tasks: MCPTaskManagerInterface;
|
|
4716
5544
|
/** Decides whether the call in hand is deferred, and under which stable key. */
|
|
4717
|
-
readonly
|
|
5545
|
+
readonly deferral: MCPTaskHandler;
|
|
4718
5546
|
}
|
|
4719
5547
|
|
|
4720
5548
|
/**
|
|
4721
|
-
*
|
|
5549
|
+
* Represents the modern `tools/call` result announcing that the call became a durable task.
|
|
4722
5550
|
*
|
|
4723
5551
|
* @remarks
|
|
4724
5552
|
* The only result in this package whose `resultType` is `'task'`. It is FLAT — the
|
|
@@ -4728,12 +5556,12 @@ export declare interface MCPTaskOptions {
|
|
|
4728
5556
|
*/
|
|
4729
5557
|
export declare type MCPTaskResult = MCPTask & {
|
|
4730
5558
|
readonly resultType: 'task';
|
|
4731
|
-
/**
|
|
5559
|
+
/** Carries open modern protocol metadata, including reserved namespaced keys. */
|
|
4732
5560
|
readonly _meta?: MCPResultMetaObject;
|
|
4733
5561
|
};
|
|
4734
5562
|
|
|
4735
5563
|
/**
|
|
4736
|
-
*
|
|
5564
|
+
* Names the lifecycle state of one durable task.
|
|
4737
5565
|
*
|
|
4738
5566
|
* @remarks
|
|
4739
5567
|
* `completed`, `failed`, and `cancelled` are TERMINAL: a task that reaches one never
|
|
@@ -4750,7 +5578,7 @@ export declare type MCPTaskResult = MCPTask & {
|
|
|
4750
5578
|
*/
|
|
4751
5579
|
export declare type MCPTaskStatus = 'working' | 'input_required' | 'completed' | 'failed' | 'cancelled';
|
|
4752
5580
|
|
|
4753
|
-
/**
|
|
5581
|
+
/** Represents a textual MCP content block. */
|
|
4754
5582
|
export declare interface MCPTextContent {
|
|
4755
5583
|
readonly type: 'text';
|
|
4756
5584
|
readonly text: string;
|
|
@@ -4758,7 +5586,7 @@ export declare interface MCPTextContent {
|
|
|
4758
5586
|
readonly _meta?: MCPMetaObject;
|
|
4759
5587
|
}
|
|
4760
5588
|
|
|
4761
|
-
/**
|
|
5589
|
+
/** Represents embedded textual resource contents. */
|
|
4762
5590
|
export declare interface MCPTextResource {
|
|
4763
5591
|
readonly uri: string;
|
|
4764
5592
|
readonly mimeType?: string;
|
|
@@ -4766,11 +5594,11 @@ export declare interface MCPTextResource {
|
|
|
4766
5594
|
readonly text: string;
|
|
4767
5595
|
}
|
|
4768
5596
|
|
|
4769
|
-
/**
|
|
5597
|
+
/** Mirrors {@link MCPStream} at the string boundary — the same sequence, already serialized. */
|
|
4770
5598
|
export declare type MCPTextStream = AsyncGenerator<string, string, unknown>;
|
|
4771
5599
|
|
|
4772
5600
|
/**
|
|
4773
|
-
*
|
|
5601
|
+
* Mirrors a controlled held-open result at the string boundary — the same exchange, already
|
|
4774
5602
|
* serialized.
|
|
4775
5603
|
*
|
|
4776
5604
|
* @remarks
|
|
@@ -4870,7 +5698,7 @@ export declare class MCPTextStreamController implements MCPTextStreamControllerI
|
|
|
4870
5698
|
}
|
|
4871
5699
|
|
|
4872
5700
|
/**
|
|
4873
|
-
*
|
|
5701
|
+
* Mirrors {@link MCPStreamControllerInterface} at the string boundary — the same exchange,
|
|
4874
5702
|
* already serialized.
|
|
4875
5703
|
*
|
|
4876
5704
|
* @remarks
|
|
@@ -4944,7 +5772,7 @@ export declare interface MCPTextStreamControllerInterface extends MCPTextStream
|
|
|
4944
5772
|
}
|
|
4945
5773
|
|
|
4946
5774
|
/**
|
|
4947
|
-
*
|
|
5775
|
+
* Represents one entry of the MCP `tools/list` result — a tool's `name`, optional
|
|
4948
5776
|
* `description`, and its JSON-Schema `inputSchema`.
|
|
4949
5777
|
*
|
|
4950
5778
|
* @remarks
|
|
@@ -4958,8 +5786,27 @@ export declare interface MCPToolDescriptor {
|
|
|
4958
5786
|
readonly inputSchema: Readonly<Record<string, unknown>>;
|
|
4959
5787
|
}
|
|
4960
5788
|
|
|
5789
|
+
/** Represents one tool's outcome returned to the model, carried in a sampling completion. */
|
|
5790
|
+
export declare interface MCPToolResultContent {
|
|
5791
|
+
readonly type: 'tool_result';
|
|
5792
|
+
readonly toolUseId: string;
|
|
5793
|
+
readonly content: readonly MCPContent[];
|
|
5794
|
+
readonly isError?: boolean;
|
|
5795
|
+
readonly structuredContent?: JSONValue;
|
|
5796
|
+
readonly _meta?: MCPMetaObject;
|
|
5797
|
+
}
|
|
5798
|
+
|
|
5799
|
+
/** Represents a model's request to call one tool, carried inside a sampling completion. */
|
|
5800
|
+
export declare interface MCPToolUseContent {
|
|
5801
|
+
readonly type: 'tool_use';
|
|
5802
|
+
readonly id: string;
|
|
5803
|
+
readonly name: string;
|
|
5804
|
+
readonly input: Readonly<Record<string, unknown>>;
|
|
5805
|
+
readonly _meta?: MCPMetaObject;
|
|
5806
|
+
}
|
|
5807
|
+
|
|
4961
5808
|
/**
|
|
4962
|
-
*
|
|
5809
|
+
* Represents a duplex message channel an environment face provides to the pure engine — the
|
|
4963
5810
|
* one port `bindServer` and `bindClient` (`./helpers.js`) pipe an
|
|
4964
5811
|
* {@link MCPServerInterface} / {@link MCPClientInterface} over.
|
|
4965
5812
|
*
|
|
@@ -4993,7 +5840,7 @@ export declare interface MCPTransportInterface {
|
|
|
4993
5840
|
}
|
|
4994
5841
|
|
|
4995
5842
|
/**
|
|
4996
|
-
*
|
|
5843
|
+
* Represents a `tools/call` result BEFORE the modern stamp — the executed tool's output as
|
|
4997
5844
|
* `content` blocks, with `isError` flagging a tool failure.
|
|
4998
5845
|
*
|
|
4999
5846
|
* @remarks
|
|
@@ -5013,15 +5860,15 @@ export declare interface MCPTransportInterface {
|
|
|
5013
5860
|
*/
|
|
5014
5861
|
export declare type MCPUnstampedCallResult = {
|
|
5015
5862
|
readonly content: readonly MCPContent[];
|
|
5016
|
-
/**
|
|
5863
|
+
/** Holds the successful tool value in its original structure; absent when none was returned. */
|
|
5017
5864
|
readonly structuredContent?: JSONValue;
|
|
5018
|
-
/**
|
|
5865
|
+
/** Flags a failed tool — its error text is in `content`. */
|
|
5019
5866
|
readonly isError?: boolean;
|
|
5020
|
-
/**
|
|
5867
|
+
/** Carries open modern protocol metadata, including reserved namespaced keys. */
|
|
5021
5868
|
readonly _meta?: MCPResultMetaObject;
|
|
5022
5869
|
};
|
|
5023
5870
|
|
|
5024
|
-
/**
|
|
5871
|
+
/** Names a protocol revision supported by an MCP package surface. */
|
|
5025
5872
|
export declare type MCPVersion = MCPModernVersion | MCPLegacyVersion;
|
|
5026
5873
|
|
|
5027
5874
|
/**
|
|
@@ -5104,17 +5951,18 @@ export declare function parseJSONRPCMessage(value: unknown, limits?: MCPJSONLimi
|
|
|
5104
5951
|
* This parser does not open the opaque continuation carrier; the configured
|
|
5105
5952
|
* continuation port performs that boundary first. The protected
|
|
5106
5953
|
* payload binds the authenticated principal, absolute expiry, ORIGINAL request id, version,
|
|
5107
|
-
* method,
|
|
5108
|
-
*
|
|
5109
|
-
*
|
|
5110
|
-
*
|
|
5954
|
+
* method, the exact round that was issued, tool name, argument digest, and optional
|
|
5955
|
+
* application state. Every member is required except application state: a payload missing its
|
|
5956
|
+
* round cannot have the client's answers enforced, so it is refused rather than admitted
|
|
5957
|
+
* unenforced. An EMPTY round is refused for the same reason — a retry against it would answer
|
|
5958
|
+
* no question at all. Total over malformed or hostile input.
|
|
5111
5959
|
*
|
|
5112
5960
|
* @param value - The opened canonical continuation value to parse
|
|
5113
5961
|
* @returns The protected input state, or `undefined` when malformed
|
|
5114
5962
|
*
|
|
5115
5963
|
* @example
|
|
5116
5964
|
* ```ts
|
|
5117
|
-
* parseMCPInputState('{"principal":"user-1","expiry":2000,"id":1,"version":"2026-07-28","method":"tools/call","
|
|
5965
|
+
* parseMCPInputState('{"principal":"user-1","expiry":2000,"id":1,"version":"2026-07-28","method":"tools/call","requests":{"k":{"method":"roots/list"}},"name":"reply","digest":"abc"}')
|
|
5118
5966
|
* ```
|
|
5119
5967
|
*/
|
|
5120
5968
|
export declare function parseMCPInputState(value: unknown): MCPInputState | undefined;
|
|
@@ -5161,6 +6009,55 @@ export declare function parseRequestContext(value: unknown, limits?: MCPJSONLimi
|
|
|
5161
6009
|
*/
|
|
5162
6010
|
export declare function readCancelledId(message: JSONRPCMessage): JSONRPCId | undefined;
|
|
5163
6011
|
|
|
6012
|
+
/**
|
|
6013
|
+
* Decodes a `fetch` Response's Server-Sent-Events body into the JSON-RPC messages it
|
|
6014
|
+
* carried — the CLIENT-side inverse of a server's Streamable-HTTP SSE response.
|
|
6015
|
+
*
|
|
6016
|
+
* @remarks
|
|
6017
|
+
* Reads the whole `response.body` stream chunk-by-chunk through a `TextDecoder({ stream: true
|
|
6018
|
+
* })` (handling a multi-byte character split across reads) and `@orkestrel/sse`'s
|
|
6019
|
+
* {@link SSEParserInterface} (handling a partial line or in-progress event split across
|
|
6020
|
+
* reads), then narrows each dispatched event's `data` to a {@link JSONRPCMessage} through
|
|
6021
|
+
* {@link decodeEvent} (so a non-message or non-JSON `data:` event is DROPPED, never thrown —
|
|
6022
|
+
* total). It reuses the SAME `SSEParser` a server's `createStream` seam serializes against, so
|
|
6023
|
+
* the wire round-trips. A `null` body (no stream) yields no messages;
|
|
6024
|
+
* {@link import('./transports/HTTPClientTransport.js').HTTPClientTransport} reads a
|
|
6025
|
+
* request/response SSE reply (the server sends one `data:` event then ends), so this drains to
|
|
6026
|
+
* completion.
|
|
6027
|
+
*
|
|
6028
|
+
* @param response - The SSE `fetch` Response to decode (its `body` is read to completion)
|
|
6029
|
+
* @returns Every {@link JSONRPCMessage} the stream carried, in order
|
|
6030
|
+
*
|
|
6031
|
+
* @example
|
|
6032
|
+
* ```ts
|
|
6033
|
+
* const messages = await readEventStream(await fetch(url, { method: 'POST', body }))
|
|
6034
|
+
* ```
|
|
6035
|
+
*/
|
|
6036
|
+
export declare function readEventStream(response: Response): Promise<readonly JSONRPCMessage[]>;
|
|
6037
|
+
|
|
6038
|
+
/**
|
|
6039
|
+
* Renders one projected argument as the text its `Mcp-Param-*` header carries.
|
|
6040
|
+
*
|
|
6041
|
+
* @remarks
|
|
6042
|
+
* The protocol's conversion table, and the ONE place it is stated: a string travels as
|
|
6043
|
+
* itself, an integer in decimal, and a boolean as lowercase `true` or `false`. The value's
|
|
6044
|
+
* runtime shape must match the leaf's declared type, so a schema that declares `integer` and
|
|
6045
|
+
* an argument that supplies a string, a fraction, or a magnitude outside the IEEE 754 safe
|
|
6046
|
+
* range carries NOTHING — a header that cannot round-trip the body value is worse than an
|
|
6047
|
+
* absent one, and the tool's own argument validation owns the disagreement.
|
|
6048
|
+
*
|
|
6049
|
+
* @param value - The argument value read at the parameter's path
|
|
6050
|
+
* @param primitive - The leaf's declared type
|
|
6051
|
+
* @returns The header text, or `undefined` when the value cannot travel as that type
|
|
6052
|
+
*
|
|
6053
|
+
* @example
|
|
6054
|
+
* ```ts
|
|
6055
|
+
* renderHeaderValue(42, 'integer') // '42'
|
|
6056
|
+
* renderHeaderValue(false, 'boolean') // 'false'
|
|
6057
|
+
* ```
|
|
6058
|
+
*/
|
|
6059
|
+
export declare function renderHeaderValue(value: unknown, primitive: MCPHeaderPrimitive): string | undefined;
|
|
6060
|
+
|
|
5164
6061
|
/**
|
|
5165
6062
|
* Pumps a controlled serialized exchange onto a transport — every notification in order, then
|
|
5166
6063
|
* the terminating response — and END the exchange however the pump leaves.
|
|
@@ -5264,14 +6161,17 @@ export declare function snapshotToolResult(value: unknown, limits: MCPJSONLimitO
|
|
|
5264
6161
|
*/
|
|
5265
6162
|
export declare function stampSubscriptionNotification(notification: JSONRPCNotification, id: JSONRPCId): JSONRPCNotification;
|
|
5266
6163
|
|
|
5267
|
-
/**
|
|
6164
|
+
/** Lists the protocol revisions accepted by the optional legacy decorator. */
|
|
5268
6165
|
export declare const SUPPORTED_LEGACY_PROTOCOL_VERSIONS: readonly MCPLegacyVersion[];
|
|
5269
6166
|
|
|
5270
|
-
/**
|
|
6167
|
+
/**
|
|
6168
|
+
* Lists the protocol revisions the `isMCPVersion` guard admits, spanning the modern and legacy
|
|
6169
|
+
* eras.
|
|
6170
|
+
*/
|
|
5271
6171
|
export declare const SUPPORTED_MCP_VERSIONS: readonly MCPVersion[];
|
|
5272
6172
|
|
|
5273
6173
|
/**
|
|
5274
|
-
*
|
|
6174
|
+
* Lists the modern MCP protocol revisions a bare server accepts and advertises.
|
|
5275
6175
|
*
|
|
5276
6176
|
* @remarks
|
|
5277
6177
|
* Frozen in discovery-advertisement order. Legacy revisions are absent because
|
|
@@ -5280,4 +6180,51 @@ export declare const SUPPORTED_MCP_VERSIONS: readonly MCPVersion[];
|
|
|
5280
6180
|
*/
|
|
5281
6181
|
export declare const SUPPORTED_MODERN_PROTOCOL_VERSIONS: readonly MCPModernVersion[];
|
|
5282
6182
|
|
|
6183
|
+
/**
|
|
6184
|
+
* Determines whether a client capability record declares form-mode elicitation.
|
|
6185
|
+
*
|
|
6186
|
+
* @remarks
|
|
6187
|
+
* The protocol's empty `elicitation` object is the implicit form-only declaration.
|
|
6188
|
+
* A non-empty declaration must carry a record-valued `form` member; URL-only support
|
|
6189
|
+
* does not authorize a form request. Total over hostile input.
|
|
6190
|
+
*
|
|
6191
|
+
* @param value - The client capability record to inspect
|
|
6192
|
+
* @returns True if form-mode elicitation is declared; false otherwise
|
|
6193
|
+
*
|
|
6194
|
+
* @example
|
|
6195
|
+
* ```ts
|
|
6196
|
+
* supportsFormElicitation({ elicitation: {} }) // true — implicit form mode
|
|
6197
|
+
* supportsFormElicitation({ elicitation: { url: {} } }) // false
|
|
6198
|
+
* ```
|
|
6199
|
+
*/
|
|
6200
|
+
export declare function supportsFormElicitation(value: unknown): boolean;
|
|
6201
|
+
|
|
6202
|
+
/**
|
|
6203
|
+
* Determines whether a client capability record declares the stable Tasks extension.
|
|
6204
|
+
*
|
|
6205
|
+
* @remarks
|
|
6206
|
+
* The declaration lives at `extensions['io.modelcontextprotocol/tasks']` and the schema
|
|
6207
|
+
* types its value EXACTLY EMPTY — `Record<string, never>`, an object with no additional
|
|
6208
|
+
* properties. So the key's presence is the whole declaration, and the value carries the
|
|
6209
|
+
* whole of the check: a `true` or a string there is a client speaking a different protocol
|
|
6210
|
+
* rather than a shorthand, and a member inside the object is a client declaring an option
|
|
6211
|
+
* this extension does not define. Both are refused, because a server that accepted either
|
|
6212
|
+
* would be reading a shape no peer can produce from the snapshot's own schema.
|
|
6213
|
+
*
|
|
6214
|
+
* A client declares this PER REQUEST. Nothing here consults a session, because the modern
|
|
6215
|
+
* revision is stateless and a capability declared once at connect time says nothing about
|
|
6216
|
+
* the request in hand. Total over hostile input.
|
|
6217
|
+
*
|
|
6218
|
+
* @param value - The client capability record to inspect
|
|
6219
|
+
* @returns True if the tasks extension is declared as the schema's empty object; false otherwise
|
|
6220
|
+
*
|
|
6221
|
+
* @example
|
|
6222
|
+
* ```ts
|
|
6223
|
+
* supportsTask({ extensions: { 'io.modelcontextprotocol/tasks': {} } }) // true
|
|
6224
|
+
* supportsTask({ extensions: {} }) // false — the key is the declaration
|
|
6225
|
+
* supportsTask({ extensions: { 'io.modelcontextprotocol/tasks': { on: true } } }) // false
|
|
6226
|
+
* ```
|
|
6227
|
+
*/
|
|
6228
|
+
export declare function supportsTask(value: unknown): boolean;
|
|
6229
|
+
|
|
5283
6230
|
export { }
|