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