@fragments-sdk/mcp 0.10.1 → 1.0.2

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