@orkestrel/mcp 0.0.27 → 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 +135 -273
- package/dist/src/browser/index.js +128 -431
- package/dist/src/browser/index.js.map +1 -1
- package/dist/src/core/index.cjs +617 -200
- package/dist/src/core/index.cjs.map +1 -1
- package/dist/src/core/index.d.cts +881 -547
- package/dist/src/core/index.d.ts +881 -547
- package/dist/src/core/index.js +606 -200
- package/dist/src/core/index.js.map +1 -1
- package/dist/src/server/index.cjs +275 -591
- package/dist/src/server/index.cjs.map +1 -1
- package/dist/src/server/index.d.cts +216 -343
- package/dist/src/server/index.d.ts +216 -343
- package/dist/src/server/index.js +269 -576
- package/dist/src/server/index.js.map +1 -1
- package/package.json +22 -22
|
@@ -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
|
*
|
|
@@ -223,7 +223,7 @@ export declare function buildHeaderParameters(schema: unknown): readonly MCPHead
|
|
|
223
223
|
*
|
|
224
224
|
* @remarks
|
|
225
225
|
* The projection SEP-2243 requires of an HTTP client, and the same derivation a server runs
|
|
226
|
-
* to know what the request
|
|
226
|
+
* to know what the request must carry. Each parameter's value is read at its exact
|
|
227
227
|
* property path in the call's own `arguments`; an absent or `null` value omits its header
|
|
228
228
|
* entirely, which is the protocol's distinction between "not supplied" and "supplied empty".
|
|
229
229
|
* The rendered text then travels through {@link encodeSentinel}, so a value carrying
|
|
@@ -358,6 +358,20 @@ export declare function buildModernResult<T extends object>(result: T, identity:
|
|
|
358
358
|
*/
|
|
359
359
|
export declare function buildProgressNotification(token: string | number, progress: MCPProgress): JSONRPCNotification;
|
|
360
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
|
+
|
|
361
375
|
/**
|
|
362
376
|
* Builds the first notification carrying a subscription id for a listen request.
|
|
363
377
|
*
|
|
@@ -423,7 +437,7 @@ export declare function buildToolDescriptors(manager: ToolManagerInterface): rea
|
|
|
423
437
|
* `ClientCapabilities` shape the schema defines rather than as a list of names.
|
|
424
438
|
*
|
|
425
439
|
* Each kind maps to one declaration: `sampling/createMessage` to `sampling`, `roots/list` to
|
|
426
|
-
* `roots`, a form elicitation to what {@link
|
|
440
|
+
* `roots`, a form elicitation to what {@link supportsFormElicitation} accepts, and a
|
|
427
441
|
* URL-mode elicitation to a record-valued `elicitation.url`. A request this package cannot
|
|
428
442
|
* recognize needs nothing, because {@link import('./validators.js').isMCPInputRequestMap}
|
|
429
443
|
* has already refused the round it would have travelled in. Total over hostile input.
|
|
@@ -473,7 +487,7 @@ export declare function countHeaderAnnotations(value: unknown): number;
|
|
|
473
487
|
|
|
474
488
|
/**
|
|
475
489
|
* Adapts an {@link MCPTransportInterface} (the environment-agnostic duplex message
|
|
476
|
-
* channel) into a {@link
|
|
490
|
+
* channel) into a {@link MCPMessageTransportInterface} — the additive bridge that lets
|
|
477
491
|
* `createMCPClient` run over the new port without any change to `MCPClient`'s
|
|
478
492
|
* existing shape.
|
|
479
493
|
*
|
|
@@ -496,7 +510,7 @@ export declare function countHeaderAnnotations(value: unknown): number;
|
|
|
496
510
|
* capable emitter for `bindClient` to push onto.
|
|
497
511
|
*
|
|
498
512
|
* @param transport - The duplex channel to adapt
|
|
499
|
-
* @returns A {@link
|
|
513
|
+
* @returns A {@link MCPMessageTransportInterface} `createMCPClient` can drive
|
|
500
514
|
*
|
|
501
515
|
* @example
|
|
502
516
|
* ```ts
|
|
@@ -505,11 +519,11 @@ export declare function countHeaderAnnotations(value: unknown): number;
|
|
|
505
519
|
* await client.connect()
|
|
506
520
|
* ```
|
|
507
521
|
*/
|
|
508
|
-
export declare function createDuplexClientTransport(transport: MCPTransportInterface):
|
|
522
|
+
export declare function createDuplexClientTransport(transport: MCPTransportInterface): MCPMessageTransportInterface;
|
|
509
523
|
|
|
510
524
|
/**
|
|
511
525
|
* Creates a transport-agnostic Model Context Protocol CLIENT — connects to a REMOTE
|
|
512
|
-
* MCP server over an injected {@link import('./types.js').
|
|
526
|
+
* MCP server over an injected {@link import('./types.js').MCPMessageTransportInterface},
|
|
513
527
|
* negotiates the modern revision through `server/discover`, and exposes the server's tools as local
|
|
514
528
|
* {@link import('@orkestrel/tool').ToolInterface}s an agent can run.
|
|
515
529
|
*
|
|
@@ -540,7 +554,7 @@ export declare function createDuplexClientTransport(transport: MCPTransportInter
|
|
|
540
554
|
* })
|
|
541
555
|
* await client.connect()
|
|
542
556
|
* agent.context.tools.add(await client.tools()) // give the agent the remote tools
|
|
543
|
-
* const
|
|
557
|
+
* const outcome = await client.call('search', { query: 'mcp' })
|
|
544
558
|
* ```
|
|
545
559
|
*/
|
|
546
560
|
export declare function createMCPClient(options: MCPClientOptions): MCPClientInterface;
|
|
@@ -568,14 +582,14 @@ export declare function createMCPLegacy(server: MCPServerInterface): MCPDispatch
|
|
|
568
582
|
* client.version // '2026-07-28'
|
|
569
583
|
* ```
|
|
570
584
|
*/
|
|
571
|
-
export declare function createMCPLegacyClientTransport(transport:
|
|
585
|
+
export declare function createMCPLegacyClientTransport(transport: MCPMessageTransportInterface, options?: MCPLegacyClientTransportOptions): MCPMessageTransportInterface;
|
|
572
586
|
|
|
573
587
|
/**
|
|
574
588
|
* Creates a transport-agnostic Model Context Protocol server — exposes a live
|
|
575
589
|
* {@link import('@orkestrel/tool').ToolManagerInterface} and an optional
|
|
576
590
|
* {@link import('./types.js').MCPResourceManagerInterface},
|
|
577
591
|
* {@link import('./types.js').MCPPromptManagerInterface}, and
|
|
578
|
-
* {@link import('./types.js').
|
|
592
|
+
* {@link import('./types.js').MCPCompletionInterface} over JSON-RPC 2.0.
|
|
579
593
|
*
|
|
580
594
|
* @remarks
|
|
581
595
|
* Pump raw message strings through `handle` (parse → dispatch → serialize) from a
|
|
@@ -618,7 +632,7 @@ export declare function createMCPServer(options: MCPServerOptions): MCPServerInt
|
|
|
618
632
|
*
|
|
619
633
|
* @remarks
|
|
620
634
|
* The bound is checked FIRST, against the raw string, so an oversized message is never
|
|
621
|
-
*
|
|
635
|
+
* parsed at all: a decoder that parses before it measures has already spent the work
|
|
622
636
|
* the bound exists to refuse. A message over the bound, malformed JSON, and a well-formed
|
|
623
637
|
* value that is not a JSON-RPC message are one answer — `undefined` — because a binder does
|
|
624
638
|
* exactly the same thing with each of them: nothing, and let
|
|
@@ -638,6 +652,26 @@ export declare function createMCPServer(options: MCPServerOptions): MCPServerInt
|
|
|
638
652
|
*/
|
|
639
653
|
export declare function decodeBoundedMessage(message: string, limits: MCPJSONLimitOptions): JSONRPCMessage | undefined;
|
|
640
654
|
|
|
655
|
+
/**
|
|
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
|
+
|
|
641
675
|
/**
|
|
642
676
|
* Reads the value one standard MCP request header carries, decoding the Base64 sentinel.
|
|
643
677
|
*
|
|
@@ -688,7 +722,7 @@ export declare function decodeBoundedMessage(message: string, limits: MCPJSONLim
|
|
|
688
722
|
export declare function decodeSentinel(value: string): string | undefined;
|
|
689
723
|
|
|
690
724
|
/**
|
|
691
|
-
*
|
|
725
|
+
* Sets the default modern result freshness lifetime in milliseconds.
|
|
692
726
|
*
|
|
693
727
|
* @remarks
|
|
694
728
|
* `ttlMs` is required on cacheable results, while zero means immediately stale
|
|
@@ -696,14 +730,21 @@ export declare function decodeSentinel(value: string): string | undefined;
|
|
|
696
730
|
*/
|
|
697
731
|
export declare const DEFAULT_MCP_CACHE_TTL = 60000;
|
|
698
732
|
|
|
699
|
-
/**
|
|
700
|
-
|
|
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";
|
|
701
738
|
|
|
702
|
-
/**
|
|
739
|
+
/**
|
|
740
|
+
* Supplies the default client version reported in the MCP `initialize` handshake
|
|
741
|
+
* (`clientInfo.version`).
|
|
742
|
+
*/
|
|
703
743
|
export declare const DEFAULT_MCP_CLIENT_VERSION = "1.0.0";
|
|
704
744
|
|
|
705
745
|
/**
|
|
706
|
-
*
|
|
746
|
+
* Sets the secure server bounds used when the matching `limit` option leaf is absent or
|
|
747
|
+
* malformed.
|
|
707
748
|
*
|
|
708
749
|
* @remarks
|
|
709
750
|
* One MiB admits ordinary JSON-RPC requests and substantial tool arguments; 16 KiB admits
|
|
@@ -726,14 +767,39 @@ export declare const DEFAULT_MCP_LIMITS: Readonly<{
|
|
|
726
767
|
}>;
|
|
727
768
|
|
|
728
769
|
/**
|
|
729
|
-
*
|
|
770
|
+
* Sets the default per-request deadline (ms) an `MCPClient` applies when `options.timeout`
|
|
730
771
|
* is unset — a request the remote server does not answer within it rejects.
|
|
731
772
|
*/
|
|
732
773
|
export declare const DEFAULT_MCP_REQUEST_TIMEOUT = 30000;
|
|
733
774
|
|
|
734
|
-
/**
|
|
775
|
+
/** Sets the default number of subscription frames retained while no client read is parked. */
|
|
735
776
|
export declare const DEFAULT_MCP_SUBSCRIPTION_CAPACITY = 64;
|
|
736
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
|
+
|
|
737
803
|
/**
|
|
738
804
|
* Computes a lowercase host-neutral SHA-256 digest of one bounded canonical JSON value.
|
|
739
805
|
*
|
|
@@ -744,7 +810,7 @@ export declare const DEFAULT_MCP_SUBSCRIPTION_CAPACITY = 64;
|
|
|
744
810
|
export declare function digestJSON(value: unknown, limits: MCPJSONLimitOptions): Promise<string | undefined>;
|
|
745
811
|
|
|
746
812
|
/**
|
|
747
|
-
*
|
|
813
|
+
* Holds the one empty argument record every argument-less modern `tools/call` runs with.
|
|
748
814
|
*
|
|
749
815
|
* @remarks
|
|
750
816
|
* Frozen and null-prototype, and SHARED: two calls that name no `arguments` receive the same
|
|
@@ -867,6 +933,107 @@ export declare function extractHeaderAnnotations(schema: unknown, path: readonly
|
|
|
867
933
|
*/
|
|
868
934
|
export declare function extractToolSchema(response: unknown, name: string): Readonly<Record<string, unknown>> | undefined;
|
|
869
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
|
+
|
|
870
1037
|
/**
|
|
871
1038
|
* Infers the wire era for an MCP protocol revision.
|
|
872
1039
|
*
|
|
@@ -881,6 +1048,26 @@ export declare function extractToolSchema(response: unknown, name: string): Read
|
|
|
881
1048
|
*/
|
|
882
1049
|
export declare function inferEra(version: string): MCPEra | undefined;
|
|
883
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
|
+
|
|
884
1071
|
/**
|
|
885
1072
|
* Infers the protocol version an outbound message announces itself with — the ONE
|
|
886
1073
|
* projection every HTTP client transport stamps `mcp-protocol-version` from.
|
|
@@ -928,7 +1115,7 @@ export declare function inferVersion(offered: readonly string[]): MCPModernVersi
|
|
|
928
1115
|
* scheme allowlist. Component scanning is bounded by the input length.
|
|
929
1116
|
*
|
|
930
1117
|
* @param value - The unknown value to inspect
|
|
931
|
-
* @returns
|
|
1118
|
+
* @returns True if the value is an RFC 3986 URI rather than a relative reference; false otherwise
|
|
932
1119
|
*/
|
|
933
1120
|
export declare function isAbsoluteURI(value: unknown): value is string;
|
|
934
1121
|
|
|
@@ -942,7 +1129,7 @@ export declare function isAbsoluteURI(value: unknown): value is string;
|
|
|
942
1129
|
*
|
|
943
1130
|
* @param value - The unknown value to inspect
|
|
944
1131
|
* @param limits - Serialized byte, optional key, and nesting-depth bounds
|
|
945
|
-
* @returns `
|
|
1132
|
+
* @returns True if `value` is safe JSON satisfying every bound; false otherwise
|
|
946
1133
|
*
|
|
947
1134
|
* @example
|
|
948
1135
|
* ```ts
|
|
@@ -956,7 +1143,7 @@ export declare function isBoundedJSON<T>(value: T, limits: MCPJSONLimitOptions):
|
|
|
956
1143
|
*
|
|
957
1144
|
* @param value - The unknown value to inspect
|
|
958
1145
|
* @param bytes - The maximum accepted encoded bytes
|
|
959
|
-
* @returns `
|
|
1146
|
+
* @returns True if `value` is a string whose UTF-8 representation fits the bound; false otherwise
|
|
960
1147
|
*
|
|
961
1148
|
* @example
|
|
962
1149
|
* ```ts
|
|
@@ -993,7 +1180,7 @@ export declare function isBoundedString(value: unknown, bytes: number): value is
|
|
|
993
1180
|
*
|
|
994
1181
|
* @param value - The accepted response content to check
|
|
995
1182
|
* @param schema - The exact {@link MCPElicitSchema} that was issued with the elicitation
|
|
996
|
-
* @returns
|
|
1183
|
+
* @returns True if every declared and undeclared value is legal under `schema`; false otherwise
|
|
997
1184
|
*
|
|
998
1185
|
* @example
|
|
999
1186
|
* ```ts
|
|
@@ -1020,7 +1207,7 @@ export declare function isElicitContent(value: unknown, schema: unknown): value
|
|
|
1020
1207
|
* {@link MCP_PARAM_PREFIX} and must survive as an HTTP field name.
|
|
1021
1208
|
*
|
|
1022
1209
|
* @param value - The unknown value to inspect
|
|
1023
|
-
* @returns
|
|
1210
|
+
* @returns True if the value is a non-empty RFC 9110 token; false otherwise
|
|
1024
1211
|
*
|
|
1025
1212
|
* @example
|
|
1026
1213
|
* ```ts
|
|
@@ -1030,30 +1217,11 @@ export declare function isElicitContent(value: unknown, schema: unknown): value
|
|
|
1030
1217
|
*/
|
|
1031
1218
|
export declare function isFieldToken(value: unknown): value is string;
|
|
1032
1219
|
|
|
1033
|
-
/**
|
|
1034
|
-
* Determines whether a client capability record declares form-mode elicitation.
|
|
1035
|
-
*
|
|
1036
|
-
* @remarks
|
|
1037
|
-
* The protocol's empty `elicitation` object is the implicit form-only declaration.
|
|
1038
|
-
* A non-empty declaration must carry a record-valued `form` member; URL-only support
|
|
1039
|
-
* does not authorize a form request. Total over hostile input.
|
|
1040
|
-
*
|
|
1041
|
-
* @param value - The client capability record to inspect
|
|
1042
|
-
* @returns `true` when form-mode elicitation is declared
|
|
1043
|
-
*
|
|
1044
|
-
* @example
|
|
1045
|
-
* ```ts
|
|
1046
|
-
* isFormElicitationSupported({ elicitation: {} }) // true — implicit form mode
|
|
1047
|
-
* isFormElicitationSupported({ elicitation: { url: {} } }) // false
|
|
1048
|
-
* ```
|
|
1049
|
-
*/
|
|
1050
|
-
export declare function isFormElicitationSupported(value: unknown): boolean;
|
|
1051
|
-
|
|
1052
1220
|
/**
|
|
1053
1221
|
* Determines whether a parsed value is an MCP `initialize` invocation.
|
|
1054
1222
|
*
|
|
1055
1223
|
* @param value - The already-parsed value to test
|
|
1056
|
-
* @returns
|
|
1224
|
+
* @returns True if `value` is a valid `initialize` request or notification; false otherwise
|
|
1057
1225
|
*
|
|
1058
1226
|
* @example
|
|
1059
1227
|
* ```ts
|
|
@@ -1085,7 +1253,7 @@ export declare function isJSONObject(value: unknown): value is Readonly<Record<s
|
|
|
1085
1253
|
* itself the hostile step, and it is bounded here rather than allowed to escape. Total.
|
|
1086
1254
|
*
|
|
1087
1255
|
* @param value - The already-parsed value to test
|
|
1088
|
-
* @returns
|
|
1256
|
+
* @returns True if `value` carries an integer `code` and a string `message`; false otherwise
|
|
1089
1257
|
*
|
|
1090
1258
|
* @example
|
|
1091
1259
|
* ```ts
|
|
@@ -1106,7 +1274,7 @@ export declare function isJSONRPCError(value: unknown): value is JSONRPCError;
|
|
|
1106
1274
|
* `result`. `error` carries an integer `code` and a string `message`. Total.
|
|
1107
1275
|
*
|
|
1108
1276
|
* @param value - The already-parsed value to test
|
|
1109
|
-
* @returns
|
|
1277
|
+
* @returns True if `value` is a valid JSON-RPC error response; false otherwise
|
|
1110
1278
|
*
|
|
1111
1279
|
* @example
|
|
1112
1280
|
* ```ts
|
|
@@ -1128,7 +1296,7 @@ export declare function isJSONRPCErrorResponse(value: unknown): value is JSONRPC
|
|
|
1128
1296
|
* no minimum length. Total: any other input returns `false`.
|
|
1129
1297
|
*
|
|
1130
1298
|
* @param value - The already-parsed value to test
|
|
1131
|
-
* @returns
|
|
1299
|
+
* @returns True if `value` is a string or a finite integer; false otherwise
|
|
1132
1300
|
*
|
|
1133
1301
|
* @example
|
|
1134
1302
|
* ```ts
|
|
@@ -1150,7 +1318,7 @@ export declare function isJSONRPCId(value: unknown): value is JSONRPCId;
|
|
|
1150
1318
|
* mutually exclusive, so a positive answer names exactly one arm. Total.
|
|
1151
1319
|
*
|
|
1152
1320
|
* @param value - The already-parsed value to test
|
|
1153
|
-
* @returns
|
|
1321
|
+
* @returns True if `value` is a valid JSON-RPC request or notification; false otherwise
|
|
1154
1322
|
*/
|
|
1155
1323
|
export declare function isJSONRPCInvocation(value: unknown): value is JSONRPCInvocation;
|
|
1156
1324
|
|
|
@@ -1162,7 +1330,7 @@ export declare function isJSONRPCInvocation(value: unknown): value is JSONRPCInv
|
|
|
1162
1330
|
* The union of {@link isJSONRPCInvocation} and {@link isJSONRPCResponse}. Total.
|
|
1163
1331
|
*
|
|
1164
1332
|
* @param value - The already-parsed value to test
|
|
1165
|
-
* @returns
|
|
1333
|
+
* @returns True if `value` is a valid JSON-RPC message; false otherwise
|
|
1166
1334
|
*/
|
|
1167
1335
|
export declare function isJSONRPCMessage(value: unknown): value is JSONRPCMessage;
|
|
1168
1336
|
|
|
@@ -1175,7 +1343,7 @@ export declare function isJSONRPCMessage(value: unknown): value is JSONRPCMessag
|
|
|
1175
1343
|
* be a record. Total: any other input returns `false`.
|
|
1176
1344
|
*
|
|
1177
1345
|
* @param value - The already-parsed value to test
|
|
1178
|
-
* @returns
|
|
1346
|
+
* @returns True if `value` is a valid JSON-RPC notification; false otherwise
|
|
1179
1347
|
*
|
|
1180
1348
|
* @example
|
|
1181
1349
|
* ```ts
|
|
@@ -1197,7 +1365,7 @@ export declare function isJSONRPCNotification(value: unknown): value is JSONRPCN
|
|
|
1197
1365
|
* be a record. Total: any other input returns `false`.
|
|
1198
1366
|
*
|
|
1199
1367
|
* @param value - The already-parsed value to test
|
|
1200
|
-
* @returns
|
|
1368
|
+
* @returns True if `value` is a valid JSON-RPC request; false otherwise
|
|
1201
1369
|
*
|
|
1202
1370
|
* @example
|
|
1203
1371
|
* ```ts
|
|
@@ -1215,7 +1383,7 @@ export declare function isJSONRPCRequest(value: unknown): value is JSONRPCReques
|
|
|
1215
1383
|
* The union of the mutually exclusive arms. Total.
|
|
1216
1384
|
*
|
|
1217
1385
|
* @param value - The already-parsed value to test
|
|
1218
|
-
* @returns
|
|
1386
|
+
* @returns True if `value` is a valid JSON-RPC response; false otherwise
|
|
1219
1387
|
*/
|
|
1220
1388
|
export declare function isJSONRPCResponse(value: unknown): value is JSONRPCResponse;
|
|
1221
1389
|
|
|
@@ -1232,7 +1400,7 @@ export declare function isJSONRPCResponse(value: unknown): value is JSONRPCRespo
|
|
|
1232
1400
|
* Total.
|
|
1233
1401
|
*
|
|
1234
1402
|
* @param value - The already-parsed value to test
|
|
1235
|
-
* @returns
|
|
1403
|
+
* @returns True if `value` is a valid JSON-RPC result response; false otherwise
|
|
1236
1404
|
*
|
|
1237
1405
|
* @example
|
|
1238
1406
|
* ```ts
|
|
@@ -1246,7 +1414,7 @@ export declare function isJSONRPCResultResponse(value: unknown): value is JSONRP
|
|
|
1246
1414
|
* Determines whether a value carries valid dated-schema MCP content annotations.
|
|
1247
1415
|
*
|
|
1248
1416
|
* @param value - The unknown value to inspect
|
|
1249
|
-
* @returns
|
|
1417
|
+
* @returns True if the value is valid MCP annotations; false otherwise
|
|
1250
1418
|
*/
|
|
1251
1419
|
export declare function isMCPAnnotations(value: unknown): value is MCPAnnotations;
|
|
1252
1420
|
|
|
@@ -1254,7 +1422,7 @@ export declare function isMCPAnnotations(value: unknown): value is MCPAnnotation
|
|
|
1254
1422
|
* Determines whether a value is embedded blob MCP resource contents.
|
|
1255
1423
|
*
|
|
1256
1424
|
* @param value - The unknown value to inspect
|
|
1257
|
-
* @returns
|
|
1425
|
+
* @returns True if the value is embedded blob resource contents; false otherwise
|
|
1258
1426
|
*/
|
|
1259
1427
|
export declare function isMCPBlobResource(value: unknown): value is MCPBlobResource;
|
|
1260
1428
|
|
|
@@ -1262,7 +1430,7 @@ export declare function isMCPBlobResource(value: unknown): value is MCPBlobResou
|
|
|
1262
1430
|
* Determines whether a value is a complete modern MCP tool result.
|
|
1263
1431
|
*
|
|
1264
1432
|
* @param value - The unknown value to inspect
|
|
1265
|
-
* @returns
|
|
1433
|
+
* @returns True if the value is a complete MCP call result; false otherwise
|
|
1266
1434
|
*/
|
|
1267
1435
|
export declare function isMCPCallResult(value: unknown): value is MCPCallResult;
|
|
1268
1436
|
|
|
@@ -1273,7 +1441,7 @@ export declare function isMCPClientCapabilities(value: unknown): value is MCPCli
|
|
|
1273
1441
|
* Determines whether a value is one host-produced completion candidate set.
|
|
1274
1442
|
*
|
|
1275
1443
|
* @param value - The unknown value to inspect
|
|
1276
|
-
* @returns
|
|
1444
|
+
* @returns True if its candidates and optional result facts are valid; false otherwise
|
|
1277
1445
|
*/
|
|
1278
1446
|
export declare function isMCPCompletion(value: unknown): value is MCPCompletion;
|
|
1279
1447
|
|
|
@@ -1281,7 +1449,7 @@ export declare function isMCPCompletion(value: unknown): value is MCPCompletion;
|
|
|
1281
1449
|
* Determines whether a value is one `completion/complete` parameter object.
|
|
1282
1450
|
*
|
|
1283
1451
|
* @param value - The unknown value to inspect
|
|
1284
|
-
* @returns
|
|
1452
|
+
* @returns True if its reference, fragment, and optional string context are valid; false otherwise
|
|
1285
1453
|
*/
|
|
1286
1454
|
export declare function isMCPCompletionParams(value: unknown): value is MCPCompletionParams;
|
|
1287
1455
|
|
|
@@ -1289,7 +1457,7 @@ export declare function isMCPCompletionParams(value: unknown): value is MCPCompl
|
|
|
1289
1457
|
* Determines whether a value is a prompt or resource-template completion reference.
|
|
1290
1458
|
*
|
|
1291
1459
|
* @param value - The unknown value to inspect
|
|
1292
|
-
* @returns
|
|
1460
|
+
* @returns True if the discriminated reference is valid; false otherwise
|
|
1293
1461
|
*/
|
|
1294
1462
|
export declare function isMCPCompletionReference(value: unknown): value is MCPCompletionReference;
|
|
1295
1463
|
|
|
@@ -1297,7 +1465,7 @@ export declare function isMCPCompletionReference(value: unknown): value is MCPCo
|
|
|
1297
1465
|
* Determines whether a value is one complete, capped `completion/complete` result.
|
|
1298
1466
|
*
|
|
1299
1467
|
* @param value - The unknown value to inspect
|
|
1300
|
-
* @returns
|
|
1468
|
+
* @returns True if the result is complete and carries at most 100 candidates; false otherwise
|
|
1301
1469
|
*/
|
|
1302
1470
|
export declare function isMCPCompletionResult(value: unknown): value is MCPCompletionResult;
|
|
1303
1471
|
|
|
@@ -1305,7 +1473,7 @@ export declare function isMCPCompletionResult(value: unknown): value is MCPCompl
|
|
|
1305
1473
|
* Determines whether a value is one exact dated-schema MCP tool content block.
|
|
1306
1474
|
*
|
|
1307
1475
|
* @param value - The unknown value to inspect
|
|
1308
|
-
* @returns
|
|
1476
|
+
* @returns True if the value is valid MCP content; false otherwise
|
|
1309
1477
|
*/
|
|
1310
1478
|
export declare function isMCPContent(value: unknown): value is MCPContent;
|
|
1311
1479
|
|
|
@@ -1313,7 +1481,7 @@ export declare function isMCPContent(value: unknown): value is MCPContent;
|
|
|
1313
1481
|
* Determines whether a value is one restricted primitive form-elicitation schema.
|
|
1314
1482
|
*
|
|
1315
1483
|
* @param value - The unknown value to inspect
|
|
1316
|
-
* @returns `
|
|
1484
|
+
* @returns True if `value` is a supported boolean, numeric, string, or string-array schema; false otherwise
|
|
1317
1485
|
*
|
|
1318
1486
|
* @example
|
|
1319
1487
|
* ```ts
|
|
@@ -1327,7 +1495,7 @@ export declare function isMCPElicitFieldSchema(value: unknown): value is MCPElic
|
|
|
1327
1495
|
* Determines whether a value is a form-mode elicitation parameter object.
|
|
1328
1496
|
*
|
|
1329
1497
|
* @param value - The unknown value to inspect
|
|
1330
|
-
* @returns
|
|
1498
|
+
* @returns True if `value` has the restricted form elicitation shape; false otherwise
|
|
1331
1499
|
*
|
|
1332
1500
|
* @example
|
|
1333
1501
|
* ```ts
|
|
@@ -1343,7 +1511,7 @@ export declare function isMCPElicitForm(value: unknown): value is MCPElicitForm;
|
|
|
1343
1511
|
* Determines whether a value is an embedded `elicitation/create` request.
|
|
1344
1512
|
*
|
|
1345
1513
|
* @param value - The unknown value to inspect
|
|
1346
|
-
* @returns
|
|
1514
|
+
* @returns True if `value` is a form- or URL-mode elicitation request; false otherwise
|
|
1347
1515
|
*
|
|
1348
1516
|
* @example
|
|
1349
1517
|
* ```ts
|
|
@@ -1359,7 +1527,7 @@ export declare function isMCPElicitRequest(value: unknown): value is MCPElicitRe
|
|
|
1359
1527
|
* Determines whether a value is one elicitation response.
|
|
1360
1528
|
*
|
|
1361
1529
|
* @param value - The unknown value to inspect
|
|
1362
|
-
* @returns
|
|
1530
|
+
* @returns True if action/content have the protocol shape; false otherwise
|
|
1363
1531
|
*
|
|
1364
1532
|
* @example
|
|
1365
1533
|
* ```ts
|
|
@@ -1379,7 +1547,7 @@ export declare function isMCPElicitResult(value: unknown): value is MCPElicitRes
|
|
|
1379
1547
|
* an unrecognized top-level annotation is data rather than a rejection.
|
|
1380
1548
|
*
|
|
1381
1549
|
* @param value - The unknown value to inspect
|
|
1382
|
-
* @returns
|
|
1550
|
+
* @returns True if `value` is a restricted object schema of supported field schemas; false otherwise
|
|
1383
1551
|
*
|
|
1384
1552
|
* @example
|
|
1385
1553
|
* ```ts
|
|
@@ -1393,7 +1561,7 @@ export declare function isMCPElicitSchema(value: unknown): value is MCPElicitSch
|
|
|
1393
1561
|
* Determines whether a value is a URL-mode elicitation parameter object.
|
|
1394
1562
|
*
|
|
1395
1563
|
* @param value - The unknown value to inspect
|
|
1396
|
-
* @returns
|
|
1564
|
+
* @returns True if `value` has the URL elicitation shape; false otherwise
|
|
1397
1565
|
*
|
|
1398
1566
|
* @example
|
|
1399
1567
|
* ```ts
|
|
@@ -1406,7 +1574,7 @@ export declare function isMCPElicitURL(value: unknown): value is MCPElicitURL;
|
|
|
1406
1574
|
* Determines whether an unknown value is an {@link MCPError}.
|
|
1407
1575
|
*
|
|
1408
1576
|
* @param value - The unknown value to inspect
|
|
1409
|
-
* @returns
|
|
1577
|
+
* @returns True if the value is an `MCPError`; false otherwise
|
|
1410
1578
|
*
|
|
1411
1579
|
* @example
|
|
1412
1580
|
* ```ts
|
|
@@ -1425,7 +1593,7 @@ export declare function isMCPError(value: unknown): value is MCPError;
|
|
|
1425
1593
|
* exactly, and the server compares it numerically.
|
|
1426
1594
|
*
|
|
1427
1595
|
* @param value - The unknown value to inspect
|
|
1428
|
-
* @returns
|
|
1596
|
+
* @returns True if the value is one of `'string'`, `'integer'`, or `'boolean'`; false otherwise
|
|
1429
1597
|
*
|
|
1430
1598
|
* @example
|
|
1431
1599
|
* ```ts
|
|
@@ -1439,7 +1607,7 @@ export declare function isMCPHeaderPrimitive(value: unknown): value is MCPHeader
|
|
|
1439
1607
|
* Determines whether a value is one exact dated-schema MCP icon.
|
|
1440
1608
|
*
|
|
1441
1609
|
* @param value - The unknown value to inspect
|
|
1442
|
-
* @returns
|
|
1610
|
+
* @returns True if the value is a valid MCP icon; false otherwise
|
|
1443
1611
|
*/
|
|
1444
1612
|
export declare function isMCPIcon(value: unknown): value is MCPIcon;
|
|
1445
1613
|
|
|
@@ -1450,7 +1618,7 @@ export declare function isMCPIdentity(value: unknown): value is MCPIdentity;
|
|
|
1450
1618
|
* Determines whether a value is one legal embedded multi-round-trip request.
|
|
1451
1619
|
*
|
|
1452
1620
|
* @param value - The unknown value to inspect
|
|
1453
|
-
* @returns `
|
|
1621
|
+
* @returns True if `value` is an embedded elicitation, sampling, or roots request; false otherwise
|
|
1454
1622
|
*
|
|
1455
1623
|
* @example
|
|
1456
1624
|
* ```ts
|
|
@@ -1463,7 +1631,7 @@ export declare function isMCPInputRequest(value: unknown): value is MCPInputRequ
|
|
|
1463
1631
|
* Determines whether a value is a consumer-keyed map of embedded input requests.
|
|
1464
1632
|
*
|
|
1465
1633
|
* @param value - The unknown value to inspect
|
|
1466
|
-
* @returns
|
|
1634
|
+
* @returns True if every own value is a legal {@link MCPInputRequest}; false otherwise
|
|
1467
1635
|
*
|
|
1468
1636
|
* @example
|
|
1469
1637
|
* ```ts
|
|
@@ -1486,7 +1654,7 @@ export declare function isMCPInputRequestMap(value: unknown): value is MCPInputR
|
|
|
1486
1654
|
*
|
|
1487
1655
|
* @param value - The client's answer to check
|
|
1488
1656
|
* @param request - The exact {@link MCPInputRequest} that was issued under the same key
|
|
1489
|
-
* @returns
|
|
1657
|
+
* @returns True if the answer is legal for that request; false otherwise
|
|
1490
1658
|
*
|
|
1491
1659
|
* @example
|
|
1492
1660
|
* ```ts
|
|
@@ -1504,7 +1672,7 @@ export declare function isMCPInputResponse(value: unknown, request: unknown): va
|
|
|
1504
1672
|
* both must be present and valid. Total over hostile input.
|
|
1505
1673
|
*
|
|
1506
1674
|
* @param value - The unknown value to inspect
|
|
1507
|
-
* @returns
|
|
1675
|
+
* @returns True if `value` is a valid input-required result; false otherwise
|
|
1508
1676
|
*
|
|
1509
1677
|
* @example
|
|
1510
1678
|
* ```ts
|
|
@@ -1523,7 +1691,7 @@ export declare function isMCPInputResult(value: unknown): value is MCPInputResul
|
|
|
1523
1691
|
* hostile input.
|
|
1524
1692
|
*
|
|
1525
1693
|
* @param value - The unknown value to inspect
|
|
1526
|
-
* @returns
|
|
1694
|
+
* @returns True if the value is a legacy result; false otherwise
|
|
1527
1695
|
*
|
|
1528
1696
|
* @example
|
|
1529
1697
|
* ```ts
|
|
@@ -1537,7 +1705,7 @@ export declare function isMCPLegacyResult(value: unknown): value is MCPLegacyRes
|
|
|
1537
1705
|
* Determines whether a value is a revision accepted by the optional legacy decorator.
|
|
1538
1706
|
*
|
|
1539
1707
|
* @param value - The unknown value to inspect
|
|
1540
|
-
* @returns
|
|
1708
|
+
* @returns True if the value is one of {@link SUPPORTED_LEGACY_PROTOCOL_VERSIONS}; false otherwise
|
|
1541
1709
|
*/
|
|
1542
1710
|
export declare function isMCPLegacyVersion(value: unknown): value is MCPLegacyVersion;
|
|
1543
1711
|
|
|
@@ -1554,7 +1722,7 @@ export declare function isMCPMetaObject(value: unknown): value is MCPMetaObject;
|
|
|
1554
1722
|
* Determines whether a value is a modern protocol revision accepted by a bare server.
|
|
1555
1723
|
*
|
|
1556
1724
|
* @param value - The unknown value to inspect
|
|
1557
|
-
* @returns
|
|
1725
|
+
* @returns True if the value is one of {@link SUPPORTED_MODERN_PROTOCOL_VERSIONS}; false otherwise
|
|
1558
1726
|
*/
|
|
1559
1727
|
export declare function isMCPModernVersion(value: unknown): value is MCPModernVersion;
|
|
1560
1728
|
|
|
@@ -1568,7 +1736,7 @@ export declare function isMCPModernVersion(value: unknown): value is MCPModernVe
|
|
|
1568
1736
|
* {@link JSONRPCId}, because a stamp naming nothing addressable is worse than no stamp.
|
|
1569
1737
|
*
|
|
1570
1738
|
* @param value - The unknown value to inspect
|
|
1571
|
-
* @returns
|
|
1739
|
+
* @returns True if the value is exact metadata whose subscription stamp, if present, is valid; false otherwise
|
|
1572
1740
|
*
|
|
1573
1741
|
* @example
|
|
1574
1742
|
* ```ts
|
|
@@ -1583,7 +1751,7 @@ export declare function isMCPNotificationMetaObject(value: unknown): value is MC
|
|
|
1583
1751
|
* Determines whether a value carries the shared optional pagination cursor.
|
|
1584
1752
|
*
|
|
1585
1753
|
* @param value - The unknown value to inspect
|
|
1586
|
-
* @returns
|
|
1754
|
+
* @returns True if a present `cursor` is a string; false otherwise
|
|
1587
1755
|
*/
|
|
1588
1756
|
export declare function isMCPPaginationParams(value: unknown): value is MCPPaginationParams;
|
|
1589
1757
|
|
|
@@ -1591,7 +1759,7 @@ export declare function isMCPPaginationParams(value: unknown): value is MCPPagin
|
|
|
1591
1759
|
* Determines whether a value is one exact finite MCP progress payload.
|
|
1592
1760
|
*
|
|
1593
1761
|
* @param value - The unknown value to inspect
|
|
1594
|
-
* @returns
|
|
1762
|
+
* @returns True if required progress and optional total/message fields match the dated schema; false otherwise
|
|
1595
1763
|
*/
|
|
1596
1764
|
export declare function isMCPProgress(value: unknown): value is MCPProgress;
|
|
1597
1765
|
|
|
@@ -1599,7 +1767,7 @@ export declare function isMCPProgress(value: unknown): value is MCPProgress;
|
|
|
1599
1767
|
* Determines whether a value is one `prompts/list` descriptor.
|
|
1600
1768
|
*
|
|
1601
1769
|
* @param value - The unknown value to inspect
|
|
1602
|
-
* @returns
|
|
1770
|
+
* @returns True if the prompt descriptor is valid; false otherwise
|
|
1603
1771
|
*/
|
|
1604
1772
|
export declare function isMCPPrompt(value: unknown): value is MCPPrompt;
|
|
1605
1773
|
|
|
@@ -1607,7 +1775,7 @@ export declare function isMCPPrompt(value: unknown): value is MCPPrompt;
|
|
|
1607
1775
|
* Determines whether a value is one prompt argument descriptor.
|
|
1608
1776
|
*
|
|
1609
1777
|
* @param value - The unknown value to inspect
|
|
1610
|
-
* @returns
|
|
1778
|
+
* @returns True if the prompt argument descriptor is valid; false otherwise
|
|
1611
1779
|
*/
|
|
1612
1780
|
export declare function isMCPPromptArgument(value: unknown): value is MCPPromptArgument;
|
|
1613
1781
|
|
|
@@ -1615,7 +1783,7 @@ export declare function isMCPPromptArgument(value: unknown): value is MCPPromptA
|
|
|
1615
1783
|
* Determines whether a value is one complete `prompts/get` result.
|
|
1616
1784
|
*
|
|
1617
1785
|
* @param value - The unknown value to inspect
|
|
1618
|
-
* @returns
|
|
1786
|
+
* @returns True if the prompt result and all messages are valid; false otherwise
|
|
1619
1787
|
*/
|
|
1620
1788
|
export declare function isMCPPromptGetResult(value: unknown): value is MCPPromptGetResult;
|
|
1621
1789
|
|
|
@@ -1623,7 +1791,7 @@ export declare function isMCPPromptGetResult(value: unknown): value is MCPPrompt
|
|
|
1623
1791
|
* Determines whether a value is one prompt message with existing rich content.
|
|
1624
1792
|
*
|
|
1625
1793
|
* @param value - The unknown value to inspect
|
|
1626
|
-
* @returns
|
|
1794
|
+
* @returns True if the role and content are valid; false otherwise
|
|
1627
1795
|
*/
|
|
1628
1796
|
export declare function isMCPPromptMessage(value: unknown): value is MCPPromptMessage;
|
|
1629
1797
|
|
|
@@ -1631,7 +1799,7 @@ export declare function isMCPPromptMessage(value: unknown): value is MCPPromptMe
|
|
|
1631
1799
|
* Determines whether a value is one consumer-owned prompt page.
|
|
1632
1800
|
*
|
|
1633
1801
|
* @param value - The unknown value to inspect
|
|
1634
|
-
* @returns
|
|
1802
|
+
* @returns True if the prompts and optional following cursor are valid; false otherwise
|
|
1635
1803
|
*/
|
|
1636
1804
|
export declare function isMCPPromptPage(value: unknown): value is MCPPromptPage;
|
|
1637
1805
|
|
|
@@ -1639,7 +1807,7 @@ export declare function isMCPPromptPage(value: unknown): value is MCPPromptPage;
|
|
|
1639
1807
|
* Determines whether a value is one `resources/list` descriptor.
|
|
1640
1808
|
*
|
|
1641
1809
|
* @param value - The unknown value to inspect
|
|
1642
|
-
* @returns
|
|
1810
|
+
* @returns True if the value is a valid resource descriptor; false otherwise
|
|
1643
1811
|
*/
|
|
1644
1812
|
export declare function isMCPResource(value: unknown): value is MCPResource;
|
|
1645
1813
|
|
|
@@ -1647,7 +1815,7 @@ export declare function isMCPResource(value: unknown): value is MCPResource;
|
|
|
1647
1815
|
* Determines whether a value is structurally discriminated resource contents.
|
|
1648
1816
|
*
|
|
1649
1817
|
* @param value - The unknown value to inspect
|
|
1650
|
-
* @returns
|
|
1818
|
+
* @returns True if exactly one of `text` and `blob` is present and valid; false otherwise
|
|
1651
1819
|
*/
|
|
1652
1820
|
export declare function isMCPResourceContents(value: unknown): value is MCPResourceContents;
|
|
1653
1821
|
|
|
@@ -1655,7 +1823,7 @@ export declare function isMCPResourceContents(value: unknown): value is MCPResou
|
|
|
1655
1823
|
* Determines whether a value is one consumer-owned resource page.
|
|
1656
1824
|
*
|
|
1657
1825
|
* @param value - The unknown value to inspect
|
|
1658
|
-
* @returns
|
|
1826
|
+
* @returns True if the resources and optional following cursor are valid; false otherwise
|
|
1659
1827
|
*/
|
|
1660
1828
|
export declare function isMCPResourcePage(value: unknown): value is MCPResourcePage;
|
|
1661
1829
|
|
|
@@ -1667,7 +1835,7 @@ export declare function isMCPResourcePage(value: unknown): value is MCPResourceP
|
|
|
1667
1835
|
* level belong to the consumer-supplied resource manager; this package projects the string.
|
|
1668
1836
|
*
|
|
1669
1837
|
* @param value - The unknown value to inspect
|
|
1670
|
-
* @returns
|
|
1838
|
+
* @returns True if the value is a valid resource-template descriptor; false otherwise
|
|
1671
1839
|
*/
|
|
1672
1840
|
export declare function isMCPResourceTemplate(value: unknown): value is MCPResourceTemplate;
|
|
1673
1841
|
|
|
@@ -1675,7 +1843,7 @@ export declare function isMCPResourceTemplate(value: unknown): value is MCPResou
|
|
|
1675
1843
|
* Determines whether a value is one consumer-owned resource-template page.
|
|
1676
1844
|
*
|
|
1677
1845
|
* @param value - The unknown value to inspect
|
|
1678
|
-
* @returns
|
|
1846
|
+
* @returns True if the templates and optional following cursor are valid; false otherwise
|
|
1679
1847
|
*/
|
|
1680
1848
|
export declare function isMCPResourceTemplatePage(value: unknown): value is MCPResourceTemplatePage;
|
|
1681
1849
|
|
|
@@ -1692,7 +1860,7 @@ export declare function isMCPResourceTemplatePage(value: unknown): value is MCPR
|
|
|
1692
1860
|
* input.
|
|
1693
1861
|
*
|
|
1694
1862
|
* @param value - The unknown value to inspect
|
|
1695
|
-
* @returns
|
|
1863
|
+
* @returns True if the value is a modern result; false otherwise
|
|
1696
1864
|
*
|
|
1697
1865
|
* @example
|
|
1698
1866
|
* ```ts
|
|
@@ -1715,7 +1883,7 @@ export declare function isMCPResultMetaObject(value: unknown): value is MCPResul
|
|
|
1715
1883
|
* including a URL-mode elicitation's `url`. Total over hostile input.
|
|
1716
1884
|
*
|
|
1717
1885
|
* @param value - The unknown value to inspect
|
|
1718
|
-
* @returns
|
|
1886
|
+
* @returns True if `value` carries an absolute `uri` and an optional string `name`; false otherwise
|
|
1719
1887
|
*
|
|
1720
1888
|
* @example
|
|
1721
1889
|
* ```ts
|
|
@@ -1733,7 +1901,7 @@ export declare function isMCPRoot(value: unknown): value is MCPRoot;
|
|
|
1733
1901
|
* {@link isMCPRoot}. Total over hostile input.
|
|
1734
1902
|
*
|
|
1735
1903
|
* @param value - The unknown value to inspect
|
|
1736
|
-
* @returns
|
|
1904
|
+
* @returns True if `value` carries an array of valid roots; false otherwise
|
|
1737
1905
|
*
|
|
1738
1906
|
* @example
|
|
1739
1907
|
* ```ts
|
|
@@ -1755,7 +1923,7 @@ export declare function isMCPRootResult(value: unknown): value is MCPRootResult;
|
|
|
1755
1923
|
* input.
|
|
1756
1924
|
*
|
|
1757
1925
|
* @param value - The unknown value to inspect
|
|
1758
|
-
* @returns
|
|
1926
|
+
* @returns True if `value` is one legal sampling content block; false otherwise
|
|
1759
1927
|
*
|
|
1760
1928
|
* @example
|
|
1761
1929
|
* ```ts
|
|
@@ -1777,7 +1945,7 @@ export declare function isMCPSampleContent(value: unknown): value is MCPSampleCo
|
|
|
1777
1945
|
* names four values and permits any other a provider reports. Total over hostile input.
|
|
1778
1946
|
*
|
|
1779
1947
|
* @param value - The unknown value to inspect
|
|
1780
|
-
* @returns
|
|
1948
|
+
* @returns True if `value` has the sampling-completion shape; false otherwise
|
|
1781
1949
|
*
|
|
1782
1950
|
* @example
|
|
1783
1951
|
* ```ts
|
|
@@ -1802,7 +1970,7 @@ export declare function isMCPServerCapabilities(value: unknown): value is MCPSer
|
|
|
1802
1970
|
* Determines whether a value is a string-valued MCP argument record.
|
|
1803
1971
|
*
|
|
1804
1972
|
* @param value - The unknown value to inspect
|
|
1805
|
-
* @returns
|
|
1973
|
+
* @returns True if every own argument value is a string; false otherwise
|
|
1806
1974
|
*/
|
|
1807
1975
|
export declare function isMCPStringArguments(value: unknown): value is Readonly<Record<string, string>>;
|
|
1808
1976
|
|
|
@@ -1820,7 +1988,7 @@ export declare function isMCPStringArguments(value: unknown): value is Readonly<
|
|
|
1820
1988
|
* the caller asked for.
|
|
1821
1989
|
*
|
|
1822
1990
|
* @param value - The unknown value to inspect
|
|
1823
|
-
* @returns
|
|
1991
|
+
* @returns True if every recognized filter field has its protocol shape; false otherwise
|
|
1824
1992
|
*/
|
|
1825
1993
|
export declare function isMCPSubscriptionFilter(value: unknown): value is MCPSubscriptionFilter;
|
|
1826
1994
|
|
|
@@ -1828,7 +1996,7 @@ export declare function isMCPSubscriptionFilter(value: unknown): value is MCPSub
|
|
|
1828
1996
|
* Determines whether a value is a graceful `subscriptions/listen` result.
|
|
1829
1997
|
*
|
|
1830
1998
|
* @param value - The unknown value to inspect
|
|
1831
|
-
* @returns
|
|
1999
|
+
* @returns True if the result is complete and carries a valid subscription id; false otherwise
|
|
1832
2000
|
*/
|
|
1833
2001
|
export declare function isMCPSubscriptionResult(value: unknown): value is MCPSubscriptionResult;
|
|
1834
2002
|
|
|
@@ -1852,7 +2020,7 @@ export declare function isMCPSubscriptionResult(value: unknown): value is MCPSub
|
|
|
1852
2020
|
* What is checked is what this package publishes as the contract.
|
|
1853
2021
|
*
|
|
1854
2022
|
* @param value - The unknown value to inspect
|
|
1855
|
-
* @returns
|
|
2023
|
+
* @returns True if the value is a well-formed {@link MCPTaskDetail}; false otherwise
|
|
1856
2024
|
*
|
|
1857
2025
|
* @example
|
|
1858
2026
|
* ```ts
|
|
@@ -1879,7 +2047,7 @@ export declare function isMCPTaskDetail(value: unknown): value is MCPTaskDetail;
|
|
|
1879
2047
|
* peer stamps there is the peer's to write.
|
|
1880
2048
|
*
|
|
1881
2049
|
* @param value - The unknown value to inspect
|
|
1882
|
-
* @returns
|
|
2050
|
+
* @returns True if the value is a well-formed {@link MCPTaskDetailResult}; false otherwise
|
|
1883
2051
|
*
|
|
1884
2052
|
* @example
|
|
1885
2053
|
* ```ts
|
|
@@ -1906,7 +2074,7 @@ export declare function isMCPTaskDetailResult(value: unknown): value is MCPTaskD
|
|
|
1906
2074
|
* to it, so a guard that demanded the stamp would refuse every frame a producer emits.
|
|
1907
2075
|
*
|
|
1908
2076
|
* @param value - The unknown value to inspect
|
|
1909
|
-
* @returns
|
|
2077
|
+
* @returns True if the value is a well-formed `notifications/tasks` notification; false otherwise
|
|
1910
2078
|
*
|
|
1911
2079
|
* @example
|
|
1912
2080
|
* ```ts
|
|
@@ -1917,10 +2085,7 @@ export declare function isMCPTaskDetailResult(value: unknown): value is MCPTaskD
|
|
|
1917
2085
|
* params: { taskId: 'a' } }) // false — the params owe a whole snapshot
|
|
1918
2086
|
* ```
|
|
1919
2087
|
*/
|
|
1920
|
-
export declare function isMCPTaskNotification(value: unknown): value is
|
|
1921
|
-
readonly method: 'notifications/tasks';
|
|
1922
|
-
readonly params: MCPTaskNotificationParams;
|
|
1923
|
-
};
|
|
2088
|
+
export declare function isMCPTaskNotification(value: unknown): value is MCPTaskNotification;
|
|
1924
2089
|
|
|
1925
2090
|
/**
|
|
1926
2091
|
* Determines whether a value is a modern MCP task-creation result.
|
|
@@ -1934,7 +2099,7 @@ export declare function isMCPTaskNotification(value: unknown): value is JSONRPCN
|
|
|
1934
2099
|
* INTEGER milliseconds because the schema formats them `int`.
|
|
1935
2100
|
*
|
|
1936
2101
|
* @param value - The unknown value to inspect
|
|
1937
|
-
* @returns
|
|
2102
|
+
* @returns True if the value is a well-formed `resultType: 'task'` result; false otherwise
|
|
1938
2103
|
*
|
|
1939
2104
|
* @example
|
|
1940
2105
|
* ```ts
|
|
@@ -1948,7 +2113,7 @@ export declare function isMCPTaskResult(value: unknown): value is MCPTaskResult;
|
|
|
1948
2113
|
* Determines whether a value is one of the extension's task lifecycle states.
|
|
1949
2114
|
*
|
|
1950
2115
|
* @param value - The unknown value to inspect
|
|
1951
|
-
* @returns
|
|
2116
|
+
* @returns True if the value is an {@link MCPTaskStatus}; false otherwise
|
|
1952
2117
|
*
|
|
1953
2118
|
* @example
|
|
1954
2119
|
* ```ts
|
|
@@ -1962,7 +2127,7 @@ export declare function isMCPTaskStatus(value: unknown): value is MCPTaskStatus;
|
|
|
1962
2127
|
* Determines whether a value is embedded textual MCP resource contents.
|
|
1963
2128
|
*
|
|
1964
2129
|
* @param value - The unknown value to inspect
|
|
1965
|
-
* @returns
|
|
2130
|
+
* @returns True if the value is embedded textual resource contents; false otherwise
|
|
1966
2131
|
*/
|
|
1967
2132
|
export declare function isMCPTextResource(value: unknown): value is MCPTextResource;
|
|
1968
2133
|
|
|
@@ -1970,7 +2135,7 @@ export declare function isMCPTextResource(value: unknown): value is MCPTextResou
|
|
|
1970
2135
|
* Determines whether a value is a supported {@link MCPVersion}.
|
|
1971
2136
|
*
|
|
1972
2137
|
* @param value - The unknown value to inspect
|
|
1973
|
-
* @returns
|
|
2138
|
+
* @returns True if the value is one of {@link SUPPORTED_MCP_VERSIONS}; false otherwise
|
|
1974
2139
|
*/
|
|
1975
2140
|
export declare function isMCPVersion(value: unknown): value is MCPVersion;
|
|
1976
2141
|
|
|
@@ -1985,7 +2150,7 @@ export declare function isMCPVersion(value: unknown): value is MCPVersion;
|
|
|
1985
2150
|
* legacy dispatch. Total over hostile and malformed input.
|
|
1986
2151
|
*
|
|
1987
2152
|
* @param value - The already-parsed value to inspect
|
|
1988
|
-
* @returns
|
|
2153
|
+
* @returns True if the value is an invocation carrying the reserved version key; false otherwise
|
|
1989
2154
|
*/
|
|
1990
2155
|
export declare function isModernRequest(value: unknown): value is JSONRPCInvocation;
|
|
1991
2156
|
|
|
@@ -2004,7 +2169,7 @@ export declare function isModernRequest(value: unknown): value is JSONRPCInvocat
|
|
|
2004
2169
|
* refuse. It is a SYNTAX guard: no time zone, locale, calendar era, or leap second applies.
|
|
2005
2170
|
*
|
|
2006
2171
|
* @param value - The unknown value to inspect
|
|
2007
|
-
* @returns
|
|
2172
|
+
* @returns True if the value is an RFC 3339 `full-date` for a day that exists; false otherwise
|
|
2008
2173
|
*
|
|
2009
2174
|
* @example
|
|
2010
2175
|
* ```ts
|
|
@@ -2028,7 +2193,7 @@ export declare function isRFC3339Date(value: unknown): value is string;
|
|
|
2028
2193
|
* second.
|
|
2029
2194
|
*
|
|
2030
2195
|
* @param value - The unknown value to inspect
|
|
2031
|
-
* @returns
|
|
2196
|
+
* @returns True if the value is an RFC 3339 `date-time` for a day that exists; false otherwise
|
|
2032
2197
|
*
|
|
2033
2198
|
* @example
|
|
2034
2199
|
* ```ts
|
|
@@ -2043,40 +2208,13 @@ export declare function isRFC3339DateTime(value: unknown): value is string;
|
|
|
2043
2208
|
* Determines whether a value is standard padded base64 as required by JSON Schema `byte` format.
|
|
2044
2209
|
*
|
|
2045
2210
|
* @param value - The unknown value to inspect
|
|
2046
|
-
* @returns
|
|
2211
|
+
* @returns True if the value is an empty or completely padded standard base64 encoding; false otherwise
|
|
2047
2212
|
*/
|
|
2048
2213
|
export declare function isStandardBase64(value: unknown): value is string;
|
|
2049
2214
|
|
|
2050
2215
|
/**
|
|
2051
|
-
*
|
|
2052
|
-
*
|
|
2053
|
-
* @remarks
|
|
2054
|
-
* The declaration lives at `extensions['io.modelcontextprotocol/tasks']` and the schema
|
|
2055
|
-
* types its value EXACTLY EMPTY — `Record<string, never>`, an object with no additional
|
|
2056
|
-
* properties. So the key's presence is the whole declaration, and the value carries the
|
|
2057
|
-
* whole of the check: a `true` or a string there is a client speaking a different protocol
|
|
2058
|
-
* rather than a shorthand, and a member inside the object is a client declaring an option
|
|
2059
|
-
* this extension does not define. Both are refused, because a server that accepted either
|
|
2060
|
-
* would be reading a shape no peer can produce from the snapshot's own schema.
|
|
2061
|
-
*
|
|
2062
|
-
* A client declares this PER REQUEST. Nothing here consults a session, because the modern
|
|
2063
|
-
* revision is stateless and a capability declared once at connect time says nothing about
|
|
2064
|
-
* the request in hand. Total over hostile input.
|
|
2065
|
-
*
|
|
2066
|
-
* @param value - The client capability record to inspect
|
|
2067
|
-
* @returns `true` when the tasks extension is declared as the schema's empty object
|
|
2068
|
-
*
|
|
2069
|
-
* @example
|
|
2070
|
-
* ```ts
|
|
2071
|
-
* isTaskSupported({ extensions: { 'io.modelcontextprotocol/tasks': {} } }) // true
|
|
2072
|
-
* isTaskSupported({ extensions: {} }) // false — the key is the declaration
|
|
2073
|
-
* isTaskSupported({ extensions: { 'io.modelcontextprotocol/tasks': { on: true } } }) // false
|
|
2074
|
-
* ```
|
|
2075
|
-
*/
|
|
2076
|
-
export declare function isTaskSupported(value: unknown): boolean;
|
|
2077
|
-
|
|
2078
|
-
/**
|
|
2079
|
-
* 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.
|
|
2080
2218
|
*
|
|
2081
2219
|
* @remarks
|
|
2082
2220
|
* The code every MODERN internal fault answers with — a provider, handler, continuation,
|
|
@@ -2086,20 +2224,20 @@ export declare function isTaskSupported(value: unknown): boolean;
|
|
|
2086
2224
|
*/
|
|
2087
2225
|
export declare const JSONRPC_INTERNAL_ERROR = -32603;
|
|
2088
2226
|
|
|
2089
|
-
/** JSON-RPC 2.0 reserved error
|
|
2227
|
+
/** Names the JSON-RPC 2.0 reserved error for a method's invalid parameters. */
|
|
2090
2228
|
export declare const JSONRPC_INVALID_PARAMS = -32602;
|
|
2091
2229
|
|
|
2092
|
-
/** 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. */
|
|
2093
2231
|
export declare const JSONRPC_INVALID_REQUEST = -32600;
|
|
2094
2232
|
|
|
2095
|
-
/** JSON-RPC 2.0 reserved error
|
|
2233
|
+
/** Names the JSON-RPC 2.0 reserved error for a requested method that does not exist. */
|
|
2096
2234
|
export declare const JSONRPC_METHOD_NOT_FOUND = -32601;
|
|
2097
2235
|
|
|
2098
|
-
/** JSON-RPC 2.0 reserved error
|
|
2236
|
+
/** Names the JSON-RPC 2.0 reserved error for invalid JSON received (the message did not parse). */
|
|
2099
2237
|
export declare const JSONRPC_PARSE_ERROR = -32700;
|
|
2100
2238
|
|
|
2101
2239
|
/**
|
|
2102
|
-
* 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).
|
|
2103
2241
|
*
|
|
2104
2242
|
* @remarks
|
|
2105
2243
|
* Retained for the LEGACY branch alone. A modern fault answers
|
|
@@ -2109,7 +2247,7 @@ export declare const JSONRPC_PARSE_ERROR = -32700;
|
|
|
2109
2247
|
export declare const JSONRPC_SERVER_ERROR = -32000;
|
|
2110
2248
|
|
|
2111
2249
|
/**
|
|
2112
|
-
*
|
|
2250
|
+
* Represents a JSON-RPC 2.0 error object — the `error` member of a
|
|
2113
2251
|
* {@link JSONRPCErrorResponse}.
|
|
2114
2252
|
*
|
|
2115
2253
|
* @remarks
|
|
@@ -2124,8 +2262,8 @@ export declare interface JSONRPCError {
|
|
|
2124
2262
|
}
|
|
2125
2263
|
|
|
2126
2264
|
/**
|
|
2127
|
-
*
|
|
2128
|
-
* {@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.
|
|
2129
2267
|
*
|
|
2130
2268
|
* @remarks
|
|
2131
2269
|
* `id` is OMITTED, never `null`, when the request could not be parsed or its id
|
|
@@ -2134,18 +2272,18 @@ export declare interface JSONRPCError {
|
|
|
2134
2272
|
*/
|
|
2135
2273
|
export declare interface JSONRPCErrorResponse {
|
|
2136
2274
|
readonly jsonrpc: '2.0';
|
|
2137
|
-
/**
|
|
2275
|
+
/** Holds the failed request's id; ABSENT when no id could be read. */
|
|
2138
2276
|
readonly id?: JSONRPCId;
|
|
2139
2277
|
readonly error: JSONRPCError;
|
|
2140
|
-
/**
|
|
2278
|
+
/** Forbids this member; an answer carries a result or an error, never both. */
|
|
2141
2279
|
readonly result?: never;
|
|
2142
2280
|
}
|
|
2143
2281
|
|
|
2144
|
-
/**
|
|
2282
|
+
/** Represents a JSON-RPC 2.0 correlation id — the value a request and its response share. */
|
|
2145
2283
|
export declare type JSONRPCId = string | number;
|
|
2146
2284
|
|
|
2147
2285
|
/**
|
|
2148
|
-
*
|
|
2286
|
+
* Represents one inbound JSON-RPC call — the common dispatch input.
|
|
2149
2287
|
*
|
|
2150
2288
|
* @remarks
|
|
2151
2289
|
* Narrow the arms apart on the id: `invocation.id === undefined` is the notification
|
|
@@ -2154,7 +2292,7 @@ export declare type JSONRPCId = string | number;
|
|
|
2154
2292
|
export declare type JSONRPCInvocation = JSONRPCRequest | JSONRPCNotification;
|
|
2155
2293
|
|
|
2156
2294
|
/**
|
|
2157
|
-
*
|
|
2295
|
+
* Represents a JSON-RPC 2.0 message on the wire — a {@link JSONRPCInvocation} or a
|
|
2158
2296
|
* {@link JSONRPCResponse}.
|
|
2159
2297
|
*
|
|
2160
2298
|
* @remarks
|
|
@@ -2164,8 +2302,8 @@ export declare type JSONRPCInvocation = JSONRPCRequest | JSONRPCNotification;
|
|
|
2164
2302
|
export declare type JSONRPCMessage = JSONRPCInvocation | JSONRPCResponse;
|
|
2165
2303
|
|
|
2166
2304
|
/**
|
|
2167
|
-
*
|
|
2168
|
-
* 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`).
|
|
2169
2307
|
*
|
|
2170
2308
|
* @remarks
|
|
2171
2309
|
* A notification MUST NOT carry an `id`, so `id` is declared `never`: a
|
|
@@ -2175,14 +2313,14 @@ export declare type JSONRPCMessage = JSONRPCInvocation | JSONRPCResponse;
|
|
|
2175
2313
|
export declare interface JSONRPCNotification {
|
|
2176
2314
|
readonly jsonrpc: '2.0';
|
|
2177
2315
|
readonly method: string;
|
|
2178
|
-
/**
|
|
2316
|
+
/** Forbids this member; an id is what makes a call a {@link JSONRPCRequest} instead. */
|
|
2179
2317
|
readonly id?: never;
|
|
2180
|
-
/**
|
|
2318
|
+
/** Holds the method's open argument record (narrowed by the handler). */
|
|
2181
2319
|
readonly params?: Readonly<Record<string, unknown>>;
|
|
2182
2320
|
}
|
|
2183
2321
|
|
|
2184
2322
|
/**
|
|
2185
|
-
*
|
|
2323
|
+
* Represents a JSON-RPC 2.0 request — a `method` call with optional `params`, correlated to
|
|
2186
2324
|
* its response by the `id` it REQUIRES.
|
|
2187
2325
|
*
|
|
2188
2326
|
* @remarks
|
|
@@ -2195,12 +2333,12 @@ export declare interface JSONRPCRequest {
|
|
|
2195
2333
|
readonly method: string;
|
|
2196
2334
|
/** Correlates the request with its response. */
|
|
2197
2335
|
readonly id: JSONRPCId;
|
|
2198
|
-
/**
|
|
2336
|
+
/** Holds the method's open argument record (narrowed by the handler). */
|
|
2199
2337
|
readonly params?: Readonly<Record<string, unknown>>;
|
|
2200
2338
|
}
|
|
2201
2339
|
|
|
2202
2340
|
/**
|
|
2203
|
-
*
|
|
2341
|
+
* Represents a JSON-RPC 2.0 response — the answer to one {@link JSONRPCRequest}.
|
|
2204
2342
|
*
|
|
2205
2343
|
* @remarks
|
|
2206
2344
|
* The arms are mutually exclusive in the type and in their guards. Narrow them
|
|
@@ -2209,8 +2347,8 @@ export declare interface JSONRPCRequest {
|
|
|
2209
2347
|
export declare type JSONRPCResponse = JSONRPCResultResponse | JSONRPCErrorResponse;
|
|
2210
2348
|
|
|
2211
2349
|
/**
|
|
2212
|
-
*
|
|
2213
|
-
* 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`.
|
|
2214
2352
|
*
|
|
2215
2353
|
* @remarks
|
|
2216
2354
|
* A result answers a request, and a request always has a readable `id`, so `id` is
|
|
@@ -2221,7 +2359,7 @@ export declare interface JSONRPCResultResponse {
|
|
|
2221
2359
|
readonly jsonrpc: '2.0';
|
|
2222
2360
|
readonly id: JSONRPCId;
|
|
2223
2361
|
readonly result: MCPResult | MCPLegacyResult;
|
|
2224
|
-
/**
|
|
2362
|
+
/** Forbids this member; an answer carries a result or an error, never both. */
|
|
2225
2363
|
readonly error?: never;
|
|
2226
2364
|
}
|
|
2227
2365
|
|
|
@@ -2262,7 +2400,7 @@ export declare function legacyResultToModern(result: MCPLegacyResult, method: st
|
|
|
2262
2400
|
*
|
|
2263
2401
|
* @param method - The method the pending request was issued for
|
|
2264
2402
|
* @param resultType - The unknown `resultType` the peer answered with
|
|
2265
|
-
* @returns
|
|
2403
|
+
* @returns True if that method may legally answer with that `resultType`; false otherwise
|
|
2266
2404
|
*
|
|
2267
2405
|
* @example
|
|
2268
2406
|
* ```ts
|
|
@@ -2278,12 +2416,12 @@ export declare function matchesResultType(method: string, resultType: unknown):
|
|
|
2278
2416
|
*
|
|
2279
2417
|
* @param notification - The server notification offered by the configured producer
|
|
2280
2418
|
* @param filter - The filter acknowledged to the client
|
|
2281
|
-
* @returns
|
|
2419
|
+
* @returns True if the notification belongs on this subscription stream; false otherwise
|
|
2282
2420
|
*/
|
|
2283
2421
|
export declare function matchesSubscriptionNotification(notification: JSONRPCNotification, filter: MCPSubscriptionFilter): boolean;
|
|
2284
2422
|
|
|
2285
2423
|
/**
|
|
2286
|
-
*
|
|
2424
|
+
* Names the reserved extension key identifying the stable Tasks extension.
|
|
2287
2425
|
*
|
|
2288
2426
|
* @remarks
|
|
2289
2427
|
* The ONE spelling of it in this package, and the identity of the immutable snapshot dated
|
|
@@ -2294,11 +2432,11 @@ export declare function matchesSubscriptionNotification(notification: JSONRPCNot
|
|
|
2294
2432
|
*/
|
|
2295
2433
|
export declare const MCP_EXTENSION_TASKS = "io.modelcontextprotocol/tasks";
|
|
2296
2434
|
|
|
2297
|
-
/**
|
|
2435
|
+
/** Names the older legacy revision the optional legacy decorator accepts and an adapter can pin. */
|
|
2298
2436
|
export declare const MCP_FALLBACK_VERSION: MCPLegacyVersion;
|
|
2299
2437
|
|
|
2300
2438
|
/**
|
|
2301
|
-
*
|
|
2439
|
+
* Names the revision offered and defaulted to in the legacy `initialize` handshake.
|
|
2302
2440
|
*
|
|
2303
2441
|
* @remarks
|
|
2304
2442
|
* This is deliberately a legacy revision, and the newest one supported. 2026-07-28 is stateless
|
|
@@ -2308,7 +2446,7 @@ export declare const MCP_FALLBACK_VERSION: MCPLegacyVersion;
|
|
|
2308
2446
|
export declare const MCP_HANDSHAKE_VERSION: MCPLegacyVersion;
|
|
2309
2447
|
|
|
2310
2448
|
/**
|
|
2311
|
-
*
|
|
2449
|
+
* Identifies the tool-schema annotation key naming the header one parameter projects into.
|
|
2312
2450
|
*
|
|
2313
2451
|
* @remarks
|
|
2314
2452
|
* It is valid ONLY on a primitive property schema statically reachable from the `inputSchema`
|
|
@@ -2318,11 +2456,11 @@ export declare const MCP_HANDSHAKE_VERSION: MCPLegacyVersion;
|
|
|
2318
2456
|
*/
|
|
2319
2457
|
export declare const MCP_HEADER_ANNOTATION = "x-mcp-header";
|
|
2320
2458
|
|
|
2321
|
-
/** MCP reserved error
|
|
2459
|
+
/** Names the MCP reserved error for required HTTP metadata that does not match the request body. */
|
|
2322
2460
|
export declare const MCP_HEADER_MISMATCH = -32020;
|
|
2323
2461
|
|
|
2324
2462
|
/**
|
|
2325
|
-
*
|
|
2463
|
+
* Bounds the `tools/list` pages one modern `tools/call` walks to reach its own annotations.
|
|
2326
2464
|
*
|
|
2327
2465
|
* @remarks
|
|
2328
2466
|
* The HTTP POST handler reads a called tool's {@link MCP_HEADER_ANNOTATION} annotations by
|
|
@@ -2337,23 +2475,32 @@ export declare const MCP_HEADER_MISMATCH = -32020;
|
|
|
2337
2475
|
*/
|
|
2338
2476
|
export declare const MCP_LOOKUP_PAGES = 8;
|
|
2339
2477
|
|
|
2340
|
-
/**
|
|
2478
|
+
/** Names the reserved modern `_meta` key carrying the client's open capability record. */
|
|
2341
2479
|
export declare const MCP_META_CAPABILITIES = "io.modelcontextprotocol/clientCapabilities";
|
|
2342
2480
|
|
|
2343
|
-
/**
|
|
2481
|
+
/** Names the reserved modern `_meta` key carrying the optional client identity. */
|
|
2344
2482
|
export declare const MCP_META_CLIENT = "io.modelcontextprotocol/clientInfo";
|
|
2345
2483
|
|
|
2346
|
-
/**
|
|
2484
|
+
/** Names the reserved modern `_meta` key carrying the server identity on results. */
|
|
2347
2485
|
export declare const MCP_META_SERVER = "io.modelcontextprotocol/serverInfo";
|
|
2348
2486
|
|
|
2349
|
-
/**
|
|
2487
|
+
/** Names the reserved modern `_meta` key carrying a `subscriptions/listen` request id. */
|
|
2350
2488
|
export declare const MCP_META_SUBSCRIPTION = "io.modelcontextprotocol/subscriptionId";
|
|
2351
2489
|
|
|
2352
|
-
/**
|
|
2490
|
+
/** Names the reserved modern `_meta` key carrying the request's protocol revision. */
|
|
2353
2491
|
export declare const MCP_META_VERSION = "io.modelcontextprotocol/protocolVersion";
|
|
2354
2492
|
|
|
2355
2493
|
/**
|
|
2356
|
-
*
|
|
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.
|
|
2357
2504
|
*
|
|
2358
2505
|
* @remarks
|
|
2359
2506
|
* The GENERIC code for the whole condition, not one capability's code. This server answers
|
|
@@ -2367,11 +2514,20 @@ export declare const MCP_META_VERSION = "io.modelcontextprotocol/protocolVersion
|
|
|
2367
2514
|
*/
|
|
2368
2515
|
export declare const MCP_MISSING_CAPABILITY = -32021;
|
|
2369
2516
|
|
|
2370
|
-
/**
|
|
2517
|
+
/** Names the modern revision offered by an unpinned client during discovery. */
|
|
2371
2518
|
export declare const MCP_MODERN_VERSION: MCPModernVersion;
|
|
2372
2519
|
|
|
2373
2520
|
/**
|
|
2374
|
-
*
|
|
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.
|
|
2375
2531
|
*
|
|
2376
2532
|
* @remarks
|
|
2377
2533
|
* The full field name is this prefix followed by the annotation's own value verbatim, so
|
|
@@ -2382,7 +2538,16 @@ export declare const MCP_MODERN_VERSION: MCPModernVersion;
|
|
|
2382
2538
|
export declare const MCP_PARAM_PREFIX = "Mcp-Param-";
|
|
2383
2539
|
|
|
2384
2540
|
/**
|
|
2385
|
-
*
|
|
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.
|
|
2386
2551
|
*
|
|
2387
2552
|
* @remarks
|
|
2388
2553
|
* The markers are LOWERCASE and exact, and this constant with {@link MCP_SENTINEL_SUFFIX} is
|
|
@@ -2392,20 +2557,48 @@ export declare const MCP_PARAM_PREFIX = "Mcp-Param-";
|
|
|
2392
2557
|
*/
|
|
2393
2558
|
export declare const MCP_SENTINEL_PREFIX = "=?base64?";
|
|
2394
2559
|
|
|
2395
|
-
/**
|
|
2560
|
+
/** Names the closing marker of the Base64 sentinel a standard MCP header value travels in. */
|
|
2396
2561
|
export declare const MCP_SENTINEL_SUFFIX = "?=";
|
|
2397
2562
|
|
|
2398
|
-
/**
|
|
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. */
|
|
2399
2575
|
export declare const MCP_UNSUPPORTED_VERSION = -32022;
|
|
2400
2576
|
|
|
2401
|
-
/**
|
|
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. */
|
|
2402
2595
|
export declare interface MCPAnnotations {
|
|
2403
2596
|
readonly audience?: readonly MCPRole[];
|
|
2404
2597
|
readonly priority?: number;
|
|
2405
2598
|
readonly lastModified?: string;
|
|
2406
2599
|
}
|
|
2407
2600
|
|
|
2408
|
-
/**
|
|
2601
|
+
/** Represents a base64-encoded audio MCP content block. */
|
|
2409
2602
|
export declare interface MCPAudioContent {
|
|
2410
2603
|
readonly type: 'audio';
|
|
2411
2604
|
readonly data: string;
|
|
@@ -2414,7 +2607,7 @@ export declare interface MCPAudioContent {
|
|
|
2414
2607
|
readonly _meta?: MCPMetaObject;
|
|
2415
2608
|
}
|
|
2416
2609
|
|
|
2417
|
-
/**
|
|
2610
|
+
/** Represents embedded base64-encoded resource contents. */
|
|
2418
2611
|
export declare interface MCPBlobResource {
|
|
2419
2612
|
readonly uri: string;
|
|
2420
2613
|
readonly mimeType?: string;
|
|
@@ -2459,7 +2652,7 @@ export declare interface MCPCallOptions {
|
|
|
2459
2652
|
}
|
|
2460
2653
|
|
|
2461
2654
|
/**
|
|
2462
|
-
*
|
|
2655
|
+
* Represents what one remote `tools/call` answered — the arms the dated protocol permits.
|
|
2463
2656
|
*
|
|
2464
2657
|
* @remarks
|
|
2465
2658
|
* The peer chooses the arm, so the caller narrows on `resultType`:
|
|
@@ -2478,19 +2671,19 @@ export declare interface MCPCallOptions {
|
|
|
2478
2671
|
*/
|
|
2479
2672
|
export declare type MCPCallOutcome = {
|
|
2480
2673
|
readonly resultType: 'complete';
|
|
2481
|
-
/**
|
|
2674
|
+
/** Holds the remote tool's value — its `structuredContent`, or its parsed text. */
|
|
2482
2675
|
readonly value: unknown;
|
|
2483
2676
|
} | MCPTaskResult | MCPInputResult;
|
|
2484
2677
|
|
|
2485
|
-
/**
|
|
2678
|
+
/** Represents a required complete modern `tools/call` result. */
|
|
2486
2679
|
export declare type MCPCallResult = MCPUnstampedCallResult & {
|
|
2487
2680
|
readonly resultType: 'complete';
|
|
2488
2681
|
};
|
|
2489
2682
|
|
|
2490
2683
|
/**
|
|
2491
|
-
*
|
|
2492
|
-
*
|
|
2493
|
-
*
|
|
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.
|
|
2494
2687
|
*
|
|
2495
2688
|
* @remarks
|
|
2496
2689
|
* - **The mirror of `MCPServer`.** The server DISPATCHES requests over a tool registry;
|
|
@@ -2554,7 +2747,7 @@ export declare class MCPClient implements MCPClientInterface {
|
|
|
2554
2747
|
get emitter(): EmitterInterface<MCPClientEventMap>;
|
|
2555
2748
|
get connected(): boolean;
|
|
2556
2749
|
get version(): MCPModernVersion | undefined;
|
|
2557
|
-
get transport():
|
|
2750
|
+
get transport(): MCPMessageTransportInterface;
|
|
2558
2751
|
get tasks(): MCPTaskClientInterface;
|
|
2559
2752
|
connect(): Promise<void>;
|
|
2560
2753
|
discover(): Promise<MCPDiscoverResult>;
|
|
@@ -2564,7 +2757,7 @@ export declare class MCPClient implements MCPClientInterface {
|
|
|
2564
2757
|
call(name: string, args: Readonly<Record<string, unknown>>, options?: MCPCallOptions): Promise<MCPCallOutcome>;
|
|
2565
2758
|
}
|
|
2566
2759
|
|
|
2567
|
-
/**
|
|
2760
|
+
/** Represents the open dated client-capability declaration carried by modern requests. */
|
|
2568
2761
|
export declare type MCPClientCapabilities = Readonly<Record<string, MCPMetaObject>> & {
|
|
2569
2762
|
readonly experimental?: Readonly<Record<string, MCPMetaObject>>;
|
|
2570
2763
|
readonly roots?: MCPMetaObject;
|
|
@@ -2580,7 +2773,7 @@ export declare type MCPClientCapabilities = Readonly<Record<string, MCPMetaObjec
|
|
|
2580
2773
|
};
|
|
2581
2774
|
|
|
2582
2775
|
/**
|
|
2583
|
-
*
|
|
2776
|
+
* Represents the push observation surface of an {@link MCPClientInterface} — the moments a
|
|
2584
2777
|
* fire-and-forget observer (logging, tracing) subscribes to through `client.emitter.on`.
|
|
2585
2778
|
*
|
|
2586
2779
|
* @remarks
|
|
@@ -2601,20 +2794,19 @@ export declare type MCPClientCapabilities = Readonly<Record<string, MCPMetaObjec
|
|
|
2601
2794
|
* Declared as a `type` alias so the literal satisfies `EventMap`.
|
|
2602
2795
|
*/
|
|
2603
2796
|
export declare type MCPClientEventMap = {
|
|
2604
|
-
/**
|
|
2797
|
+
/** Reports that era negotiation completed — the client is connected. */
|
|
2605
2798
|
readonly connect: readonly [];
|
|
2606
|
-
/**
|
|
2799
|
+
/** Reports that the client disconnected — pending requests rejected, the connection it owned closed or its close failed. */
|
|
2607
2800
|
readonly disconnect: readonly [];
|
|
2608
|
-
/**
|
|
2801
|
+
/** Reports that a server-initiated notification arrived (not a response to a pending request). */
|
|
2609
2802
|
readonly notification: readonly [message: JSONRPCMessage];
|
|
2610
|
-
/**
|
|
2803
|
+
/** Reports a client-level fault surfaced for observation (typed `unknown`). */
|
|
2611
2804
|
readonly error: readonly [error: unknown];
|
|
2612
2805
|
};
|
|
2613
2806
|
|
|
2614
2807
|
/**
|
|
2615
|
-
*
|
|
2616
|
-
*
|
|
2617
|
-
* 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
|
|
2618
2810
|
* {@link ToolInterface}s an agent can run.
|
|
2619
2811
|
*
|
|
2620
2812
|
* @remarks
|
|
@@ -2633,7 +2825,7 @@ export declare type MCPClientEventMap = {
|
|
|
2633
2825
|
* non-`'complete'` arm throws there instead.
|
|
2634
2826
|
* - **Per-request cancellation.** `call`'s `options.signal` cancels ONE in-flight request:
|
|
2635
2827
|
* it rejects locally on every carrier, and additionally writes `notifications/cancelled`
|
|
2636
|
-
* where the transport declares itself {@link
|
|
2828
|
+
* where the transport declares itself {@link MCPMessageTransportInterface.duplex}. It
|
|
2637
2829
|
* never cancels the connection, and never a durable task — a call that already answered
|
|
2638
2830
|
* `resultType: 'task'` is a request that is over. Cancellation is advisory, so a
|
|
2639
2831
|
* response arriving after the abort is discarded rather than raised.
|
|
@@ -2666,14 +2858,15 @@ export declare type MCPClientEventMap = {
|
|
|
2666
2858
|
*/
|
|
2667
2859
|
export declare interface MCPClientInterface {
|
|
2668
2860
|
readonly emitter: EmitterInterface<MCPClientEventMap>;
|
|
2669
|
-
/**
|
|
2861
|
+
/** Reports whether modern revision negotiation has completed and the client is connected. */
|
|
2670
2862
|
readonly connected: boolean;
|
|
2671
|
-
/**
|
|
2863
|
+
/** Holds the negotiated protocol revision, or `undefined` while disconnected. */
|
|
2672
2864
|
readonly version: MCPModernVersion | undefined;
|
|
2673
|
-
/**
|
|
2674
|
-
readonly transport:
|
|
2865
|
+
/** Holds the injected transport the client drives the remote server over. */
|
|
2866
|
+
readonly transport: MCPMessageTransportInterface;
|
|
2675
2867
|
/**
|
|
2676
|
-
*
|
|
2868
|
+
* Holds the stable Tasks extension's client half — reading, answering, and stopping a durable
|
|
2869
|
+
* task.
|
|
2677
2870
|
*
|
|
2678
2871
|
* @remarks
|
|
2679
2872
|
* Always present, because the `tasks/*` methods are ordinary requests a client may
|
|
@@ -2795,7 +2988,7 @@ export declare interface MCPClientInterface {
|
|
|
2795
2988
|
*
|
|
2796
2989
|
* `options.signal` cancels THIS request only — the caller stops waiting, the pending
|
|
2797
2990
|
* request rejects, and the peer is TOLD on a carrier that can carry a client
|
|
2798
|
-
* notification (see {@link
|
|
2991
|
+
* notification (see {@link MCPMessageTransportInterface.duplex}). MCP cancellation is
|
|
2799
2992
|
* advisory: the peer may answer anyway, and that late answer is discarded rather than
|
|
2800
2993
|
* raised. `options.progress` receives this request's progress frames.
|
|
2801
2994
|
*
|
|
@@ -2808,7 +3001,7 @@ export declare interface MCPClientInterface {
|
|
|
2808
3001
|
}
|
|
2809
3002
|
|
|
2810
3003
|
/**
|
|
2811
|
-
* Options for `createMCPClient` — the {@link
|
|
3004
|
+
* Options for `createMCPClient` — the {@link MCPMessageTransportInterface} to drive, the
|
|
2812
3005
|
* optional client {@link MCPIdentity}, the per-request `timeout`, and the reserved
|
|
2813
3006
|
* `on` hooks.
|
|
2814
3007
|
*
|
|
@@ -2835,176 +3028,52 @@ export declare interface MCPClientInterface {
|
|
|
2835
3028
|
*/
|
|
2836
3029
|
export declare interface MCPClientOptions {
|
|
2837
3030
|
readonly on?: EmitterHooks<MCPClientEventMap>;
|
|
2838
|
-
/**
|
|
3031
|
+
/** Holds the emitter's listener-error handler — a listener throw routes here, not to a domain event. */
|
|
2839
3032
|
readonly error?: EmitterErrorHandler;
|
|
2840
|
-
readonly transport:
|
|
3033
|
+
readonly transport: MCPMessageTransportInterface;
|
|
2841
3034
|
readonly identity?: MCPIdentity;
|
|
2842
|
-
/**
|
|
3035
|
+
/** Holds the open client-capability record carried by modern requests. */
|
|
2843
3036
|
readonly capabilities?: MCPClientCapabilities;
|
|
2844
3037
|
/**
|
|
2845
|
-
*
|
|
3038
|
+
* Pins an optional exact modern protocol revision; absence permits modern negotiation. A defined
|
|
2846
3039
|
* pin must match the peer's discovery advertisement. An unsupported runtime value throws an
|
|
2847
3040
|
* {@link MCPError} synchronously during construction.
|
|
2848
3041
|
*/
|
|
2849
3042
|
readonly version?: MCPModernVersion;
|
|
2850
|
-
/**
|
|
3043
|
+
/** Sets the per-request deadline in milliseconds (default {@link import('./constants.js').DEFAULT_MCP_REQUEST_TIMEOUT}). */
|
|
2851
3044
|
readonly timeout?: number;
|
|
2852
3045
|
}
|
|
2853
3046
|
|
|
2854
|
-
/**
|
|
2855
|
-
* The observable events of a {@link MCPClientTransportInterface} — the moments the
|
|
2856
|
-
* {@link MCPClientInterface} (and any tracer) subscribes to through `transport.emitter.on`.
|
|
2857
|
-
*
|
|
2858
|
-
* @remarks
|
|
2859
|
-
* - `message` — a JSON-RPC message ARRIVED from the remote server (a response the
|
|
2860
|
-
* client correlates to a pending request by `id`, or a server-initiated
|
|
2861
|
-
* notification). The transport decodes the wire bytes (a JSON body or an SSE
|
|
2862
|
-
* `data:` event) and emits the parsed {@link JSONRPCMessage}.
|
|
2863
|
-
* - `close` — the transport's connection ended (a stream closed, `close()` ran).
|
|
2864
|
-
* - `error` — a transport-level fault (a malformed message, a network error); the
|
|
2865
|
-
* payload is typed `unknown`. This is a DOMAIN event, distinct from the emitter's
|
|
2866
|
-
* own listener-error channel: a listener throw is routed to the emitter's `error` handler
|
|
2867
|
-
* (the `error` option), never onto this map. Declared as a `type` alias so the
|
|
2868
|
-
* type-literal satisfies `EventMap` structurally.
|
|
2869
|
-
*/
|
|
2870
|
-
export declare type MCPClientTransportEventMap = {
|
|
2871
|
-
/** A JSON-RPC message arrived from the remote server (a response, or a notification). */
|
|
2872
|
-
readonly message: readonly [message: JSONRPCMessage];
|
|
2873
|
-
/** The transport's connection ended. */
|
|
2874
|
-
readonly close: readonly [];
|
|
2875
|
-
/** A transport-level fault — the caught error (typed `unknown`). */
|
|
2876
|
-
readonly error: readonly [error: unknown];
|
|
2877
|
-
};
|
|
2878
|
-
|
|
2879
|
-
/**
|
|
2880
|
-
* A transport-agnostic MCP message carrier — pumps JSON-RPC messages to a peer and
|
|
2881
|
-
* surfaces received messages on its `emitter`'s `message` event, with no knowledge
|
|
2882
|
-
* of the protocol role on either side.
|
|
2883
|
-
*
|
|
2884
|
-
* @remarks
|
|
2885
|
-
* A client hands the transport one {@link JSONRPCMessage} through `send`, and the
|
|
2886
|
-
* transport delivers each decoded reply through the `message` event. Server bridges
|
|
2887
|
-
* use the same carrier for bidirectional WebSocket and stdio channels. The minimal surface is a
|
|
2888
|
-
* `start` (open the connection / arm any reader), `send` (write one message),
|
|
2889
|
-
* and `close` (tear down). `session` exposes a server-assigned session id once a
|
|
2890
|
-
* stateful transport has one (`undefined` for the stateless v1) — reserved for the
|
|
2891
|
-
* later sessions tier. Concrete transports live in the browser and server environments;
|
|
2892
|
-
* the in-process loopback transport in the tests implements the same contract.
|
|
2893
|
-
*/
|
|
2894
|
-
export declare interface MCPClientTransportInterface {
|
|
2895
|
-
readonly emitter: EmitterInterface<MCPClientTransportEventMap>;
|
|
2896
|
-
/** A server-assigned session id once a stateful transport has one; `undefined` otherwise. */
|
|
2897
|
-
readonly session: string | undefined;
|
|
2898
|
-
/**
|
|
2899
|
-
* Whether this carrier accepts a CLIENT-INITIATED notification — one written with no
|
|
2900
|
-
* `id`, which no response will ever answer.
|
|
2901
|
-
*
|
|
2902
|
-
* @remarks
|
|
2903
|
-
* The transport states it because only the transport knows it, and getting it wrong is
|
|
2904
|
-
* invisible: `send` accepts any {@link JSONRPCMessage}, so a carrier with no
|
|
2905
|
-
* client→server notification channel will happily write one and drop it silently.
|
|
2906
|
-
*
|
|
2907
|
-
* `true` for a genuinely bidirectional channel — a WebSocket, a stdio pipe pair, an
|
|
2908
|
-
* in-process duplex port — where a frame the client writes at any moment reaches the
|
|
2909
|
-
* peer. `false` for a request/response carrier such as Streamable HTTP: the dated
|
|
2910
|
-
* revision defines NO client-to-server notification over it, and the cancellation
|
|
2911
|
-
* signal there is closing the response stream rather than a frame. A `false` carrier
|
|
2912
|
-
* is not a degraded one — it has its own signal — so the client withholds the frame
|
|
2913
|
-
* rather than writing one nothing will read.
|
|
2914
|
-
*/
|
|
2915
|
-
readonly duplex: boolean;
|
|
2916
|
-
/**
|
|
2917
|
-
* Opens the transport — establishes the connection and arms any reply reader.
|
|
2918
|
-
*
|
|
2919
|
-
* @remarks
|
|
2920
|
-
* A `start` that REJECTS must first release whatever it had already acquired. The
|
|
2921
|
-
* {@link MCPClientInterface} claims a connection only once `start` resolves, so a rejection
|
|
2922
|
-
* leaves it holding an error and no claim: a socket, session, or reader the transport opened
|
|
2923
|
-
* before failing is reachable by nothing the client can call, and no client-side mechanism can
|
|
2924
|
-
* be added that would reach it.
|
|
2925
|
-
*
|
|
2926
|
-
* @returns Resolves once the transport is ready to `send`
|
|
2927
|
-
*/
|
|
2928
|
-
start(): Promise<void>;
|
|
2929
|
-
/**
|
|
2930
|
-
* Sends one JSON-RPC message to the remote server.
|
|
2931
|
-
*
|
|
2932
|
-
* @remarks
|
|
2933
|
-
* Each decoded reply is surfaced on the `emitter`'s `message` event — `send`
|
|
2934
|
-
* itself resolves once the message has been written (and, for a request/response
|
|
2935
|
-
* transport, its synchronous reply emitted), not when a logical response arrives;
|
|
2936
|
-
* the {@link MCPClientInterface} awaits the response through its `id` correlation.
|
|
2937
|
-
*
|
|
2938
|
-
* A `send` that FAILS must fail by REJECTING, never by throwing synchronously. The
|
|
2939
|
-
* {@link MCPClientInterface} registers the write inside the same promise executor that
|
|
2940
|
-
* records the request's pending entry, so a synchronous throw leaves no promise for that
|
|
2941
|
-
* registration to attach to: the entry set one statement earlier is never settled, and a
|
|
2942
|
-
* later abort writes `notifications/cancelled` naming a request the write never delivered.
|
|
2943
|
-
* An `async send` satisfies this by construction, which is why every transport this package
|
|
2944
|
-
* ships declares one; a non-`async` implementation returns a rejected promise instead of
|
|
2945
|
-
* throwing. The client cannot enforce this from its side — the throw and the write are
|
|
2946
|
-
* indistinguishable to it — so it is stated here, on the contract that owns it.
|
|
2947
|
-
*
|
|
2948
|
-
* A transport whose channel confirms the write rejects on its failure. A transport whose
|
|
2949
|
-
* exchange reports through the emitter resolves. A transport whose channel cannot confirm a
|
|
2950
|
-
* write answers a closed channel from its own state, and each states which in its own
|
|
2951
|
-
* remarks.
|
|
2952
|
-
*
|
|
2953
|
-
* @param message - The message to write to the wire
|
|
2954
|
-
* @returns Resolves once the message has been sent, and rejects — never throws — when the
|
|
2955
|
-
* write fails
|
|
2956
|
-
*/
|
|
2957
|
-
send(message: JSONRPCMessage): Promise<void>;
|
|
2958
|
-
/**
|
|
2959
|
-
* Closes the transport — ends the connection and releases resources.
|
|
2960
|
-
*
|
|
2961
|
-
* @remarks
|
|
2962
|
-
* A `close` must SETTLE, and its settlements mean different things to its caller: resolving
|
|
2963
|
-
* says the connection ended, rejecting says it did not. The
|
|
2964
|
-
* {@link MCPClientInterface}'s only other bound is a deadline, which reports that the shutdown
|
|
2965
|
-
* did not ANSWER and never that it did not happen — so a `close` that resolves or rejects hours
|
|
2966
|
-
* late still decides the outcome, and one that never settles leaves the connection owed for the
|
|
2967
|
-
* client's life. `close` is never called twice concurrently for one connection: a caller that
|
|
2968
|
-
* gave up waiting JOINS the `close` still running rather than issuing another. It IS called
|
|
2969
|
-
* again after an earlier `close` REJECTED, because a rejected close ended nothing.
|
|
2970
|
-
*
|
|
2971
|
-
* `close` is IDEMPOTENT: a call on a transport an earlier `close` already ended resolves
|
|
2972
|
-
* without emitting `close` again and without releasing anything a second time. Idempotence
|
|
2973
|
-
* bounds ONE closed lifetime rather than the object — a transport that reopens on `start`
|
|
2974
|
-
* arms itself there, and its next `close` ends that connection and emits once for it.
|
|
2975
|
-
*
|
|
2976
|
-
* @returns Resolves once the transport is closed
|
|
2977
|
-
*/
|
|
2978
|
-
close(): Promise<void>;
|
|
2979
|
-
}
|
|
2980
|
-
|
|
2981
|
-
/** 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. */
|
|
2982
3048
|
export declare interface MCPCompletion {
|
|
2983
3049
|
readonly values: readonly string[];
|
|
2984
3050
|
readonly total?: number;
|
|
2985
3051
|
readonly hasMore?: boolean;
|
|
2986
3052
|
}
|
|
2987
3053
|
|
|
2988
|
-
/**
|
|
3054
|
+
/** Represents the argument fragment being completed. */
|
|
2989
3055
|
export declare interface MCPCompletionArgument {
|
|
2990
3056
|
readonly name: string;
|
|
2991
3057
|
readonly value: string;
|
|
2992
3058
|
}
|
|
2993
3059
|
|
|
2994
|
-
/**
|
|
3060
|
+
/** Holds previously resolved string arguments supplied as completion context. */
|
|
2995
3061
|
export declare interface MCPCompletionContext {
|
|
2996
3062
|
readonly arguments?: Readonly<Record<string, string>>;
|
|
2997
3063
|
}
|
|
2998
3064
|
|
|
2999
3065
|
/**
|
|
3000
|
-
*
|
|
3066
|
+
* Represents the consumer-supplied completion port for prompt and resource-template arguments.
|
|
3001
3067
|
*
|
|
3002
3068
|
* @remarks
|
|
3003
3069
|
* The host owns reference lookup and template-variable knowledge. MCP forwards the reference
|
|
3004
3070
|
* verbatim and performs no template parsing or expansion. Returning `undefined` means the
|
|
3005
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.
|
|
3006
3075
|
*/
|
|
3007
|
-
export declare interface
|
|
3076
|
+
export declare interface MCPCompletionInterface {
|
|
3008
3077
|
/**
|
|
3009
3078
|
* Completes one argument against its host-owned reference.
|
|
3010
3079
|
*
|
|
@@ -3022,20 +3091,20 @@ export declare interface MCPCompletionParams {
|
|
|
3022
3091
|
readonly context?: MCPCompletionContext;
|
|
3023
3092
|
}
|
|
3024
3093
|
|
|
3025
|
-
/**
|
|
3094
|
+
/** Represents the prompt or resource-template reference accepted by `completion/complete`. */
|
|
3026
3095
|
export declare type MCPCompletionReference = MCPPromptReference | MCPResourceTemplateReference;
|
|
3027
3096
|
|
|
3028
|
-
/**
|
|
3097
|
+
/** Represents the complete `completion/complete` result. */
|
|
3029
3098
|
export declare interface MCPCompletionResult {
|
|
3030
3099
|
readonly resultType: 'complete';
|
|
3031
3100
|
readonly completion: MCPCompletion;
|
|
3032
3101
|
readonly _meta?: MCPResultMetaObject;
|
|
3033
3102
|
}
|
|
3034
3103
|
|
|
3035
|
-
/**
|
|
3104
|
+
/** Represents one exact dated-schema tool content block. */
|
|
3036
3105
|
export declare type MCPContent = MCPTextContent | MCPImageContent | MCPAudioContent | MCPResourceLink | MCPEmbeddedResource;
|
|
3037
3106
|
|
|
3038
|
-
/**
|
|
3107
|
+
/** Represents the host-neutral integrity and storage port for opaque MRTR continuation state. */
|
|
3039
3108
|
export declare interface MCPContinuationInterface {
|
|
3040
3109
|
/** Protects a canonical state string and returns the opaque client carrier. */
|
|
3041
3110
|
seal(value: string): Promise<string>;
|
|
@@ -3043,7 +3112,7 @@ export declare interface MCPContinuationInterface {
|
|
|
3043
3112
|
open(value: string): Promise<string | undefined>;
|
|
3044
3113
|
}
|
|
3045
3114
|
|
|
3046
|
-
/**
|
|
3115
|
+
/** Represents the mandatory modern `server/discover` result. */
|
|
3047
3116
|
export declare type MCPDiscoverResult = {
|
|
3048
3117
|
readonly supportedVersions: readonly MCPModernVersion[];
|
|
3049
3118
|
readonly capabilities: MCPServerCapabilities;
|
|
@@ -3055,7 +3124,7 @@ export declare type MCPDiscoverResult = {
|
|
|
3055
3124
|
};
|
|
3056
3125
|
|
|
3057
3126
|
/**
|
|
3058
|
-
*
|
|
3127
|
+
* Represents the minimal transport-facing MCP dispatch surface.
|
|
3059
3128
|
*
|
|
3060
3129
|
* @remarks
|
|
3061
3130
|
* A transport-facing dispatcher needs the resolved message limit and the `dispatch` and
|
|
@@ -3063,9 +3132,9 @@ export declare type MCPDiscoverResult = {
|
|
|
3063
3132
|
* no response channel for a contained transport fault and must report that fault as an event.
|
|
3064
3133
|
*/
|
|
3065
3134
|
export declare interface MCPDispatcherInterface {
|
|
3066
|
-
/**
|
|
3135
|
+
/** Holds the shared server observation surface, including contained transport faults. */
|
|
3067
3136
|
readonly emitter: EmitterInterface<MCPServerEventMap>;
|
|
3068
|
-
/**
|
|
3137
|
+
/** Holds the resolved bounds the dispatcher enforces. */
|
|
3069
3138
|
readonly limit: Required<MCPLimitOptions>;
|
|
3070
3139
|
/**
|
|
3071
3140
|
* Dispatches a parsed JSON-RPC request.
|
|
@@ -3102,7 +3171,7 @@ export declare interface MCPDispatcherInterface {
|
|
|
3102
3171
|
}
|
|
3103
3172
|
|
|
3104
3173
|
/**
|
|
3105
|
-
*
|
|
3174
|
+
* Represents the per-request execution options every dispatched handler receives.
|
|
3106
3175
|
*
|
|
3107
3176
|
* @remarks
|
|
3108
3177
|
* `caller` is consumer-ASSERTED and NEVER VERIFIED. Sessions mint transport identity, not
|
|
@@ -3113,17 +3182,17 @@ export declare interface MCPDispatcherInterface {
|
|
|
3113
3182
|
export declare interface MCPDispatchOptions {
|
|
3114
3183
|
/** Aborts when the bound transport can observe that the caller's request has ended. */
|
|
3115
3184
|
readonly signal?: AbortSignal;
|
|
3116
|
-
/**
|
|
3185
|
+
/** Carries consumer-asserted caller context, forwarded opaquely and never protocol-verified. */
|
|
3117
3186
|
readonly caller?: unknown;
|
|
3118
3187
|
}
|
|
3119
3188
|
|
|
3120
|
-
/**
|
|
3189
|
+
/** Represents one titled value in a form elicitation's single- or multi-select schema. */
|
|
3121
3190
|
export declare interface MCPElicitChoice {
|
|
3122
3191
|
readonly const: string;
|
|
3123
3192
|
readonly title: string;
|
|
3124
3193
|
}
|
|
3125
3194
|
|
|
3126
|
-
/**
|
|
3195
|
+
/** Represents one restricted single-field schema accepted by MCP form-mode elicitation. */
|
|
3127
3196
|
export declare type MCPElicitFieldSchema = {
|
|
3128
3197
|
readonly type: 'boolean';
|
|
3129
3198
|
readonly title?: string;
|
|
@@ -3178,29 +3247,29 @@ export declare type MCPElicitFieldSchema = {
|
|
|
3178
3247
|
};
|
|
3179
3248
|
};
|
|
3180
3249
|
|
|
3181
|
-
/**
|
|
3250
|
+
/** Represents the parameters of a form-mode `elicitation/create` request. */
|
|
3182
3251
|
export declare interface MCPElicitForm {
|
|
3183
3252
|
readonly mode?: 'form';
|
|
3184
3253
|
readonly message: string;
|
|
3185
3254
|
readonly requestedSchema: MCPElicitSchema;
|
|
3186
3255
|
}
|
|
3187
3256
|
|
|
3188
|
-
/**
|
|
3257
|
+
/** Represents the mode-discriminated parameters of an `elicitation/create` request. */
|
|
3189
3258
|
export declare type MCPElicitParams = MCPElicitForm | MCPElicitURL;
|
|
3190
3259
|
|
|
3191
|
-
/**
|
|
3260
|
+
/** Represents an embedded MCP request asking the client to elicit input from its operator. */
|
|
3192
3261
|
export declare interface MCPElicitRequest {
|
|
3193
3262
|
readonly method: 'elicitation/create';
|
|
3194
3263
|
readonly params: MCPElicitParams;
|
|
3195
3264
|
}
|
|
3196
3265
|
|
|
3197
|
-
/**
|
|
3266
|
+
/** Represents the result supplied by a client for one embedded {@link MCPElicitRequest}. */
|
|
3198
3267
|
export declare interface MCPElicitResult {
|
|
3199
3268
|
readonly action: 'accept' | 'decline' | 'cancel';
|
|
3200
3269
|
readonly content?: Readonly<Record<string, MCPElicitValue>>;
|
|
3201
3270
|
}
|
|
3202
3271
|
|
|
3203
|
-
/**
|
|
3272
|
+
/** Represents the restricted top-level object schema in a form-mode elicitation request. */
|
|
3204
3273
|
export declare interface MCPElicitSchema extends Readonly<Record<string, unknown>> {
|
|
3205
3274
|
readonly $schema?: string;
|
|
3206
3275
|
readonly type: 'object';
|
|
@@ -3208,17 +3277,17 @@ export declare interface MCPElicitSchema extends Readonly<Record<string, unknown
|
|
|
3208
3277
|
readonly required?: readonly string[];
|
|
3209
3278
|
}
|
|
3210
3279
|
|
|
3211
|
-
/**
|
|
3280
|
+
/** Represents the parameters of a URL-mode `elicitation/create` request. */
|
|
3212
3281
|
export declare interface MCPElicitURL {
|
|
3213
3282
|
readonly mode: 'url';
|
|
3214
3283
|
readonly message: string;
|
|
3215
3284
|
readonly url: string;
|
|
3216
3285
|
}
|
|
3217
3286
|
|
|
3218
|
-
/**
|
|
3287
|
+
/** Names the primitive value shapes accepted in an MCP form elicitation response. */
|
|
3219
3288
|
export declare type MCPElicitValue = string | number | boolean | readonly string[];
|
|
3220
3289
|
|
|
3221
|
-
/**
|
|
3290
|
+
/** Represents an MCP content block carrying embedded text or blob resource contents. */
|
|
3222
3291
|
export declare interface MCPEmbeddedResource {
|
|
3223
3292
|
readonly type: 'resource';
|
|
3224
3293
|
readonly resource: MCPTextResource | MCPBlobResource;
|
|
@@ -3227,7 +3296,7 @@ export declare interface MCPEmbeddedResource {
|
|
|
3227
3296
|
}
|
|
3228
3297
|
|
|
3229
3298
|
/**
|
|
3230
|
-
*
|
|
3299
|
+
* Names the wire era selected by an MCP request's structure.
|
|
3231
3300
|
*
|
|
3232
3301
|
* @remarks
|
|
3233
3302
|
* `'modern'` and `'legacy'`, and not the boolean such a union would usually be: this is
|
|
@@ -3240,7 +3309,7 @@ export declare interface MCPEmbeddedResource {
|
|
|
3240
3309
|
export declare type MCPEra = 'modern' | 'legacy';
|
|
3241
3310
|
|
|
3242
3311
|
/**
|
|
3243
|
-
*
|
|
3312
|
+
* Preserves a Model Context Protocol error's machine-readable numeric code and
|
|
3244
3313
|
* optional structured context.
|
|
3245
3314
|
*
|
|
3246
3315
|
* @remarks
|
|
@@ -3276,7 +3345,7 @@ export declare class MCPError extends Error {
|
|
|
3276
3345
|
constructor(message: string, code: number, context?: unknown);
|
|
3277
3346
|
}
|
|
3278
3347
|
|
|
3279
|
-
/**
|
|
3348
|
+
/** Represents the explicit, host-neutral context for one modern tool execution. */
|
|
3280
3349
|
export declare interface MCPExecutionContext {
|
|
3281
3350
|
readonly request: JSONRPCRequest;
|
|
3282
3351
|
readonly call: ToolCall;
|
|
@@ -3285,11 +3354,11 @@ export declare interface MCPExecutionContext {
|
|
|
3285
3354
|
readonly progress?: MCPProgressInterface;
|
|
3286
3355
|
}
|
|
3287
3356
|
|
|
3288
|
-
/** Executes one canonical tool call or
|
|
3357
|
+
/** Executes one canonical tool call or returns a fully formed complete MCP result. */
|
|
3289
3358
|
export declare type MCPExecutionHandler = (context: MCPExecutionContext) => ToolResult | MCPCallResult | Promise<ToolResult | MCPCallResult>;
|
|
3290
3359
|
|
|
3291
3360
|
/**
|
|
3292
|
-
*
|
|
3361
|
+
* Represents one `x-mcp-header` projection a tool's `inputSchema` declares.
|
|
3293
3362
|
*
|
|
3294
3363
|
* @remarks
|
|
3295
3364
|
* - `name` — the annotation's own value, appended verbatim to {@link MCP_PARAM_PREFIX} to
|
|
@@ -3306,7 +3375,7 @@ export declare interface MCPHeaderParameter {
|
|
|
3306
3375
|
}
|
|
3307
3376
|
|
|
3308
3377
|
/**
|
|
3309
|
-
*
|
|
3378
|
+
* Names the JSON Schema types an `x-mcp-header` annotation may sit on.
|
|
3310
3379
|
*
|
|
3311
3380
|
* @remarks
|
|
3312
3381
|
* The protocol admits primitives alone, and it splits the JSON Schema number tower: `integer`
|
|
@@ -3316,7 +3385,7 @@ export declare interface MCPHeaderParameter {
|
|
|
3316
3385
|
*/
|
|
3317
3386
|
export declare type MCPHeaderPrimitive = 'boolean' | 'integer' | 'string';
|
|
3318
3387
|
|
|
3319
|
-
/**
|
|
3388
|
+
/** Represents one sized, themed icon associated with an MCP resource link. */
|
|
3320
3389
|
export declare type MCPIcon = MCPMetaObject & {
|
|
3321
3390
|
readonly src: string;
|
|
3322
3391
|
readonly mimeType?: string;
|
|
@@ -3324,7 +3393,7 @@ export declare type MCPIcon = MCPMetaObject & {
|
|
|
3324
3393
|
readonly theme?: 'light' | 'dark';
|
|
3325
3394
|
};
|
|
3326
3395
|
|
|
3327
|
-
/**
|
|
3396
|
+
/** Represents the complete dated identity of an MCP server or client. */
|
|
3328
3397
|
export declare type MCPIdentity = MCPMetaObject & {
|
|
3329
3398
|
readonly name: string;
|
|
3330
3399
|
readonly version: string;
|
|
@@ -3334,7 +3403,7 @@ export declare type MCPIdentity = MCPMetaObject & {
|
|
|
3334
3403
|
readonly icons?: readonly MCPIcon[];
|
|
3335
3404
|
};
|
|
3336
3405
|
|
|
3337
|
-
/**
|
|
3406
|
+
/** Represents a base64-encoded image MCP content block. */
|
|
3338
3407
|
export declare interface MCPImageContent {
|
|
3339
3408
|
readonly type: 'image';
|
|
3340
3409
|
readonly data: string;
|
|
@@ -3343,12 +3412,12 @@ export declare interface MCPImageContent {
|
|
|
3343
3412
|
readonly _meta?: MCPMetaObject;
|
|
3344
3413
|
}
|
|
3345
3414
|
|
|
3346
|
-
/**
|
|
3415
|
+
/** Represents the call-in-hand context supplied to an {@link MCPInputHandler}. */
|
|
3347
3416
|
export declare interface MCPInputContext {
|
|
3348
3417
|
readonly request: JSONRPCRequest;
|
|
3349
3418
|
readonly name: string;
|
|
3350
3419
|
readonly arguments: Readonly<Record<string, unknown>>;
|
|
3351
|
-
/**
|
|
3420
|
+
/** Holds every verified answer to the previous round, under the keys that round assigned. */
|
|
3352
3421
|
readonly responses?: MCPInputResponseMap;
|
|
3353
3422
|
readonly state?: JSONValue;
|
|
3354
3423
|
}
|
|
@@ -3362,11 +3431,13 @@ export declare interface MCPInputContext {
|
|
|
3362
3431
|
*/
|
|
3363
3432
|
export declare type MCPInputHandler = (context: MCPInputContext, options: MCPMethodOptions) => MCPInputRound | undefined | Promise<MCPInputRound | undefined>;
|
|
3364
3433
|
|
|
3365
|
-
/**
|
|
3434
|
+
/** Configures the consumer policy for the server's multi-round-trip input mechanism. */
|
|
3366
3435
|
export declare interface MCPInputOptions {
|
|
3367
|
-
/**
|
|
3436
|
+
/** Holds the host-neutral integrity/storage port for the opaque continuation carrier. */
|
|
3368
3437
|
readonly continuation: MCPContinuationInterface;
|
|
3369
|
-
/**
|
|
3438
|
+
/**
|
|
3439
|
+
* Sets the continuation lifetime in milliseconds; required so MCP never invents an expiry policy.
|
|
3440
|
+
*/
|
|
3370
3441
|
readonly ttl: number;
|
|
3371
3442
|
/** Resolves the authenticated principal for the call in hand. */
|
|
3372
3443
|
readonly principal: MCPPrincipalHandler;
|
|
@@ -3375,7 +3446,7 @@ export declare interface MCPInputOptions {
|
|
|
3375
3446
|
}
|
|
3376
3447
|
|
|
3377
3448
|
/**
|
|
3378
|
-
*
|
|
3449
|
+
* Represents one embedded multi-round-trip request.
|
|
3379
3450
|
*
|
|
3380
3451
|
* @remarks
|
|
3381
3452
|
* A consumer composes any of the three arms into an {@link MCPInputRound}, and this server
|
|
@@ -3392,11 +3463,11 @@ export declare type MCPInputRequest = MCPElicitRequest | {
|
|
|
3392
3463
|
readonly params?: Readonly<Record<string, unknown>>;
|
|
3393
3464
|
};
|
|
3394
3465
|
|
|
3395
|
-
/**
|
|
3466
|
+
/** Represents a consumer-keyed map of embedded requests the client must fulfil. */
|
|
3396
3467
|
export declare type MCPInputRequestMap = Readonly<Record<string, MCPInputRequest>>;
|
|
3397
3468
|
|
|
3398
3469
|
/**
|
|
3399
|
-
*
|
|
3470
|
+
* Represents one client answer to one embedded input request.
|
|
3400
3471
|
*
|
|
3401
3472
|
* @remarks
|
|
3402
3473
|
* The arms are discriminated by their own required members — `action` for an elicitation,
|
|
@@ -3407,11 +3478,12 @@ export declare type MCPInputRequestMap = Readonly<Record<string, MCPInputRequest
|
|
|
3407
3478
|
*/
|
|
3408
3479
|
export declare type MCPInputResponse = MCPElicitResult | MCPSampleResult | MCPRootResult;
|
|
3409
3480
|
|
|
3410
|
-
/**
|
|
3481
|
+
/** Represents a consumer-keyed map of the client's answers to one issued round. */
|
|
3411
3482
|
export declare type MCPInputResponseMap = Readonly<Record<string, MCPInputResponse>>;
|
|
3412
3483
|
|
|
3413
3484
|
/**
|
|
3414
|
-
*
|
|
3485
|
+
* Represents an incomplete modern result carrying input requests, protected request state,
|
|
3486
|
+
* or both.
|
|
3415
3487
|
*
|
|
3416
3488
|
* @remarks
|
|
3417
3489
|
* The union enforces the protocol's at-least-one-of rule at the type boundary:
|
|
@@ -3430,7 +3502,8 @@ export declare type MCPInputResult = {
|
|
|
3430
3502
|
};
|
|
3431
3503
|
|
|
3432
3504
|
/**
|
|
3433
|
-
*
|
|
3505
|
+
* Represents one consumer-composed round of embedded requests, before MCP seals its
|
|
3506
|
+
* continuation state.
|
|
3434
3507
|
*
|
|
3435
3508
|
* @remarks
|
|
3436
3509
|
* The consumer owns the keys and the request kinds, because the keys are how it correlates
|
|
@@ -3444,7 +3517,7 @@ export declare interface MCPInputRound {
|
|
|
3444
3517
|
}
|
|
3445
3518
|
|
|
3446
3519
|
/**
|
|
3447
|
-
*
|
|
3520
|
+
* Represents the integrity-protected payload carried inside an opaque `requestState` token.
|
|
3448
3521
|
*
|
|
3449
3522
|
* @remarks
|
|
3450
3523
|
* `id` is the FIRST round's request id and stays bound across every later round, so a
|
|
@@ -3461,7 +3534,7 @@ export declare interface MCPInputState {
|
|
|
3461
3534
|
readonly id: JSONRPCId;
|
|
3462
3535
|
readonly version: string;
|
|
3463
3536
|
readonly method: string;
|
|
3464
|
-
/**
|
|
3537
|
+
/** Holds the exact round issued under this state, enforced answer by answer on the retry. */
|
|
3465
3538
|
readonly requests: MCPInputRequestMap;
|
|
3466
3539
|
readonly name: string;
|
|
3467
3540
|
readonly digest: string;
|
|
@@ -3470,11 +3543,11 @@ export declare interface MCPInputState {
|
|
|
3470
3543
|
|
|
3471
3544
|
/** Limits applied by {@link isBoundedJSON} to one JSON value. */
|
|
3472
3545
|
export declare interface MCPJSONLimitOptions {
|
|
3473
|
-
/**
|
|
3546
|
+
/** Bounds the serialized UTF-8 bytes. */
|
|
3474
3547
|
readonly bytes: number;
|
|
3475
|
-
/**
|
|
3548
|
+
/** Bounds the total enumerable keys; omitted when bytes alone bound breadth. */
|
|
3476
3549
|
readonly keys?: number;
|
|
3477
|
-
/**
|
|
3550
|
+
/** Bounds the array/object nesting depth. */
|
|
3478
3551
|
readonly depth: number;
|
|
3479
3552
|
}
|
|
3480
3553
|
|
|
@@ -3515,7 +3588,7 @@ export declare class MCPLegacy implements MCPDispatcherInterface {
|
|
|
3515
3588
|
* restores legacy results to modern complete-result shapes before delivery, and bounds retained
|
|
3516
3589
|
* request correlations with the configured deadline.
|
|
3517
3590
|
*/
|
|
3518
|
-
export declare class MCPLegacyClientTransport implements
|
|
3591
|
+
export declare class MCPLegacyClientTransport implements MCPMessageTransportInterface {
|
|
3519
3592
|
#private;
|
|
3520
3593
|
/**
|
|
3521
3594
|
* Creates a legacy client transport adapter.
|
|
@@ -3523,8 +3596,8 @@ export declare class MCPLegacyClientTransport implements MCPClientTransportInter
|
|
|
3523
3596
|
* @param transport - The legacy peer transport
|
|
3524
3597
|
* @param options - The legacy handshake identity, capabilities, revision, and deadline
|
|
3525
3598
|
*/
|
|
3526
|
-
constructor(transport:
|
|
3527
|
-
get emitter(): EmitterInterface<
|
|
3599
|
+
constructor(transport: MCPMessageTransportInterface, options?: MCPLegacyClientTransportOptions);
|
|
3600
|
+
get emitter(): EmitterInterface<MCPMessageTransportEventMap>;
|
|
3528
3601
|
get session(): string | undefined;
|
|
3529
3602
|
get duplex(): boolean;
|
|
3530
3603
|
start(): Promise<void>;
|
|
@@ -3560,26 +3633,26 @@ export declare class MCPLegacyClientTransport implements MCPClientTransportInter
|
|
|
3560
3633
|
* the peer. Do not send unrelated id-`0` traffic through the wrapped transport in that window.
|
|
3561
3634
|
*/
|
|
3562
3635
|
export declare interface MCPLegacyClientTransportOptions {
|
|
3563
|
-
/**
|
|
3636
|
+
/** Holds the client identity sent during the legacy handshake. */
|
|
3564
3637
|
readonly identity?: MCPIdentity;
|
|
3565
|
-
/**
|
|
3638
|
+
/** Holds the client capabilities sent during the legacy handshake. */
|
|
3566
3639
|
readonly capabilities?: MCPClientCapabilities;
|
|
3567
|
-
/**
|
|
3640
|
+
/** Names the exact legacy revision to request and require. */
|
|
3568
3641
|
readonly version?: MCPLegacyVersion;
|
|
3569
|
-
/**
|
|
3642
|
+
/** Sets the legacy handshake and forwarded-request deadline in milliseconds. */
|
|
3570
3643
|
readonly timeout?: number;
|
|
3571
3644
|
}
|
|
3572
3645
|
|
|
3573
|
-
/**
|
|
3646
|
+
/** Represents the construction options for the removable legacy protocol decorator. */
|
|
3574
3647
|
export declare interface MCPLegacyOptions {
|
|
3575
|
-
/**
|
|
3648
|
+
/** Holds the sole dispatcher and execution engine. */
|
|
3576
3649
|
readonly dispatcher: MCPDispatcherInterface;
|
|
3577
|
-
/**
|
|
3650
|
+
/** Holds the identity returned by the legacy `initialize` handshake. */
|
|
3578
3651
|
readonly identity: MCPIdentity;
|
|
3579
3652
|
}
|
|
3580
3653
|
|
|
3581
3654
|
/**
|
|
3582
|
-
*
|
|
3655
|
+
* Represents one legacy-era result — the payload of an answer produced by the fixed legacy
|
|
3583
3656
|
* method switch.
|
|
3584
3657
|
*
|
|
3585
3658
|
* @remarks
|
|
@@ -3593,45 +3666,45 @@ export declare interface MCPLegacyOptions {
|
|
|
3593
3666
|
* This arm exists only for the optional legacy server decorator and client transport adapter.
|
|
3594
3667
|
*/
|
|
3595
3668
|
export declare interface MCPLegacyResult {
|
|
3596
|
-
/**
|
|
3669
|
+
/** Forbids this member; the legacy revision has no result discriminator. */
|
|
3597
3670
|
readonly resultType?: never;
|
|
3598
3671
|
readonly [key: string]: unknown;
|
|
3599
3672
|
}
|
|
3600
3673
|
|
|
3601
|
-
/**
|
|
3674
|
+
/** Names a legacy protocol revision supported by the optional legacy decorators. */
|
|
3602
3675
|
export declare type MCPLegacyVersion = '2025-11-25' | '2025-06-18';
|
|
3603
3676
|
|
|
3604
|
-
/**
|
|
3677
|
+
/** Configures the hostile-input and live-resource bounds for an MCP server. */
|
|
3605
3678
|
export declare interface MCPLimitOptions {
|
|
3606
|
-
/**
|
|
3679
|
+
/** Bounds the UTF-8 bytes accepted by the raw string boundary. */
|
|
3607
3680
|
readonly message?: number;
|
|
3608
|
-
/**
|
|
3681
|
+
/** Bounds the serialized UTF-8 bytes accepted in one `_meta` value. */
|
|
3609
3682
|
readonly metadata?: number;
|
|
3610
3683
|
/**
|
|
3611
|
-
*
|
|
3684
|
+
* Bounds the total enumerable keys accepted in one bounded value: one `_meta` value under
|
|
3612
3685
|
* `metadata`, and one produced tool-call result under `content`.
|
|
3613
3686
|
*/
|
|
3614
3687
|
readonly keys?: number;
|
|
3615
|
-
/**
|
|
3688
|
+
/** Bounds the UTF-8 bytes accepted in one protected `requestState`. */
|
|
3616
3689
|
readonly state?: number;
|
|
3617
|
-
/**
|
|
3690
|
+
/** Bounds the serialized UTF-8 bytes accepted from one complete produced tool-call result. */
|
|
3618
3691
|
readonly content?: number;
|
|
3619
|
-
/**
|
|
3692
|
+
/** Bounds the simultaneously live built-in subscription streams. */
|
|
3620
3693
|
readonly subscriptions?: number;
|
|
3621
|
-
/**
|
|
3694
|
+
/** Bounds the nesting depth accepted by bounded JSON values. */
|
|
3622
3695
|
readonly depth?: number;
|
|
3623
3696
|
}
|
|
3624
3697
|
|
|
3625
|
-
/**
|
|
3698
|
+
/** Configures the per-subscription cancellation and bounded buffering policy. */
|
|
3626
3699
|
export declare interface MCPListenOptions {
|
|
3627
3700
|
/** Aborts the subscription and rejects its pending read with the signal reason. */
|
|
3628
3701
|
readonly signal: AbortSignal;
|
|
3629
|
-
/**
|
|
3702
|
+
/** Bounds the number of delivered frames retained while no read is parked. */
|
|
3630
3703
|
readonly capacity?: number;
|
|
3631
3704
|
}
|
|
3632
3705
|
|
|
3633
3706
|
/**
|
|
3634
|
-
*
|
|
3707
|
+
* Represents the MCP `tools/list` result — tool descriptors plus optional modern result
|
|
3635
3708
|
* stamps.
|
|
3636
3709
|
*
|
|
3637
3710
|
* @remarks
|
|
@@ -3647,11 +3720,138 @@ export declare type MCPListResult = {
|
|
|
3647
3720
|
readonly _meta?: MCPResultMetaObject;
|
|
3648
3721
|
};
|
|
3649
3722
|
|
|
3650
|
-
/**
|
|
3723
|
+
/** Names the dated logging levels accepted by MCP request metadata. */
|
|
3651
3724
|
export declare type MCPLoggingLevel = 'debug' | 'info' | 'notice' | 'warning' | 'error' | 'critical' | 'alert' | 'emergency';
|
|
3652
3725
|
|
|
3653
3726
|
/**
|
|
3654
|
-
*
|
|
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.
|
|
3655
3855
|
*
|
|
3656
3856
|
* @remarks
|
|
3657
3857
|
* The `Object` suffix is not a role suffix from the type table — it NAMES THE SHAPE.
|
|
@@ -3663,7 +3863,7 @@ export declare type MCPLoggingLevel = 'debug' | 'info' | 'notice' | 'warning' |
|
|
|
3663
3863
|
export declare type MCPMetaObject = Readonly<Record<string, JSONValue>>;
|
|
3664
3864
|
|
|
3665
3865
|
/**
|
|
3666
|
-
*
|
|
3866
|
+
* Represents one modern method, registered on the seam that dispatches it.
|
|
3667
3867
|
*
|
|
3668
3868
|
* @remarks
|
|
3669
3869
|
* A registered method answers a {@link JSONRPCRequest} — with a terminating
|
|
@@ -3696,7 +3896,7 @@ export declare type MCPMetaObject = Readonly<Record<string, JSONValue>>;
|
|
|
3696
3896
|
export declare type MCPMethodHandler = (request: JSONRPCRequest, options: MCPMethodOptions) => Promise<JSONRPCResponse | MCPStream>;
|
|
3697
3897
|
|
|
3698
3898
|
/**
|
|
3699
|
-
*
|
|
3899
|
+
* Holds the modern methods an {@link import('./types.js').MCPServerInterface}
|
|
3700
3900
|
* dispatches through — a name-keyed store of {@link MCPMethodHandler}s that owns its
|
|
3701
3901
|
* map rather than exposing one.
|
|
3702
3902
|
*
|
|
@@ -3725,8 +3925,8 @@ export declare class MCPMethodManager implements MCPMethodManagerInterface {
|
|
|
3725
3925
|
}
|
|
3726
3926
|
|
|
3727
3927
|
/**
|
|
3728
|
-
*
|
|
3729
|
-
* 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.
|
|
3730
3930
|
*
|
|
3731
3931
|
* @remarks
|
|
3732
3932
|
* `server/discover`, `tools/list`, `tools/call`, and `subscriptions/listen` are registered here at construction,
|
|
@@ -3754,7 +3954,7 @@ export declare interface MCPMethodManagerInterface {
|
|
|
3754
3954
|
}
|
|
3755
3955
|
|
|
3756
3956
|
/**
|
|
3757
|
-
*
|
|
3957
|
+
* Represents the RESOLVED per-request options one dispatched method receives.
|
|
3758
3958
|
*
|
|
3759
3959
|
* @remarks
|
|
3760
3960
|
* The mirror of {@link MCPDispatchOptions} on the far side of dispatch: a CALLER may
|
|
@@ -3780,15 +3980,15 @@ export declare interface MCPMethodManagerInterface {
|
|
|
3780
3980
|
export declare interface MCPMethodOptions {
|
|
3781
3981
|
/** Aborts when the caller's request ends, or when the answer it produced is finished. */
|
|
3782
3982
|
readonly signal: AbortSignal;
|
|
3783
|
-
/**
|
|
3983
|
+
/** Carries consumer-asserted caller context, forwarded opaquely and never protocol-verified. */
|
|
3784
3984
|
readonly caller?: unknown;
|
|
3785
3985
|
}
|
|
3786
3986
|
|
|
3787
|
-
/**
|
|
3987
|
+
/** Names a modern protocol revision supported by the bare MCP server. */
|
|
3788
3988
|
export declare type MCPModernVersion = '2026-07-28';
|
|
3789
3989
|
|
|
3790
3990
|
/**
|
|
3791
|
-
*
|
|
3991
|
+
* Carries open notification metadata with the dated reserved subscription field.
|
|
3792
3992
|
*
|
|
3793
3993
|
* @remarks
|
|
3794
3994
|
* The subscription id is OPTIONAL here, and that is the schema's own split rather than
|
|
@@ -3801,19 +4001,21 @@ export declare type MCPModernVersion = '2026-07-28';
|
|
|
3801
4001
|
* sits on the terminating result of a stream, so a subscription always exists to name.
|
|
3802
4002
|
*/
|
|
3803
4003
|
export declare type MCPNotificationMetaObject = MCPMetaObject & {
|
|
3804
|
-
/**
|
|
4004
|
+
/**
|
|
4005
|
+
* Holds the JSON-RPC id of the `subscriptions/listen` request whose stream delivered the frame.
|
|
4006
|
+
*/
|
|
3805
4007
|
readonly 'io.modelcontextprotocol/subscriptionId'?: JSONRPCId;
|
|
3806
4008
|
};
|
|
3807
4009
|
|
|
3808
|
-
/**
|
|
4010
|
+
/** Represents the cursor parameters shared by every paginated modern list method. */
|
|
3809
4011
|
export declare interface MCPPaginationParams {
|
|
3810
|
-
/**
|
|
4012
|
+
/** Holds the opaque cursor returned by the preceding page. */
|
|
3811
4013
|
readonly cursor?: string;
|
|
3812
4014
|
}
|
|
3813
4015
|
|
|
3814
|
-
/**
|
|
4016
|
+
/** Represents the cursor result fields shared by every paginated modern list method. */
|
|
3815
4017
|
export declare interface MCPPaginationResult {
|
|
3816
|
-
/**
|
|
4018
|
+
/** Holds the opaque cursor for the following page; absent when this is the final page. */
|
|
3817
4019
|
readonly nextCursor?: string;
|
|
3818
4020
|
}
|
|
3819
4021
|
|
|
@@ -3826,7 +4028,7 @@ export declare interface MCPPaginationResult {
|
|
|
3826
4028
|
*/
|
|
3827
4029
|
export declare type MCPPrincipalHandler = (request: JSONRPCRequest, options: MCPMethodOptions) => string | Promise<string>;
|
|
3828
4030
|
|
|
3829
|
-
/**
|
|
4031
|
+
/** Represents one official request-scoped progress payload. */
|
|
3830
4032
|
export declare interface MCPProgress {
|
|
3831
4033
|
readonly progress: number;
|
|
3832
4034
|
readonly total?: number;
|
|
@@ -3851,14 +4053,43 @@ export declare interface MCPProgress {
|
|
|
3851
4053
|
*/
|
|
3852
4054
|
export declare type MCPProgressHandler = (progress: MCPProgress) => void;
|
|
3853
4055
|
|
|
3854
|
-
/**
|
|
4056
|
+
/**
|
|
4057
|
+
* Reports request-scoped progress under backpressure — the reporter supplied to an explicit
|
|
4058
|
+
* executor.
|
|
4059
|
+
*/
|
|
3855
4060
|
export declare interface MCPProgressInterface {
|
|
3856
4061
|
/** Reports one finite, strictly increasing progress value and awaits its consumption. */
|
|
3857
4062
|
report(progress: MCPProgress): Promise<void>;
|
|
3858
4063
|
}
|
|
3859
4064
|
|
|
3860
4065
|
/**
|
|
3861
|
-
*
|
|
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.
|
|
3862
4093
|
*
|
|
3863
4094
|
* The reporter holds at most one owned progress item. {@link report} applies backpressure until
|
|
3864
4095
|
* {@link take} consumes that slot. It has no replay, queue, concurrent-consumer coordination,
|
|
@@ -3880,7 +4111,7 @@ export declare interface MCPProgressInterface {
|
|
|
3880
4111
|
* reporter.stop()
|
|
3881
4112
|
* ```
|
|
3882
4113
|
*/
|
|
3883
|
-
export declare class MCPProgressReporter implements
|
|
4114
|
+
export declare class MCPProgressReporter implements MCPProgressOwnerInterface {
|
|
3884
4115
|
#private;
|
|
3885
4116
|
/**
|
|
3886
4117
|
* Creates one non-durable progress slot for an active request.
|
|
@@ -3916,7 +4147,7 @@ export declare class MCPProgressReporter implements MCPProgressInterface {
|
|
|
3916
4147
|
stop(): void;
|
|
3917
4148
|
}
|
|
3918
4149
|
|
|
3919
|
-
/**
|
|
4150
|
+
/** Represents one prompt descriptor advertised by `prompts/list`. */
|
|
3920
4151
|
export declare interface MCPPrompt {
|
|
3921
4152
|
readonly name: string;
|
|
3922
4153
|
readonly title?: string;
|
|
@@ -3926,7 +4157,7 @@ export declare interface MCPPrompt {
|
|
|
3926
4157
|
readonly _meta?: MCPMetaObject;
|
|
3927
4158
|
}
|
|
3928
4159
|
|
|
3929
|
-
/**
|
|
4160
|
+
/** Represents one argument descriptor advertised with an MCP prompt. */
|
|
3930
4161
|
export declare interface MCPPromptArgument {
|
|
3931
4162
|
readonly name: string;
|
|
3932
4163
|
readonly title?: string;
|
|
@@ -3942,7 +4173,7 @@ export declare interface MCPPromptGetParams {
|
|
|
3942
4173
|
readonly requestState?: string;
|
|
3943
4174
|
}
|
|
3944
4175
|
|
|
3945
|
-
/**
|
|
4176
|
+
/** Represents the complete, non-cacheable `prompts/get` result. */
|
|
3946
4177
|
export declare interface MCPPromptGetResult {
|
|
3947
4178
|
readonly resultType: 'complete';
|
|
3948
4179
|
readonly description?: string;
|
|
@@ -3950,7 +4181,7 @@ export declare interface MCPPromptGetResult {
|
|
|
3950
4181
|
readonly _meta?: MCPResultMetaObject;
|
|
3951
4182
|
}
|
|
3952
4183
|
|
|
3953
|
-
/**
|
|
4184
|
+
/** Represents the complete cacheable `prompts/list` result. */
|
|
3954
4185
|
export declare type MCPPromptListResult = MCPPromptPage & {
|
|
3955
4186
|
readonly resultType: 'complete';
|
|
3956
4187
|
readonly ttlMs: number;
|
|
@@ -3959,7 +4190,7 @@ export declare type MCPPromptListResult = MCPPromptPage & {
|
|
|
3959
4190
|
};
|
|
3960
4191
|
|
|
3961
4192
|
/**
|
|
3962
|
-
*
|
|
4193
|
+
* Represents the consumer-supplied prompt registry port.
|
|
3963
4194
|
*
|
|
3964
4195
|
* @remarks
|
|
3965
4196
|
* MCP owns no prompt storage. The host projects one shared-cursor page at a time and resolves
|
|
@@ -3984,25 +4215,25 @@ export declare interface MCPPromptManagerInterface {
|
|
|
3984
4215
|
prompt(params: MCPPromptGetParams, options: MCPMethodOptions): MCPPromptGetResult | MCPInputResult | undefined | Promise<MCPPromptGetResult | MCPInputResult | undefined>;
|
|
3985
4216
|
}
|
|
3986
4217
|
|
|
3987
|
-
/**
|
|
4218
|
+
/** Represents one user or assistant message returned by `prompts/get`. */
|
|
3988
4219
|
export declare interface MCPPromptMessage {
|
|
3989
4220
|
readonly role: 'user' | 'assistant';
|
|
3990
4221
|
readonly content: MCPContent;
|
|
3991
4222
|
}
|
|
3992
4223
|
|
|
3993
|
-
/**
|
|
4224
|
+
/** Represents one consumer-owned page projected by `prompts/list`. */
|
|
3994
4225
|
export declare interface MCPPromptPage extends MCPPaginationResult {
|
|
3995
4226
|
readonly prompts: readonly MCPPrompt[];
|
|
3996
4227
|
}
|
|
3997
4228
|
|
|
3998
|
-
/**
|
|
4229
|
+
/** Represents a completion reference to one named prompt. */
|
|
3999
4230
|
export declare interface MCPPromptReference {
|
|
4000
4231
|
readonly type: 'ref/prompt';
|
|
4001
4232
|
readonly name: string;
|
|
4002
4233
|
}
|
|
4003
4234
|
|
|
4004
4235
|
/**
|
|
4005
|
-
*
|
|
4236
|
+
* Represents the validated per-request context projected from a modern request's reserved
|
|
4006
4237
|
* `_meta` keys.
|
|
4007
4238
|
*
|
|
4008
4239
|
* @remarks
|
|
@@ -4039,7 +4270,7 @@ export declare interface MCPRequestContext {
|
|
|
4039
4270
|
*/
|
|
4040
4271
|
export declare type MCPRequestFunction = (method: string, params: Readonly<Record<string, unknown>> | undefined, deadline: number | undefined) => Promise<unknown>;
|
|
4041
4272
|
|
|
4042
|
-
/**
|
|
4273
|
+
/** Represents one resource descriptor advertised by `resources/list`. */
|
|
4043
4274
|
export declare interface MCPResource {
|
|
4044
4275
|
readonly uri: string;
|
|
4045
4276
|
readonly name: string;
|
|
@@ -4053,7 +4284,7 @@ export declare interface MCPResource {
|
|
|
4053
4284
|
}
|
|
4054
4285
|
|
|
4055
4286
|
/**
|
|
4056
|
-
*
|
|
4287
|
+
* Represents the resource contents returned by `resources/read`.
|
|
4057
4288
|
*
|
|
4058
4289
|
* @remarks
|
|
4059
4290
|
* The wire has no tag field. Presence of `text` or `blob` is the structural
|
|
@@ -4065,7 +4296,7 @@ export declare type MCPResourceContents = (MCPTextResource & {
|
|
|
4065
4296
|
readonly text?: never;
|
|
4066
4297
|
});
|
|
4067
4298
|
|
|
4068
|
-
/**
|
|
4299
|
+
/** Represents a link to an MCP resource, including its exact dated-schema metadata. */
|
|
4069
4300
|
export declare interface MCPResourceLink {
|
|
4070
4301
|
readonly type: 'resource_link';
|
|
4071
4302
|
readonly name: string;
|
|
@@ -4079,7 +4310,7 @@ export declare interface MCPResourceLink {
|
|
|
4079
4310
|
readonly _meta?: MCPMetaObject;
|
|
4080
4311
|
}
|
|
4081
4312
|
|
|
4082
|
-
/**
|
|
4313
|
+
/** Represents the complete cacheable `resources/list` result. */
|
|
4083
4314
|
export declare type MCPResourceListResult = MCPResourcePage & {
|
|
4084
4315
|
readonly resultType: 'complete';
|
|
4085
4316
|
readonly ttlMs: number;
|
|
@@ -4088,7 +4319,7 @@ export declare type MCPResourceListResult = MCPResourcePage & {
|
|
|
4088
4319
|
};
|
|
4089
4320
|
|
|
4090
4321
|
/**
|
|
4091
|
-
*
|
|
4322
|
+
* Represents the consumer-supplied resource registry port.
|
|
4092
4323
|
*
|
|
4093
4324
|
* @remarks
|
|
4094
4325
|
* MCP owns no storage. The host may back this port with memory, a workspace, a database,
|
|
@@ -4127,7 +4358,7 @@ export declare interface MCPResourceManagerInterface {
|
|
|
4127
4358
|
templates(pagination: MCPPaginationParams, options: MCPMethodOptions): MCPResourceTemplatePage | Promise<MCPResourceTemplatePage>;
|
|
4128
4359
|
}
|
|
4129
4360
|
|
|
4130
|
-
/**
|
|
4361
|
+
/** Represents one consumer-owned page projected by `resources/list`. */
|
|
4131
4362
|
export declare interface MCPResourcePage extends MCPPaginationResult {
|
|
4132
4363
|
readonly resources: readonly MCPResource[];
|
|
4133
4364
|
}
|
|
@@ -4139,7 +4370,7 @@ export declare interface MCPResourceReadParams {
|
|
|
4139
4370
|
readonly requestState?: string;
|
|
4140
4371
|
}
|
|
4141
4372
|
|
|
4142
|
-
/**
|
|
4373
|
+
/** Represents the complete cacheable `resources/read` result. */
|
|
4143
4374
|
export declare type MCPResourceReadResult = {
|
|
4144
4375
|
readonly contents: readonly MCPResourceContents[];
|
|
4145
4376
|
readonly resultType: 'complete';
|
|
@@ -4148,7 +4379,7 @@ export declare type MCPResourceReadResult = {
|
|
|
4148
4379
|
readonly _meta?: MCPResultMetaObject;
|
|
4149
4380
|
};
|
|
4150
4381
|
|
|
4151
|
-
/**
|
|
4382
|
+
/** Represents one RFC 6570 resource-template descriptor advertised by `resources/templates/list`. */
|
|
4152
4383
|
export declare interface MCPResourceTemplate {
|
|
4153
4384
|
readonly uriTemplate: string;
|
|
4154
4385
|
readonly name: string;
|
|
@@ -4160,7 +4391,7 @@ export declare interface MCPResourceTemplate {
|
|
|
4160
4391
|
readonly _meta?: MCPMetaObject;
|
|
4161
4392
|
}
|
|
4162
4393
|
|
|
4163
|
-
/**
|
|
4394
|
+
/** Represents the complete cacheable `resources/templates/list` result. */
|
|
4164
4395
|
export declare type MCPResourceTemplateListResult = MCPResourceTemplatePage & {
|
|
4165
4396
|
readonly resultType: 'complete';
|
|
4166
4397
|
readonly ttlMs: number;
|
|
@@ -4168,19 +4399,19 @@ export declare type MCPResourceTemplateListResult = MCPResourceTemplatePage & {
|
|
|
4168
4399
|
readonly _meta?: MCPResultMetaObject;
|
|
4169
4400
|
};
|
|
4170
4401
|
|
|
4171
|
-
/**
|
|
4402
|
+
/** Represents one consumer-owned page projected by `resources/templates/list`. */
|
|
4172
4403
|
export declare interface MCPResourceTemplatePage extends MCPPaginationResult {
|
|
4173
4404
|
readonly resourceTemplates: readonly MCPResourceTemplate[];
|
|
4174
4405
|
}
|
|
4175
4406
|
|
|
4176
|
-
/**
|
|
4407
|
+
/** Represents a completion reference to one resource-template URI descriptor. */
|
|
4177
4408
|
export declare interface MCPResourceTemplateReference {
|
|
4178
4409
|
readonly type: 'ref/resource';
|
|
4179
4410
|
readonly uri: string;
|
|
4180
4411
|
}
|
|
4181
4412
|
|
|
4182
4413
|
/**
|
|
4183
|
-
*
|
|
4414
|
+
* Represents one modern MCP result — the open contract every dated-revision result satisfies.
|
|
4184
4415
|
*
|
|
4185
4416
|
* @remarks
|
|
4186
4417
|
* The dated schema requires a `resultType` on EVERY modern result and leaves the
|
|
@@ -4198,36 +4429,38 @@ export declare interface MCPResourceTemplateReference {
|
|
|
4198
4429
|
* answer any registered method through, and nowhere else.
|
|
4199
4430
|
*/
|
|
4200
4431
|
export declare interface MCPResult {
|
|
4201
|
-
/**
|
|
4432
|
+
/**
|
|
4433
|
+
* Names the result's protocol discriminator (`'complete'`, `'input_required'`, or a later value).
|
|
4434
|
+
*/
|
|
4202
4435
|
readonly resultType: string;
|
|
4203
|
-
/**
|
|
4436
|
+
/** Carries open modern protocol metadata, including reserved namespaced keys. */
|
|
4204
4437
|
readonly _meta?: MCPResultMetaObject;
|
|
4205
4438
|
readonly [key: string]: unknown;
|
|
4206
4439
|
}
|
|
4207
4440
|
|
|
4208
|
-
/**
|
|
4441
|
+
/** Carries open result metadata with the dated reserved server identity field. */
|
|
4209
4442
|
export declare type MCPResultMetaObject = MCPMetaObject & {
|
|
4210
4443
|
readonly 'io.modelcontextprotocol/serverInfo'?: MCPIdentity;
|
|
4211
4444
|
};
|
|
4212
4445
|
|
|
4213
|
-
/**
|
|
4446
|
+
/** Names the intended recipient of annotated MCP content. */
|
|
4214
4447
|
export declare type MCPRole = 'user' | 'assistant';
|
|
4215
4448
|
|
|
4216
|
-
/**
|
|
4449
|
+
/** Represents one filesystem root a client exposes to a server. */
|
|
4217
4450
|
export declare interface MCPRoot {
|
|
4218
4451
|
readonly uri: string;
|
|
4219
4452
|
readonly name?: string;
|
|
4220
4453
|
readonly _meta?: MCPMetaObject;
|
|
4221
4454
|
}
|
|
4222
4455
|
|
|
4223
|
-
/**
|
|
4456
|
+
/** Represents the client's answer to one embedded `roots/list` request. */
|
|
4224
4457
|
export declare interface MCPRootResult {
|
|
4225
4458
|
readonly roots: readonly MCPRoot[];
|
|
4226
4459
|
readonly _meta?: MCPMetaObject;
|
|
4227
4460
|
}
|
|
4228
4461
|
|
|
4229
4462
|
/**
|
|
4230
|
-
*
|
|
4463
|
+
* Represents one block a sampling completion may carry.
|
|
4231
4464
|
*
|
|
4232
4465
|
* @remarks
|
|
4233
4466
|
* The dated schema's `SamplingMessageContentBlock`: the text, image, and audio blocks
|
|
@@ -4238,7 +4471,7 @@ export declare interface MCPRootResult {
|
|
|
4238
4471
|
export declare type MCPSampleContent = MCPTextContent | MCPImageContent | MCPAudioContent | MCPToolUseContent | MCPToolResultContent;
|
|
4239
4472
|
|
|
4240
4473
|
/**
|
|
4241
|
-
*
|
|
4474
|
+
* Represents the client's answer to one embedded `sampling/createMessage` request.
|
|
4242
4475
|
*
|
|
4243
4476
|
* @remarks
|
|
4244
4477
|
* `content` is the dated schema's own `anyOf`: one {@link MCPSampleContent} block, or an array
|
|
@@ -4257,8 +4490,8 @@ export declare interface MCPSampleResult {
|
|
|
4257
4490
|
}
|
|
4258
4491
|
|
|
4259
4492
|
/**
|
|
4260
|
-
*
|
|
4261
|
-
*
|
|
4493
|
+
* Dispatches JSON-RPC 2.0 requests over a live {@link ToolManagerInterface}, with NO
|
|
4494
|
+
* transport coupling.
|
|
4262
4495
|
*
|
|
4263
4496
|
* @remarks
|
|
4264
4497
|
* - **`dispatch` and `handle`.** `dispatch(invocation)` runs an already-parsed invocation and
|
|
@@ -4304,7 +4537,7 @@ export declare class MCPServer implements MCPServerInterface {
|
|
|
4304
4537
|
handle(message: string, options?: MCPDispatchOptions): Promise<string | MCPTextStreamControllerInterface | undefined>;
|
|
4305
4538
|
}
|
|
4306
4539
|
|
|
4307
|
-
/**
|
|
4540
|
+
/** Represents the open dated server-capability declaration returned by discovery. */
|
|
4308
4541
|
export declare type MCPServerCapabilities = Readonly<Record<string, MCPMetaObject>> & {
|
|
4309
4542
|
readonly experimental?: Readonly<Record<string, MCPMetaObject>>;
|
|
4310
4543
|
readonly logging?: MCPMetaObject;
|
|
@@ -4323,7 +4556,7 @@ export declare type MCPServerCapabilities = Readonly<Record<string, MCPMetaObjec
|
|
|
4323
4556
|
};
|
|
4324
4557
|
|
|
4325
4558
|
/**
|
|
4326
|
-
*
|
|
4559
|
+
* Represents the push observation surface of an {@link MCPServerInterface} — the
|
|
4327
4560
|
* dispatch moments a fire-and-forget observer (logging, tracing) subscribes to
|
|
4328
4561
|
* through `server.emitter.on`.
|
|
4329
4562
|
*
|
|
@@ -4337,7 +4570,7 @@ export declare type MCPServerCapabilities = Readonly<Record<string, MCPMetaObjec
|
|
|
4337
4570
|
*/
|
|
4338
4571
|
export declare type MCPServerEventMap = {
|
|
4339
4572
|
/**
|
|
4340
|
-
*
|
|
4573
|
+
* Reports that an invocation is being dispatched — its method, correlating id (absent for a
|
|
4341
4574
|
* notification), and structural wire era.
|
|
4342
4575
|
*
|
|
4343
4576
|
* @remarks
|
|
@@ -4359,7 +4592,8 @@ export declare type MCPServerEventMap = {
|
|
|
4359
4592
|
*/
|
|
4360
4593
|
readonly request: readonly [method: string, id: JSONRPCId | undefined, era: MCPEra];
|
|
4361
4594
|
/**
|
|
4362
|
-
*
|
|
4595
|
+
* Reports an operational fault the server CONTAINED — the caught value, exactly once per
|
|
4596
|
+
* fault.
|
|
4363
4597
|
*
|
|
4364
4598
|
* @remarks
|
|
4365
4599
|
* Every fault this server answers with an internal-error response reports here first: a
|
|
@@ -4380,8 +4614,7 @@ export declare type MCPServerEventMap = {
|
|
|
4380
4614
|
};
|
|
4381
4615
|
|
|
4382
4616
|
/**
|
|
4383
|
-
*
|
|
4384
|
-
* modern requests over a live
|
|
4617
|
+
* Dispatches JSON-RPC 2.0 modern requests over a live
|
|
4385
4618
|
* {@link ToolManagerInterface}, with NO transport coupling (a transport layer
|
|
4386
4619
|
* pumps strings through `handle`).
|
|
4387
4620
|
*
|
|
@@ -4410,10 +4643,10 @@ export declare type MCPServerEventMap = {
|
|
|
4410
4643
|
*/
|
|
4411
4644
|
export declare interface MCPServerInterface extends MCPDispatcherInterface {
|
|
4412
4645
|
readonly identity: MCPIdentity;
|
|
4413
|
-
/**
|
|
4646
|
+
/** Holds the modern method registry this server dispatches through (built-ins included). */
|
|
4414
4647
|
readonly methods: MCPMethodManagerInterface;
|
|
4415
4648
|
/**
|
|
4416
|
-
*
|
|
4649
|
+
* Holds the bounds this server actually enforces — every leaf resolved, none optional.
|
|
4417
4650
|
*
|
|
4418
4651
|
* @remarks
|
|
4419
4652
|
* Derived from {@link MCPServerOptions.limit} at construction and stored nowhere else, so
|
|
@@ -4516,19 +4749,21 @@ export declare interface MCPServerInterface extends MCPDispatcherInterface {
|
|
|
4516
4749
|
*/
|
|
4517
4750
|
export declare interface MCPServerOptions {
|
|
4518
4751
|
readonly on?: EmitterHooks<MCPServerEventMap>;
|
|
4519
|
-
/**
|
|
4752
|
+
/** Holds the emitter's listener-error handler — a listener throw routes here, not to a domain event. */
|
|
4520
4753
|
readonly error?: EmitterErrorHandler;
|
|
4521
4754
|
readonly identity: MCPIdentity;
|
|
4522
|
-
/**
|
|
4755
|
+
/** Holds the live tool registry the server exposes over `tools/list` / `tools/call`. */
|
|
4523
4756
|
readonly tools: ToolManagerInterface;
|
|
4524
|
-
/**
|
|
4757
|
+
/**
|
|
4758
|
+
* Holds the optional consumer-owned resource registry exposed over the modern resource methods.
|
|
4759
|
+
*/
|
|
4525
4760
|
readonly resources?: MCPResourceManagerInterface;
|
|
4526
|
-
/**
|
|
4761
|
+
/** Holds the optional consumer-owned prompt registry exposed over the modern prompt methods. */
|
|
4527
4762
|
readonly prompts?: MCPPromptManagerInterface;
|
|
4528
|
-
/**
|
|
4529
|
-
readonly completion?:
|
|
4763
|
+
/** Holds the optional host-owned prompt and resource-template completion provider. */
|
|
4764
|
+
readonly completion?: MCPCompletionInterface;
|
|
4530
4765
|
/**
|
|
4531
|
-
*
|
|
4766
|
+
* Holds the optional explicit execution policy above the canonical live tool registry.
|
|
4532
4767
|
*
|
|
4533
4768
|
* @remarks
|
|
4534
4769
|
* This is also the ONLY way a tool observes cancellation. The default path calls
|
|
@@ -4544,19 +4779,23 @@ export declare interface MCPServerOptions {
|
|
|
4544
4779
|
* whose peer reads that key composes it through `buildModernResult` itself.
|
|
4545
4780
|
*/
|
|
4546
4781
|
readonly execution?: MCPExecutionHandler;
|
|
4547
|
-
/**
|
|
4782
|
+
/** Holds the optional human guidance exposed by `server/discover`. */
|
|
4548
4783
|
readonly instructions?: string;
|
|
4549
|
-
/**
|
|
4784
|
+
/** Holds the modern cache stamps; omitted values use the protocol-safe defaults. */
|
|
4550
4785
|
readonly cache?: {
|
|
4551
4786
|
readonly ttl?: number;
|
|
4552
4787
|
readonly scope?: 'public' | 'private';
|
|
4553
4788
|
};
|
|
4554
|
-
/**
|
|
4789
|
+
/**
|
|
4790
|
+
* Holds the optional multi-round-trip input mechanism; all continuation and expiry policy is
|
|
4791
|
+
* consumer-supplied.
|
|
4792
|
+
*/
|
|
4555
4793
|
readonly input?: MCPInputOptions;
|
|
4556
|
-
/**
|
|
4794
|
+
/** Holds the optional event-driven producer for the modern `subscriptions/listen` method. */
|
|
4557
4795
|
readonly subscription?: MCPSubscriptionOptions;
|
|
4558
4796
|
/**
|
|
4559
|
-
*
|
|
4797
|
+
* Holds the optional Tasks extension; the durable store and the deferral decision are
|
|
4798
|
+
* consumer-supplied.
|
|
4560
4799
|
*
|
|
4561
4800
|
* @remarks
|
|
4562
4801
|
* Omitting it leaves every existing path untouched — nothing is advertised, no call is
|
|
@@ -4564,12 +4803,12 @@ export declare interface MCPServerOptions {
|
|
|
4564
4803
|
* snapshot dated 2026-07-28, so the shape this option admits is fixed.
|
|
4565
4804
|
*/
|
|
4566
4805
|
readonly task?: MCPTaskOptions;
|
|
4567
|
-
/**
|
|
4806
|
+
/** Holds the hostile-input and live-resource bounds; omitted leaves use secure defaults. */
|
|
4568
4807
|
readonly limit?: MCPLimitOptions;
|
|
4569
4808
|
}
|
|
4570
4809
|
|
|
4571
4810
|
/**
|
|
4572
|
-
*
|
|
4811
|
+
* Represents a held-open modern result: each `yield` is a {@link JSONRPCNotification}; the
|
|
4573
4812
|
* `return` value is the terminating response.
|
|
4574
4813
|
*
|
|
4575
4814
|
* @remarks
|
|
@@ -4587,7 +4826,8 @@ export declare interface MCPServerOptions {
|
|
|
4587
4826
|
export declare type MCPStream = AsyncGenerator<JSONRPCNotification, JSONRPCResponse, unknown>;
|
|
4588
4827
|
|
|
4589
4828
|
/**
|
|
4590
|
-
*
|
|
4829
|
+
* Provides the one cancellation engine every modern held-open result leaves `MCPServer`
|
|
4830
|
+
* through.
|
|
4591
4831
|
*
|
|
4592
4832
|
* @remarks
|
|
4593
4833
|
* A native async generator decides cancellation with a QUEUE: `return()` and `throw()` wait
|
|
@@ -4693,8 +4933,8 @@ export declare class MCPStreamController implements MCPStreamControllerInterface
|
|
|
4693
4933
|
}
|
|
4694
4934
|
|
|
4695
4935
|
/**
|
|
4696
|
-
*
|
|
4697
|
-
* 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.
|
|
4698
4938
|
*
|
|
4699
4939
|
* @remarks
|
|
4700
4940
|
* The generator protocol states what a stream yields and says nothing about who ends one,
|
|
@@ -4783,7 +5023,7 @@ export declare interface MCPStreamControllerInterface extends MCPStream {
|
|
|
4783
5023
|
}
|
|
4784
5024
|
|
|
4785
5025
|
/**
|
|
4786
|
-
*
|
|
5026
|
+
* Names the notification families a client may opt in to on a `subscriptions/listen` stream.
|
|
4787
5027
|
*
|
|
4788
5028
|
* @remarks
|
|
4789
5029
|
* Every key here is a WIRE SPELLING, carried verbatim from the dated schema's
|
|
@@ -4837,31 +5077,35 @@ export declare interface MCPSubscriptionFilter {
|
|
|
4837
5077
|
*/
|
|
4838
5078
|
export declare type MCPSubscriptionHandler = (notifications: MCPSubscriptionFilter, options: MCPMethodOptions) => AsyncIterable<JSONRPCNotification> | Promise<AsyncIterable<JSONRPCNotification>>;
|
|
4839
5079
|
|
|
4840
|
-
/**
|
|
5080
|
+
/** Configures the server's built-in `subscriptions/listen` method. */
|
|
4841
5081
|
export declare interface MCPSubscriptionOptions {
|
|
4842
|
-
/**
|
|
5082
|
+
/** Holds the notification filter this server can actually honour. */
|
|
4843
5083
|
readonly notifications: MCPSubscriptionFilter;
|
|
4844
5084
|
/** Opens the producer for one honoured filter. */
|
|
4845
|
-
readonly
|
|
5085
|
+
readonly producer: MCPSubscriptionHandler;
|
|
4846
5086
|
}
|
|
4847
5087
|
|
|
4848
|
-
/**
|
|
5088
|
+
/**
|
|
5089
|
+
* Represents the terminating result returned when a `subscriptions/listen` stream closes
|
|
5090
|
+
* gracefully.
|
|
5091
|
+
*/
|
|
4849
5092
|
export declare type MCPSubscriptionResult = {
|
|
4850
5093
|
readonly resultType: 'complete';
|
|
4851
5094
|
readonly _meta: MCPSubscriptionResultMetaObject;
|
|
4852
5095
|
};
|
|
4853
5096
|
|
|
4854
|
-
/**
|
|
5097
|
+
/** Represents the required metadata on a graceful `subscriptions/listen` result. */
|
|
4855
5098
|
export declare type MCPSubscriptionResultMetaObject = MCPResultMetaObject & {
|
|
4856
|
-
/**
|
|
5099
|
+
/** Holds the JSON-RPC id of the `subscriptions/listen` request whose stream is closing. */
|
|
4857
5100
|
readonly 'io.modelcontextprotocol/subscriptionId': JSONRPCId;
|
|
4858
5101
|
};
|
|
4859
5102
|
|
|
4860
|
-
/**
|
|
5103
|
+
/** Represents a client subscription's owned notifications and graceful terminal result. */
|
|
4861
5104
|
export declare type MCPSubscriptionStream = AsyncGenerator<JSONRPCNotification, MCPSubscriptionResult, unknown>;
|
|
4862
5105
|
|
|
4863
5106
|
/**
|
|
4864
|
-
*
|
|
5107
|
+
* Represents one durable task's wire snapshot — the payload a deferred `tools/call` answers
|
|
5108
|
+
* with.
|
|
4865
5109
|
*
|
|
4866
5110
|
* @remarks
|
|
4867
5111
|
* Every field name here is a WIRE SPELLING carried verbatim from the extension's
|
|
@@ -4874,22 +5118,22 @@ export declare type MCPSubscriptionStream = AsyncGenerator<JSONRPCNotification,
|
|
|
4874
5118
|
* again; a manager that pushes notifications instead simply omits it.
|
|
4875
5119
|
*/
|
|
4876
5120
|
export declare type MCPTask = {
|
|
4877
|
-
/**
|
|
5121
|
+
/** Holds the durable handle a later `tasks/get` / `tasks/update` / `tasks/cancel` names. */
|
|
4878
5122
|
readonly taskId: string;
|
|
4879
5123
|
readonly status: MCPTaskStatus;
|
|
4880
|
-
/**
|
|
5124
|
+
/** Carries optional human-readable detail about the current status. */
|
|
4881
5125
|
readonly statusMessage?: string;
|
|
4882
5126
|
readonly createdAt: string;
|
|
4883
5127
|
readonly lastUpdatedAt: string;
|
|
4884
|
-
/**
|
|
5128
|
+
/** Reports the remaining lifetime in milliseconds, or `null` when the task does not expire. */
|
|
4885
5129
|
readonly ttlMs: number | null;
|
|
4886
|
-
/**
|
|
5130
|
+
/** Suggests the milliseconds between polls; absent when the manager suggests none. */
|
|
4887
5131
|
readonly pollIntervalMs?: number;
|
|
4888
5132
|
};
|
|
4889
5133
|
|
|
4890
5134
|
/**
|
|
4891
|
-
*
|
|
4892
|
-
*
|
|
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
|
|
4893
5137
|
* `tasks`.
|
|
4894
5138
|
*
|
|
4895
5139
|
* @remarks
|
|
@@ -4932,8 +5176,8 @@ export declare class MCPTaskClient implements MCPTaskClientInterface {
|
|
|
4932
5176
|
}
|
|
4933
5177
|
|
|
4934
5178
|
/**
|
|
4935
|
-
*
|
|
4936
|
-
*
|
|
5179
|
+
* Reads, answers, and stops a durable task the peer created — the CLIENT half of the stable
|
|
5180
|
+
* Tasks extension.
|
|
4937
5181
|
*
|
|
4938
5182
|
* @remarks
|
|
4939
5183
|
* The mirror of {@link MCPTaskManagerInterface} minus `start`, because creating a task is
|
|
@@ -5034,7 +5278,7 @@ export declare interface MCPTaskClientInterface {
|
|
|
5034
5278
|
}
|
|
5035
5279
|
|
|
5036
5280
|
/**
|
|
5037
|
-
*
|
|
5281
|
+
* Represents the construction options for an {@link MCPTaskClientInterface}.
|
|
5038
5282
|
*
|
|
5039
5283
|
* @remarks
|
|
5040
5284
|
* `request` is the correlated-request door (see {@link MCPRequestFunction}); an
|
|
@@ -5043,14 +5287,14 @@ export declare interface MCPTaskClientInterface {
|
|
|
5043
5287
|
* to its own calls, stated here because this client does not read the other one's options.
|
|
5044
5288
|
*/
|
|
5045
5289
|
export declare interface MCPTaskClientOptions {
|
|
5046
|
-
/**
|
|
5290
|
+
/** Holds the correlated-request door every task request is issued through. */
|
|
5047
5291
|
readonly request: MCPRequestFunction;
|
|
5048
|
-
/**
|
|
5292
|
+
/** Sets the deadline each task request carries; omitted waits on the peer indefinitely. */
|
|
5049
5293
|
readonly timeout?: number;
|
|
5050
5294
|
}
|
|
5051
5295
|
|
|
5052
5296
|
/**
|
|
5053
|
-
*
|
|
5297
|
+
* Represents the call-in-hand context supplied to an {@link MCPTaskHandler} and to
|
|
5054
5298
|
* {@link MCPTaskManagerInterface.start}.
|
|
5055
5299
|
*
|
|
5056
5300
|
* @remarks
|
|
@@ -5075,8 +5319,8 @@ export declare interface MCPTaskContext {
|
|
|
5075
5319
|
}
|
|
5076
5320
|
|
|
5077
5321
|
/**
|
|
5078
|
-
*
|
|
5079
|
-
* 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.
|
|
5080
5324
|
*
|
|
5081
5325
|
* @remarks
|
|
5082
5326
|
* The union is the schema's own: `input_required` carries the requests to answer,
|
|
@@ -5106,7 +5350,7 @@ export declare type MCPTaskDetail = (MCPTask & {
|
|
|
5106
5350
|
});
|
|
5107
5351
|
|
|
5108
5352
|
/**
|
|
5109
|
-
*
|
|
5353
|
+
* Represents the wire answer to `tasks/get` — one snapshot under the completed-result stamp.
|
|
5110
5354
|
*
|
|
5111
5355
|
* @remarks
|
|
5112
5356
|
* DISTINCT from {@link MCPTaskDetail}, and the distinction is the whole point. A detail is
|
|
@@ -5122,7 +5366,7 @@ export declare type MCPTaskDetail = (MCPTask & {
|
|
|
5122
5366
|
*/
|
|
5123
5367
|
export declare type MCPTaskDetailResult = MCPTaskDetail & {
|
|
5124
5368
|
readonly resultType: 'complete';
|
|
5125
|
-
/**
|
|
5369
|
+
/** Carries open modern protocol metadata, including reserved namespaced keys. */
|
|
5126
5370
|
readonly _meta?: MCPResultMetaObject;
|
|
5127
5371
|
};
|
|
5128
5372
|
|
|
@@ -5154,8 +5398,8 @@ export declare type MCPTaskDetailResult = MCPTaskDetail & {
|
|
|
5154
5398
|
export declare type MCPTaskHandler = (context: MCPTaskContext, options: MCPMethodOptions) => string | undefined | Promise<string | undefined>;
|
|
5155
5399
|
|
|
5156
5400
|
/**
|
|
5157
|
-
*
|
|
5158
|
-
* 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.
|
|
5159
5403
|
*
|
|
5160
5404
|
* @remarks
|
|
5161
5405
|
* There is deliberately NO plural accessor. The extension defines no `tasks/list`, and
|
|
@@ -5174,7 +5418,7 @@ export declare type MCPTaskHandler = (context: MCPTaskContext, options: MCPMetho
|
|
|
5174
5418
|
*/
|
|
5175
5419
|
export declare interface MCPTaskManagerInterface {
|
|
5176
5420
|
/**
|
|
5177
|
-
* Creates — or
|
|
5421
|
+
* Creates — or returns the existing — durable task for one stable operation key.
|
|
5178
5422
|
*
|
|
5179
5423
|
* @remarks
|
|
5180
5424
|
* The obligations this package cannot enforce, and one consequence that is easy
|
|
@@ -5252,8 +5496,22 @@ export declare interface MCPTaskManagerInterface {
|
|
|
5252
5496
|
}
|
|
5253
5497
|
|
|
5254
5498
|
/**
|
|
5255
|
-
*
|
|
5256
|
-
*
|
|
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.
|
|
5257
5515
|
*
|
|
5258
5516
|
* @remarks
|
|
5259
5517
|
* FLAT, and that is the schema's shape rather than a choice: the extension types these
|
|
@@ -5267,13 +5525,13 @@ export declare interface MCPTaskManagerInterface {
|
|
|
5267
5525
|
* {@link MCPNotificationMetaObject}.
|
|
5268
5526
|
*/
|
|
5269
5527
|
export declare type MCPTaskNotificationParams = MCPTaskDetail & {
|
|
5270
|
-
/**
|
|
5528
|
+
/** Carries open notification metadata, including the reserved subscription stamp. */
|
|
5271
5529
|
readonly _meta?: MCPNotificationMetaObject;
|
|
5272
5530
|
readonly [key: string]: unknown;
|
|
5273
5531
|
};
|
|
5274
5532
|
|
|
5275
5533
|
/**
|
|
5276
|
-
*
|
|
5534
|
+
* Configures the consumer policy for the server's stable Tasks extension.
|
|
5277
5535
|
*
|
|
5278
5536
|
* @remarks
|
|
5279
5537
|
* Supplying this is what turns the extension on: an unconfigured server advertises
|
|
@@ -5281,14 +5539,14 @@ export declare type MCPTaskNotificationParams = MCPTaskDetail & {
|
|
|
5281
5539
|
* reply from a server that does not implement an optional extension.
|
|
5282
5540
|
*/
|
|
5283
5541
|
export declare interface MCPTaskOptions {
|
|
5284
|
-
/**
|
|
5542
|
+
/** Holds the durable store the server creates tasks in and reads them back from. */
|
|
5285
5543
|
readonly tasks: MCPTaskManagerInterface;
|
|
5286
5544
|
/** Decides whether the call in hand is deferred, and under which stable key. */
|
|
5287
|
-
readonly
|
|
5545
|
+
readonly deferral: MCPTaskHandler;
|
|
5288
5546
|
}
|
|
5289
5547
|
|
|
5290
5548
|
/**
|
|
5291
|
-
*
|
|
5549
|
+
* Represents the modern `tools/call` result announcing that the call became a durable task.
|
|
5292
5550
|
*
|
|
5293
5551
|
* @remarks
|
|
5294
5552
|
* The only result in this package whose `resultType` is `'task'`. It is FLAT — the
|
|
@@ -5298,12 +5556,12 @@ export declare interface MCPTaskOptions {
|
|
|
5298
5556
|
*/
|
|
5299
5557
|
export declare type MCPTaskResult = MCPTask & {
|
|
5300
5558
|
readonly resultType: 'task';
|
|
5301
|
-
/**
|
|
5559
|
+
/** Carries open modern protocol metadata, including reserved namespaced keys. */
|
|
5302
5560
|
readonly _meta?: MCPResultMetaObject;
|
|
5303
5561
|
};
|
|
5304
5562
|
|
|
5305
5563
|
/**
|
|
5306
|
-
*
|
|
5564
|
+
* Names the lifecycle state of one durable task.
|
|
5307
5565
|
*
|
|
5308
5566
|
* @remarks
|
|
5309
5567
|
* `completed`, `failed`, and `cancelled` are TERMINAL: a task that reaches one never
|
|
@@ -5320,7 +5578,7 @@ export declare type MCPTaskResult = MCPTask & {
|
|
|
5320
5578
|
*/
|
|
5321
5579
|
export declare type MCPTaskStatus = 'working' | 'input_required' | 'completed' | 'failed' | 'cancelled';
|
|
5322
5580
|
|
|
5323
|
-
/**
|
|
5581
|
+
/** Represents a textual MCP content block. */
|
|
5324
5582
|
export declare interface MCPTextContent {
|
|
5325
5583
|
readonly type: 'text';
|
|
5326
5584
|
readonly text: string;
|
|
@@ -5328,7 +5586,7 @@ export declare interface MCPTextContent {
|
|
|
5328
5586
|
readonly _meta?: MCPMetaObject;
|
|
5329
5587
|
}
|
|
5330
5588
|
|
|
5331
|
-
/**
|
|
5589
|
+
/** Represents embedded textual resource contents. */
|
|
5332
5590
|
export declare interface MCPTextResource {
|
|
5333
5591
|
readonly uri: string;
|
|
5334
5592
|
readonly mimeType?: string;
|
|
@@ -5336,11 +5594,11 @@ export declare interface MCPTextResource {
|
|
|
5336
5594
|
readonly text: string;
|
|
5337
5595
|
}
|
|
5338
5596
|
|
|
5339
|
-
/**
|
|
5597
|
+
/** Mirrors {@link MCPStream} at the string boundary — the same sequence, already serialized. */
|
|
5340
5598
|
export declare type MCPTextStream = AsyncGenerator<string, string, unknown>;
|
|
5341
5599
|
|
|
5342
5600
|
/**
|
|
5343
|
-
*
|
|
5601
|
+
* Mirrors a controlled held-open result at the string boundary — the same exchange, already
|
|
5344
5602
|
* serialized.
|
|
5345
5603
|
*
|
|
5346
5604
|
* @remarks
|
|
@@ -5440,7 +5698,7 @@ export declare class MCPTextStreamController implements MCPTextStreamControllerI
|
|
|
5440
5698
|
}
|
|
5441
5699
|
|
|
5442
5700
|
/**
|
|
5443
|
-
*
|
|
5701
|
+
* Mirrors {@link MCPStreamControllerInterface} at the string boundary — the same exchange,
|
|
5444
5702
|
* already serialized.
|
|
5445
5703
|
*
|
|
5446
5704
|
* @remarks
|
|
@@ -5514,7 +5772,7 @@ export declare interface MCPTextStreamControllerInterface extends MCPTextStream
|
|
|
5514
5772
|
}
|
|
5515
5773
|
|
|
5516
5774
|
/**
|
|
5517
|
-
*
|
|
5775
|
+
* Represents one entry of the MCP `tools/list` result — a tool's `name`, optional
|
|
5518
5776
|
* `description`, and its JSON-Schema `inputSchema`.
|
|
5519
5777
|
*
|
|
5520
5778
|
* @remarks
|
|
@@ -5528,7 +5786,7 @@ export declare interface MCPToolDescriptor {
|
|
|
5528
5786
|
readonly inputSchema: Readonly<Record<string, unknown>>;
|
|
5529
5787
|
}
|
|
5530
5788
|
|
|
5531
|
-
/**
|
|
5789
|
+
/** Represents one tool's outcome returned to the model, carried in a sampling completion. */
|
|
5532
5790
|
export declare interface MCPToolResultContent {
|
|
5533
5791
|
readonly type: 'tool_result';
|
|
5534
5792
|
readonly toolUseId: string;
|
|
@@ -5538,7 +5796,7 @@ export declare interface MCPToolResultContent {
|
|
|
5538
5796
|
readonly _meta?: MCPMetaObject;
|
|
5539
5797
|
}
|
|
5540
5798
|
|
|
5541
|
-
/**
|
|
5799
|
+
/** Represents a model's request to call one tool, carried inside a sampling completion. */
|
|
5542
5800
|
export declare interface MCPToolUseContent {
|
|
5543
5801
|
readonly type: 'tool_use';
|
|
5544
5802
|
readonly id: string;
|
|
@@ -5548,7 +5806,7 @@ export declare interface MCPToolUseContent {
|
|
|
5548
5806
|
}
|
|
5549
5807
|
|
|
5550
5808
|
/**
|
|
5551
|
-
*
|
|
5809
|
+
* Represents a duplex message channel an environment face provides to the pure engine — the
|
|
5552
5810
|
* one port `bindServer` and `bindClient` (`./helpers.js`) pipe an
|
|
5553
5811
|
* {@link MCPServerInterface} / {@link MCPClientInterface} over.
|
|
5554
5812
|
*
|
|
@@ -5582,7 +5840,7 @@ export declare interface MCPTransportInterface {
|
|
|
5582
5840
|
}
|
|
5583
5841
|
|
|
5584
5842
|
/**
|
|
5585
|
-
*
|
|
5843
|
+
* Represents a `tools/call` result BEFORE the modern stamp — the executed tool's output as
|
|
5586
5844
|
* `content` blocks, with `isError` flagging a tool failure.
|
|
5587
5845
|
*
|
|
5588
5846
|
* @remarks
|
|
@@ -5602,15 +5860,15 @@ export declare interface MCPTransportInterface {
|
|
|
5602
5860
|
*/
|
|
5603
5861
|
export declare type MCPUnstampedCallResult = {
|
|
5604
5862
|
readonly content: readonly MCPContent[];
|
|
5605
|
-
/**
|
|
5863
|
+
/** Holds the successful tool value in its original structure; absent when none was returned. */
|
|
5606
5864
|
readonly structuredContent?: JSONValue;
|
|
5607
|
-
/**
|
|
5865
|
+
/** Flags a failed tool — its error text is in `content`. */
|
|
5608
5866
|
readonly isError?: boolean;
|
|
5609
|
-
/**
|
|
5867
|
+
/** Carries open modern protocol metadata, including reserved namespaced keys. */
|
|
5610
5868
|
readonly _meta?: MCPResultMetaObject;
|
|
5611
5869
|
};
|
|
5612
5870
|
|
|
5613
|
-
/**
|
|
5871
|
+
/** Names a protocol revision supported by an MCP package surface. */
|
|
5614
5872
|
export declare type MCPVersion = MCPModernVersion | MCPLegacyVersion;
|
|
5615
5873
|
|
|
5616
5874
|
/**
|
|
@@ -5751,6 +6009,32 @@ export declare function parseRequestContext(value: unknown, limits?: MCPJSONLimi
|
|
|
5751
6009
|
*/
|
|
5752
6010
|
export declare function readCancelledId(message: JSONRPCMessage): JSONRPCId | undefined;
|
|
5753
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
|
+
|
|
5754
6038
|
/**
|
|
5755
6039
|
* Renders one projected argument as the text its `Mcp-Param-*` header carries.
|
|
5756
6040
|
*
|
|
@@ -5877,14 +6161,17 @@ export declare function snapshotToolResult(value: unknown, limits: MCPJSONLimitO
|
|
|
5877
6161
|
*/
|
|
5878
6162
|
export declare function stampSubscriptionNotification(notification: JSONRPCNotification, id: JSONRPCId): JSONRPCNotification;
|
|
5879
6163
|
|
|
5880
|
-
/**
|
|
6164
|
+
/** Lists the protocol revisions accepted by the optional legacy decorator. */
|
|
5881
6165
|
export declare const SUPPORTED_LEGACY_PROTOCOL_VERSIONS: readonly MCPLegacyVersion[];
|
|
5882
6166
|
|
|
5883
|
-
/**
|
|
6167
|
+
/**
|
|
6168
|
+
* Lists the protocol revisions the `isMCPVersion` guard admits, spanning the modern and legacy
|
|
6169
|
+
* eras.
|
|
6170
|
+
*/
|
|
5884
6171
|
export declare const SUPPORTED_MCP_VERSIONS: readonly MCPVersion[];
|
|
5885
6172
|
|
|
5886
6173
|
/**
|
|
5887
|
-
*
|
|
6174
|
+
* Lists the modern MCP protocol revisions a bare server accepts and advertises.
|
|
5888
6175
|
*
|
|
5889
6176
|
* @remarks
|
|
5890
6177
|
* Frozen in discovery-advertisement order. Legacy revisions are absent because
|
|
@@ -5893,4 +6180,51 @@ export declare const SUPPORTED_MCP_VERSIONS: readonly MCPVersion[];
|
|
|
5893
6180
|
*/
|
|
5894
6181
|
export declare const SUPPORTED_MODERN_PROTOCOL_VERSIONS: readonly MCPModernVersion[];
|
|
5895
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
|
+
|
|
5896
6230
|
export { }
|