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