@fragments-sdk/mcp 0.10.0 → 1.0.1

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,1443 @@
1
+ import { ConformInput, ConformResult } from '@fragments-sdk/core';
2
+ export { ConformChange, ConformComponentMapping, ConformConfidence, ConformInput, ConformLocation, ConformPropMapping, ConformResult, ConformSuggestion, ConformUnresolved } from '@fragments-sdk/core';
3
+
4
+ type JsonObject = Record<string, unknown>;
5
+ interface McpPrimitive {
6
+ id: string;
7
+ name: string;
8
+ primitiveName?: string;
9
+ category?: string;
10
+ status?: string;
11
+ isActive?: boolean;
12
+ description?: string;
13
+ usageGuidance?: string;
14
+ importPath?: string | null;
15
+ packageName?: string | null;
16
+ filePath?: string | null;
17
+ sourceRepoFullName?: string | null;
18
+ publicRef?: string;
19
+ parentComponentId?: string;
20
+ parentComponentName?: string;
21
+ props?: JsonObject;
22
+ dos?: string[];
23
+ donts?: string[];
24
+ examples?: unknown[];
25
+ }
26
+
27
+ interface DataProvider {
28
+ listPrimitives(): Promise<McpPrimitive[]>;
29
+ conform(input: ConformInput): Promise<ConformResult>;
30
+ }
31
+ interface SamplingInputResponse {
32
+ role?: string;
33
+ content?: unknown;
34
+ model?: string;
35
+ stopReason?: string;
36
+ [key: string]: unknown;
37
+ }
38
+ interface ToolCallContext {
39
+ provider: DataProvider;
40
+ tasks: TaskStore;
41
+ requestMeta?: JsonObject;
42
+ clientCapabilities?: JsonObject;
43
+ inputResponses?: Record<string, SamplingInputResponse | unknown>;
44
+ requestState?: string;
45
+ }
46
+ interface ToolDefinition {
47
+ name: string;
48
+ title: string;
49
+ description: string;
50
+ inputSchema: JsonObject;
51
+ outputSchema?: JsonObject;
52
+ annotations?: JsonObject;
53
+ _meta?: JsonObject;
54
+ call(args: JsonObject, context: ToolCallContext): Promise<ToolResult | InputRequiredToolResult>;
55
+ }
56
+ interface ToolResult {
57
+ content?: Array<{
58
+ type: "text";
59
+ text: string;
60
+ }>;
61
+ structuredContent?: unknown;
62
+ _meta?: JsonObject;
63
+ }
64
+ interface InputRequiredToolResult {
65
+ resultType: "input_required";
66
+ inputRequests?: Record<string, JsonObject>;
67
+ requestState?: string;
68
+ _meta?: JsonObject;
69
+ }
70
+ interface ResourceDefinition {
71
+ uri: string;
72
+ name: string;
73
+ title: string;
74
+ description: string;
75
+ mimeType: string;
76
+ _meta?: JsonObject;
77
+ read(context: ToolCallContext): Promise<ResourceReadResult>;
78
+ }
79
+ interface ResourceReadResult {
80
+ contents: Array<{
81
+ uri: string;
82
+ mimeType: string;
83
+ text: string;
84
+ _meta?: JsonObject;
85
+ }>;
86
+ }
87
+ type TaskStatus = "working" | "input_required" | "completed" | "failed" | "cancelled";
88
+ interface TaskRecord {
89
+ taskId: string;
90
+ status: TaskStatus;
91
+ title: string;
92
+ createdAt: number;
93
+ updatedAt: number;
94
+ ttlMs: number;
95
+ pollIntervalMs: number;
96
+ result?: ToolResult;
97
+ error?: JsonObject;
98
+ progress?: {
99
+ current?: number;
100
+ total?: number;
101
+ message?: string;
102
+ };
103
+ }
104
+ interface WorkflowTaskInput {
105
+ kind: string;
106
+ arguments?: JsonObject;
107
+ }
108
+ interface TaskStore {
109
+ create(input: {
110
+ title: string;
111
+ ttlMs?: number;
112
+ pollIntervalMs?: number;
113
+ result?: ToolResult;
114
+ workflow?: WorkflowTaskInput;
115
+ }): Promise<TaskRecord>;
116
+ get(taskId: string): Promise<TaskRecord | null>;
117
+ update(taskId: string, patch: Partial<TaskRecord>): Promise<TaskRecord | null>;
118
+ cancel(taskId: string): Promise<TaskRecord | null>;
119
+ }
120
+ interface JsonRpcRequest {
121
+ jsonrpc?: "2.0";
122
+ id?: string | number | null;
123
+ method: string;
124
+ params?: JsonObject;
125
+ }
126
+ interface JsonRpcSuccess {
127
+ jsonrpc: "2.0";
128
+ id: string | number | null;
129
+ result: unknown;
130
+ }
131
+ interface JsonRpcFailure {
132
+ jsonrpc: "2.0";
133
+ id: string | number | null;
134
+ error: {
135
+ code: number;
136
+ message: string;
137
+ data?: unknown;
138
+ };
139
+ }
140
+ type JsonRpcResponse = JsonRpcSuccess | JsonRpcFailure;
141
+
142
+ declare const MCP_APP_RESOURCES: ResourceDefinition[];
143
+ declare function getResource(_uri: string): ResourceDefinition | null;
144
+ declare function listResources(): never[];
145
+
146
+ interface FragmentsMcpServerOptions {
147
+ provider: DataProvider;
148
+ tasks?: TaskStore;
149
+ }
150
+ declare class McpProtocolError extends Error {
151
+ readonly code: number;
152
+ readonly data?: unknown;
153
+ constructor(code: number, message: string, data?: unknown);
154
+ }
155
+ declare class FragmentsMcpServer {
156
+ private readonly provider;
157
+ private readonly tasks;
158
+ constructor(options: FragmentsMcpServerOptions);
159
+ handleJsonRpc(request: JsonRpcRequest): Promise<JsonRpcResponse>;
160
+ private dispatch;
161
+ private discover;
162
+ private callTool;
163
+ private readResource;
164
+ private getTask;
165
+ private updateTask;
166
+ private cancelTask;
167
+ }
168
+ declare function handleMcpJsonRpc(request: JsonRpcRequest, options: FragmentsMcpServerOptions): Promise<JsonRpcResponse>;
169
+ declare function handleMcpHttpRequest(request: Request, options: FragmentsMcpServerOptions): Promise<Response>;
170
+
171
+ declare class MemoryTaskStore implements TaskStore {
172
+ private readonly tasks;
173
+ create(input: {
174
+ title: string;
175
+ ttlMs?: number;
176
+ pollIntervalMs?: number;
177
+ result?: ToolResult;
178
+ workflow?: {
179
+ kind: string;
180
+ arguments?: Record<string, unknown>;
181
+ };
182
+ }): Promise<TaskRecord>;
183
+ get(taskId: string): Promise<TaskRecord | null>;
184
+ update(taskId: string, patch: Partial<TaskRecord>): Promise<TaskRecord | null>;
185
+ cancel(taskId: string): Promise<TaskRecord | null>;
186
+ }
187
+
188
+ /**
189
+ * @category Common Types
190
+ */
191
+ type JSONValue = string | number | boolean | null | JSONObject | JSONArray;
192
+ /**
193
+ * @category Common Types
194
+ */
195
+ type JSONObject = {
196
+ [key: string]: JSONValue;
197
+ };
198
+ /**
199
+ * @category Common Types
200
+ */
201
+ type JSONArray = JSONValue[];
202
+ /**
203
+ * Refers to any valid JSON-RPC object that can be decoded off the wire, or encoded to be sent.
204
+ *
205
+ * @category JSON-RPC
206
+ */
207
+ type JSONRPCMessage = JSONRPCRequest | JSONRPCNotification | JSONRPCResponse;
208
+ /** @internal */
209
+ declare const LATEST_PROTOCOL_VERSION = "DRAFT-2026-v1";
210
+ /** @internal */
211
+ declare const JSONRPC_VERSION = "2.0";
212
+ /**
213
+ * Represents the contents of a `_meta` field, which clients and servers use to attach additional metadata to their interactions.
214
+ *
215
+ * 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.
216
+ *
217
+ * Valid keys have two segments:
218
+ *
219
+ * **Prefix:**
220
+ * - Optional — if specified, MUST be a series of _labels_ separated by dots (`.`), followed by a slash (`/`).
221
+ * - Labels MUST start with a letter and end with a letter or digit. Interior characters may be letters, digits, or hyphens (`-`).
222
+ * - Implementations SHOULD use reverse DNS notation (e.g., `com.example/` rather than `example.com/`).
223
+ * - 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`.
224
+ *
225
+ * **Name:**
226
+ * - Unless empty, MUST start and end with an alphanumeric character (`[a-z0-9A-Z]`).
227
+ * - Interior characters may be alphanumeric, hyphens (`-`), underscores (`_`), or dots (`.`).
228
+ *
229
+ * @see [General fields: `_meta`](/specification/draft/basic/index#meta) for more details.
230
+ * @category Common Types
231
+ */
232
+ type MetaObject = Record<string, unknown>;
233
+ /**
234
+ * Extends {@link MetaObject} with additional request-specific fields. All key naming rules from `MetaObject` apply.
235
+ *
236
+ * @see {@link MetaObject} for key naming rules and reserved prefixes.
237
+ * @see [General fields: `_meta`](/specification/draft/basic/index#meta) for more details.
238
+ * @category Common Types
239
+ */
240
+ interface RequestMetaObject extends MetaObject {
241
+ /**
242
+ * 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.
243
+ */
244
+ progressToken?: ProgressToken;
245
+ /**
246
+ * The MCP Protocol Version being used for this request. Required.
247
+ *
248
+ * For the HTTP transport, this value MUST match the `MCP-Protocol-Version`
249
+ * header; otherwise the server MUST return a `400 Bad Request`. If the
250
+ * server does not support the requested version, it MUST return an
251
+ * {@link UnsupportedProtocolVersionError}.
252
+ */
253
+ "io.modelcontextprotocol/protocolVersion": string;
254
+ /**
255
+ * Identifies the client software making the request. Required.
256
+ *
257
+ * The {@link Implementation} schema requires `name` and `version`; other
258
+ * fields are optional.
259
+ */
260
+ "io.modelcontextprotocol/clientInfo": Implementation;
261
+ /**
262
+ * The client's capabilities for this specific request. Required.
263
+ *
264
+ * Capabilities are declared per-request rather than once at initialization;
265
+ * an empty object means the client supports no optional capabilities.
266
+ * Servers MUST NOT infer capabilities from prior requests.
267
+ */
268
+ "io.modelcontextprotocol/clientCapabilities": ClientCapabilities;
269
+ /**
270
+ * The desired log level for this request. Optional.
271
+ *
272
+ * If absent, the server MUST NOT send any {@link LoggingMessageNotification | notifications/message}
273
+ * notifications for this request. The client opts in to log messages by
274
+ * explicitly setting a level. Replaces the former `logging/setLevel` RPC.
275
+ */
276
+ "io.modelcontextprotocol/logLevel"?: LoggingLevel;
277
+ }
278
+ /**
279
+ * A progress token, used to associate progress notifications with the original request.
280
+ *
281
+ * @category Common Types
282
+ */
283
+ type ProgressToken = string | number;
284
+ /**
285
+ * An opaque token used to represent a cursor for pagination.
286
+ *
287
+ * @category Common Types
288
+ */
289
+ type Cursor = string;
290
+ /**
291
+ * Common params for any request.
292
+ *
293
+ * @category Common Types
294
+ */
295
+ interface RequestParams {
296
+ _meta: RequestMetaObject;
297
+ }
298
+ /** @internal */
299
+ interface Request$1 {
300
+ method: string;
301
+ params?: {
302
+ [key: string]: any;
303
+ };
304
+ }
305
+ /** @internal */
306
+ interface Notification {
307
+ method: string;
308
+ params?: {
309
+ [key: string]: any;
310
+ };
311
+ }
312
+ /**
313
+ * Indicates the type of a {@link Result} object, allowing the client to
314
+ * determine how to parse the response.
315
+ *
316
+ * complete - the request completed successfully and the result contains the final content.
317
+ * 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.
318
+ * @category Common Types
319
+ */
320
+ type ResultType = "complete" | "input_required";
321
+ /**
322
+ * Common result fields.
323
+ *
324
+ * @category Common Types
325
+ */
326
+ interface Result {
327
+ _meta?: MetaObject;
328
+ /**
329
+ * Indicates the type of the result, which allows the client to determine
330
+ * how to parse the result object.
331
+ *
332
+ * Servers implementing this protocol version MUST include this field.
333
+ * For backward compatibility, when a client receives a result from a
334
+ * server implementing an earlier protocol version (which does not include
335
+ * `resultType`), the client MUST treat the absent field as `"complete"`.
336
+ */
337
+ resultType: ResultType;
338
+ [key: string]: unknown;
339
+ }
340
+ /**
341
+ * @category Errors
342
+ */
343
+ interface Error$1 {
344
+ /**
345
+ * The error type that occurred.
346
+ */
347
+ code: number;
348
+ /**
349
+ * A short description of the error. The message SHOULD be limited to a concise single sentence.
350
+ */
351
+ message: string;
352
+ /**
353
+ * Additional information about the error. The value of this member is defined by the sender (e.g. detailed error information, nested errors etc.).
354
+ */
355
+ data?: unknown;
356
+ }
357
+ /**
358
+ * A uniquely identifying ID for a request in JSON-RPC.
359
+ *
360
+ * @category Common Types
361
+ */
362
+ type RequestId = string | number;
363
+ /**
364
+ * A request that expects a response.
365
+ *
366
+ * @category JSON-RPC
367
+ */
368
+ interface JSONRPCRequest extends Request$1 {
369
+ jsonrpc: typeof JSONRPC_VERSION;
370
+ id: RequestId;
371
+ }
372
+ /**
373
+ * A notification which does not expect a response.
374
+ *
375
+ * @category JSON-RPC
376
+ */
377
+ interface JSONRPCNotification extends Notification {
378
+ jsonrpc: typeof JSONRPC_VERSION;
379
+ }
380
+ /**
381
+ * A successful (non-error) response to a request.
382
+ *
383
+ * @category JSON-RPC
384
+ */
385
+ interface JSONRPCResultResponse {
386
+ jsonrpc: typeof JSONRPC_VERSION;
387
+ id: RequestId;
388
+ result: Result;
389
+ }
390
+ /**
391
+ * A response to a request that indicates an error occurred.
392
+ *
393
+ * @category JSON-RPC
394
+ */
395
+ interface JSONRPCErrorResponse {
396
+ jsonrpc: typeof JSONRPC_VERSION;
397
+ id?: RequestId;
398
+ error: Error$1;
399
+ }
400
+ /**
401
+ * A response to a request, containing either the result or error.
402
+ *
403
+ * @category JSON-RPC
404
+ */
405
+ type JSONRPCResponse = JSONRPCResultResponse | JSONRPCErrorResponse;
406
+ /** @internal */
407
+ type InputResponse = CreateMessageResult | ListRootsResult | ElicitResult;
408
+ /**
409
+ * A map of client responses to server-initiated requests.
410
+ * Keys correspond to the keys in the {@link InputRequests} map;
411
+ * values are the client's result for each request.
412
+ *
413
+ * @example Elicitation and sampling input responses
414
+ * {@includeCode ./examples/InputResponses/elicitation-and-sampling-input-responses.json}
415
+ *
416
+ * @category Multi Round-Trip
417
+ */
418
+ interface InputResponses {
419
+ [key: string]: InputResponse;
420
+ }
421
+ interface InputResponseRequestParams extends RequestParams {
422
+ inputResponses?: InputResponses;
423
+ requestState?: string;
424
+ }
425
+ /**
426
+ * 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.
427
+ *
428
+ * @category `server/discover`
429
+ */
430
+ interface ClientCapabilities {
431
+ /**
432
+ * Experimental, non-standard capabilities that the client supports.
433
+ */
434
+ experimental?: {
435
+ [key: string]: JSONObject;
436
+ };
437
+ /**
438
+ * Present if the client supports listing roots.
439
+ *
440
+ * @example Roots — minimum baseline support
441
+ * {@includeCode ./examples/ClientCapabilities/roots-minimum-baseline-support.json}
442
+ */
443
+ roots?: {};
444
+ /**
445
+ * Present if the client supports sampling from an LLM.
446
+ *
447
+ * @example Sampling — minimum baseline support
448
+ * {@includeCode ./examples/ClientCapabilities/sampling-minimum-baseline-support.json}
449
+ *
450
+ * @example Sampling — tool use support
451
+ * {@includeCode ./examples/ClientCapabilities/sampling-tool-use-support.json}
452
+ *
453
+ * @example Sampling — context inclusion support (soft-deprecated)
454
+ * {@includeCode ./examples/ClientCapabilities/sampling-context-inclusion-support-soft-deprecated.json}
455
+ */
456
+ sampling?: {
457
+ /**
458
+ * Whether the client supports context inclusion via `includeContext` parameter.
459
+ * If not declared, servers SHOULD only use `includeContext: "none"` (or omit it).
460
+ */
461
+ context?: JSONObject;
462
+ /**
463
+ * Whether the client supports tool use via `tools` and `toolChoice` parameters.
464
+ */
465
+ tools?: JSONObject;
466
+ };
467
+ /**
468
+ * Present if the client supports elicitation from the server.
469
+ *
470
+ * @example Elicitation — form and URL mode support
471
+ * {@includeCode ./examples/ClientCapabilities/elicitation-form-and-url-mode-support.json}
472
+ *
473
+ * @example Elicitation — form mode only (implicit)
474
+ * {@includeCode ./examples/ClientCapabilities/elicitation-form-only-implicit.json}
475
+ */
476
+ elicitation?: {
477
+ form?: JSONObject;
478
+ url?: JSONObject;
479
+ };
480
+ /**
481
+ * Optional MCP extensions that the client supports. Keys are extension identifiers
482
+ * (e.g., "io.modelcontextprotocol/oauth-client-credentials"), and values are
483
+ * per-extension settings objects. An empty object indicates support with no settings.
484
+ *
485
+ * @example Extensions — UI extension with MIME type support
486
+ * {@includeCode ./examples/ClientCapabilities/extensions-ui-mime-types.json}
487
+ */
488
+ extensions?: {
489
+ [key: string]: JSONObject;
490
+ };
491
+ }
492
+ /**
493
+ * 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.
494
+ *
495
+ * @category `server/discover`
496
+ */
497
+ interface ServerCapabilities {
498
+ /**
499
+ * Experimental, non-standard capabilities that the server supports.
500
+ */
501
+ experimental?: {
502
+ [key: string]: JSONObject;
503
+ };
504
+ /**
505
+ * Present if the server supports sending log messages to the client.
506
+ *
507
+ * @example Logging — minimum baseline support
508
+ * {@includeCode ./examples/ServerCapabilities/logging-minimum-baseline-support.json}
509
+ */
510
+ logging?: JSONObject;
511
+ /**
512
+ * Present if the server supports argument autocompletion suggestions.
513
+ *
514
+ * @example Completions — minimum baseline support
515
+ * {@includeCode ./examples/ServerCapabilities/completions-minimum-baseline-support.json}
516
+ */
517
+ completions?: JSONObject;
518
+ /**
519
+ * Present if the server offers any prompt templates.
520
+ *
521
+ * @example Prompts — minimum baseline support
522
+ * {@includeCode ./examples/ServerCapabilities/prompts-minimum-baseline-support.json}
523
+ *
524
+ * @example Prompts — list changed notifications
525
+ * {@includeCode ./examples/ServerCapabilities/prompts-list-changed-notifications.json}
526
+ */
527
+ prompts?: {
528
+ /**
529
+ * Whether this server supports notifications for changes to the prompt list.
530
+ */
531
+ listChanged?: boolean;
532
+ };
533
+ /**
534
+ * Present if the server offers any resources to read.
535
+ *
536
+ * @example Resources — minimum baseline support
537
+ * {@includeCode ./examples/ServerCapabilities/resources-minimum-baseline-support.json}
538
+ *
539
+ * @example Resources — subscription to individual resource updates (only)
540
+ * {@includeCode ./examples/ServerCapabilities/resources-subscription-to-individual-resource-updates-only.json}
541
+ *
542
+ * @example Resources — list changed notifications (only)
543
+ * {@includeCode ./examples/ServerCapabilities/resources-list-changed-notifications-only.json}
544
+ *
545
+ * @example Resources — all notifications
546
+ * {@includeCode ./examples/ServerCapabilities/resources-all-notifications.json}
547
+ */
548
+ resources?: {
549
+ /**
550
+ * Whether this server supports subscribing to resource updates.
551
+ */
552
+ subscribe?: boolean;
553
+ /**
554
+ * Whether this server supports notifications for changes to the resource list.
555
+ */
556
+ listChanged?: boolean;
557
+ };
558
+ /**
559
+ * Present if the server offers any tools to call.
560
+ *
561
+ * @example Tools — minimum baseline support
562
+ * {@includeCode ./examples/ServerCapabilities/tools-minimum-baseline-support.json}
563
+ *
564
+ * @example Tools — list changed notifications
565
+ * {@includeCode ./examples/ServerCapabilities/tools-list-changed-notifications.json}
566
+ */
567
+ tools?: {
568
+ /**
569
+ * Whether this server supports notifications for changes to the tool list.
570
+ */
571
+ listChanged?: boolean;
572
+ };
573
+ /**
574
+ * Optional MCP extensions that the server supports. Keys are extension identifiers
575
+ * (e.g., "io.modelcontextprotocol/apps"), and values are per-extension settings
576
+ * objects. An empty object indicates support with no settings.
577
+ *
578
+ * @example Extensions — UI extension support
579
+ * {@includeCode ./examples/ServerCapabilities/extensions-ui.json}
580
+ */
581
+ extensions?: {
582
+ [key: string]: JSONObject;
583
+ };
584
+ }
585
+ /**
586
+ * An optionally-sized icon that can be displayed in a user interface.
587
+ *
588
+ * @category Common Types
589
+ */
590
+ interface Icon {
591
+ /**
592
+ * A standard URI pointing to an icon resource. May be an HTTP/HTTPS URL or a
593
+ * `data:` URI with Base64-encoded image data.
594
+ *
595
+ * Consumers SHOULD take steps to ensure URLs serving icons are from the
596
+ * same domain as the client/server or a trusted domain.
597
+ *
598
+ * Consumers SHOULD take appropriate precautions when consuming SVGs as they can contain
599
+ * executable JavaScript.
600
+ *
601
+ * @format uri
602
+ */
603
+ src: string;
604
+ /**
605
+ * Optional MIME type override if the source MIME type is missing or generic.
606
+ * For example: `"image/png"`, `"image/jpeg"`, or `"image/svg+xml"`.
607
+ */
608
+ mimeType?: string;
609
+ /**
610
+ * Optional array of strings that specify sizes at which the icon can be used.
611
+ * Each string should be in WxH format (e.g., `"48x48"`, `"96x96"`) or `"any"` for scalable formats like SVG.
612
+ *
613
+ * If not provided, the client should assume that the icon can be used at any size.
614
+ */
615
+ sizes?: string[];
616
+ /**
617
+ * Optional specifier for the theme this icon is designed for. `"light"` indicates
618
+ * the icon is designed to be used with a light background, and `"dark"` indicates
619
+ * the icon is designed to be used with a dark background.
620
+ *
621
+ * If not provided, the client should assume the icon can be used with any theme.
622
+ */
623
+ theme?: "light" | "dark";
624
+ }
625
+ /**
626
+ * Base interface to add `icons` property.
627
+ *
628
+ * @internal
629
+ */
630
+ interface Icons {
631
+ /**
632
+ * Optional set of sized icons that the client can display in a user interface.
633
+ *
634
+ * Clients that support rendering icons MUST support at least the following MIME types:
635
+ * - `image/png` - PNG images (safe, universal compatibility)
636
+ * - `image/jpeg` (and `image/jpg`) - JPEG images (safe, universal compatibility)
637
+ *
638
+ * Clients that support rendering icons SHOULD also support:
639
+ * - `image/svg+xml` - SVG images (scalable but requires security precautions)
640
+ * - `image/webp` - WebP images (modern, efficient format)
641
+ */
642
+ icons?: Icon[];
643
+ }
644
+ /**
645
+ * Base interface for metadata with name (identifier) and title (display name) properties.
646
+ *
647
+ * @internal
648
+ */
649
+ interface BaseMetadata {
650
+ /**
651
+ * Intended for programmatic or logical use, but used as a display name in past specs or fallback (if title isn't present).
652
+ */
653
+ name: string;
654
+ /**
655
+ * Intended for UI and end-user contexts — optimized to be human-readable and easily understood,
656
+ * even by those unfamiliar with domain-specific terminology.
657
+ *
658
+ * If not provided, the name should be used for display (except for {@link Tool},
659
+ * where `annotations.title` should be given precedence over using `name`,
660
+ * if present).
661
+ */
662
+ title?: string;
663
+ }
664
+ /**
665
+ * Describes the MCP implementation.
666
+ *
667
+ * @category `server/discover`
668
+ */
669
+ interface Implementation extends BaseMetadata, Icons {
670
+ /**
671
+ * The version of this implementation.
672
+ */
673
+ version: string;
674
+ /**
675
+ * An optional human-readable description of what this implementation does.
676
+ *
677
+ * This can be used by clients or servers to provide context about their purpose
678
+ * and capabilities. For example, a server might describe the types of resources
679
+ * or tools it provides, while a client might describe its intended use case.
680
+ */
681
+ description?: string;
682
+ /**
683
+ * An optional URL of the website for this implementation.
684
+ *
685
+ * @format uri
686
+ */
687
+ websiteUrl?: string;
688
+ }
689
+ /** @internal */
690
+ interface PaginatedResult extends Result {
691
+ /**
692
+ * An opaque token representing the pagination position after the last returned result.
693
+ * If present, there may be more results available.
694
+ */
695
+ nextCursor?: Cursor;
696
+ }
697
+ /**
698
+ * A result that supports a time-to-live (TTL) hint for client-side caching.
699
+ *
700
+ * @internal
701
+ */
702
+ interface CacheableResult extends Result {
703
+ /**
704
+ * A hint from the server indicating how long (in milliseconds) the
705
+ * client MAY cache this response before re-fetching. Semantics are
706
+ * analogous to HTTP Cache-Control max-age.
707
+ *
708
+ * - If 0, The response SHOULD be considered immediately stale,
709
+ * The client MAY re-fetch every time the result is needed.
710
+ * - If positive, the client SHOULD consider the result fresh for this many
711
+ * milliseconds after receiving the response.
712
+ *
713
+ * @minimum 0
714
+ */
715
+ ttlMs: number;
716
+ /**
717
+ * Indicates the intended scope of the cached response, analogous to HTTP
718
+ * `Cache-Control: public` vs `Cache-Control: private`.
719
+ *
720
+ * - `"public"`: Any client or intermediary (e.g., shared gateway, proxy)
721
+ * MAY cache the response and serve it to any user.
722
+ * - `"private"`: Only the requesting user's client MAY cache the response.
723
+ * Shared caches (e.g., multi-tenant gateways) MUST NOT serve a cached
724
+ * copy to a different user.
725
+ *
726
+ */
727
+ cacheScope: "public" | "private";
728
+ }
729
+ /**
730
+ * The result returned by the server for a {@link ListResourcesRequest | resources/list} request.
731
+ *
732
+ * @example Resources list with cursor and TTL
733
+ * {@includeCode ./examples/ListResourcesResult/resources-list-with-cursor-and-ttl.json}
734
+ *
735
+ * @category `resources/list`
736
+ */
737
+ interface ListResourcesResult extends PaginatedResult, CacheableResult {
738
+ resources: Resource[];
739
+ }
740
+ /**
741
+ * Common params for resource-related requests.
742
+ *
743
+ * @internal
744
+ */
745
+ interface ResourceRequestParams extends RequestParams {
746
+ /**
747
+ * The URI of the resource. The URI can use any protocol; it is up to the server how to interpret it.
748
+ *
749
+ * @format uri
750
+ */
751
+ uri: string;
752
+ }
753
+ /**
754
+ * Parameters for a `resources/read` request.
755
+ *
756
+ * @category `resources/read`
757
+ */
758
+ interface ReadResourceRequestParams extends ResourceRequestParams, InputResponseRequestParams {
759
+ }
760
+ /**
761
+ * Sent from the client to the server, to read a specific resource URI.
762
+ *
763
+ * @example Read resource request
764
+ * {@includeCode ./examples/ReadResourceRequest/read-resource-request.json}
765
+ *
766
+ * @category `resources/read`
767
+ */
768
+ interface ReadResourceRequest extends JSONRPCRequest {
769
+ method: "resources/read";
770
+ params: ReadResourceRequestParams;
771
+ }
772
+ /**
773
+ * The result returned by the server for a {@link ReadResourceRequest | resources/read} request.
774
+ *
775
+ * @example File resource contents
776
+ * {@includeCode ./examples/ReadResourceResult/file-resource-contents.json}
777
+ *
778
+ * @category `resources/read`
779
+ */
780
+ interface ReadResourceResult extends CacheableResult {
781
+ contents: (TextResourceContents | BlobResourceContents)[];
782
+ }
783
+ /**
784
+ * A known resource that the server is capable of reading.
785
+ *
786
+ * @example File resource with annotations
787
+ * {@includeCode ./examples/Resource/file-resource-with-annotations.json}
788
+ *
789
+ * @category `resources/list`
790
+ */
791
+ interface Resource extends BaseMetadata, Icons {
792
+ /**
793
+ * The URI of this resource.
794
+ *
795
+ * @format uri
796
+ */
797
+ uri: string;
798
+ /**
799
+ * A description of what this resource represents.
800
+ *
801
+ * 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.
802
+ */
803
+ description?: string;
804
+ /**
805
+ * The MIME type of this resource, if known.
806
+ */
807
+ mimeType?: string;
808
+ /**
809
+ * Optional annotations for the client.
810
+ */
811
+ annotations?: Annotations;
812
+ /**
813
+ * The size of the raw resource content, in bytes (i.e., before base64 encoding or any tokenization), if known.
814
+ *
815
+ * This can be used by Hosts to display file sizes and estimate context window usage.
816
+ */
817
+ size?: number;
818
+ _meta?: MetaObject;
819
+ }
820
+ /**
821
+ * The contents of a specific resource or sub-resource.
822
+ *
823
+ * @internal
824
+ */
825
+ interface ResourceContents {
826
+ /**
827
+ * The URI of this resource.
828
+ *
829
+ * @format uri
830
+ */
831
+ uri: string;
832
+ /**
833
+ * The MIME type of this resource, if known.
834
+ */
835
+ mimeType?: string;
836
+ _meta?: MetaObject;
837
+ }
838
+ /**
839
+ * @example Text file contents
840
+ * {@includeCode ./examples/TextResourceContents/text-file-contents.json}
841
+ *
842
+ * @category Content
843
+ */
844
+ interface TextResourceContents extends ResourceContents {
845
+ /**
846
+ * The text of the item. This must only be set if the item can actually be represented as text (not binary data).
847
+ */
848
+ text: string;
849
+ }
850
+ /**
851
+ * @example Image file contents
852
+ * {@includeCode ./examples/BlobResourceContents/image-file-contents.json}
853
+ *
854
+ * @category Content
855
+ */
856
+ interface BlobResourceContents extends ResourceContents {
857
+ /**
858
+ * A base64-encoded string representing the binary data of the item.
859
+ *
860
+ * @format byte
861
+ */
862
+ blob: string;
863
+ }
864
+ /**
865
+ * The sender or recipient of messages and data in a conversation.
866
+ *
867
+ * @category Common Types
868
+ */
869
+ type Role = "user" | "assistant";
870
+ /**
871
+ * A resource that the server is capable of reading, included in a prompt or tool call result.
872
+ *
873
+ * Note: resource links returned by tools are not guaranteed to appear in the results of {@link ListResourcesRequest | resources/list} requests.
874
+ *
875
+ * @example File resource link
876
+ * {@includeCode ./examples/ResourceLink/file-resource-link.json}
877
+ *
878
+ * @category Content
879
+ */
880
+ interface ResourceLink extends Resource {
881
+ type: "resource_link";
882
+ }
883
+ /**
884
+ * The contents of a resource, embedded into a prompt or tool call result.
885
+ *
886
+ * It is up to the client how best to render embedded resources for the benefit
887
+ * of the LLM and/or the user.
888
+ *
889
+ * @example Embedded file resource with annotations
890
+ * {@includeCode ./examples/EmbeddedResource/embedded-file-resource-with-annotations.json}
891
+ *
892
+ * @category Content
893
+ */
894
+ interface EmbeddedResource {
895
+ type: "resource";
896
+ resource: TextResourceContents | BlobResourceContents;
897
+ /**
898
+ * Optional annotations for the client.
899
+ */
900
+ annotations?: Annotations;
901
+ _meta?: MetaObject;
902
+ }
903
+ /**
904
+ * The result returned by the server for a {@link ListToolsRequest | tools/list} request.
905
+ *
906
+ * @example Tools list with cursor and TTL
907
+ * {@includeCode ./examples/ListToolsResult/tools-list-with-cursor-and-ttl.json}
908
+ *
909
+ * @category `tools/list`
910
+ */
911
+ interface ListToolsResult extends PaginatedResult, CacheableResult {
912
+ tools: Tool[];
913
+ }
914
+ /**
915
+ * The result returned by the server for a {@link CallToolRequest | tools/call} request.
916
+ *
917
+ * @example Result with unstructured text
918
+ * {@includeCode ./examples/CallToolResult/result-with-unstructured-text.json}
919
+ *
920
+ * @example Result with structured content
921
+ * {@includeCode ./examples/CallToolResult/result-with-structured-content.json}
922
+ *
923
+ * @example Invalid tool input error
924
+ * {@includeCode ./examples/CallToolResult/invalid-tool-input-error.json}
925
+ *
926
+ * @category `tools/call`
927
+ */
928
+ interface CallToolResult extends Result {
929
+ /**
930
+ * A list of content objects that represent the unstructured result of the tool call.
931
+ */
932
+ content: ContentBlock[];
933
+ /**
934
+ * An optional JSON value that represents the structured result of the tool call.
935
+ *
936
+ * This can be any JSON value (object, array, string, number, boolean, or null)
937
+ * that conforms to the tool's outputSchema if one is defined.
938
+ */
939
+ structuredContent?: unknown;
940
+ /**
941
+ * Whether the tool call ended in an error.
942
+ *
943
+ * If not set, this is assumed to be false (the call was successful).
944
+ *
945
+ * Any errors that originate from the tool SHOULD be reported inside the result
946
+ * object, with `isError` set to true, _not_ as an MCP protocol-level error
947
+ * response. Otherwise, the LLM would not be able to see that an error occurred
948
+ * and self-correct.
949
+ *
950
+ * However, any errors in _finding_ the tool, an error indicating that the
951
+ * server does not support tool calls, or any other exceptional conditions,
952
+ * should be reported as an MCP error response.
953
+ */
954
+ isError?: boolean;
955
+ }
956
+ /**
957
+ * Parameters for a `tools/call` request.
958
+ *
959
+ * @example `get_weather` tool call params
960
+ * {@includeCode ./examples/CallToolRequestParams/get-weather-tool-call-params.json}
961
+ *
962
+ * @example Tool call params with progress token
963
+ * {@includeCode ./examples/CallToolRequestParams/tool-call-params-with-progress-token.json}
964
+ *
965
+ * @category `tools/call`
966
+ */
967
+ interface CallToolRequestParams extends InputResponseRequestParams {
968
+ /**
969
+ * The name of the tool.
970
+ */
971
+ name: string;
972
+ /**
973
+ * Arguments to use for the tool call.
974
+ */
975
+ arguments?: {
976
+ [key: string]: unknown;
977
+ };
978
+ }
979
+ /**
980
+ * Used by the client to invoke a tool provided by the server.
981
+ *
982
+ * @example Call tool request
983
+ * {@includeCode ./examples/CallToolRequest/call-tool-request.json}
984
+ *
985
+ * @category `tools/call`
986
+ */
987
+ interface CallToolRequest extends JSONRPCRequest {
988
+ method: "tools/call";
989
+ params: CallToolRequestParams;
990
+ }
991
+ /**
992
+ * Additional properties describing a {@link Tool} to clients.
993
+ *
994
+ * NOTE: all properties in `ToolAnnotations` are **hints**.
995
+ * They are not guaranteed to provide a faithful description of
996
+ * tool behavior (including descriptive properties like `title`).
997
+ *
998
+ * Clients should never make tool use decisions based on `ToolAnnotations`
999
+ * received from untrusted servers.
1000
+ *
1001
+ * @category `tools/list`
1002
+ */
1003
+ interface ToolAnnotations {
1004
+ /**
1005
+ * A human-readable title for the tool.
1006
+ */
1007
+ title?: string;
1008
+ /**
1009
+ * If true, the tool does not modify its environment.
1010
+ *
1011
+ * Default: false
1012
+ */
1013
+ readOnlyHint?: boolean;
1014
+ /**
1015
+ * If true, the tool may perform destructive updates to its environment.
1016
+ * If false, the tool performs only additive updates.
1017
+ *
1018
+ * (This property is meaningful only when `readOnlyHint == false`)
1019
+ *
1020
+ * Default: true
1021
+ */
1022
+ destructiveHint?: boolean;
1023
+ /**
1024
+ * If true, calling the tool repeatedly with the same arguments
1025
+ * will have no additional effect on its environment.
1026
+ *
1027
+ * (This property is meaningful only when `readOnlyHint == false`)
1028
+ *
1029
+ * Default: false
1030
+ */
1031
+ idempotentHint?: boolean;
1032
+ /**
1033
+ * If true, this tool may interact with an "open world" of external
1034
+ * entities. If false, the tool's domain of interaction is closed.
1035
+ * For example, the world of a web search tool is open, whereas that
1036
+ * of a memory tool is not.
1037
+ *
1038
+ * Default: true
1039
+ */
1040
+ openWorldHint?: boolean;
1041
+ }
1042
+ /**
1043
+ * Definition for a tool the client can call.
1044
+ *
1045
+ * @example With default 2020-12 input schema
1046
+ * {@includeCode ./examples/Tool/with-default-2020-12-input-schema.json}
1047
+ *
1048
+ * @example With explicit draft-07 input schema
1049
+ * {@includeCode ./examples/Tool/with-explicit-draft-07-input-schema.json}
1050
+ *
1051
+ * @example With no parameters
1052
+ * {@includeCode ./examples/Tool/with-no-parameters.json}
1053
+ *
1054
+ * @example With output schema for structured content
1055
+ * {@includeCode ./examples/Tool/with-output-schema-for-structured-content.json}
1056
+ *
1057
+ * @category `tools/list`
1058
+ */
1059
+ interface Tool extends BaseMetadata, Icons {
1060
+ /**
1061
+ * A human-readable description of the tool.
1062
+ *
1063
+ * 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.
1064
+ */
1065
+ description?: string;
1066
+ /**
1067
+ * A JSON Schema object defining the expected parameters for the tool.
1068
+ *
1069
+ * Tool arguments are always JSON objects, so `type: "object"` is required at the root.
1070
+ * Beyond that, any JSON Schema 2020-12 keyword may appear alongside `type` — including
1071
+ * composition keywords (`oneOf`, `anyOf`, `allOf`, `not`), conditional keywords
1072
+ * (`if`/`then`/`else`), reference keywords (`$ref`, `$defs`, `$anchor`), and any other
1073
+ * standard validation or annotation keywords.
1074
+ *
1075
+ * Defaults to JSON Schema 2020-12 when no explicit `$schema` is provided.
1076
+ */
1077
+ inputSchema: {
1078
+ $schema?: string;
1079
+ type: "object";
1080
+ [key: string]: unknown;
1081
+ };
1082
+ /**
1083
+ * An optional JSON Schema object defining the structure of the tool's output returned in
1084
+ * the structuredContent field of a {@link CallToolResult}. This can be any valid JSON Schema 2020-12.
1085
+ *
1086
+ * Defaults to JSON Schema 2020-12 when no explicit `$schema` is provided.
1087
+ */
1088
+ outputSchema?: {
1089
+ $schema?: string;
1090
+ [key: string]: unknown;
1091
+ };
1092
+ /**
1093
+ * Optional additional tool information.
1094
+ *
1095
+ * Display name precedence order is: `title`, `annotations.title`, then `name`.
1096
+ */
1097
+ annotations?: ToolAnnotations;
1098
+ _meta?: MetaObject;
1099
+ }
1100
+ /**
1101
+ * The severity of a log message.
1102
+ *
1103
+ * These map to syslog message severities, as specified in RFC-5424:
1104
+ * https://datatracker.ietf.org/doc/html/rfc5424#section-6.2.1
1105
+ *
1106
+ * @category Common Types
1107
+ */
1108
+ type LoggingLevel = "debug" | "info" | "notice" | "warning" | "error" | "critical" | "alert" | "emergency";
1109
+ /**
1110
+ * The result returned by the client for a {@link CreateMessageRequest | sampling/createMessage} request.
1111
+ * The client should inform the user before returning the sampled message, to allow them
1112
+ * to inspect the response (human in the loop) and decide whether to allow the server to see it.
1113
+ *
1114
+ * @example Text response
1115
+ * {@includeCode ./examples/CreateMessageResult/text-response.json}
1116
+ *
1117
+ * @example Tool use response
1118
+ * {@includeCode ./examples/CreateMessageResult/tool-use-response.json}
1119
+ *
1120
+ * @example Final response after tool use
1121
+ * {@includeCode ./examples/CreateMessageResult/final-response.json}
1122
+ *
1123
+ * @category `sampling/createMessage`
1124
+ */
1125
+ interface CreateMessageResult extends SamplingMessage {
1126
+ /**
1127
+ * The name of the model that generated the message.
1128
+ */
1129
+ model: string;
1130
+ /**
1131
+ * The reason why sampling stopped, if known.
1132
+ *
1133
+ * Standard values:
1134
+ * - `"endTurn"`: Natural end of the assistant's turn
1135
+ * - `"stopSequence"`: A stop sequence was encountered
1136
+ * - `"maxTokens"`: Maximum token limit was reached
1137
+ * - `"toolUse"`: The model wants to use one or more tools
1138
+ *
1139
+ * This field is an open string to allow for provider-specific stop reasons.
1140
+ */
1141
+ stopReason?: "endTurn" | "stopSequence" | "maxTokens" | "toolUse" | string;
1142
+ }
1143
+ /**
1144
+ * Describes a message issued to or received from an LLM API.
1145
+ *
1146
+ * @example Single content block
1147
+ * {@includeCode ./examples/SamplingMessage/single-content-block.json}
1148
+ *
1149
+ * @example Multiple content blocks
1150
+ * {@includeCode ./examples/SamplingMessage/multiple-content-blocks.json}
1151
+ *
1152
+ * @category `sampling/createMessage`
1153
+ */
1154
+ interface SamplingMessage {
1155
+ role: Role;
1156
+ content: SamplingMessageContentBlock | SamplingMessageContentBlock[];
1157
+ _meta?: MetaObject;
1158
+ }
1159
+ /**
1160
+ * @category `sampling/createMessage`
1161
+ */
1162
+ type SamplingMessageContentBlock = TextContent | ImageContent | AudioContent | ToolUseContent | ToolResultContent;
1163
+ /**
1164
+ * Optional annotations for the client. The client can use annotations to inform how objects are used or displayed
1165
+ *
1166
+ * @category Common Types
1167
+ */
1168
+ interface Annotations {
1169
+ /**
1170
+ * Describes who the intended audience of this object or data is.
1171
+ *
1172
+ * It can include multiple entries to indicate content useful for multiple audiences (e.g., `["user", "assistant"]`).
1173
+ */
1174
+ audience?: Role[];
1175
+ /**
1176
+ * Describes how important this data is for operating the server.
1177
+ *
1178
+ * A value of 1 means "most important," and indicates that the data is
1179
+ * effectively required, while 0 means "least important," and indicates that
1180
+ * the data is entirely optional.
1181
+ *
1182
+ * @TJS-type number
1183
+ * @minimum 0
1184
+ * @maximum 1
1185
+ */
1186
+ priority?: number;
1187
+ /**
1188
+ * The moment the resource was last modified, as an ISO 8601 formatted string.
1189
+ *
1190
+ * Should be an ISO 8601 formatted string (e.g., "2025-01-12T15:00:58Z").
1191
+ *
1192
+ * Examples: last activity timestamp in an open file, timestamp when the resource
1193
+ * was attached, etc.
1194
+ */
1195
+ lastModified?: string;
1196
+ }
1197
+ /**
1198
+ * @category Content
1199
+ */
1200
+ type ContentBlock = TextContent | ImageContent | AudioContent | ResourceLink | EmbeddedResource;
1201
+ /**
1202
+ * Text provided to or from an LLM.
1203
+ *
1204
+ * @example Text content
1205
+ * {@includeCode ./examples/TextContent/text-content.json}
1206
+ *
1207
+ * @category Content
1208
+ */
1209
+ interface TextContent {
1210
+ type: "text";
1211
+ /**
1212
+ * The text content of the message.
1213
+ */
1214
+ text: string;
1215
+ /**
1216
+ * Optional annotations for the client.
1217
+ */
1218
+ annotations?: Annotations;
1219
+ _meta?: MetaObject;
1220
+ }
1221
+ /**
1222
+ * An image provided to or from an LLM.
1223
+ *
1224
+ * @example `image/png` content with annotations
1225
+ * {@includeCode ./examples/ImageContent/image-png-content-with-annotations.json}
1226
+ *
1227
+ * @category Content
1228
+ */
1229
+ interface ImageContent {
1230
+ type: "image";
1231
+ /**
1232
+ * The base64-encoded image data.
1233
+ *
1234
+ * @format byte
1235
+ */
1236
+ data: string;
1237
+ /**
1238
+ * The MIME type of the image. Different providers may support different image types.
1239
+ */
1240
+ mimeType: string;
1241
+ /**
1242
+ * Optional annotations for the client.
1243
+ */
1244
+ annotations?: Annotations;
1245
+ _meta?: MetaObject;
1246
+ }
1247
+ /**
1248
+ * Audio provided to or from an LLM.
1249
+ *
1250
+ * @example `audio/wav` content
1251
+ * {@includeCode ./examples/AudioContent/audio-wav-content.json}
1252
+ *
1253
+ * @category Content
1254
+ */
1255
+ interface AudioContent {
1256
+ type: "audio";
1257
+ /**
1258
+ * The base64-encoded audio data.
1259
+ *
1260
+ * @format byte
1261
+ */
1262
+ data: string;
1263
+ /**
1264
+ * The MIME type of the audio. Different providers may support different audio types.
1265
+ */
1266
+ mimeType: string;
1267
+ /**
1268
+ * Optional annotations for the client.
1269
+ */
1270
+ annotations?: Annotations;
1271
+ _meta?: MetaObject;
1272
+ }
1273
+ /**
1274
+ * A request from the assistant to call a tool.
1275
+ *
1276
+ * @example `get_weather` tool use
1277
+ * {@includeCode ./examples/ToolUseContent/get-weather-tool-use.json}
1278
+ *
1279
+ * @category `sampling/createMessage`
1280
+ */
1281
+ interface ToolUseContent {
1282
+ type: "tool_use";
1283
+ /**
1284
+ * A unique identifier for this tool use.
1285
+ *
1286
+ * This ID is used to match tool results to their corresponding tool uses.
1287
+ */
1288
+ id: string;
1289
+ /**
1290
+ * The name of the tool to call.
1291
+ */
1292
+ name: string;
1293
+ /**
1294
+ * The arguments to pass to the tool, conforming to the tool's input schema.
1295
+ */
1296
+ input: {
1297
+ [key: string]: unknown;
1298
+ };
1299
+ /**
1300
+ * Optional metadata about the tool use. Clients SHOULD preserve this field when
1301
+ * including tool uses in subsequent sampling requests to enable caching optimizations.
1302
+ */
1303
+ _meta?: MetaObject;
1304
+ }
1305
+ /**
1306
+ * The result of a tool use, provided by the user back to the assistant.
1307
+ *
1308
+ * @example `get_weather` tool result
1309
+ * {@includeCode ./examples/ToolResultContent/get-weather-tool-result.json}
1310
+ *
1311
+ * @category `sampling/createMessage`
1312
+ */
1313
+ interface ToolResultContent {
1314
+ type: "tool_result";
1315
+ /**
1316
+ * The ID of the tool use this result corresponds to.
1317
+ *
1318
+ * This MUST match the ID from a previous {@link ToolUseContent}.
1319
+ */
1320
+ toolUseId: string;
1321
+ /**
1322
+ * The unstructured result content of the tool use.
1323
+ *
1324
+ * This has the same format as {@link CallToolResult.content} and can include text, images,
1325
+ * audio, resource links, and embedded resources.
1326
+ */
1327
+ content: ContentBlock[];
1328
+ /**
1329
+ * An optional structured result value.
1330
+ *
1331
+ * This can be any JSON value (object, array, string, number, boolean, or null).
1332
+ * If the tool defined an {@link Tool.outputSchema}, this SHOULD conform to that schema.
1333
+ */
1334
+ structuredContent?: unknown;
1335
+ /**
1336
+ * Whether the tool use resulted in an error.
1337
+ *
1338
+ * If true, the content typically describes the error that occurred.
1339
+ * Default: false
1340
+ */
1341
+ isError?: boolean;
1342
+ /**
1343
+ * Optional metadata about the tool result. Clients SHOULD preserve this field when
1344
+ * including tool results in subsequent sampling requests to enable caching optimizations.
1345
+ */
1346
+ _meta?: MetaObject;
1347
+ }
1348
+ /**
1349
+ * The result returned by the client for a {@link ListRootsRequest | roots/list} request.
1350
+ * This result contains an array of {@link Root} objects, each representing a root directory
1351
+ * or file that the server can operate on.
1352
+ *
1353
+ * @example Single root directory
1354
+ * {@includeCode ./examples/ListRootsResult/single-root-directory.json}
1355
+ *
1356
+ * @example Multiple root directories
1357
+ * {@includeCode ./examples/ListRootsResult/multiple-root-directories.json}
1358
+ *
1359
+ * @category `roots/list`
1360
+ */
1361
+ interface ListRootsResult {
1362
+ roots: Root[];
1363
+ }
1364
+ /**
1365
+ * Represents a root directory or file that the server can operate on.
1366
+ *
1367
+ * @example Project directory root
1368
+ * {@includeCode ./examples/Root/project-directory.json}
1369
+ *
1370
+ * @category `roots/list`
1371
+ */
1372
+ interface Root {
1373
+ /**
1374
+ * The URI identifying the root. This *must* start with `file://` for now.
1375
+ * This restriction may be relaxed in future versions of the protocol to allow
1376
+ * other URI schemes.
1377
+ *
1378
+ * @format uri
1379
+ */
1380
+ uri: string;
1381
+ /**
1382
+ * An optional name for the root. This can be used to provide a human-readable
1383
+ * identifier for the root, which may be useful for display purposes or for
1384
+ * referencing the root in other parts of the application.
1385
+ */
1386
+ name?: string;
1387
+ _meta?: MetaObject;
1388
+ }
1389
+ /**
1390
+ * The result returned by the client for an {@link ElicitRequest| elicitation/create} request.
1391
+ *
1392
+ * @example Input single field
1393
+ * {@includeCode ./examples/ElicitResult/input-single-field.json}
1394
+ *
1395
+ * @example Input multiple fields
1396
+ * {@includeCode ./examples/ElicitResult/input-multiple-fields.json}
1397
+ *
1398
+ * @example Accept URL mode (no content)
1399
+ * {@includeCode ./examples/ElicitResult/accept-url-mode-no-content.json}
1400
+ *
1401
+ * @category `elicitation/create`
1402
+ */
1403
+ interface ElicitResult {
1404
+ /**
1405
+ * The user action in response to the elicitation.
1406
+ * - `"accept"`: User submitted the form/confirmed the action
1407
+ * - `"decline"`: User explicitly declined the action
1408
+ * - `"cancel"`: User dismissed without making an explicit choice
1409
+ */
1410
+ action: "accept" | "decline" | "cancel";
1411
+ /**
1412
+ * The submitted form data, only present when action is `"accept"` and mode was `"form"`.
1413
+ * Contains values matching the requested schema.
1414
+ * Omitted for out-of-band mode responses.
1415
+ */
1416
+ content?: {
1417
+ [key: string]: string | number | boolean | string[];
1418
+ };
1419
+ }
1420
+
1421
+ declare const MCP_TOOLS: ToolDefinition[];
1422
+ declare function getTool(name: string): ToolDefinition | null;
1423
+ declare function listToolDescriptors(): {
1424
+ annotations: {
1425
+ cacheScope: string;
1426
+ ttlMs: number;
1427
+ };
1428
+ outputSchema?: unknown;
1429
+ inputSchema: unknown;
1430
+ name: string;
1431
+ title: string;
1432
+ description: string;
1433
+ _meta?: JsonObject;
1434
+ }[];
1435
+
1436
+ declare const fixturePrimitives: McpPrimitive[];
1437
+ declare const fixtureConformResult: ConformResult;
1438
+ declare function createFixtureProvider(args?: {
1439
+ primitives?: McpPrimitive[];
1440
+ conform?: ConformResult;
1441
+ }): DataProvider;
1442
+
1443
+ export { type CallToolRequest, type CallToolResult, type ClientCapabilities, type DataProvider, FragmentsMcpServer, type Implementation, type InputRequiredToolResult, type JSONRPCMessage, JSONRPC_VERSION, type JsonObject, type JsonRpcRequest, type JsonRpcResponse, LATEST_PROTOCOL_VERSION, type ListResourcesResult, type ListToolsResult, MCP_APP_RESOURCES, MCP_TOOLS, type McpPrimitive, McpProtocolError, MemoryTaskStore, type ReadResourceRequest, type ReadResourceResult, type RequestMetaObject, type Resource, type ResourceDefinition, type ServerCapabilities, type TaskRecord, type TaskStore, type Tool, type ToolDefinition, type ToolResult, type WorkflowTaskInput, createFixtureProvider, fixtureConformResult, fixturePrimitives, getResource, getTool, handleMcpHttpRequest, handleMcpJsonRpc, listResources, listToolDescriptors };