@toolgrain/protocol 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2874 @@
1
+ /**
2
+ * @category Common Types
3
+ */
4
+ export type JSONValue = string | number | boolean | null | JSONObject | JSONArray;
5
+ /**
6
+ * @category Common Types
7
+ */
8
+ export type JSONObject = {
9
+ [key: string]: JSONValue;
10
+ };
11
+ /**
12
+ * @category Common Types
13
+ */
14
+ export type JSONArray = JSONValue[];
15
+ /**
16
+ * Refers to any valid JSON-RPC object that can be decoded off the wire, or encoded to be sent.
17
+ *
18
+ * @category JSON-RPC
19
+ */
20
+ export type JSONRPCMessage = JSONRPCRequest | JSONRPCNotification | JSONRPCResponse;
21
+ /** @internal */
22
+ export declare const LATEST_PROTOCOL_VERSION = "2026-07-28";
23
+ /** @internal */
24
+ export declare const JSONRPC_VERSION = "2.0";
25
+ /**
26
+ * Represents the contents of a `_meta` field, which clients and servers use to attach additional metadata to their interactions.
27
+ *
28
+ * Certain key names are reserved by MCP for protocol-level metadata; implementations MUST NOT make assumptions about values at these keys. Additionally, specific schema definitions may reserve particular names for purpose-specific metadata, as declared in those definitions.
29
+ *
30
+ * Valid keys have two segments:
31
+ *
32
+ * **Prefix:**
33
+ * - Optional — if specified, MUST be a series of _labels_ separated by dots (`.`), followed by a slash (`/`).
34
+ * - Labels MUST start with a letter and end with a letter or digit. Interior characters may be letters, digits, or hyphens (`-`).
35
+ * - Implementations SHOULD use reverse DNS notation (e.g., `com.example/` rather than `example.com/`).
36
+ * - Any prefix where the second label is `modelcontextprotocol` or `mcp` is **reserved** for MCP use. For example: `io.modelcontextprotocol/`, `dev.mcp/`, `org.modelcontextprotocol.api/`, and `com.mcp.tools/` are all reserved. However, `com.example.mcp/` is NOT reserved, as the second label is `example`.
37
+ *
38
+ * **Name:**
39
+ * - Unless empty, MUST start and end with an alphanumeric character (`[a-z0-9A-Z]`).
40
+ * - Interior characters may be alphanumeric, hyphens (`-`), underscores (`_`), or dots (`.`).
41
+ *
42
+ * @see [General fields: `_meta`](/specification/2026-07-28/basic/index#meta) for more details.
43
+ * @category Common Types
44
+ */
45
+ export type MetaObject = Record<string, unknown>;
46
+ /**
47
+ * Extends {@link MetaObject} with additional request-specific fields. All key naming rules from `MetaObject` apply.
48
+ *
49
+ * @see {@link MetaObject} for key naming rules and reserved prefixes.
50
+ * @see [General fields: `_meta`](/specification/2026-07-28/basic/index#meta) for more details.
51
+ * @category Common Types
52
+ */
53
+ export interface RequestMetaObject extends MetaObject {
54
+ /**
55
+ * If specified, the caller is requesting out-of-band progress notifications for this request (as represented by {@link ProgressNotification | notifications/progress}). The value of this parameter is an opaque token that will be attached to any subsequent notifications. The receiver is not obligated to provide these notifications.
56
+ */
57
+ progressToken?: ProgressToken;
58
+ /**
59
+ * The MCP Protocol Version being used for this request. Required.
60
+ *
61
+ * For the HTTP transport, this value MUST match the `MCP-Protocol-Version`
62
+ * header; otherwise the server MUST return a `400 Bad Request`. If the
63
+ * server does not support the requested version, it MUST return an
64
+ * {@link UnsupportedProtocolVersionError}.
65
+ */
66
+ "io.modelcontextprotocol/protocolVersion": string;
67
+ /**
68
+ * Identifies the client software making the request. Clients SHOULD
69
+ * include this field on every request unless specifically configured not
70
+ * to do so.
71
+ *
72
+ * The {@link Implementation} schema requires `name` and `version`; other
73
+ * fields are optional.
74
+ *
75
+ * The value is self-reported by the client and is not verified by the
76
+ * protocol. It is intended for display, logging, and debugging. Servers
77
+ * SHOULD NOT use it to change their behavior, and SHOULD NOT rely on it for
78
+ * security decisions.
79
+ */
80
+ "io.modelcontextprotocol/clientInfo"?: Implementation;
81
+ /**
82
+ * The client's capabilities for this specific request. Required.
83
+ *
84
+ * Capabilities are declared per-request rather than once at initialization;
85
+ * an empty object means the client supports no optional capabilities.
86
+ * Servers MUST NOT infer capabilities from prior requests.
87
+ */
88
+ "io.modelcontextprotocol/clientCapabilities": ClientCapabilities;
89
+ /**
90
+ * The desired log level for this request. Optional.
91
+ *
92
+ * If absent, the server MUST NOT send any {@link LoggingMessageNotification | notifications/message}
93
+ * notifications for this request. The client opts in to log messages by
94
+ * explicitly setting a level. Replaces the former `logging/setLevel` RPC.
95
+ *
96
+ * @deprecated Deprecated as of protocol version 2026-07-28 (SEP-2577).
97
+ * Remains in the specification for at least twelve months; see the
98
+ * deprecated features registry.
99
+ */
100
+ "io.modelcontextprotocol/logLevel"?: LoggingLevel;
101
+ }
102
+ /**
103
+ * Extends {@link MetaObject} with additional notification-specific fields. All key naming rules from `MetaObject` apply.
104
+ *
105
+ * @see {@link MetaObject} for key naming rules and reserved prefixes.
106
+ * @see [General fields: `_meta`](/specification/2026-07-28/basic/index#meta) for more details.
107
+ * @category Common Types
108
+ */
109
+ export interface NotificationMetaObject extends MetaObject {
110
+ /**
111
+ * Identifies the subscription stream a notification was delivered on. The
112
+ * server MUST include this key on every notification delivered via a
113
+ * {@link SubscriptionsListenRequest | subscriptions/listen} stream, so the
114
+ * client can correlate the notification with the originating subscription.
115
+ * The key is absent on notifications not delivered via a subscription
116
+ * stream (e.g. progress notifications for an in-flight request), which is
117
+ * why it is optional here.
118
+ *
119
+ * The value is the JSON-RPC ID of the `subscriptions/listen` request that
120
+ * opened the stream.
121
+ */
122
+ "io.modelcontextprotocol/subscriptionId"?: RequestId;
123
+ }
124
+ /**
125
+ * Extends {@link MetaObject} with additional result-specific fields. All key naming rules from `MetaObject` apply.
126
+ *
127
+ * @see {@link MetaObject} for key naming rules and reserved prefixes.
128
+ * @see [General fields: `_meta`](/specification/2026-07-28/basic/index#meta) for more details.
129
+ * @category Common Types
130
+ */
131
+ export interface ResultMetaObject extends MetaObject {
132
+ /**
133
+ * Identifies the server software producing the response. Servers SHOULD
134
+ * include this field on every response unless specifically configured not
135
+ * to do so.
136
+ *
137
+ * The {@link Implementation} schema requires `name` and `version`; other
138
+ * fields are optional.
139
+ *
140
+ * The value is self-reported by the server and is not verified by the
141
+ * protocol. It is intended for display, logging, and debugging. Clients
142
+ * SHOULD NOT use it to change their behavior, and SHOULD NOT rely on it for
143
+ * security decisions.
144
+ */
145
+ "io.modelcontextprotocol/serverInfo"?: Implementation;
146
+ }
147
+ /**
148
+ * A progress token, used to associate progress notifications with the original request.
149
+ *
150
+ * @category Common Types
151
+ */
152
+ export type ProgressToken = string | number;
153
+ /**
154
+ * An opaque token used to represent a cursor for pagination.
155
+ *
156
+ * @category Common Types
157
+ */
158
+ export type Cursor = string;
159
+ /**
160
+ * Common params for any request.
161
+ *
162
+ * @category Common Types
163
+ */
164
+ export interface RequestParams {
165
+ _meta: RequestMetaObject;
166
+ }
167
+ /** @internal */
168
+ export interface Request {
169
+ method: string;
170
+ params?: {
171
+ [key: string]: any;
172
+ };
173
+ }
174
+ /**
175
+ * Common params for any notification.
176
+ *
177
+ * @category Common Types
178
+ */
179
+ export interface NotificationParams {
180
+ _meta?: NotificationMetaObject;
181
+ }
182
+ /** @internal */
183
+ export interface Notification {
184
+ method: string;
185
+ params?: {
186
+ [key: string]: any;
187
+ };
188
+ }
189
+ /**
190
+ * Indicates the type of a {@link Result} object, allowing the client to
191
+ * determine how to parse the response.
192
+ *
193
+ * complete - the request completed successfully and the result contains the final content.
194
+ * input_required - the request requires additional input and the result contains an {@link InputRequiredResult} object with instructions for the client to provide additional input before retrying the original request.
195
+ * @category Common Types
196
+ */
197
+ export type ResultType = "complete" | "input_required" | string;
198
+ /**
199
+ * Common result fields.
200
+ *
201
+ * @category Common Types
202
+ */
203
+ export interface Result {
204
+ _meta?: ResultMetaObject;
205
+ /**
206
+ * Indicates the type of the result, which allows the client to determine
207
+ * how to parse the result object.
208
+ *
209
+ * Servers implementing this protocol version MUST include this field.
210
+ * For backward compatibility, when a client receives a result from a
211
+ * server implementing an earlier protocol version (which does not include
212
+ * `resultType`), the client MUST treat the absent field as `"complete"`.
213
+ */
214
+ resultType: ResultType;
215
+ [key: string]: unknown;
216
+ }
217
+ /**
218
+ * @category Errors
219
+ */
220
+ export interface Error {
221
+ /**
222
+ * The error type that occurred.
223
+ */
224
+ code: number;
225
+ /**
226
+ * A short description of the error. The message SHOULD be limited to a concise single sentence.
227
+ */
228
+ message: string;
229
+ /**
230
+ * Additional information about the error. The value of this member is defined by the sender (e.g. detailed error information, nested errors etc.).
231
+ */
232
+ data?: unknown;
233
+ }
234
+ /**
235
+ * A uniquely identifying ID for a request in JSON-RPC.
236
+ *
237
+ * @category Common Types
238
+ */
239
+ export type RequestId = string | number;
240
+ /**
241
+ * A request that expects a response.
242
+ *
243
+ * @category JSON-RPC
244
+ */
245
+ export interface JSONRPCRequest extends Request {
246
+ jsonrpc: typeof JSONRPC_VERSION;
247
+ id: RequestId;
248
+ }
249
+ /**
250
+ * A notification which does not expect a response.
251
+ *
252
+ * @category JSON-RPC
253
+ */
254
+ export interface JSONRPCNotification extends Notification {
255
+ jsonrpc: typeof JSONRPC_VERSION;
256
+ }
257
+ /**
258
+ * A successful (non-error) response to a request.
259
+ *
260
+ * @category JSON-RPC
261
+ */
262
+ export interface JSONRPCResultResponse {
263
+ jsonrpc: typeof JSONRPC_VERSION;
264
+ id: RequestId;
265
+ result: Result;
266
+ }
267
+ /**
268
+ * A response to a request that indicates an error occurred.
269
+ *
270
+ * @category JSON-RPC
271
+ */
272
+ export interface JSONRPCErrorResponse {
273
+ jsonrpc: typeof JSONRPC_VERSION;
274
+ id?: RequestId;
275
+ error: Error;
276
+ }
277
+ /**
278
+ * A response to a request, containing either the result or error.
279
+ *
280
+ * @category JSON-RPC
281
+ */
282
+ export type JSONRPCResponse = JSONRPCResultResponse | JSONRPCErrorResponse;
283
+ export declare const PARSE_ERROR = -32700;
284
+ export declare const INVALID_REQUEST = -32600;
285
+ export declare const METHOD_NOT_FOUND = -32601;
286
+ export declare const INVALID_PARAMS = -32602;
287
+ export declare const INTERNAL_ERROR = -32603;
288
+ /**
289
+ * A JSON-RPC error indicating that invalid JSON was received by the server. This error is returned when the server cannot parse the JSON text of a message.
290
+ *
291
+ * @see {@link https://www.jsonrpc.org/specification#error_object | JSON-RPC 2.0 Error Object}
292
+ *
293
+ * @example Invalid JSON
294
+ * {@includeCode ./examples/ParseError/invalid-json.json}
295
+ *
296
+ * @category Errors
297
+ */
298
+ export interface ParseError extends Error {
299
+ code: typeof PARSE_ERROR;
300
+ }
301
+ /**
302
+ * A JSON-RPC error indicating that the request is not a valid request object. This error is returned when the message structure does not conform to the JSON-RPC 2.0 specification requirements for a request (e.g., missing required fields like `jsonrpc` or `method`, or using invalid types for these fields).
303
+ *
304
+ * @see {@link https://www.jsonrpc.org/specification#error_object | JSON-RPC 2.0 Error Object}
305
+ *
306
+ * @category Errors
307
+ */
308
+ export interface InvalidRequestError extends Error {
309
+ code: typeof INVALID_REQUEST;
310
+ }
311
+ /**
312
+ * A JSON-RPC error indicating that the requested method does not exist or is not available.
313
+ *
314
+ * In MCP, a server returns this error when a client invokes a method the server does not implement — either a genuinely unknown method, or one gated behind a server capability the server did not advertise (e.g., calling `prompts/list` when the `prompts` capability was not advertised).
315
+ *
316
+ * A request that requires a client capability the client did not declare is signalled instead by {@link MissingRequiredClientCapabilityError} (`-32021`).
317
+ *
318
+ * @see {@link https://www.jsonrpc.org/specification#error_object | JSON-RPC 2.0 Error Object}
319
+ *
320
+ * @example Prompts not supported
321
+ * {@includeCode ./examples/MethodNotFoundError/prompts-not-supported.json}
322
+ *
323
+ * @category Errors
324
+ */
325
+ export interface MethodNotFoundError extends Error {
326
+ code: typeof METHOD_NOT_FOUND;
327
+ }
328
+ /**
329
+ * A JSON-RPC error indicating that the method parameters are invalid or malformed.
330
+ *
331
+ * In MCP, this error is returned in various contexts when request parameters fail validation:
332
+ *
333
+ * - **Tools**: Unknown tool name or invalid tool arguments
334
+ * - **Prompts**: Unknown prompt name or missing required arguments
335
+ * - **Pagination**: Invalid or expired cursor values
336
+ * - **Logging**: Invalid log level
337
+ * - **Elicitation**: Server requests an elicitation mode not declared in client capabilities
338
+ * - **Sampling**: Missing tool result or tool results mixed with other content
339
+ *
340
+ * @see {@link https://www.jsonrpc.org/specification#error_object | JSON-RPC 2.0 Error Object}
341
+ *
342
+ * @example Unknown tool
343
+ * {@includeCode ./examples/InvalidParamsError/unknown-tool.json}
344
+ *
345
+ * @example Invalid tool arguments
346
+ * {@includeCode ./examples/InvalidParamsError/invalid-tool-arguments.json}
347
+ *
348
+ * @example Unknown prompt
349
+ * {@includeCode ./examples/InvalidParamsError/unknown-prompt.json}
350
+ *
351
+ * @example Invalid cursor
352
+ * {@includeCode ./examples/InvalidParamsError/invalid-cursor.json}
353
+ *
354
+ * @category Errors
355
+ */
356
+ export interface InvalidParamsError extends Error {
357
+ code: typeof INVALID_PARAMS;
358
+ }
359
+ /**
360
+ * A JSON-RPC error indicating that an internal error occurred on the receiver. This error is returned when the receiver encounters an unexpected condition that prevents it from fulfilling the request.
361
+ *
362
+ * @see {@link https://www.jsonrpc.org/specification#error_object | JSON-RPC 2.0 Error Object}
363
+ *
364
+ * @example Unexpected error
365
+ * {@includeCode ./examples/InternalError/unexpected-error.json}
366
+ *
367
+ * @category Errors
368
+ */
369
+ export interface InternalError extends Error {
370
+ code: typeof INTERNAL_ERROR;
371
+ }
372
+ /**
373
+ * Error code returned when the HTTP headers of a request do not match the
374
+ * corresponding values in the request body, or required headers are
375
+ * missing or malformed.
376
+ *
377
+ * @category Errors
378
+ */
379
+ export declare const HEADER_MISMATCH = -32020;
380
+ /**
381
+ * Error code returned when a server requires a client capability that was
382
+ * not declared in the request's `clientCapabilities`.
383
+ *
384
+ * @category Errors
385
+ */
386
+ export declare const MISSING_REQUIRED_CLIENT_CAPABILITY = -32021;
387
+ /**
388
+ * Error code returned when the request's protocol version is not supported
389
+ * by the server.
390
+ *
391
+ * @category Errors
392
+ */
393
+ export declare const UNSUPPORTED_PROTOCOL_VERSION = -32022;
394
+ /**
395
+ * Returned when a server rejects a request because the values in the HTTP
396
+ * headers do not match the corresponding values in the request body, or
397
+ * because required headers are missing or malformed. For HTTP, the response
398
+ * status code MUST be `400 Bad Request`.
399
+ *
400
+ * @example Header mismatch
401
+ * {@includeCode ./examples/HeaderMismatchError/header-mismatch.json}
402
+ *
403
+ * @category Errors
404
+ */
405
+ export interface HeaderMismatchError extends Omit<JSONRPCErrorResponse, "error"> {
406
+ error: Error & {
407
+ code: typeof HEADER_MISMATCH;
408
+ };
409
+ }
410
+ /**
411
+ * Returned when the request's protocol version is unknown to the server or
412
+ * unsupported (e.g., a known experimental or draft version the server has
413
+ * chosen not to implement). For HTTP, the response status code MUST be
414
+ * `400 Bad Request`.
415
+ *
416
+ * @example Unsupported protocol version
417
+ * {@includeCode ./examples/UnsupportedProtocolVersionError/unsupported-version.json}
418
+ *
419
+ * @category Errors
420
+ */
421
+ export interface UnsupportedProtocolVersionError extends Omit<JSONRPCErrorResponse, "error"> {
422
+ error: Error & {
423
+ code: typeof UNSUPPORTED_PROTOCOL_VERSION;
424
+ data: {
425
+ /**
426
+ * Protocol versions the server supports. The client should choose a
427
+ * mutually supported version from this list and retry.
428
+ */
429
+ supported: string[];
430
+ /**
431
+ * The protocol version that was requested by the client.
432
+ */
433
+ requested: string;
434
+ };
435
+ };
436
+ }
437
+ /**
438
+ * Returned when processing a request requires a capability the client did not
439
+ * declare in `clientCapabilities`. For HTTP, the response status code MUST be
440
+ * `400 Bad Request`.
441
+ *
442
+ * @example Missing elicitation capability
443
+ * {@includeCode ./examples/MissingRequiredClientCapabilityError/missing-elicitation-capability.json}
444
+ *
445
+ * @category Errors
446
+ */
447
+ export interface MissingRequiredClientCapabilityError extends Omit<JSONRPCErrorResponse, "error"> {
448
+ error: Error & {
449
+ code: typeof MISSING_REQUIRED_CLIENT_CAPABILITY;
450
+ data: {
451
+ /**
452
+ * The capabilities the server requires from the client to process this request.
453
+ */
454
+ requiredCapabilities: ClientCapabilities;
455
+ };
456
+ };
457
+ }
458
+ /**
459
+ * A result that indicates success but carries no data.
460
+ *
461
+ * @category Common Types
462
+ */
463
+ export type EmptyResult = Result;
464
+ /** @internal */
465
+ export type InputRequest = CreateMessageRequest | ListRootsRequest | ElicitRequest;
466
+ /** @internal */
467
+ export type InputResponse = CreateMessageResult | ListRootsResult | ElicitResult;
468
+ /**
469
+ * A map of server-initiated requests that the client must fulfill.
470
+ * Keys are server-assigned identifiers; values are the request objects.
471
+ *
472
+ * @example Elicitation and sampling input requests
473
+ * {@includeCode ./examples/InputRequests/elicitation-and-sampling-input-requests.json}
474
+ *
475
+ * @category Multi Round-Trip
476
+ */
477
+ export interface InputRequests {
478
+ [key: string]: InputRequest;
479
+ }
480
+ /**
481
+ * A map of client responses to server-initiated requests.
482
+ * Keys correspond to the keys in the {@link InputRequests} map;
483
+ * values are the client's result for each request.
484
+ *
485
+ * @example Elicitation and sampling input responses
486
+ * {@includeCode ./examples/InputResponses/elicitation-and-sampling-input-responses.json}
487
+ *
488
+ * @category Multi Round-Trip
489
+ */
490
+ export interface InputResponses {
491
+ [key: string]: InputResponse;
492
+ }
493
+ /**
494
+ * An InputRequiredResult sent by the server to indicate that additional input is needed
495
+ * before the request can be completed.
496
+ *
497
+ * At least one of `inputRequests` or `requestState` MUST be present.
498
+ * @example InputRequiredResult with elicitation and sampling input requests and request state
499
+ * {@includeCode ./examples/InputRequiredResult/input-required-result-with-elicitation-and-sampling-and-request-state.json}
500
+ *
501
+ * @example InputRequiredResult with request state only (load shedding)
502
+ * {@includeCode ./examples/InputRequiredResult/input-required-result-with-request-state-only.json}
503
+ *
504
+ * @category Multi Round-Trip
505
+ */
506
+ export interface InputRequiredResult extends Result {
507
+ inputRequests?: InputRequests;
508
+ requestState?: string;
509
+ }
510
+ export interface InputResponseRequestParams extends RequestParams {
511
+ inputResponses?: InputResponses;
512
+ requestState?: string;
513
+ }
514
+ /**
515
+ * Parameters for a `notifications/cancelled` notification.
516
+ *
517
+ * @example User-requested cancellation
518
+ * {@includeCode ./examples/CancelledNotificationParams/user-requested-cancellation.json}
519
+ *
520
+ * @category `notifications/cancelled`
521
+ */
522
+ export interface CancelledNotificationParams extends NotificationParams {
523
+ /**
524
+ * The ID of the request to cancel.
525
+ *
526
+ * This MUST correspond to the ID of a request the client previously issued.
527
+ */
528
+ requestId: RequestId;
529
+ /**
530
+ * An optional string describing the reason for the cancellation. This MAY be logged or presented to the user.
531
+ */
532
+ reason?: string;
533
+ }
534
+ /**
535
+ * This notification is sent by the client to indicate that it is cancelling a request it previously issued.
536
+ *
537
+ * On stdio, the server also sends this notification, solely to terminate a {@link SubscriptionsListenRequest | subscriptions/listen} stream: it references the ID of the `subscriptions/listen` request that opened the stream. Servers MUST NOT use this notification to cancel any other request.
538
+ *
539
+ * The request SHOULD still be in-flight, but due to communication latency, it is always possible that this notification MAY arrive after the request has already finished.
540
+ *
541
+ * This notification indicates that the result will be unused, so any associated processing SHOULD cease.
542
+ *
543
+ * @example User-requested cancellation
544
+ * {@includeCode ./examples/CancelledNotification/user-requested-cancellation.json}
545
+ *
546
+ * @category `notifications/cancelled`
547
+ */
548
+ export interface CancelledNotification extends JSONRPCNotification {
549
+ method: "notifications/cancelled";
550
+ params: CancelledNotificationParams;
551
+ }
552
+ /**
553
+ * A request from the client asking the server to advertise its supported
554
+ * protocol versions, capabilities, and other metadata. Servers **MUST**
555
+ * implement `server/discover`. Clients **MAY** call it but are not required
556
+ * to — version negotiation can also happen inline via per-request `_meta`.
557
+ *
558
+ * @example Discover request
559
+ * {@includeCode ./examples/DiscoverRequest/server-discover-request.json}
560
+ *
561
+ * @category `server/discover`
562
+ */
563
+ export interface DiscoverRequest extends JSONRPCRequest {
564
+ method: "server/discover";
565
+ params: RequestParams;
566
+ }
567
+ /**
568
+ * The result returned by the server for a {@link DiscoverRequest | server/discover} request.
569
+ *
570
+ * @example Server capabilities discovery
571
+ * {@includeCode ./examples/DiscoverResult/server-capabilities-discovery.json}
572
+ *
573
+ * @category `server/discover`
574
+ */
575
+ export interface DiscoverResult extends CacheableResult {
576
+ /**
577
+ * MCP Protocol Versions this server supports. The client should choose a
578
+ * version from this list for use in subsequent requests.
579
+ */
580
+ supportedVersions: string[];
581
+ /**
582
+ * The capabilities of the server.
583
+ */
584
+ capabilities: ServerCapabilities;
585
+ /**
586
+ * Natural-language guidance describing the server and its features.
587
+ *
588
+ * This can be used by clients to improve an LLM's understanding of
589
+ * available tools (e.g., by including it in a system prompt). It should
590
+ * focus on information that helps the model use the server effectively
591
+ * and should not duplicate information already in tool descriptions.
592
+ */
593
+ instructions?: string;
594
+ }
595
+ /**
596
+ * A successful response from the server for a {@link DiscoverRequest | server/discover} request.
597
+ *
598
+ * @example Discover result response
599
+ * {@includeCode ./examples/DiscoverResultResponse/discover-result-response.json}
600
+ *
601
+ * @category `server/discover`
602
+ */
603
+ export interface DiscoverResultResponse extends JSONRPCResultResponse {
604
+ result: DiscoverResult;
605
+ }
606
+ /**
607
+ * Capabilities a client may support. Known capabilities are defined here, in this schema, but this is not a closed set: any client can define its own, additional capabilities.
608
+ *
609
+ * @category `server/discover`
610
+ */
611
+ export interface ClientCapabilities {
612
+ /**
613
+ * Experimental, non-standard capabilities that the client supports.
614
+ */
615
+ experimental?: {
616
+ [key: string]: JSONObject;
617
+ };
618
+ /**
619
+ * Present if the client supports listing roots.
620
+ *
621
+ * @deprecated Deprecated as of protocol version 2026-07-28 (SEP-2577).
622
+ * Remains in the specification for at least twelve months; see the
623
+ * deprecated features registry.
624
+ *
625
+ * @example Roots — minimum baseline support
626
+ * {@includeCode ./examples/ClientCapabilities/roots-minimum-baseline-support.json}
627
+ */
628
+ roots?: {};
629
+ /**
630
+ * Present if the client supports sampling from an LLM.
631
+ *
632
+ * @deprecated Deprecated as of protocol version 2026-07-28 (SEP-2577).
633
+ * Remains in the specification for at least twelve months; see the
634
+ * deprecated features registry.
635
+ *
636
+ * @example Sampling — minimum baseline support
637
+ * {@includeCode ./examples/ClientCapabilities/sampling-minimum-baseline-support.json}
638
+ *
639
+ * @example Sampling — tool use support
640
+ * {@includeCode ./examples/ClientCapabilities/sampling-tool-use-support.json}
641
+ *
642
+ * @example Sampling — context inclusion support (deprecated)
643
+ * {@includeCode ./examples/ClientCapabilities/sampling-context-inclusion-support-deprecated.json}
644
+ */
645
+ sampling?: {
646
+ /**
647
+ * Whether the client supports context inclusion via `includeContext` parameter.
648
+ * If not declared, servers SHOULD only use `includeContext: "none"` (or omit it).
649
+ */
650
+ context?: JSONObject;
651
+ /**
652
+ * Whether the client supports tool use via `tools` and `toolChoice` parameters.
653
+ */
654
+ tools?: JSONObject;
655
+ };
656
+ /**
657
+ * Present if the client supports elicitation from the server.
658
+ *
659
+ * @example Elicitation — form and URL mode support
660
+ * {@includeCode ./examples/ClientCapabilities/elicitation-form-and-url-mode-support.json}
661
+ *
662
+ * @example Elicitation — form mode only (implicit)
663
+ * {@includeCode ./examples/ClientCapabilities/elicitation-form-only-implicit.json}
664
+ */
665
+ elicitation?: {
666
+ form?: JSONObject;
667
+ url?: JSONObject;
668
+ };
669
+ /**
670
+ * Optional MCP extensions that the client supports. Keys are extension identifiers
671
+ * (e.g., "io.modelcontextprotocol/oauth-client-credentials"), and values are
672
+ * per-extension settings objects. An empty object indicates support with no settings.
673
+ *
674
+ * Keys MUST follow the {@link MetaObject | `_meta` key naming rules}, with a
675
+ * mandatory prefix.
676
+ *
677
+ * @example Extensions — MCP Apps (UI) extension with MIME type support
678
+ * {@includeCode ./examples/ClientCapabilities/extensions-ui-mime-types.json}
679
+ */
680
+ extensions?: {
681
+ [key: string]: JSONObject;
682
+ };
683
+ }
684
+ /**
685
+ * Capabilities that a server may support. Known capabilities are defined here, in this schema, but this is not a closed set: any server can define its own, additional capabilities.
686
+ *
687
+ * @category `server/discover`
688
+ */
689
+ export interface ServerCapabilities {
690
+ /**
691
+ * Experimental, non-standard capabilities that the server supports.
692
+ */
693
+ experimental?: {
694
+ [key: string]: JSONObject;
695
+ };
696
+ /**
697
+ * Present if the server supports sending log messages to the client.
698
+ *
699
+ * @deprecated Deprecated as of protocol version 2026-07-28 (SEP-2577).
700
+ * Remains in the specification for at least twelve months; see the
701
+ * deprecated features registry.
702
+ *
703
+ * @example Logging — minimum baseline support
704
+ * {@includeCode ./examples/ServerCapabilities/logging-minimum-baseline-support.json}
705
+ */
706
+ logging?: JSONObject;
707
+ /**
708
+ * Present if the server supports argument autocompletion suggestions.
709
+ *
710
+ * @example Completions — minimum baseline support
711
+ * {@includeCode ./examples/ServerCapabilities/completions-minimum-baseline-support.json}
712
+ */
713
+ completions?: JSONObject;
714
+ /**
715
+ * Present if the server offers any prompt templates.
716
+ *
717
+ * @example Prompts — minimum baseline support
718
+ * {@includeCode ./examples/ServerCapabilities/prompts-minimum-baseline-support.json}
719
+ *
720
+ * @example Prompts — list changed notifications
721
+ * {@includeCode ./examples/ServerCapabilities/prompts-list-changed-notifications.json}
722
+ */
723
+ prompts?: {
724
+ /**
725
+ * Whether this server supports notifications for changes to the prompt list.
726
+ */
727
+ listChanged?: boolean;
728
+ };
729
+ /**
730
+ * Present if the server offers any resources to read.
731
+ *
732
+ * @example Resources — minimum baseline support
733
+ * {@includeCode ./examples/ServerCapabilities/resources-minimum-baseline-support.json}
734
+ *
735
+ * @example Resources — subscription to individual resource updates (only)
736
+ * {@includeCode ./examples/ServerCapabilities/resources-subscription-to-individual-resource-updates-only.json}
737
+ *
738
+ * @example Resources — list changed notifications (only)
739
+ * {@includeCode ./examples/ServerCapabilities/resources-list-changed-notifications-only.json}
740
+ *
741
+ * @example Resources — all notifications
742
+ * {@includeCode ./examples/ServerCapabilities/resources-all-notifications.json}
743
+ */
744
+ resources?: {
745
+ /**
746
+ * Whether this server supports subscribing to resource updates.
747
+ */
748
+ subscribe?: boolean;
749
+ /**
750
+ * Whether this server supports notifications for changes to the resource list.
751
+ */
752
+ listChanged?: boolean;
753
+ };
754
+ /**
755
+ * Present if the server offers any tools to call.
756
+ *
757
+ * @example Tools — minimum baseline support
758
+ * {@includeCode ./examples/ServerCapabilities/tools-minimum-baseline-support.json}
759
+ *
760
+ * @example Tools — list changed notifications
761
+ * {@includeCode ./examples/ServerCapabilities/tools-list-changed-notifications.json}
762
+ */
763
+ tools?: {
764
+ /**
765
+ * Whether this server supports notifications for changes to the tool list.
766
+ */
767
+ listChanged?: boolean;
768
+ };
769
+ /**
770
+ * Optional MCP extensions that the server supports. Keys are extension identifiers
771
+ * (e.g., "io.modelcontextprotocol/tasks"), and values are per-extension settings
772
+ * objects. An empty object indicates support with no settings.
773
+ *
774
+ * Keys MUST follow the {@link MetaObject | `_meta` key naming rules}, with a
775
+ * mandatory prefix.
776
+ *
777
+ * @example Extensions — Tasks extension support
778
+ * {@includeCode ./examples/ServerCapabilities/extensions-tasks.json}
779
+ */
780
+ extensions?: {
781
+ [key: string]: JSONObject;
782
+ };
783
+ }
784
+ /**
785
+ * An optionally-sized icon that can be displayed in a user interface.
786
+ *
787
+ * @category Common Types
788
+ */
789
+ export interface Icon {
790
+ /**
791
+ * A standard URI pointing to an icon resource. May be an HTTP/HTTPS URL or a
792
+ * `data:` URI with Base64-encoded image data.
793
+ *
794
+ * Consumers SHOULD take steps to ensure URLs serving icons are from the
795
+ * same domain as the client/server or a trusted domain.
796
+ *
797
+ * Consumers SHOULD take appropriate precautions when consuming SVGs as they can contain
798
+ * executable JavaScript.
799
+ *
800
+ * @format uri
801
+ */
802
+ src: string;
803
+ /**
804
+ * Optional MIME type override if the source MIME type is missing or generic.
805
+ * For example: `"image/png"`, `"image/jpeg"`, or `"image/svg+xml"`.
806
+ */
807
+ mimeType?: string;
808
+ /**
809
+ * Optional array of strings that specify sizes at which the icon can be used.
810
+ * Each string should be in WxH format (e.g., `"48x48"`, `"96x96"`) or `"any"` for scalable formats like SVG.
811
+ *
812
+ * If not provided, the client should assume that the icon can be used at any size.
813
+ */
814
+ sizes?: string[];
815
+ /**
816
+ * Optional specifier for the theme this icon is designed for. `"light"` indicates
817
+ * the icon is designed to be used with a light background, and `"dark"` indicates
818
+ * the icon is designed to be used with a dark background.
819
+ *
820
+ * If not provided, the client should assume the icon can be used with any theme.
821
+ */
822
+ theme?: "light" | "dark";
823
+ }
824
+ /**
825
+ * Base interface to add `icons` property.
826
+ *
827
+ * @internal
828
+ */
829
+ export interface Icons {
830
+ /**
831
+ * Optional set of sized icons that the client can display in a user interface.
832
+ *
833
+ * Clients that support rendering icons MUST support at least the following MIME types:
834
+ * - `image/png` - PNG images (safe, universal compatibility)
835
+ * - `image/jpeg` (and `image/jpg`) - JPEG images (safe, universal compatibility)
836
+ *
837
+ * Clients that support rendering icons SHOULD also support:
838
+ * - `image/svg+xml` - SVG images (scalable but requires security precautions)
839
+ * - `image/webp` - WebP images (modern, efficient format)
840
+ */
841
+ icons?: Icon[];
842
+ }
843
+ /**
844
+ * Base interface for metadata with name (identifier) and title (display name) properties.
845
+ *
846
+ * @internal
847
+ */
848
+ export interface BaseMetadata {
849
+ /**
850
+ * Intended for programmatic or logical use, but used as a display name in past specs or fallback (if title isn't present).
851
+ */
852
+ name: string;
853
+ /**
854
+ * Intended for UI and end-user contexts — optimized to be human-readable and easily understood,
855
+ * even by those unfamiliar with domain-specific terminology.
856
+ *
857
+ * If not provided, the name should be used for display (except for {@link Tool},
858
+ * where `annotations.title` should be given precedence over using `name`,
859
+ * if present).
860
+ */
861
+ title?: string;
862
+ }
863
+ /**
864
+ * Describes the MCP implementation.
865
+ *
866
+ * @category `server/discover`
867
+ */
868
+ export interface Implementation extends BaseMetadata, Icons {
869
+ /**
870
+ * The version of this implementation.
871
+ */
872
+ version: string;
873
+ /**
874
+ * An optional human-readable description of what this implementation does.
875
+ *
876
+ * This can be used by clients or servers to provide context about their purpose
877
+ * and capabilities. For example, a server might describe the types of resources
878
+ * or tools it provides, while a client might describe its intended use case.
879
+ */
880
+ description?: string;
881
+ /**
882
+ * An optional URL of the website for this implementation.
883
+ *
884
+ * @format uri
885
+ */
886
+ websiteUrl?: string;
887
+ }
888
+ /**
889
+ * Parameters for a {@link ProgressNotification | notifications/progress} notification.
890
+ *
891
+ * @example Progress message
892
+ * {@includeCode ./examples/ProgressNotificationParams/progress-message.json}
893
+ *
894
+ * @category `notifications/progress`
895
+ */
896
+ export interface ProgressNotificationParams extends NotificationParams {
897
+ /**
898
+ * The progress token which was given in the initial request, used to associate this notification with the request that is proceeding.
899
+ */
900
+ progressToken: ProgressToken;
901
+ /**
902
+ * The progress thus far. This should increase every time progress is made, even if the total is unknown.
903
+ *
904
+ * @TJS-type number
905
+ */
906
+ progress: number;
907
+ /**
908
+ * Total number of items to process (or total progress required), if known.
909
+ *
910
+ * @TJS-type number
911
+ */
912
+ total?: number;
913
+ /**
914
+ * An optional message describing the current progress.
915
+ */
916
+ message?: string;
917
+ }
918
+ /**
919
+ * An out-of-band notification used to inform the receiver of a progress update for a long-running request.
920
+ *
921
+ * @example Progress message
922
+ * {@includeCode ./examples/ProgressNotification/progress-message.json}
923
+ *
924
+ * @category `notifications/progress`
925
+ */
926
+ export interface ProgressNotification extends JSONRPCNotification {
927
+ method: "notifications/progress";
928
+ params: ProgressNotificationParams;
929
+ }
930
+ /**
931
+ * Common params for paginated requests.
932
+ *
933
+ * @example List request with cursor
934
+ * {@includeCode ./examples/PaginatedRequestParams/list-with-cursor.json}
935
+ *
936
+ * @category Common Types
937
+ */
938
+ export interface PaginatedRequestParams extends RequestParams {
939
+ /**
940
+ * An opaque token representing the current pagination position.
941
+ * If provided, the server should return results starting after this cursor.
942
+ */
943
+ cursor?: Cursor;
944
+ }
945
+ /** @internal */
946
+ export interface PaginatedRequest extends JSONRPCRequest {
947
+ params: PaginatedRequestParams;
948
+ }
949
+ /** @internal */
950
+ export interface PaginatedResult extends Result {
951
+ /**
952
+ * An opaque token representing the pagination position after the last returned result.
953
+ * If present, there may be more results available.
954
+ */
955
+ nextCursor?: Cursor;
956
+ }
957
+ /**
958
+ * A result that supports a time-to-live (TTL) hint for client-side caching.
959
+ *
960
+ * @internal
961
+ */
962
+ export interface CacheableResult extends Result {
963
+ /**
964
+ * A hint from the server indicating how long (in milliseconds) the
965
+ * client MAY cache this response before re-fetching. Semantics are
966
+ * analogous to HTTP Cache-Control max-age.
967
+ *
968
+ * - If 0, The response SHOULD be considered immediately stale,
969
+ * The client MAY re-fetch every time the result is needed.
970
+ * - If positive, the client SHOULD consider the result fresh for this many
971
+ * milliseconds after receiving the response.
972
+ *
973
+ * @minimum 0
974
+ */
975
+ ttlMs: number;
976
+ /**
977
+ * Indicates the intended scope of the cached response, analogous to HTTP
978
+ * `Cache-Control: public` vs `Cache-Control: private`.
979
+ *
980
+ * - `"public"`: The response does not contain user-specific data. Any
981
+ * client or intermediary (e.g., shared gateway, caching proxy) MAY cache
982
+ * the response and serve it across authorization contexts.
983
+ * - `"private"`: The response MAY be cached and reused only within the
984
+ * same authorization context. Caches MUST NOT be shared across
985
+ * authorization contexts (e.g., a different access token requires a
986
+ * different cache).
987
+ *
988
+ */
989
+ cacheScope: "public" | "private";
990
+ }
991
+ /**
992
+ * Sent from the client to request a list of resources the server has.
993
+ *
994
+ * @example List resources request
995
+ * {@includeCode ./examples/ListResourcesRequest/list-resources-request.json}
996
+ *
997
+ * @category `resources/list`
998
+ */
999
+ export interface ListResourcesRequest extends PaginatedRequest {
1000
+ method: "resources/list";
1001
+ }
1002
+ /**
1003
+ * The result returned by the server for a {@link ListResourcesRequest | resources/list} request.
1004
+ *
1005
+ * @example Resources list with cursor and TTL
1006
+ * {@includeCode ./examples/ListResourcesResult/resources-list-with-cursor-and-ttl.json}
1007
+ *
1008
+ * @category `resources/list`
1009
+ */
1010
+ export interface ListResourcesResult extends PaginatedResult, CacheableResult {
1011
+ resources: Resource[];
1012
+ }
1013
+ /**
1014
+ * A successful response from the server for a {@link ListResourcesRequest | resources/list} request.
1015
+ *
1016
+ * @example List resources result response
1017
+ * {@includeCode ./examples/ListResourcesResultResponse/list-resources-result-response.json}
1018
+ *
1019
+ * @category `resources/list`
1020
+ */
1021
+ export interface ListResourcesResultResponse extends JSONRPCResultResponse {
1022
+ result: ListResourcesResult;
1023
+ }
1024
+ /**
1025
+ * Sent from the client to request a list of resource templates the server has.
1026
+ *
1027
+ * @example List resource templates request
1028
+ * {@includeCode ./examples/ListResourceTemplatesRequest/list-resource-templates-request.json}
1029
+ *
1030
+ * @category `resources/templates/list`
1031
+ */
1032
+ export interface ListResourceTemplatesRequest extends PaginatedRequest {
1033
+ method: "resources/templates/list";
1034
+ }
1035
+ /**
1036
+ * The result returned by the server for a {@link ListResourceTemplatesRequest | resources/templates/list} request.
1037
+ *
1038
+ * @example Resource templates list with cursor and TTL
1039
+ * {@includeCode ./examples/ListResourceTemplatesResult/resource-templates-list-with-cursor-and-ttl.json}
1040
+ *
1041
+ * @category `resources/templates/list`
1042
+ */
1043
+ export interface ListResourceTemplatesResult extends PaginatedResult, CacheableResult {
1044
+ resourceTemplates: ResourceTemplate[];
1045
+ }
1046
+ /**
1047
+ * A successful response from the server for a {@link ListResourceTemplatesRequest | resources/templates/list} request.
1048
+ *
1049
+ * @example List resource templates result response
1050
+ * {@includeCode ./examples/ListResourceTemplatesResultResponse/list-resource-templates-result-response.json}
1051
+ *
1052
+ * @category `resources/templates/list`
1053
+ */
1054
+ export interface ListResourceTemplatesResultResponse extends JSONRPCResultResponse {
1055
+ result: ListResourceTemplatesResult;
1056
+ }
1057
+ /**
1058
+ * Common params for resource-related requests.
1059
+ *
1060
+ * @internal
1061
+ */
1062
+ export interface ResourceRequestParams extends RequestParams {
1063
+ /**
1064
+ * The URI of the resource. The URI can use any protocol; it is up to the server how to interpret it.
1065
+ *
1066
+ * @format uri
1067
+ */
1068
+ uri: string;
1069
+ }
1070
+ /**
1071
+ * Parameters for a `resources/read` request.
1072
+ *
1073
+ * @category `resources/read`
1074
+ */
1075
+ export interface ReadResourceRequestParams extends ResourceRequestParams, InputResponseRequestParams {
1076
+ }
1077
+ /**
1078
+ * Sent from the client to the server, to read a specific resource URI.
1079
+ *
1080
+ * @example Read resource request
1081
+ * {@includeCode ./examples/ReadResourceRequest/read-resource-request.json}
1082
+ *
1083
+ * @category `resources/read`
1084
+ */
1085
+ export interface ReadResourceRequest extends JSONRPCRequest {
1086
+ method: "resources/read";
1087
+ params: ReadResourceRequestParams;
1088
+ }
1089
+ /**
1090
+ * The result returned by the server for a {@link ReadResourceRequest | resources/read} request.
1091
+ *
1092
+ * @example File resource contents
1093
+ * {@includeCode ./examples/ReadResourceResult/file-resource-contents.json}
1094
+ *
1095
+ * @category `resources/read`
1096
+ */
1097
+ export interface ReadResourceResult extends CacheableResult {
1098
+ contents: (TextResourceContents | BlobResourceContents)[];
1099
+ }
1100
+ /**
1101
+ * A successful response from the server for a {@link ReadResourceRequest | resources/read} request.
1102
+ *
1103
+ * @example Read resource result response
1104
+ * {@includeCode ./examples/ReadResourceResultResponse/read-resource-result-response.json}
1105
+ *
1106
+ * @example Read resource result response with TTL
1107
+ * {@includeCode ./examples/ReadResourceResultResponse/read-resource-result-response-with-ttl.json}
1108
+ *
1109
+ * @category `resources/read`
1110
+ */
1111
+ export interface ReadResourceResultResponse extends JSONRPCResultResponse {
1112
+ result: ReadResourceResult | InputRequiredResult;
1113
+ }
1114
+ /**
1115
+ * An optional notification from the server to the client, informing it that the list of resources it can read from has changed. This is only delivered on a {@link SubscriptionsListenRequest | subscriptions/listen} stream when the client requested it via the `resourcesListChanged` filter field.
1116
+ *
1117
+ * @example Resources list changed
1118
+ * {@includeCode ./examples/ResourceListChangedNotification/resources-list-changed.json}
1119
+ *
1120
+ * @category `notifications/resources/list_changed`
1121
+ */
1122
+ export interface ResourceListChangedNotification extends JSONRPCNotification {
1123
+ method: "notifications/resources/list_changed";
1124
+ params?: NotificationParams;
1125
+ }
1126
+ /**
1127
+ * The set of notification types a client may opt in to on a
1128
+ * {@link SubscriptionsListenRequest | subscriptions/listen} request.
1129
+ *
1130
+ * Each notification type is **opt-in**; the server **MUST NOT** send
1131
+ * notification types the client has not explicitly requested here.
1132
+ *
1133
+ * @category `subscriptions/listen`
1134
+ */
1135
+ export interface SubscriptionFilter {
1136
+ /**
1137
+ * If true, receive {@link ToolListChangedNotification | notifications/tools/list_changed}.
1138
+ */
1139
+ toolsListChanged?: boolean;
1140
+ /**
1141
+ * If true, receive {@link PromptListChangedNotification | notifications/prompts/list_changed}.
1142
+ */
1143
+ promptsListChanged?: boolean;
1144
+ /**
1145
+ * If true, receive {@link ResourceListChangedNotification | notifications/resources/list_changed}.
1146
+ */
1147
+ resourcesListChanged?: boolean;
1148
+ /**
1149
+ * Subscribe to {@link ResourceUpdatedNotification | notifications/resources/updated} for these resource URIs.
1150
+ * Replaces the former `resources/subscribe` RPC.
1151
+ */
1152
+ resourceSubscriptions?: string[];
1153
+ }
1154
+ /**
1155
+ * Parameters for a {@link SubscriptionsListenRequest | subscriptions/listen} request.
1156
+ *
1157
+ * @category `subscriptions/listen`
1158
+ */
1159
+ export interface SubscriptionsListenRequestParams extends RequestParams {
1160
+ /**
1161
+ * The notifications the client opts in to on this stream. The server
1162
+ * **MUST NOT** send notification types the client has not explicitly
1163
+ * requested.
1164
+ */
1165
+ notifications: SubscriptionFilter;
1166
+ }
1167
+ /**
1168
+ * Sent from the client to open a long-lived channel for receiving notifications
1169
+ * outside the context of a specific request. Replaces the previous HTTP GET
1170
+ * endpoint and ensures consistent behavior between HTTP and STDIO.
1171
+ *
1172
+ * @example Listen for tools and resource list changes
1173
+ * {@includeCode ./examples/SubscriptionsListenRequest/listen-for-list-changes.json}
1174
+ *
1175
+ * @category `subscriptions/listen`
1176
+ */
1177
+ export interface SubscriptionsListenRequest extends JSONRPCRequest {
1178
+ method: "subscriptions/listen";
1179
+ params: SubscriptionsListenRequestParams;
1180
+ }
1181
+ /**
1182
+ * Extends {@link ResultMetaObject} with the subscription-stream identifier carried by a
1183
+ * {@link SubscriptionsListenResult}. All key naming rules from `MetaObject` apply.
1184
+ *
1185
+ * @see {@link MetaObject} for key naming rules and reserved prefixes.
1186
+ * @category `subscriptions/listen`
1187
+ */
1188
+ export interface SubscriptionsListenResultMetaObject extends ResultMetaObject {
1189
+ /**
1190
+ * Identifies the subscription stream this response closes, so the client can
1191
+ * correlate it with the originating subscription — mirroring the same key on
1192
+ * the stream's notifications. The value is the JSON-RPC ID of the
1193
+ * `subscriptions/listen` request that opened the stream (and equals this
1194
+ * response's `id`).
1195
+ */
1196
+ "io.modelcontextprotocol/subscriptionId": RequestId;
1197
+ }
1198
+ /**
1199
+ * The response to a {@link SubscriptionsListenRequest | subscriptions/listen}
1200
+ * request, signalling that the subscription has ended gracefully (for example,
1201
+ * during server shutdown). Because the listen stream is long-lived, this result
1202
+ * is sent only when the server tears the subscription down; an abrupt transport
1203
+ * close carries no response. The result body is otherwise empty.
1204
+ *
1205
+ * @example Subscription closed gracefully
1206
+ * {@includeCode ./examples/SubscriptionsListenResult/listen-closed.json}
1207
+ *
1208
+ * @category `subscriptions/listen`
1209
+ */
1210
+ export interface SubscriptionsListenResult extends Result {
1211
+ _meta: SubscriptionsListenResultMetaObject;
1212
+ }
1213
+ /**
1214
+ * A successful response from the server for a {@link SubscriptionsListenRequest | subscriptions/listen}
1215
+ * request, sent when the server tears the subscription down gracefully.
1216
+ *
1217
+ * @example Subscription closed gracefully response
1218
+ * {@includeCode ./examples/SubscriptionsListenResultResponse/listen-closed-response.json}
1219
+ *
1220
+ * @category `subscriptions/listen`
1221
+ */
1222
+ export interface SubscriptionsListenResultResponse extends JSONRPCResultResponse {
1223
+ result: SubscriptionsListenResult;
1224
+ }
1225
+ /**
1226
+ * Parameters for a {@link SubscriptionsAcknowledgedNotification | notifications/subscriptions/acknowledged} notification.
1227
+ *
1228
+ * @category `notifications/subscriptions/acknowledged`
1229
+ */
1230
+ export interface SubscriptionsAcknowledgedNotificationParams extends NotificationParams {
1231
+ /**
1232
+ * The subset of requested notification types the server agreed to honor.
1233
+ * Only includes notification types the server actually supports; if the
1234
+ * client requested an unsupported type (e.g., `promptsListChanged` when
1235
+ * the server has no prompts), it is omitted from this set.
1236
+ */
1237
+ notifications: SubscriptionFilter;
1238
+ }
1239
+ /**
1240
+ * Sent by the server to acknowledge that a
1241
+ * {@link SubscriptionsListenRequest | subscriptions/listen} subscription has been
1242
+ * established and to report which notification types it agreed to honor.
1243
+ *
1244
+ * This notification MUST be the first message the server sends carrying the
1245
+ * subscription's ID in `io.modelcontextprotocol/subscriptionId`. The server MUST
1246
+ * NOT send any notification on the subscription before acknowledging it. On
1247
+ * stdio, where every subscription shares one channel, this ordering is defined
1248
+ * per subscription ID and not per channel: messages belonging to other
1249
+ * subscriptions MAY be interleaved before it.
1250
+ *
1251
+ * @example Listen acknowledged
1252
+ * {@includeCode ./examples/SubscriptionsAcknowledgedNotification/listen-acknowledged.json}
1253
+ *
1254
+ * @category `notifications/subscriptions/acknowledged`
1255
+ */
1256
+ export interface SubscriptionsAcknowledgedNotification extends JSONRPCNotification {
1257
+ method: "notifications/subscriptions/acknowledged";
1258
+ params: SubscriptionsAcknowledgedNotificationParams;
1259
+ }
1260
+ /**
1261
+ * Parameters for a `notifications/resources/updated` notification.
1262
+ *
1263
+ * @example File resource updated
1264
+ * {@includeCode ./examples/ResourceUpdatedNotificationParams/file-resource-updated.json}
1265
+ *
1266
+ * @category `notifications/resources/updated`
1267
+ */
1268
+ export interface ResourceUpdatedNotificationParams extends NotificationParams {
1269
+ /**
1270
+ * The URI of the resource that has been updated. This might be a sub-resource of the one that the client actually subscribed to.
1271
+ *
1272
+ * @format uri
1273
+ */
1274
+ uri: string;
1275
+ }
1276
+ /**
1277
+ * A notification from the server to the client, informing it that a resource has changed and may need to be read again. This is only sent for resources the client opted in to via the `resourceSubscriptions` field of a {@link SubscriptionsListenRequest | subscriptions/listen} request.
1278
+ *
1279
+ * @example File resource updated notification
1280
+ * {@includeCode ./examples/ResourceUpdatedNotification/file-resource-updated-notification.json}
1281
+ *
1282
+ * @category `notifications/resources/updated`
1283
+ */
1284
+ export interface ResourceUpdatedNotification extends JSONRPCNotification {
1285
+ method: "notifications/resources/updated";
1286
+ params: ResourceUpdatedNotificationParams;
1287
+ }
1288
+ /**
1289
+ * A known resource that the server is capable of reading.
1290
+ *
1291
+ * @example File resource with annotations
1292
+ * {@includeCode ./examples/Resource/file-resource-with-annotations.json}
1293
+ *
1294
+ * @category `resources/list`
1295
+ */
1296
+ export interface Resource extends BaseMetadata, Icons {
1297
+ /**
1298
+ * The URI of this resource.
1299
+ *
1300
+ * @format uri
1301
+ */
1302
+ uri: string;
1303
+ /**
1304
+ * A description of what this resource represents.
1305
+ *
1306
+ * This can be used by clients to improve the LLM's understanding of available resources. It can be thought of like a "hint" to the model.
1307
+ */
1308
+ description?: string;
1309
+ /**
1310
+ * The MIME type of this resource, if known.
1311
+ */
1312
+ mimeType?: string;
1313
+ /**
1314
+ * Optional annotations for the client.
1315
+ */
1316
+ annotations?: Annotations;
1317
+ /**
1318
+ * The size of the raw resource content, in bytes (i.e., before base64 encoding or any tokenization), if known.
1319
+ *
1320
+ * This can be used by Hosts to display file sizes and estimate context window usage.
1321
+ */
1322
+ size?: number;
1323
+ _meta?: MetaObject;
1324
+ }
1325
+ /**
1326
+ * A template description for resources available on the server.
1327
+ *
1328
+ * @category `resources/templates/list`
1329
+ */
1330
+ export interface ResourceTemplate extends BaseMetadata, Icons {
1331
+ /**
1332
+ * A URI template (according to RFC 6570) that can be used to construct resource URIs.
1333
+ *
1334
+ * @format uri-template
1335
+ */
1336
+ uriTemplate: string;
1337
+ /**
1338
+ * A description of what this template is for.
1339
+ *
1340
+ * This can be used by clients to improve the LLM's understanding of available resources. It can be thought of like a "hint" to the model.
1341
+ */
1342
+ description?: string;
1343
+ /**
1344
+ * The MIME type for all resources that match this template. This should only be included if all resources matching this template have the same type.
1345
+ */
1346
+ mimeType?: string;
1347
+ /**
1348
+ * Optional annotations for the client.
1349
+ */
1350
+ annotations?: Annotations;
1351
+ _meta?: MetaObject;
1352
+ }
1353
+ /**
1354
+ * The contents of a specific resource or sub-resource.
1355
+ *
1356
+ * @internal
1357
+ */
1358
+ export interface ResourceContents {
1359
+ /**
1360
+ * The URI of this resource.
1361
+ *
1362
+ * @format uri
1363
+ */
1364
+ uri: string;
1365
+ /**
1366
+ * The MIME type of this resource, if known.
1367
+ */
1368
+ mimeType?: string;
1369
+ _meta?: MetaObject;
1370
+ }
1371
+ /**
1372
+ * @example Text file contents
1373
+ * {@includeCode ./examples/TextResourceContents/text-file-contents.json}
1374
+ *
1375
+ * @category Content
1376
+ */
1377
+ export interface TextResourceContents extends ResourceContents {
1378
+ /**
1379
+ * The text of the item. This must only be set if the item can actually be represented as text (not binary data).
1380
+ */
1381
+ text: string;
1382
+ }
1383
+ /**
1384
+ * @example Image file contents
1385
+ * {@includeCode ./examples/BlobResourceContents/image-file-contents.json}
1386
+ *
1387
+ * @category Content
1388
+ */
1389
+ export interface BlobResourceContents extends ResourceContents {
1390
+ /**
1391
+ * A base64-encoded string representing the binary data of the item.
1392
+ *
1393
+ * @format byte
1394
+ */
1395
+ blob: string;
1396
+ }
1397
+ /**
1398
+ * Sent from the client to request a list of prompts and prompt templates the server has.
1399
+ *
1400
+ * @example List prompts request
1401
+ * {@includeCode ./examples/ListPromptsRequest/list-prompts-request.json}
1402
+ *
1403
+ * @category `prompts/list`
1404
+ */
1405
+ export interface ListPromptsRequest extends PaginatedRequest {
1406
+ method: "prompts/list";
1407
+ }
1408
+ /**
1409
+ * The result returned by the server for a {@link ListPromptsRequest | prompts/list} request.
1410
+ *
1411
+ * @example Prompts list with cursor and TTL
1412
+ * {@includeCode ./examples/ListPromptsResult/prompts-list-with-cursor-and-ttl.json}
1413
+ *
1414
+ * @category `prompts/list`
1415
+ */
1416
+ export interface ListPromptsResult extends PaginatedResult, CacheableResult {
1417
+ prompts: Prompt[];
1418
+ }
1419
+ /**
1420
+ * A successful response from the server for a {@link ListPromptsRequest | prompts/list} request.
1421
+ *
1422
+ * @example List prompts result response
1423
+ * {@includeCode ./examples/ListPromptsResultResponse/list-prompts-result-response.json}
1424
+ *
1425
+ * @category `prompts/list`
1426
+ */
1427
+ export interface ListPromptsResultResponse extends JSONRPCResultResponse {
1428
+ result: ListPromptsResult;
1429
+ }
1430
+ /**
1431
+ * Parameters for a `prompts/get` request.
1432
+ *
1433
+ * @example Get code review prompt
1434
+ * {@includeCode ./examples/GetPromptRequestParams/get-code-review-prompt.json}
1435
+ *
1436
+ * @category `prompts/get`
1437
+ */
1438
+ export interface GetPromptRequestParams extends InputResponseRequestParams {
1439
+ /**
1440
+ * The name of the prompt or prompt template.
1441
+ */
1442
+ name: string;
1443
+ /**
1444
+ * Arguments to use for templating the prompt.
1445
+ */
1446
+ arguments?: {
1447
+ [key: string]: string;
1448
+ };
1449
+ }
1450
+ /**
1451
+ * Used by the client to get a prompt provided by the server.
1452
+ *
1453
+ * @example Get prompt request
1454
+ * {@includeCode ./examples/GetPromptRequest/get-prompt-request.json}
1455
+ *
1456
+ * @category `prompts/get`
1457
+ */
1458
+ export interface GetPromptRequest extends JSONRPCRequest {
1459
+ method: "prompts/get";
1460
+ params: GetPromptRequestParams;
1461
+ }
1462
+ /**
1463
+ * The result returned by the server for a {@link GetPromptRequest | prompts/get} request.
1464
+ *
1465
+ * @example Code review prompt
1466
+ * {@includeCode ./examples/GetPromptResult/code-review-prompt.json}
1467
+ *
1468
+ * @category `prompts/get`
1469
+ */
1470
+ export interface GetPromptResult extends Result {
1471
+ /**
1472
+ * An optional description for the prompt.
1473
+ */
1474
+ description?: string;
1475
+ messages: PromptMessage[];
1476
+ }
1477
+ /**
1478
+ * A successful response from the server for a {@link GetPromptRequest | prompts/get} request.
1479
+ *
1480
+ * @example Get prompt result response
1481
+ * {@includeCode ./examples/GetPromptResultResponse/get-prompt-result-response.json}
1482
+ *
1483
+ * @category `prompts/get`
1484
+ */
1485
+ export interface GetPromptResultResponse extends JSONRPCResultResponse {
1486
+ result: GetPromptResult | InputRequiredResult;
1487
+ }
1488
+ /**
1489
+ * A prompt or prompt template that the server offers.
1490
+ *
1491
+ * @category `prompts/list`
1492
+ */
1493
+ export interface Prompt extends BaseMetadata, Icons {
1494
+ /**
1495
+ * An optional description of what this prompt provides
1496
+ */
1497
+ description?: string;
1498
+ /**
1499
+ * A list of arguments to use for templating the prompt.
1500
+ */
1501
+ arguments?: PromptArgument[];
1502
+ _meta?: MetaObject;
1503
+ }
1504
+ /**
1505
+ * Describes an argument that a prompt can accept.
1506
+ *
1507
+ * @category `prompts/list`
1508
+ */
1509
+ export interface PromptArgument extends BaseMetadata {
1510
+ /**
1511
+ * A human-readable description of the argument.
1512
+ */
1513
+ description?: string;
1514
+ /**
1515
+ * Whether this argument must be provided.
1516
+ */
1517
+ required?: boolean;
1518
+ }
1519
+ /**
1520
+ * The sender or recipient of messages and data in a conversation.
1521
+ *
1522
+ * @category Common Types
1523
+ */
1524
+ export type Role = "user" | "assistant";
1525
+ /**
1526
+ * Describes a message returned as part of a prompt.
1527
+ *
1528
+ * This is similar to {@link SamplingMessage}, but also supports the embedding of
1529
+ * resources from the MCP server.
1530
+ *
1531
+ * @category `prompts/get`
1532
+ */
1533
+ export interface PromptMessage {
1534
+ role: Role;
1535
+ content: ContentBlock;
1536
+ }
1537
+ /**
1538
+ * A resource that the server is capable of reading, included in a prompt or tool call result.
1539
+ *
1540
+ * Note: resource links returned by tools are not guaranteed to appear in the results of {@link ListResourcesRequest | resources/list} requests.
1541
+ *
1542
+ * @example File resource link
1543
+ * {@includeCode ./examples/ResourceLink/file-resource-link.json}
1544
+ *
1545
+ * @category Content
1546
+ */
1547
+ export interface ResourceLink extends Resource {
1548
+ type: "resource_link";
1549
+ }
1550
+ /**
1551
+ * The contents of a resource, embedded into a prompt or tool call result.
1552
+ *
1553
+ * It is up to the client how best to render embedded resources for the benefit
1554
+ * of the LLM and/or the user.
1555
+ *
1556
+ * @example Embedded file resource with annotations
1557
+ * {@includeCode ./examples/EmbeddedResource/embedded-file-resource-with-annotations.json}
1558
+ *
1559
+ * @category Content
1560
+ */
1561
+ export interface EmbeddedResource {
1562
+ type: "resource";
1563
+ resource: TextResourceContents | BlobResourceContents;
1564
+ /**
1565
+ * Optional annotations for the client.
1566
+ */
1567
+ annotations?: Annotations;
1568
+ _meta?: MetaObject;
1569
+ }
1570
+ /**
1571
+ * An optional notification from the server to the client, informing it that the list of prompts it offers has changed. This is only delivered on a {@link SubscriptionsListenRequest | subscriptions/listen} stream when the client requested it via the `promptsListChanged` filter field.
1572
+ *
1573
+ * @example Prompts list changed
1574
+ * {@includeCode ./examples/PromptListChangedNotification/prompts-list-changed.json}
1575
+ *
1576
+ * @category `notifications/prompts/list_changed`
1577
+ */
1578
+ export interface PromptListChangedNotification extends JSONRPCNotification {
1579
+ method: "notifications/prompts/list_changed";
1580
+ params?: NotificationParams;
1581
+ }
1582
+ /**
1583
+ * Sent from the client to request a list of tools the server has.
1584
+ *
1585
+ * @example List tools request
1586
+ * {@includeCode ./examples/ListToolsRequest/list-tools-request.json}
1587
+ *
1588
+ * @category `tools/list`
1589
+ */
1590
+ export interface ListToolsRequest extends PaginatedRequest {
1591
+ method: "tools/list";
1592
+ }
1593
+ /**
1594
+ * The result returned by the server for a {@link ListToolsRequest | tools/list} request.
1595
+ *
1596
+ * @example Tools list with cursor and TTL
1597
+ * {@includeCode ./examples/ListToolsResult/tools-list-with-cursor-and-ttl.json}
1598
+ *
1599
+ * @category `tools/list`
1600
+ */
1601
+ export interface ListToolsResult extends PaginatedResult, CacheableResult {
1602
+ tools: Tool[];
1603
+ }
1604
+ /**
1605
+ * A successful response from the server for a {@link ListToolsRequest | tools/list} request.
1606
+ *
1607
+ * @example List tools result response
1608
+ * {@includeCode ./examples/ListToolsResultResponse/list-tools-result-response.json}
1609
+ *
1610
+ * @category `tools/list`
1611
+ */
1612
+ export interface ListToolsResultResponse extends JSONRPCResultResponse {
1613
+ result: ListToolsResult;
1614
+ }
1615
+ /**
1616
+ * The result returned by the server for a {@link CallToolRequest | tools/call} request.
1617
+ *
1618
+ * @example Result with unstructured text
1619
+ * {@includeCode ./examples/CallToolResult/result-with-unstructured-text.json}
1620
+ *
1621
+ * @example Result with structured content
1622
+ * {@includeCode ./examples/CallToolResult/result-with-structured-content.json}
1623
+ *
1624
+ * @example Invalid tool input error
1625
+ * {@includeCode ./examples/CallToolResult/invalid-tool-input-error.json}
1626
+ *
1627
+ * @category `tools/call`
1628
+ */
1629
+ export interface CallToolResult extends Result {
1630
+ /**
1631
+ * A list of content objects that represent the unstructured result of the tool call.
1632
+ */
1633
+ content: ContentBlock[];
1634
+ /**
1635
+ * An optional JSON value that represents the structured result of the tool call.
1636
+ *
1637
+ * This can be any JSON value (object, array, string, number, boolean, or null)
1638
+ * that conforms to the tool's outputSchema if one is defined.
1639
+ */
1640
+ structuredContent?: unknown;
1641
+ /**
1642
+ * Whether the tool call ended in an error.
1643
+ *
1644
+ * If not set, this is assumed to be false (the call was successful).
1645
+ *
1646
+ * Any errors that originate from the tool SHOULD be reported inside the result
1647
+ * object, with `isError` set to true, _not_ as an MCP protocol-level error
1648
+ * response. Otherwise, the LLM would not be able to see that an error occurred
1649
+ * and self-correct.
1650
+ *
1651
+ * However, any errors in _finding_ the tool, an error indicating that the
1652
+ * server does not support tool calls, or any other exceptional conditions,
1653
+ * should be reported as an MCP error response.
1654
+ */
1655
+ isError?: boolean;
1656
+ }
1657
+ /**
1658
+ * A successful response from the server for a {@link CallToolRequest | tools/call} request.
1659
+ *
1660
+ * @example Call tool result response
1661
+ * {@includeCode ./examples/CallToolResultResponse/call-tool-result-response.json}
1662
+ *
1663
+ * @category `tools/call`
1664
+ */
1665
+ export interface CallToolResultResponse extends JSONRPCResultResponse {
1666
+ result: CallToolResult | InputRequiredResult;
1667
+ }
1668
+ /**
1669
+ * Parameters for a `tools/call` request.
1670
+ *
1671
+ * @example `get_weather` tool call params
1672
+ * {@includeCode ./examples/CallToolRequestParams/get-weather-tool-call-params.json}
1673
+ *
1674
+ * @example Tool call params with progress token
1675
+ * {@includeCode ./examples/CallToolRequestParams/tool-call-params-with-progress-token.json}
1676
+ *
1677
+ * @category `tools/call`
1678
+ */
1679
+ export interface CallToolRequestParams extends InputResponseRequestParams {
1680
+ /**
1681
+ * The name of the tool.
1682
+ */
1683
+ name: string;
1684
+ /**
1685
+ * Arguments to use for the tool call.
1686
+ */
1687
+ arguments?: {
1688
+ [key: string]: unknown;
1689
+ };
1690
+ }
1691
+ /**
1692
+ * Used by the client to invoke a tool provided by the server.
1693
+ *
1694
+ * @example Call tool request
1695
+ * {@includeCode ./examples/CallToolRequest/call-tool-request.json}
1696
+ *
1697
+ * @category `tools/call`
1698
+ */
1699
+ export interface CallToolRequest extends JSONRPCRequest {
1700
+ method: "tools/call";
1701
+ params: CallToolRequestParams;
1702
+ }
1703
+ /**
1704
+ * An optional notification from the server to the client, informing it that the list of tools it offers has changed. This is only delivered on a {@link SubscriptionsListenRequest | subscriptions/listen} stream when the client requested it via the `toolsListChanged` filter field.
1705
+ *
1706
+ * @example Tools list changed
1707
+ * {@includeCode ./examples/ToolListChangedNotification/tools-list-changed.json}
1708
+ *
1709
+ * @category `notifications/tools/list_changed`
1710
+ */
1711
+ export interface ToolListChangedNotification extends JSONRPCNotification {
1712
+ method: "notifications/tools/list_changed";
1713
+ params?: NotificationParams;
1714
+ }
1715
+ /**
1716
+ * Additional properties describing a {@link Tool} to clients.
1717
+ *
1718
+ * NOTE: all properties in `ToolAnnotations` are **hints**.
1719
+ * They are not guaranteed to provide a faithful description of
1720
+ * tool behavior (including descriptive properties like `title`).
1721
+ *
1722
+ * Clients should never make tool use decisions based on `ToolAnnotations`
1723
+ * received from untrusted servers.
1724
+ *
1725
+ * @category `tools/list`
1726
+ */
1727
+ export interface ToolAnnotations {
1728
+ /**
1729
+ * A human-readable title for the tool.
1730
+ */
1731
+ title?: string;
1732
+ /**
1733
+ * If true, the tool does not modify its environment.
1734
+ *
1735
+ * Default: false
1736
+ */
1737
+ readOnlyHint?: boolean;
1738
+ /**
1739
+ * If true, the tool may perform destructive updates to its environment.
1740
+ * If false, the tool performs only additive updates.
1741
+ *
1742
+ * (This property is meaningful only when `readOnlyHint == false`)
1743
+ *
1744
+ * Default: true
1745
+ */
1746
+ destructiveHint?: boolean;
1747
+ /**
1748
+ * If true, calling the tool repeatedly with the same arguments
1749
+ * will have no additional effect on its environment.
1750
+ *
1751
+ * (This property is meaningful only when `readOnlyHint == false`)
1752
+ *
1753
+ * Default: false
1754
+ */
1755
+ idempotentHint?: boolean;
1756
+ /**
1757
+ * If true, this tool may interact with an "open world" of external
1758
+ * entities. If false, the tool's domain of interaction is closed.
1759
+ * For example, the world of a web search tool is open, whereas that
1760
+ * of a memory tool is not.
1761
+ *
1762
+ * Default: true
1763
+ */
1764
+ openWorldHint?: boolean;
1765
+ }
1766
+ /**
1767
+ * Definition for a tool the client can call.
1768
+ *
1769
+ * @example With default 2020-12 input schema
1770
+ * {@includeCode ./examples/Tool/with-default-2020-12-input-schema.json}
1771
+ *
1772
+ * @example With explicit draft-07 input schema
1773
+ * {@includeCode ./examples/Tool/with-explicit-draft-07-input-schema.json}
1774
+ *
1775
+ * @example With no parameters
1776
+ * {@includeCode ./examples/Tool/with-no-parameters.json}
1777
+ *
1778
+ * @example With output schema for structured content
1779
+ * {@includeCode ./examples/Tool/with-output-schema-for-structured-content.json}
1780
+ *
1781
+ * @category `tools/list`
1782
+ */
1783
+ export interface Tool extends BaseMetadata, Icons {
1784
+ /**
1785
+ * A human-readable description of the tool.
1786
+ *
1787
+ * This can be used by clients to improve the LLM's understanding of available tools. It can be thought of like a "hint" to the model.
1788
+ */
1789
+ description?: string;
1790
+ /**
1791
+ * A JSON Schema object defining the expected parameters for the tool.
1792
+ *
1793
+ * Tool arguments are always JSON objects, so `type: "object"` is required at the root.
1794
+ * Beyond that, any JSON Schema 2020-12 keyword may appear alongside `type` — including
1795
+ * composition keywords (`oneOf`, `anyOf`, `allOf`, `not`), conditional keywords
1796
+ * (`if`/`then`/`else`), reference keywords (`$ref`, `$defs`, `$anchor`), and any other
1797
+ * standard validation or annotation keywords.
1798
+ *
1799
+ * Property schemas may carry an `x-mcp-header` annotation to mirror the
1800
+ * argument value into an HTTP header on the Streamable HTTP transport. See
1801
+ * the Streamable HTTP transport specification for the validity and
1802
+ * extraction rules.
1803
+ *
1804
+ * Defaults to JSON Schema 2020-12 when no explicit `$schema` is provided.
1805
+ */
1806
+ inputSchema: {
1807
+ $schema?: string;
1808
+ type: "object";
1809
+ [key: string]: unknown;
1810
+ };
1811
+ /**
1812
+ * An optional JSON Schema object defining the structure of the tool's output returned in
1813
+ * the structuredContent field of a {@link CallToolResult}. This can be any valid JSON Schema 2020-12.
1814
+ *
1815
+ * Defaults to JSON Schema 2020-12 when no explicit `$schema` is provided.
1816
+ */
1817
+ outputSchema?: {
1818
+ $schema?: string;
1819
+ [key: string]: unknown;
1820
+ };
1821
+ /**
1822
+ * Optional additional tool information.
1823
+ *
1824
+ * Display name precedence order is: `title`, `annotations.title`, then `name`.
1825
+ */
1826
+ annotations?: ToolAnnotations;
1827
+ _meta?: MetaObject;
1828
+ }
1829
+ /**
1830
+ * Parameters for a `notifications/message` notification.
1831
+ *
1832
+ * @deprecated Deprecated as of protocol version 2026-07-28 (SEP-2577).
1833
+ * Remains in the specification for at least twelve months; see the
1834
+ * deprecated features registry.
1835
+ *
1836
+ * @example Log database connection failed
1837
+ * {@includeCode ./examples/LoggingMessageNotificationParams/log-database-connection-failed.json}
1838
+ *
1839
+ * @category `notifications/message`
1840
+ */
1841
+ export interface LoggingMessageNotificationParams extends NotificationParams {
1842
+ /**
1843
+ * The severity of this log message.
1844
+ */
1845
+ level: LoggingLevel;
1846
+ /**
1847
+ * An optional name of the logger issuing this message.
1848
+ */
1849
+ logger?: string;
1850
+ /**
1851
+ * The data to be logged, such as a string message or an object. Any JSON serializable type is allowed here.
1852
+ */
1853
+ data: unknown;
1854
+ }
1855
+ /**
1856
+ * JSONRPCNotification of a log message passed from server to client. The client opts in by setting `"io.modelcontextprotocol/logLevel"` in a request's `_meta`.
1857
+ *
1858
+ * @deprecated Deprecated as of protocol version 2026-07-28 (SEP-2577).
1859
+ * Remains in the specification for at least twelve months; see the
1860
+ * deprecated features registry.
1861
+ *
1862
+ * @example Log database connection failed
1863
+ * {@includeCode ./examples/LoggingMessageNotification/log-database-connection-failed.json}
1864
+ *
1865
+ * @category `notifications/message`
1866
+ */
1867
+ export interface LoggingMessageNotification extends JSONRPCNotification {
1868
+ method: "notifications/message";
1869
+ params: LoggingMessageNotificationParams;
1870
+ }
1871
+ /**
1872
+ * The severity of a log message.
1873
+ *
1874
+ * These map to syslog message severities, as specified in RFC-5424:
1875
+ * https://datatracker.ietf.org/doc/html/rfc5424#section-6.2.1
1876
+ *
1877
+ * @deprecated Deprecated as of protocol version 2026-07-28 (SEP-2577).
1878
+ * Remains in the specification for at least twelve months; see the
1879
+ * deprecated features registry.
1880
+ *
1881
+ * @category Common Types
1882
+ */
1883
+ export type LoggingLevel = "debug" | "info" | "notice" | "warning" | "error" | "critical" | "alert" | "emergency";
1884
+ /**
1885
+ * Parameters for a `sampling/createMessage` request.
1886
+ *
1887
+ * @example Basic request
1888
+ * {@includeCode ./examples/CreateMessageRequestParams/basic-request.json}
1889
+ *
1890
+ * @example Request with tools
1891
+ * {@includeCode ./examples/CreateMessageRequestParams/request-with-tools.json}
1892
+ *
1893
+ * @example Follow-up request with tool results
1894
+ * {@includeCode ./examples/CreateMessageRequestParams/follow-up-with-tool-results.json}
1895
+ *
1896
+ * @deprecated Deprecated as of protocol version 2026-07-28 (SEP-2577).
1897
+ * Remains in the specification for at least twelve months; see the
1898
+ * deprecated features registry.
1899
+ *
1900
+ * @category `sampling/createMessage`
1901
+ */
1902
+ export interface CreateMessageRequestParams {
1903
+ messages: SamplingMessage[];
1904
+ /**
1905
+ * The server's preferences for which model to select. The client MAY ignore these preferences.
1906
+ */
1907
+ modelPreferences?: ModelPreferences;
1908
+ /**
1909
+ * An optional system prompt the server wants to use for sampling. The client MAY modify or omit this prompt.
1910
+ */
1911
+ systemPrompt?: string;
1912
+ /**
1913
+ * A request to include context from one or more MCP servers (including the caller), to be attached to the prompt.
1914
+ * The client MAY ignore this request.
1915
+ *
1916
+ * Default is `"none"`. The values `"thisServer"` and `"allServers"` are deprecated (SEP-2596): servers SHOULD
1917
+ * omit this field or use `"none"`, and SHOULD only use the deprecated values if the client declares
1918
+ * {@link ClientCapabilities.sampling.context}.
1919
+ *
1920
+ * @deprecated The `"thisServer"` and `"allServers"` values are deprecated as of protocol version 2025-11-25
1921
+ * (SEP-2596) and will be removed no later than the Sampling feature itself (SEP-2577). Omit this field or use `"none"`.
1922
+ */
1923
+ includeContext?: "none" | "thisServer" | "allServers";
1924
+ /**
1925
+ * @TJS-type number
1926
+ */
1927
+ temperature?: number;
1928
+ /**
1929
+ * The requested maximum number of tokens to sample (to prevent runaway completions).
1930
+ *
1931
+ * The client MAY choose to sample fewer tokens than the requested maximum.
1932
+ */
1933
+ maxTokens: number;
1934
+ stopSequences?: string[];
1935
+ /**
1936
+ * Optional metadata to pass through to the LLM provider. The format of this metadata is provider-specific.
1937
+ */
1938
+ metadata?: JSONObject;
1939
+ /**
1940
+ * Tools that the model may use during generation.
1941
+ * The client MUST return an error if this field is provided but {@link ClientCapabilities.sampling.tools} is not declared.
1942
+ */
1943
+ tools?: Tool[];
1944
+ /**
1945
+ * Controls how the model uses tools.
1946
+ * The client MUST return an error if this field is provided but {@link ClientCapabilities.sampling.tools} is not declared.
1947
+ * Default is `{ mode: "auto" }`.
1948
+ */
1949
+ toolChoice?: ToolChoice;
1950
+ }
1951
+ /**
1952
+ * Controls tool selection behavior for sampling requests.
1953
+ *
1954
+ * @deprecated Deprecated as of protocol version 2026-07-28 (SEP-2577).
1955
+ * Remains in the specification for at least twelve months; see the
1956
+ * deprecated features registry.
1957
+ *
1958
+ * @category `sampling/createMessage`
1959
+ */
1960
+ export interface ToolChoice {
1961
+ /**
1962
+ * Controls the tool use ability of the model:
1963
+ * - `"auto"`: Model decides whether to use tools (default)
1964
+ * - `"required"`: Model MUST use at least one tool before completing
1965
+ * - `"none"`: Model MUST NOT use any tools
1966
+ */
1967
+ mode?: "auto" | "required" | "none";
1968
+ }
1969
+ /**
1970
+ * A request from the server to sample an LLM via the client. The client has full discretion over which model to select. The client should also inform the user before beginning sampling, to allow them to inspect the request (human in the loop) and decide whether to approve it.
1971
+ *
1972
+ * @example Sampling request
1973
+ * {@includeCode ./examples/CreateMessageRequest/sampling-request.json}
1974
+ *
1975
+ * @deprecated Deprecated as of protocol version 2026-07-28 (SEP-2577).
1976
+ * Remains in the specification for at least twelve months; see the
1977
+ * deprecated features registry.
1978
+ *
1979
+ * @category `sampling/createMessage`
1980
+ */
1981
+ export interface CreateMessageRequest {
1982
+ method: "sampling/createMessage";
1983
+ params: CreateMessageRequestParams;
1984
+ }
1985
+ /**
1986
+ * The result returned by the client for a {@link CreateMessageRequest | sampling/createMessage} request.
1987
+ * The client should inform the user before returning the sampled message, to allow them
1988
+ * to inspect the response (human in the loop) and decide whether to allow the server to see it.
1989
+ *
1990
+ * @example Text response
1991
+ * {@includeCode ./examples/CreateMessageResult/text-response.json}
1992
+ *
1993
+ * @example Tool use response
1994
+ * {@includeCode ./examples/CreateMessageResult/tool-use-response.json}
1995
+ *
1996
+ * @example Final response after tool use
1997
+ * {@includeCode ./examples/CreateMessageResult/final-response.json}
1998
+ *
1999
+ * @deprecated Deprecated as of protocol version 2026-07-28 (SEP-2577).
2000
+ * Remains in the specification for at least twelve months; see the
2001
+ * deprecated features registry.
2002
+ *
2003
+ * @category `sampling/createMessage`
2004
+ */
2005
+ export interface CreateMessageResult extends SamplingMessage {
2006
+ /**
2007
+ * The name of the model that generated the message.
2008
+ */
2009
+ model: string;
2010
+ /**
2011
+ * The reason why sampling stopped, if known.
2012
+ *
2013
+ * Standard values:
2014
+ * - `"endTurn"`: Natural end of the assistant's turn
2015
+ * - `"stopSequence"`: A stop sequence was encountered
2016
+ * - `"maxTokens"`: Maximum token limit was reached
2017
+ * - `"toolUse"`: The model wants to use one or more tools
2018
+ *
2019
+ * This field is an open string to allow for provider-specific stop reasons.
2020
+ */
2021
+ stopReason?: "endTurn" | "stopSequence" | "maxTokens" | "toolUse" | string;
2022
+ }
2023
+ /**
2024
+ * Describes a message issued to or received from an LLM API.
2025
+ *
2026
+ * @example Single content block
2027
+ * {@includeCode ./examples/SamplingMessage/single-content-block.json}
2028
+ *
2029
+ * @example Multiple content blocks
2030
+ * {@includeCode ./examples/SamplingMessage/multiple-content-blocks.json}
2031
+ *
2032
+ * @deprecated Deprecated as of protocol version 2026-07-28 (SEP-2577).
2033
+ * Remains in the specification for at least twelve months; see the
2034
+ * deprecated features registry.
2035
+ *
2036
+ * @category `sampling/createMessage`
2037
+ */
2038
+ export interface SamplingMessage {
2039
+ role: Role;
2040
+ content: SamplingMessageContentBlock | SamplingMessageContentBlock[];
2041
+ _meta?: MetaObject;
2042
+ }
2043
+ /**
2044
+ * @deprecated Deprecated as of protocol version 2026-07-28 (SEP-2577).
2045
+ * Remains in the specification for at least twelve months; see the
2046
+ * deprecated features registry.
2047
+ *
2048
+ * @category `sampling/createMessage`
2049
+ */
2050
+ export type SamplingMessageContentBlock = TextContent | ImageContent | AudioContent | ToolUseContent | ToolResultContent;
2051
+ /**
2052
+ * Optional annotations for the client. The client can use annotations to inform how objects are used or displayed
2053
+ *
2054
+ * @category Common Types
2055
+ */
2056
+ export interface Annotations {
2057
+ /**
2058
+ * Describes who the intended audience of this object or data is.
2059
+ *
2060
+ * It can include multiple entries to indicate content useful for multiple audiences (e.g., `["user", "assistant"]`).
2061
+ */
2062
+ audience?: Role[];
2063
+ /**
2064
+ * Describes how important this data is for operating the server.
2065
+ *
2066
+ * A value of 1 means "most important," and indicates that the data is
2067
+ * effectively required, while 0 means "least important," and indicates that
2068
+ * the data is entirely optional.
2069
+ *
2070
+ * @TJS-type number
2071
+ * @minimum 0
2072
+ * @maximum 1
2073
+ */
2074
+ priority?: number;
2075
+ /**
2076
+ * The moment the resource was last modified, as an ISO 8601 formatted string.
2077
+ *
2078
+ * Should be an ISO 8601 formatted string (e.g., "2025-01-12T15:00:58Z").
2079
+ *
2080
+ * Examples: last activity timestamp in an open file, timestamp when the resource
2081
+ * was attached, etc.
2082
+ */
2083
+ lastModified?: string;
2084
+ }
2085
+ /**
2086
+ * @category Content
2087
+ */
2088
+ export type ContentBlock = TextContent | ImageContent | AudioContent | ResourceLink | EmbeddedResource;
2089
+ /**
2090
+ * Text provided to or from an LLM.
2091
+ *
2092
+ * @example Text content
2093
+ * {@includeCode ./examples/TextContent/text-content.json}
2094
+ *
2095
+ * @category Content
2096
+ */
2097
+ export interface TextContent {
2098
+ type: "text";
2099
+ /**
2100
+ * The text content of the message.
2101
+ */
2102
+ text: string;
2103
+ /**
2104
+ * Optional annotations for the client.
2105
+ */
2106
+ annotations?: Annotations;
2107
+ _meta?: MetaObject;
2108
+ }
2109
+ /**
2110
+ * An image provided to or from an LLM.
2111
+ *
2112
+ * @example `image/png` content with annotations
2113
+ * {@includeCode ./examples/ImageContent/image-png-content-with-annotations.json}
2114
+ *
2115
+ * @category Content
2116
+ */
2117
+ export interface ImageContent {
2118
+ type: "image";
2119
+ /**
2120
+ * The base64-encoded image data.
2121
+ *
2122
+ * @format byte
2123
+ */
2124
+ data: string;
2125
+ /**
2126
+ * The MIME type of the image. Different providers may support different image types.
2127
+ */
2128
+ mimeType: string;
2129
+ /**
2130
+ * Optional annotations for the client.
2131
+ */
2132
+ annotations?: Annotations;
2133
+ _meta?: MetaObject;
2134
+ }
2135
+ /**
2136
+ * Audio provided to or from an LLM.
2137
+ *
2138
+ * @example `audio/wav` content
2139
+ * {@includeCode ./examples/AudioContent/audio-wav-content.json}
2140
+ *
2141
+ * @category Content
2142
+ */
2143
+ export interface AudioContent {
2144
+ type: "audio";
2145
+ /**
2146
+ * The base64-encoded audio data.
2147
+ *
2148
+ * @format byte
2149
+ */
2150
+ data: string;
2151
+ /**
2152
+ * The MIME type of the audio. Different providers may support different audio types.
2153
+ */
2154
+ mimeType: string;
2155
+ /**
2156
+ * Optional annotations for the client.
2157
+ */
2158
+ annotations?: Annotations;
2159
+ _meta?: MetaObject;
2160
+ }
2161
+ /**
2162
+ * A request from the assistant to call a tool.
2163
+ *
2164
+ * @example `get_weather` tool use
2165
+ * {@includeCode ./examples/ToolUseContent/get-weather-tool-use.json}
2166
+ *
2167
+ * @deprecated Deprecated as of protocol version 2026-07-28 (SEP-2577).
2168
+ * Remains in the specification for at least twelve months; see the
2169
+ * deprecated features registry.
2170
+ *
2171
+ * @category `sampling/createMessage`
2172
+ */
2173
+ export interface ToolUseContent {
2174
+ type: "tool_use";
2175
+ /**
2176
+ * A unique identifier for this tool use.
2177
+ *
2178
+ * This ID is used to match tool results to their corresponding tool uses.
2179
+ */
2180
+ id: string;
2181
+ /**
2182
+ * The name of the tool to call.
2183
+ */
2184
+ name: string;
2185
+ /**
2186
+ * The arguments to pass to the tool, conforming to the tool's input schema.
2187
+ */
2188
+ input: {
2189
+ [key: string]: unknown;
2190
+ };
2191
+ /**
2192
+ * Optional metadata about the tool use. Clients SHOULD preserve this field when
2193
+ * including tool uses in subsequent sampling requests to enable caching optimizations.
2194
+ */
2195
+ _meta?: MetaObject;
2196
+ }
2197
+ /**
2198
+ * The result of a tool use, provided by the user back to the assistant.
2199
+ *
2200
+ * @example `get_weather` tool result
2201
+ * {@includeCode ./examples/ToolResultContent/get-weather-tool-result.json}
2202
+ *
2203
+ * @deprecated Deprecated as of protocol version 2026-07-28 (SEP-2577).
2204
+ * Remains in the specification for at least twelve months; see the
2205
+ * deprecated features registry.
2206
+ *
2207
+ * @category `sampling/createMessage`
2208
+ */
2209
+ export interface ToolResultContent {
2210
+ type: "tool_result";
2211
+ /**
2212
+ * The ID of the tool use this result corresponds to.
2213
+ *
2214
+ * This MUST match the ID from a previous {@link ToolUseContent}.
2215
+ */
2216
+ toolUseId: string;
2217
+ /**
2218
+ * The unstructured result content of the tool use.
2219
+ *
2220
+ * This has the same format as {@link CallToolResult.content} and can include text, images,
2221
+ * audio, resource links, and embedded resources.
2222
+ */
2223
+ content: ContentBlock[];
2224
+ /**
2225
+ * An optional structured result value.
2226
+ *
2227
+ * This can be any JSON value (object, array, string, number, boolean, or null).
2228
+ * If the tool defined an {@link Tool.outputSchema}, this SHOULD conform to that schema.
2229
+ */
2230
+ structuredContent?: unknown;
2231
+ /**
2232
+ * Whether the tool use resulted in an error.
2233
+ *
2234
+ * If true, the content typically describes the error that occurred.
2235
+ * Default: false
2236
+ */
2237
+ isError?: boolean;
2238
+ /**
2239
+ * Optional metadata about the tool result. Clients SHOULD preserve this field when
2240
+ * including tool results in subsequent sampling requests to enable caching optimizations.
2241
+ */
2242
+ _meta?: MetaObject;
2243
+ }
2244
+ /**
2245
+ * The server's preferences for model selection, requested of the client during sampling.
2246
+ *
2247
+ * Because LLMs can vary along multiple dimensions, choosing the "best" model is
2248
+ * rarely straightforward. Different models excel in different areas—some are
2249
+ * faster but less capable, others are more capable but more expensive, and so
2250
+ * on. This interface allows servers to express their priorities across multiple
2251
+ * dimensions to help clients make an appropriate selection for their use case.
2252
+ *
2253
+ * These preferences are always advisory. The client MAY ignore them. It is also
2254
+ * up to the client to decide how to interpret these preferences and how to
2255
+ * balance them against other considerations.
2256
+ *
2257
+ * @example With hints and priorities
2258
+ * {@includeCode ./examples/ModelPreferences/with-hints-and-priorities.json}
2259
+ *
2260
+ * @deprecated Deprecated as of protocol version 2026-07-28 (SEP-2577).
2261
+ * Remains in the specification for at least twelve months; see the
2262
+ * deprecated features registry.
2263
+ *
2264
+ * @category `sampling/createMessage`
2265
+ */
2266
+ export interface ModelPreferences {
2267
+ /**
2268
+ * Optional hints to use for model selection.
2269
+ *
2270
+ * If multiple hints are specified, the client MUST evaluate them in order
2271
+ * (such that the first match is taken).
2272
+ *
2273
+ * The client SHOULD prioritize these hints over the numeric priorities, but
2274
+ * MAY still use the priorities to select from ambiguous matches.
2275
+ */
2276
+ hints?: ModelHint[];
2277
+ /**
2278
+ * How much to prioritize cost when selecting a model. A value of 0 means cost
2279
+ * is not important, while a value of 1 means cost is the most important
2280
+ * factor.
2281
+ *
2282
+ * @TJS-type number
2283
+ * @minimum 0
2284
+ * @maximum 1
2285
+ */
2286
+ costPriority?: number;
2287
+ /**
2288
+ * How much to prioritize sampling speed (latency) when selecting a model. A
2289
+ * value of 0 means speed is not important, while a value of 1 means speed is
2290
+ * the most important factor.
2291
+ *
2292
+ * @TJS-type number
2293
+ * @minimum 0
2294
+ * @maximum 1
2295
+ */
2296
+ speedPriority?: number;
2297
+ /**
2298
+ * How much to prioritize intelligence and capabilities when selecting a
2299
+ * model. A value of 0 means intelligence is not important, while a value of 1
2300
+ * means intelligence is the most important factor.
2301
+ *
2302
+ * @TJS-type number
2303
+ * @minimum 0
2304
+ * @maximum 1
2305
+ */
2306
+ intelligencePriority?: number;
2307
+ }
2308
+ /**
2309
+ * Hints to use for model selection.
2310
+ *
2311
+ * Keys not declared here are currently left unspecified by the spec and are up
2312
+ * to the client to interpret.
2313
+ *
2314
+ * @deprecated Deprecated as of protocol version 2026-07-28 (SEP-2577).
2315
+ * Remains in the specification for at least twelve months; see the
2316
+ * deprecated features registry.
2317
+ *
2318
+ * @category `sampling/createMessage`
2319
+ */
2320
+ export interface ModelHint {
2321
+ /**
2322
+ * A hint for a model name.
2323
+ *
2324
+ * The client SHOULD treat this as a substring of a model name; for example:
2325
+ * - `claude-3-5-sonnet` should match `claude-3-5-sonnet-20241022`
2326
+ * - `sonnet` should match `claude-3-5-sonnet-20241022`, `claude-3-sonnet-20240229`, etc.
2327
+ * - `claude` should match any Claude model
2328
+ *
2329
+ * The client MAY also map the string to a different provider's model name or a different model family, as long as it fills a similar niche; for example:
2330
+ * - `gemini-1.5-flash` could match `claude-3-haiku-20240307`
2331
+ */
2332
+ name?: string;
2333
+ }
2334
+ /**
2335
+ * Parameters for a `completion/complete` request.
2336
+ *
2337
+ * @category `completion/complete`
2338
+ *
2339
+ * @example Prompt argument completion
2340
+ * {@includeCode ./examples/CompleteRequestParams/prompt-argument-completion.json}
2341
+ *
2342
+ * @example Prompt argument completion with context
2343
+ * {@includeCode ./examples/CompleteRequestParams/prompt-argument-completion-with-context.json}
2344
+ */
2345
+ export interface CompleteRequestParams extends RequestParams {
2346
+ ref: PromptReference | ResourceTemplateReference;
2347
+ /**
2348
+ * The argument's information
2349
+ */
2350
+ argument: {
2351
+ /**
2352
+ * The name of the argument
2353
+ */
2354
+ name: string;
2355
+ /**
2356
+ * The value of the argument to use for completion matching.
2357
+ */
2358
+ value: string;
2359
+ };
2360
+ /**
2361
+ * Additional, optional context for completions
2362
+ */
2363
+ context?: {
2364
+ /**
2365
+ * Previously-resolved variables in a URI template or prompt.
2366
+ */
2367
+ arguments?: {
2368
+ [key: string]: string;
2369
+ };
2370
+ };
2371
+ }
2372
+ /**
2373
+ * A request from the client to the server, to ask for completion options.
2374
+ *
2375
+ * @example Completion request
2376
+ * {@includeCode ./examples/CompleteRequest/completion-request.json}
2377
+ *
2378
+ * @category `completion/complete`
2379
+ */
2380
+ export interface CompleteRequest extends JSONRPCRequest {
2381
+ method: "completion/complete";
2382
+ params: CompleteRequestParams;
2383
+ }
2384
+ /**
2385
+ * The result returned by the server for a {@link CompleteRequest | completion/complete} request.
2386
+ *
2387
+ * @category `completion/complete`
2388
+ *
2389
+ * @example Single completion value
2390
+ * {@includeCode ./examples/CompleteResult/single-completion-value.json}
2391
+ *
2392
+ * @example Multiple completion values with more available
2393
+ * {@includeCode ./examples/CompleteResult/multiple-completion-values-with-more-available.json}
2394
+ */
2395
+ export interface CompleteResult extends Result {
2396
+ completion: {
2397
+ /**
2398
+ * An array of completion values. Must not exceed 100 items.
2399
+ *
2400
+ * @maxItems 100
2401
+ */
2402
+ values: string[];
2403
+ /**
2404
+ * The total number of completion options available. This can exceed the number of values actually sent in the response.
2405
+ */
2406
+ total?: number;
2407
+ /**
2408
+ * Indicates whether there are additional completion options beyond those provided in the current response, even if the exact total is unknown.
2409
+ */
2410
+ hasMore?: boolean;
2411
+ };
2412
+ }
2413
+ /**
2414
+ * A successful response from the server for a {@link CompleteRequest | completion/complete} request.
2415
+ *
2416
+ * @example Completion result response
2417
+ * {@includeCode ./examples/CompleteResultResponse/completion-result-response.json}
2418
+ *
2419
+ * @category `completion/complete`
2420
+ */
2421
+ export interface CompleteResultResponse extends JSONRPCResultResponse {
2422
+ result: CompleteResult;
2423
+ }
2424
+ /**
2425
+ * A reference to a resource or resource template definition.
2426
+ *
2427
+ * @category `completion/complete`
2428
+ */
2429
+ export interface ResourceTemplateReference {
2430
+ type: "ref/resource";
2431
+ /**
2432
+ * The URI or URI template of the resource.
2433
+ *
2434
+ * @format uri-template
2435
+ */
2436
+ uri: string;
2437
+ }
2438
+ /**
2439
+ * Identifies a prompt.
2440
+ *
2441
+ * @category `completion/complete`
2442
+ */
2443
+ export interface PromptReference extends BaseMetadata {
2444
+ type: "ref/prompt";
2445
+ }
2446
+ /**
2447
+ * Sent from the server to request a list of root URIs from the client. Roots allow
2448
+ * servers to ask for specific directories or files to operate on. A common example
2449
+ * for roots is providing a set of repositories or directories a server should operate
2450
+ * on.
2451
+ *
2452
+ * This request is typically used when the server needs to understand the file system
2453
+ * structure or access specific locations that the client has permission to read from.
2454
+ *
2455
+ * @example List roots request
2456
+ * {@includeCode ./examples/ListRootsRequest/list-roots-request.json}
2457
+ *
2458
+ * @deprecated Deprecated as of protocol version 2026-07-28 (SEP-2577).
2459
+ * Remains in the specification for at least twelve months; see the
2460
+ * deprecated features registry.
2461
+ *
2462
+ * @category `roots/list`
2463
+ */
2464
+ export interface ListRootsRequest {
2465
+ method: "roots/list";
2466
+ params?: {
2467
+ _meta?: MetaObject;
2468
+ };
2469
+ }
2470
+ /**
2471
+ * The result returned by the client for a {@link ListRootsRequest | roots/list} request.
2472
+ * This result contains an array of {@link Root} objects, each representing a root directory
2473
+ * or file that the server can operate on.
2474
+ *
2475
+ * @example Single root directory
2476
+ * {@includeCode ./examples/ListRootsResult/single-root-directory.json}
2477
+ *
2478
+ * @example Multiple root directories
2479
+ * {@includeCode ./examples/ListRootsResult/multiple-root-directories.json}
2480
+ *
2481
+ * @deprecated Deprecated as of protocol version 2026-07-28 (SEP-2577).
2482
+ * Remains in the specification for at least twelve months; see the
2483
+ * deprecated features registry.
2484
+ *
2485
+ * @category `roots/list`
2486
+ */
2487
+ export interface ListRootsResult {
2488
+ roots: Root[];
2489
+ }
2490
+ /**
2491
+ * Represents a root directory or file that the server can operate on.
2492
+ *
2493
+ * @example Project directory root
2494
+ * {@includeCode ./examples/Root/project-directory.json}
2495
+ *
2496
+ * @deprecated Deprecated as of protocol version 2026-07-28 (SEP-2577).
2497
+ * Remains in the specification for at least twelve months; see the
2498
+ * deprecated features registry.
2499
+ *
2500
+ * @category `roots/list`
2501
+ */
2502
+ export interface Root {
2503
+ /**
2504
+ * The URI identifying the root. This *must* start with `file://` for now.
2505
+ * This restriction may be relaxed in future versions of the protocol to allow
2506
+ * other URI schemes.
2507
+ *
2508
+ * @format uri
2509
+ */
2510
+ uri: string;
2511
+ /**
2512
+ * An optional name for the root. This can be used to provide a human-readable
2513
+ * identifier for the root, which may be useful for display purposes or for
2514
+ * referencing the root in other parts of the application.
2515
+ */
2516
+ name?: string;
2517
+ _meta?: MetaObject;
2518
+ }
2519
+ /**
2520
+ * The parameters for a request to elicit non-sensitive information from the user via a form in the client.
2521
+ *
2522
+ * @example Elicit single field
2523
+ * {@includeCode ./examples/ElicitRequestFormParams/elicit-single-field.json}
2524
+ *
2525
+ * @example Elicit multiple fields
2526
+ * {@includeCode ./examples/ElicitRequestFormParams/elicit-multiple-fields.json}
2527
+ *
2528
+ * @category `elicitation/create`
2529
+ */
2530
+ export interface ElicitRequestFormParams {
2531
+ /**
2532
+ * The elicitation mode.
2533
+ */
2534
+ mode?: "form";
2535
+ /**
2536
+ * The message to present to the user describing what information is being requested.
2537
+ */
2538
+ message: string;
2539
+ /**
2540
+ * A restricted subset of JSON Schema.
2541
+ * Only top-level properties are allowed, without nesting.
2542
+ */
2543
+ requestedSchema: {
2544
+ $schema?: string;
2545
+ type: "object";
2546
+ properties: {
2547
+ [key: string]: PrimitiveSchemaDefinition;
2548
+ };
2549
+ required?: string[];
2550
+ };
2551
+ }
2552
+ /**
2553
+ * The parameters for a request to elicit information from the user via a URL in the client.
2554
+ *
2555
+ * @example Elicit sensitive data
2556
+ * {@includeCode ./examples/ElicitRequestURLParams/elicit-sensitive-data.json}
2557
+ *
2558
+ * @category `elicitation/create`
2559
+ */
2560
+ export interface ElicitRequestURLParams {
2561
+ /**
2562
+ * The elicitation mode.
2563
+ */
2564
+ mode: "url";
2565
+ /**
2566
+ * The message to present to the user explaining why the interaction is needed.
2567
+ */
2568
+ message: string;
2569
+ /**
2570
+ * The URL that the user should navigate to.
2571
+ *
2572
+ * @format uri
2573
+ */
2574
+ url: string;
2575
+ }
2576
+ /**
2577
+ * The parameters for a request to elicit additional information from the user via the client.
2578
+ *
2579
+ * @category `elicitation/create`
2580
+ */
2581
+ export type ElicitRequestParams = ElicitRequestFormParams | ElicitRequestURLParams;
2582
+ /**
2583
+ * A request from the server to elicit additional information from the user via the client.
2584
+ *
2585
+ * @example Elicitation request
2586
+ * {@includeCode ./examples/ElicitRequest/elicitation-request.json}
2587
+ *
2588
+ * @category `elicitation/create`
2589
+ */
2590
+ export interface ElicitRequest {
2591
+ method: "elicitation/create";
2592
+ params: ElicitRequestParams;
2593
+ }
2594
+ /**
2595
+ * Restricted schema definitions that only allow primitive types
2596
+ * without nested objects or arrays.
2597
+ *
2598
+ * @category `elicitation/create`
2599
+ */
2600
+ export type PrimitiveSchemaDefinition = StringSchema | NumberSchema | BooleanSchema | EnumSchema;
2601
+ /**
2602
+ * @example Email input schema
2603
+ * {@includeCode ./examples/StringSchema/email-input-schema.json}
2604
+ *
2605
+ * @category `elicitation/create`
2606
+ */
2607
+ export interface StringSchema {
2608
+ type: "string";
2609
+ title?: string;
2610
+ description?: string;
2611
+ minLength?: number;
2612
+ maxLength?: number;
2613
+ format?: "email" | "uri" | "date" | "date-time";
2614
+ default?: string;
2615
+ }
2616
+ /**
2617
+ * @example Number input schema
2618
+ * {@includeCode ./examples/NumberSchema/number-input-schema.json}
2619
+ *
2620
+ * @category `elicitation/create`
2621
+ */
2622
+ export interface NumberSchema {
2623
+ type: "number" | "integer";
2624
+ title?: string;
2625
+ description?: string;
2626
+ /**
2627
+ * @TJS-type number
2628
+ */
2629
+ minimum?: number;
2630
+ /**
2631
+ * @TJS-type number
2632
+ */
2633
+ maximum?: number;
2634
+ /**
2635
+ * @TJS-type number
2636
+ */
2637
+ default?: number;
2638
+ }
2639
+ /**
2640
+ * @example Boolean input schema
2641
+ * {@includeCode ./examples/BooleanSchema/boolean-input-schema.json}
2642
+ *
2643
+ * @category `elicitation/create`
2644
+ */
2645
+ export interface BooleanSchema {
2646
+ type: "boolean";
2647
+ title?: string;
2648
+ description?: string;
2649
+ default?: boolean;
2650
+ }
2651
+ /**
2652
+ * Schema for single-selection enumeration without display titles for options.
2653
+ *
2654
+ * @example Color select schema
2655
+ * {@includeCode ./examples/UntitledSingleSelectEnumSchema/color-select-schema.json}
2656
+ *
2657
+ * @category `elicitation/create`
2658
+ */
2659
+ export interface UntitledSingleSelectEnumSchema {
2660
+ type: "string";
2661
+ /**
2662
+ * Optional title for the enum field.
2663
+ */
2664
+ title?: string;
2665
+ /**
2666
+ * Optional description for the enum field.
2667
+ */
2668
+ description?: string;
2669
+ /**
2670
+ * Array of enum values to choose from.
2671
+ */
2672
+ enum: string[];
2673
+ /**
2674
+ * Optional default value.
2675
+ */
2676
+ default?: string;
2677
+ }
2678
+ /**
2679
+ * Schema for single-selection enumeration with display titles for each option.
2680
+ *
2681
+ * @example Titled color select schema
2682
+ * {@includeCode ./examples/TitledSingleSelectEnumSchema/titled-color-select-schema.json}
2683
+ *
2684
+ * @category `elicitation/create`
2685
+ */
2686
+ export interface TitledSingleSelectEnumSchema {
2687
+ type: "string";
2688
+ /**
2689
+ * Optional title for the enum field.
2690
+ */
2691
+ title?: string;
2692
+ /**
2693
+ * Optional description for the enum field.
2694
+ */
2695
+ description?: string;
2696
+ /**
2697
+ * Array of enum options with values and display labels.
2698
+ */
2699
+ oneOf: Array<{
2700
+ /**
2701
+ * The enum value.
2702
+ */
2703
+ const: string;
2704
+ /**
2705
+ * Display label for this option.
2706
+ */
2707
+ title: string;
2708
+ }>;
2709
+ /**
2710
+ * Optional default value.
2711
+ */
2712
+ default?: string;
2713
+ }
2714
+ /**
2715
+ * @category `elicitation/create`
2716
+ */
2717
+ export type SingleSelectEnumSchema = UntitledSingleSelectEnumSchema | TitledSingleSelectEnumSchema;
2718
+ /**
2719
+ * Schema for multiple-selection enumeration without display titles for options.
2720
+ *
2721
+ * @example Color multi-select schema
2722
+ * {@includeCode ./examples/UntitledMultiSelectEnumSchema/color-multi-select-schema.json}
2723
+ *
2724
+ * @category `elicitation/create`
2725
+ */
2726
+ export interface UntitledMultiSelectEnumSchema {
2727
+ type: "array";
2728
+ /**
2729
+ * Optional title for the enum field.
2730
+ */
2731
+ title?: string;
2732
+ /**
2733
+ * Optional description for the enum field.
2734
+ */
2735
+ description?: string;
2736
+ /**
2737
+ * Minimum number of items to select.
2738
+ */
2739
+ minItems?: number;
2740
+ /**
2741
+ * Maximum number of items to select.
2742
+ */
2743
+ maxItems?: number;
2744
+ /**
2745
+ * Schema for the array items.
2746
+ */
2747
+ items: {
2748
+ type: "string";
2749
+ /**
2750
+ * Array of enum values to choose from.
2751
+ */
2752
+ enum: string[];
2753
+ };
2754
+ /**
2755
+ * Optional default value.
2756
+ */
2757
+ default?: string[];
2758
+ }
2759
+ /**
2760
+ * Schema for multiple-selection enumeration with display titles for each option.
2761
+ *
2762
+ * @example Titled color multi-select schema
2763
+ * {@includeCode ./examples/TitledMultiSelectEnumSchema/titled-color-multi-select-schema.json}
2764
+ *
2765
+ * @category `elicitation/create`
2766
+ */
2767
+ export interface TitledMultiSelectEnumSchema {
2768
+ type: "array";
2769
+ /**
2770
+ * Optional title for the enum field.
2771
+ */
2772
+ title?: string;
2773
+ /**
2774
+ * Optional description for the enum field.
2775
+ */
2776
+ description?: string;
2777
+ /**
2778
+ * Minimum number of items to select.
2779
+ */
2780
+ minItems?: number;
2781
+ /**
2782
+ * Maximum number of items to select.
2783
+ */
2784
+ maxItems?: number;
2785
+ /**
2786
+ * Schema for array items with enum options and display labels.
2787
+ */
2788
+ items: {
2789
+ /**
2790
+ * Array of enum options with values and display labels.
2791
+ */
2792
+ anyOf: Array<{
2793
+ /**
2794
+ * The constant enum value.
2795
+ */
2796
+ const: string;
2797
+ /**
2798
+ * Display title for this option.
2799
+ */
2800
+ title: string;
2801
+ }>;
2802
+ };
2803
+ /**
2804
+ * Optional default value.
2805
+ */
2806
+ default?: string[];
2807
+ }
2808
+ /**
2809
+ * @category `elicitation/create`
2810
+ */
2811
+ export type MultiSelectEnumSchema = UntitledMultiSelectEnumSchema | TitledMultiSelectEnumSchema;
2812
+ /**
2813
+ * Use {@link TitledSingleSelectEnumSchema} instead.
2814
+ * This interface will be removed in a future version.
2815
+ *
2816
+ * @category `elicitation/create`
2817
+ */
2818
+ export interface LegacyTitledEnumSchema {
2819
+ type: "string";
2820
+ title?: string;
2821
+ description?: string;
2822
+ enum: string[];
2823
+ /**
2824
+ * (Legacy) Display names for enum values.
2825
+ * Non-standard according to JSON schema 2020-12.
2826
+ */
2827
+ enumNames?: string[];
2828
+ default?: string;
2829
+ }
2830
+ /**
2831
+ * @category `elicitation/create`
2832
+ */
2833
+ export type EnumSchema = SingleSelectEnumSchema | MultiSelectEnumSchema | LegacyTitledEnumSchema;
2834
+ /**
2835
+ * The result returned by the client for an {@link ElicitRequest| elicitation/create} request.
2836
+ *
2837
+ * @example Input single field
2838
+ * {@includeCode ./examples/ElicitResult/input-single-field.json}
2839
+ *
2840
+ * @example Input multiple fields
2841
+ * {@includeCode ./examples/ElicitResult/input-multiple-fields.json}
2842
+ *
2843
+ * @example Accept URL mode (no content)
2844
+ * {@includeCode ./examples/ElicitResult/accept-url-mode-no-content.json}
2845
+ *
2846
+ * @category `elicitation/create`
2847
+ */
2848
+ export interface ElicitResult {
2849
+ /**
2850
+ * The user action in response to the elicitation.
2851
+ * - `"accept"`: User submitted the form/confirmed the action
2852
+ * - `"decline"`: User explicitly declined the action
2853
+ * - `"cancel"`: User dismissed without making an explicit choice
2854
+ */
2855
+ action: "accept" | "decline" | "cancel";
2856
+ /**
2857
+ * The submitted form data, only present when action is `"accept"` and mode was `"form"`.
2858
+ * Contains values matching the requested schema.
2859
+ * Omitted for out-of-band mode responses.
2860
+ */
2861
+ content?: {
2862
+ [key: string]: string | number | boolean | string[];
2863
+ };
2864
+ }
2865
+ /** @internal */
2866
+ export type ClientRequest = DiscoverRequest | CompleteRequest | GetPromptRequest | ListPromptsRequest | ListResourcesRequest | ListResourceTemplatesRequest | ReadResourceRequest | SubscriptionsListenRequest | CallToolRequest | ListToolsRequest;
2867
+ /** @internal */
2868
+ export type ClientNotification = CancelledNotification;
2869
+ /** @internal */
2870
+ export type ClientResult = EmptyResult;
2871
+ /** @internal */
2872
+ export type ServerNotification = CancelledNotification | ProgressNotification | LoggingMessageNotification | ResourceUpdatedNotification | ResourceListChangedNotification | ToolListChangedNotification | PromptListChangedNotification | SubscriptionsAcknowledgedNotification;
2873
+ /** @internal */
2874
+ export type ServerResult = EmptyResult | DiscoverResult | CompleteResult | GetPromptResult | ListPromptsResult | ListResourceTemplatesResult | ListResourcesResult | ReadResourceResult | SubscriptionsListenResult | CallToolResult | ListToolsResult | InputRequiredResult;