@modelcontextprotocol/sdk 1.22.0 → 1.23.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +92 -11
- package/dist/cjs/client/auth.d.ts +11 -1
- package/dist/cjs/client/auth.d.ts.map +1 -1
- package/dist/cjs/client/auth.js +71 -19
- package/dist/cjs/client/auth.js.map +1 -1
- package/dist/cjs/client/index.d.ts +120 -661
- package/dist/cjs/client/index.d.ts.map +1 -1
- package/dist/cjs/client/index.js +71 -15
- package/dist/cjs/client/index.js.map +1 -1
- package/dist/cjs/client/sse.d.ts +1 -0
- package/dist/cjs/client/sse.d.ts.map +1 -1
- package/dist/cjs/client/sse.js +5 -3
- package/dist/cjs/client/sse.js.map +1 -1
- package/dist/cjs/client/streamableHttp.d.ts +2 -1
- package/dist/cjs/client/streamableHttp.d.ts.map +1 -1
- package/dist/cjs/client/streamableHttp.js +35 -15
- package/dist/cjs/client/streamableHttp.js.map +1 -1
- package/dist/cjs/examples/client/elicitationUrlExample.d.ts +2 -0
- package/dist/cjs/examples/client/elicitationUrlExample.d.ts.map +1 -0
- package/dist/cjs/examples/client/elicitationUrlExample.js +693 -0
- package/dist/cjs/examples/client/elicitationUrlExample.js.map +1 -0
- package/dist/cjs/examples/client/simpleOAuthClient.js +13 -52
- package/dist/cjs/examples/client/simpleOAuthClient.js.map +1 -1
- package/dist/cjs/examples/client/simpleOAuthClientProvider.d.ts +26 -0
- package/dist/cjs/examples/client/simpleOAuthClientProvider.d.ts.map +1 -0
- package/dist/cjs/examples/client/simpleOAuthClientProvider.js +51 -0
- package/dist/cjs/examples/client/simpleOAuthClientProvider.js.map +1 -0
- package/dist/cjs/examples/client/simpleStreamableHttp.js +10 -5
- package/dist/cjs/examples/client/simpleStreamableHttp.js.map +1 -1
- package/dist/cjs/examples/server/demoInMemoryOAuthProvider.d.ts +4 -4
- package/dist/cjs/examples/server/demoInMemoryOAuthProvider.d.ts.map +1 -1
- package/dist/cjs/examples/server/demoInMemoryOAuthProvider.js +16 -0
- package/dist/cjs/examples/server/demoInMemoryOAuthProvider.js.map +1 -1
- package/dist/cjs/examples/server/elicitationFormExample.d.ts +2 -0
- package/dist/cjs/examples/server/elicitationFormExample.d.ts.map +1 -0
- package/dist/cjs/examples/server/{elicitationExample.js → elicitationFormExample.js} +14 -8
- package/dist/cjs/examples/server/elicitationFormExample.js.map +1 -0
- package/dist/cjs/examples/server/elicitationUrlExample.d.ts +2 -0
- package/dist/cjs/examples/server/elicitationUrlExample.d.ts.map +1 -0
- package/dist/cjs/examples/server/elicitationUrlExample.js +655 -0
- package/dist/cjs/examples/server/elicitationUrlExample.js.map +1 -0
- package/dist/cjs/examples/server/jsonResponseStreamableHttp.js +26 -3
- package/dist/cjs/examples/server/jsonResponseStreamableHttp.js.map +1 -1
- package/dist/cjs/examples/server/mcpServerOutputSchema.js +34 -11
- package/dist/cjs/examples/server/mcpServerOutputSchema.js.map +1 -1
- package/dist/cjs/examples/server/simpleSseServer.js +26 -3
- package/dist/cjs/examples/server/simpleSseServer.js.map +1 -1
- package/dist/cjs/examples/server/simpleStatelessStreamableHttp.js +27 -4
- package/dist/cjs/examples/server/simpleStatelessStreamableHttp.js.map +1 -1
- package/dist/cjs/examples/server/simpleStreamableHttp.js +34 -10
- package/dist/cjs/examples/server/simpleStreamableHttp.js.map +1 -1
- package/dist/cjs/examples/server/sseAndStreamableHttpCompatibleServer.js +26 -3
- package/dist/cjs/examples/server/sseAndStreamableHttpCompatibleServer.js.map +1 -1
- package/dist/cjs/examples/server/toolWithSampleServer.js +30 -8
- package/dist/cjs/examples/server/toolWithSampleServer.js.map +1 -1
- package/dist/cjs/server/auth/handlers/authorize.js +34 -11
- package/dist/cjs/server/auth/handlers/authorize.js.map +1 -1
- package/dist/cjs/server/auth/handlers/token.js +35 -12
- package/dist/cjs/server/auth/handlers/token.js.map +1 -1
- package/dist/cjs/server/auth/middleware/bearerAuth.d.ts.map +1 -1
- package/dist/cjs/server/auth/middleware/bearerAuth.js +13 -8
- package/dist/cjs/server/auth/middleware/bearerAuth.js.map +1 -1
- package/dist/cjs/server/auth/middleware/clientAuth.js +27 -4
- package/dist/cjs/server/auth/middleware/clientAuth.js.map +1 -1
- package/dist/cjs/server/auth/router.js +1 -1
- package/dist/cjs/server/auth/router.js.map +1 -1
- package/dist/cjs/server/completable.d.ts +30 -16
- package/dist/cjs/server/completable.d.ts.map +1 -1
- package/dist/cjs/server/completable.js +38 -55
- package/dist/cjs/server/completable.js.map +1 -1
- package/dist/cjs/server/index.d.ts +192 -50
- package/dist/cjs/server/index.d.ts.map +1 -1
- package/dist/cjs/server/index.js +58 -13
- package/dist/cjs/server/index.js.map +1 -1
- package/dist/cjs/server/mcp.d.ts +14 -16
- package/dist/cjs/server/mcp.d.ts.map +1 -1
- package/dist/cjs/server/mcp.js +83 -40
- package/dist/cjs/server/mcp.js.map +1 -1
- package/dist/cjs/server/zod-compat.d.ts +82 -0
- package/dist/cjs/server/zod-compat.d.ts.map +1 -0
- package/dist/cjs/server/zod-compat.js +252 -0
- package/dist/cjs/server/zod-compat.js.map +1 -0
- package/dist/cjs/server/zod-json-schema-compat.d.ts +12 -0
- package/dist/cjs/server/zod-json-schema-compat.d.ts.map +1 -0
- package/dist/cjs/server/zod-json-schema-compat.js +80 -0
- package/dist/cjs/server/zod-json-schema-compat.js.map +1 -0
- package/dist/cjs/shared/auth.d.ts +116 -502
- package/dist/cjs/shared/auth.d.ts.map +1 -1
- package/dist/cjs/shared/auth.js +133 -112
- package/dist/cjs/shared/auth.js.map +1 -1
- package/dist/cjs/shared/protocol.d.ts +5 -9
- package/dist/cjs/shared/protocol.d.ts.map +1 -1
- package/dist/cjs/shared/protocol.js +24 -10
- package/dist/cjs/shared/protocol.js.map +1 -1
- package/dist/cjs/shared/transport.d.ts +14 -0
- package/dist/cjs/shared/transport.d.ts.map +1 -1
- package/dist/cjs/shared/transport.js +40 -0
- package/dist/cjs/shared/transport.js.map +1 -1
- package/dist/cjs/shared/zodTestMatrix.d.ts +16 -0
- package/dist/cjs/shared/zodTestMatrix.d.ts.map +1 -0
- package/dist/cjs/shared/zodTestMatrix.js +43 -0
- package/dist/cjs/shared/zodTestMatrix.js.map +1 -0
- package/dist/cjs/spec.types.d.ts +383 -69
- package/dist/cjs/spec.types.d.ts.map +1 -1
- package/dist/cjs/spec.types.js +5 -7
- package/dist/cjs/spec.types.js.map +1 -1
- package/dist/cjs/types.d.ts +3584 -23864
- package/dist/cjs/types.d.ts.map +1 -1
- package/dist/cjs/types.js +564 -336
- package/dist/cjs/types.js.map +1 -1
- package/dist/esm/client/auth.d.ts +11 -1
- package/dist/esm/client/auth.d.ts.map +1 -1
- package/dist/esm/client/auth.js +71 -20
- package/dist/esm/client/auth.js.map +1 -1
- package/dist/esm/client/index.d.ts +120 -661
- package/dist/esm/client/index.d.ts.map +1 -1
- package/dist/esm/client/index.js +70 -15
- package/dist/esm/client/index.js.map +1 -1
- package/dist/esm/client/sse.d.ts +1 -0
- package/dist/esm/client/sse.d.ts.map +1 -1
- package/dist/esm/client/sse.js +5 -3
- package/dist/esm/client/sse.js.map +1 -1
- package/dist/esm/client/streamableHttp.d.ts +2 -1
- package/dist/esm/client/streamableHttp.d.ts.map +1 -1
- package/dist/esm/client/streamableHttp.js +35 -15
- package/dist/esm/client/streamableHttp.js.map +1 -1
- package/dist/esm/examples/client/elicitationUrlExample.d.ts +2 -0
- package/dist/esm/examples/client/elicitationUrlExample.d.ts.map +1 -0
- package/dist/esm/examples/client/elicitationUrlExample.js +691 -0
- package/dist/esm/examples/client/elicitationUrlExample.js.map +1 -0
- package/dist/esm/examples/client/simpleOAuthClient.js +12 -51
- package/dist/esm/examples/client/simpleOAuthClient.js.map +1 -1
- package/dist/esm/examples/client/simpleOAuthClientProvider.d.ts +26 -0
- package/dist/esm/examples/client/simpleOAuthClientProvider.d.ts.map +1 -0
- package/dist/esm/examples/client/simpleOAuthClientProvider.js +47 -0
- package/dist/esm/examples/client/simpleOAuthClientProvider.js.map +1 -0
- package/dist/esm/examples/client/simpleStreamableHttp.js +11 -6
- package/dist/esm/examples/client/simpleStreamableHttp.js.map +1 -1
- package/dist/esm/examples/server/demoInMemoryOAuthProvider.d.ts +4 -4
- package/dist/esm/examples/server/demoInMemoryOAuthProvider.d.ts.map +1 -1
- package/dist/esm/examples/server/demoInMemoryOAuthProvider.js +16 -0
- package/dist/esm/examples/server/demoInMemoryOAuthProvider.js.map +1 -1
- package/dist/esm/examples/server/elicitationFormExample.d.ts +2 -0
- package/dist/esm/examples/server/elicitationFormExample.d.ts.map +1 -0
- package/dist/esm/examples/server/{elicitationExample.js → elicitationFormExample.js} +14 -8
- package/dist/esm/examples/server/elicitationFormExample.js.map +1 -0
- package/dist/esm/examples/server/elicitationUrlExample.d.ts +2 -0
- package/dist/esm/examples/server/elicitationUrlExample.d.ts.map +1 -0
- package/dist/esm/examples/server/elicitationUrlExample.js +650 -0
- package/dist/esm/examples/server/elicitationUrlExample.js.map +1 -0
- package/dist/esm/examples/server/jsonResponseStreamableHttp.js +1 -1
- package/dist/esm/examples/server/jsonResponseStreamableHttp.js.map +1 -1
- package/dist/esm/examples/server/mcpServerOutputSchema.js +1 -1
- package/dist/esm/examples/server/mcpServerOutputSchema.js.map +1 -1
- package/dist/esm/examples/server/simpleSseServer.js +1 -1
- package/dist/esm/examples/server/simpleSseServer.js.map +1 -1
- package/dist/esm/examples/server/simpleStatelessStreamableHttp.js +1 -1
- package/dist/esm/examples/server/simpleStatelessStreamableHttp.js.map +1 -1
- package/dist/esm/examples/server/simpleStreamableHttp.js +4 -3
- package/dist/esm/examples/server/simpleStreamableHttp.js.map +1 -1
- package/dist/esm/examples/server/sseAndStreamableHttpCompatibleServer.js +1 -1
- package/dist/esm/examples/server/sseAndStreamableHttpCompatibleServer.js.map +1 -1
- package/dist/esm/examples/server/toolWithSampleServer.js +6 -7
- package/dist/esm/examples/server/toolWithSampleServer.js.map +1 -1
- package/dist/esm/server/auth/handlers/authorize.js +1 -1
- package/dist/esm/server/auth/handlers/authorize.js.map +1 -1
- package/dist/esm/server/auth/handlers/token.js +1 -1
- package/dist/esm/server/auth/handlers/token.js.map +1 -1
- package/dist/esm/server/auth/middleware/bearerAuth.d.ts.map +1 -1
- package/dist/esm/server/auth/middleware/bearerAuth.js +13 -8
- package/dist/esm/server/auth/middleware/bearerAuth.js.map +1 -1
- package/dist/esm/server/auth/middleware/clientAuth.js +1 -1
- package/dist/esm/server/auth/middleware/clientAuth.js.map +1 -1
- package/dist/esm/server/auth/router.js +1 -1
- package/dist/esm/server/auth/router.js.map +1 -1
- package/dist/esm/server/completable.d.ts +30 -16
- package/dist/esm/server/completable.d.ts.map +1 -1
- package/dist/esm/server/completable.js +34 -53
- package/dist/esm/server/completable.js.map +1 -1
- package/dist/esm/server/index.d.ts +192 -50
- package/dist/esm/server/index.d.ts.map +1 -1
- package/dist/esm/server/index.js +58 -13
- package/dist/esm/server/index.js.map +1 -1
- package/dist/esm/server/mcp.d.ts +14 -16
- package/dist/esm/server/mcp.d.ts.map +1 -1
- package/dist/esm/server/mcp.js +84 -41
- package/dist/esm/server/mcp.js.map +1 -1
- package/dist/esm/server/zod-compat.d.ts +82 -0
- package/dist/esm/server/zod-compat.d.ts.map +1 -0
- package/dist/esm/server/zod-compat.js +217 -0
- package/dist/esm/server/zod-compat.js.map +1 -0
- package/dist/esm/server/zod-json-schema-compat.d.ts +12 -0
- package/dist/esm/server/zod-json-schema-compat.d.ts.map +1 -0
- package/dist/esm/server/zod-json-schema-compat.js +52 -0
- package/dist/esm/server/zod-json-schema-compat.js.map +1 -0
- package/dist/esm/shared/auth.d.ts +116 -502
- package/dist/esm/shared/auth.d.ts.map +1 -1
- package/dist/esm/shared/auth.js +17 -19
- package/dist/esm/shared/auth.js.map +1 -1
- package/dist/esm/shared/protocol.d.ts +5 -9
- package/dist/esm/shared/protocol.d.ts.map +1 -1
- package/dist/esm/shared/protocol.js +24 -10
- package/dist/esm/shared/protocol.js.map +1 -1
- package/dist/esm/shared/transport.d.ts +14 -0
- package/dist/esm/shared/transport.d.ts.map +1 -1
- package/dist/esm/shared/transport.js +38 -1
- package/dist/esm/shared/transport.js.map +1 -1
- package/dist/esm/shared/zodTestMatrix.d.ts +16 -0
- package/dist/esm/shared/zodTestMatrix.d.ts.map +1 -0
- package/dist/esm/shared/zodTestMatrix.js +17 -0
- package/dist/esm/shared/zodTestMatrix.js.map +1 -0
- package/dist/esm/spec.types.d.ts +383 -69
- package/dist/esm/spec.types.d.ts.map +1 -1
- package/dist/esm/spec.types.js +4 -6
- package/dist/esm/spec.types.js.map +1 -1
- package/dist/esm/types.d.ts +3584 -23864
- package/dist/esm/types.d.ts.map +1 -1
- package/dist/esm/types.js +268 -64
- package/dist/esm/types.js.map +1 -1
- package/package.json +13 -12
- package/dist/cjs/examples/server/elicitationExample.d.ts +0 -2
- package/dist/cjs/examples/server/elicitationExample.d.ts.map +0 -1
- package/dist/cjs/examples/server/elicitationExample.js.map +0 -1
- package/dist/esm/examples/server/elicitationExample.d.ts +0 -2
- package/dist/esm/examples/server/elicitationExample.d.ts.map +0 -1
- package/dist/esm/examples/server/elicitationExample.js.map +0 -1
package/dist/esm/types.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as z from 'zod/v4';
|
|
2
2
|
export const LATEST_PROTOCOL_VERSION = '2025-06-18';
|
|
3
3
|
export const DEFAULT_NEGOTIATED_PROTOCOL_VERSION = '2025-03-26';
|
|
4
4
|
export const SUPPORTED_PROTOCOL_VERSIONS = [LATEST_PROTOCOL_VERSION, '2025-03-26', '2024-11-05', '2024-10-07'];
|
|
@@ -18,21 +18,16 @@ export const ProgressTokenSchema = z.union([z.string(), z.number().int()]);
|
|
|
18
18
|
* An opaque token used to represent a cursor for pagination.
|
|
19
19
|
*/
|
|
20
20
|
export const CursorSchema = z.string();
|
|
21
|
-
const RequestMetaSchema = z
|
|
22
|
-
.object({
|
|
21
|
+
const RequestMetaSchema = z.looseObject({
|
|
23
22
|
/**
|
|
24
23
|
* If specified, the caller is requesting out-of-band progress notifications for this request (as represented by notifications/progress). The value of this parameter is an opaque token that will be attached to any subsequent notifications. The receiver is not obligated to provide these notifications.
|
|
25
24
|
*/
|
|
26
25
|
progressToken: ProgressTokenSchema.optional()
|
|
27
|
-
})
|
|
28
|
-
/**
|
|
29
|
-
* Passthrough required here because we want to allow any additional fields to be added to the request meta.
|
|
30
|
-
*/
|
|
31
|
-
.passthrough();
|
|
26
|
+
});
|
|
32
27
|
/**
|
|
33
28
|
* Common params for any request.
|
|
34
29
|
*/
|
|
35
|
-
const BaseRequestParamsSchema = z.
|
|
30
|
+
const BaseRequestParamsSchema = z.looseObject({
|
|
36
31
|
/**
|
|
37
32
|
* See [General fields: `_meta`](/specification/draft/basic/index#meta) for notes on `_meta` usage.
|
|
38
33
|
*/
|
|
@@ -40,9 +35,9 @@ const BaseRequestParamsSchema = z.object({
|
|
|
40
35
|
});
|
|
41
36
|
export const RequestSchema = z.object({
|
|
42
37
|
method: z.string(),
|
|
43
|
-
params: BaseRequestParamsSchema.
|
|
38
|
+
params: BaseRequestParamsSchema.optional()
|
|
44
39
|
});
|
|
45
|
-
const NotificationsParamsSchema = z.
|
|
40
|
+
const NotificationsParamsSchema = z.looseObject({
|
|
46
41
|
/**
|
|
47
42
|
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
48
43
|
* for notes on _meta usage.
|
|
@@ -51,20 +46,15 @@ const NotificationsParamsSchema = z.object({
|
|
|
51
46
|
});
|
|
52
47
|
export const NotificationSchema = z.object({
|
|
53
48
|
method: z.string(),
|
|
54
|
-
params: NotificationsParamsSchema.
|
|
49
|
+
params: NotificationsParamsSchema.optional()
|
|
55
50
|
});
|
|
56
|
-
export const ResultSchema = z
|
|
57
|
-
.object({
|
|
51
|
+
export const ResultSchema = z.looseObject({
|
|
58
52
|
/**
|
|
59
53
|
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
60
54
|
* for notes on _meta usage.
|
|
61
55
|
*/
|
|
62
56
|
_meta: z.record(z.string(), z.unknown()).optional()
|
|
63
|
-
})
|
|
64
|
-
/**
|
|
65
|
-
* Passthrough required here because we want to allow any additional fields to be added to the result.
|
|
66
|
-
*/
|
|
67
|
-
.passthrough();
|
|
57
|
+
});
|
|
68
58
|
/**
|
|
69
59
|
* A uniquely identifying ID for a request in JSON-RPC.
|
|
70
60
|
*/
|
|
@@ -75,9 +65,9 @@ export const RequestIdSchema = z.union([z.string(), z.number().int()]);
|
|
|
75
65
|
export const JSONRPCRequestSchema = z
|
|
76
66
|
.object({
|
|
77
67
|
jsonrpc: z.literal(JSONRPC_VERSION),
|
|
78
|
-
id: RequestIdSchema
|
|
68
|
+
id: RequestIdSchema,
|
|
69
|
+
...RequestSchema.shape
|
|
79
70
|
})
|
|
80
|
-
.merge(RequestSchema)
|
|
81
71
|
.strict();
|
|
82
72
|
export const isJSONRPCRequest = (value) => JSONRPCRequestSchema.safeParse(value).success;
|
|
83
73
|
/**
|
|
@@ -85,9 +75,9 @@ export const isJSONRPCRequest = (value) => JSONRPCRequestSchema.safeParse(value)
|
|
|
85
75
|
*/
|
|
86
76
|
export const JSONRPCNotificationSchema = z
|
|
87
77
|
.object({
|
|
88
|
-
jsonrpc: z.literal(JSONRPC_VERSION)
|
|
78
|
+
jsonrpc: z.literal(JSONRPC_VERSION),
|
|
79
|
+
...NotificationSchema.shape
|
|
89
80
|
})
|
|
90
|
-
.merge(NotificationSchema)
|
|
91
81
|
.strict();
|
|
92
82
|
export const isJSONRPCNotification = (value) => JSONRPCNotificationSchema.safeParse(value).success;
|
|
93
83
|
/**
|
|
@@ -115,6 +105,8 @@ export var ErrorCode;
|
|
|
115
105
|
ErrorCode[ErrorCode["MethodNotFound"] = -32601] = "MethodNotFound";
|
|
116
106
|
ErrorCode[ErrorCode["InvalidParams"] = -32602] = "InvalidParams";
|
|
117
107
|
ErrorCode[ErrorCode["InternalError"] = -32603] = "InternalError";
|
|
108
|
+
// MCP-specific error codes
|
|
109
|
+
ErrorCode[ErrorCode["UrlElicitationRequired"] = -32042] = "UrlElicitationRequired";
|
|
118
110
|
})(ErrorCode || (ErrorCode = {}));
|
|
119
111
|
/**
|
|
120
112
|
* A response to a request that indicates an error occurred.
|
|
@@ -232,12 +224,28 @@ export const BaseMetadataSchema = z.object({
|
|
|
232
224
|
* Describes the name and version of an MCP implementation.
|
|
233
225
|
*/
|
|
234
226
|
export const ImplementationSchema = BaseMetadataSchema.extend({
|
|
227
|
+
...BaseMetadataSchema.shape,
|
|
228
|
+
...IconsSchema.shape,
|
|
235
229
|
version: z.string(),
|
|
236
230
|
/**
|
|
237
231
|
* An optional URL of the website for this implementation.
|
|
238
232
|
*/
|
|
239
233
|
websiteUrl: z.string().optional()
|
|
240
|
-
})
|
|
234
|
+
});
|
|
235
|
+
const FormElicitationCapabilitySchema = z.intersection(z.object({
|
|
236
|
+
applyDefaults: z.boolean().optional()
|
|
237
|
+
}), z.record(z.string(), z.unknown()));
|
|
238
|
+
const ElicitationCapabilitySchema = z.preprocess(value => {
|
|
239
|
+
if (value && typeof value === 'object' && !Array.isArray(value)) {
|
|
240
|
+
if (Object.keys(value).length === 0) {
|
|
241
|
+
return { form: {} };
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
return value;
|
|
245
|
+
}, z.intersection(z.object({
|
|
246
|
+
form: FormElicitationCapabilitySchema.optional(),
|
|
247
|
+
url: AssertObjectSchema.optional()
|
|
248
|
+
}), z.record(z.string(), z.unknown()).optional()));
|
|
241
249
|
/**
|
|
242
250
|
* 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.
|
|
243
251
|
*/
|
|
@@ -249,18 +257,23 @@ export const ClientCapabilitiesSchema = z.object({
|
|
|
249
257
|
/**
|
|
250
258
|
* Present if the client supports sampling from an LLM.
|
|
251
259
|
*/
|
|
252
|
-
sampling:
|
|
253
|
-
/**
|
|
254
|
-
* Present if the client supports eliciting user input.
|
|
255
|
-
*/
|
|
256
|
-
elicitation: z.intersection(z
|
|
260
|
+
sampling: z
|
|
257
261
|
.object({
|
|
258
262
|
/**
|
|
259
|
-
*
|
|
263
|
+
* Present if the client supports context inclusion via includeContext parameter.
|
|
264
|
+
* If not declared, servers SHOULD only use `includeContext: "none"` (or omit it).
|
|
265
|
+
*/
|
|
266
|
+
context: AssertObjectSchema.optional(),
|
|
267
|
+
/**
|
|
268
|
+
* Present if the client supports tool use via tools and toolChoice parameters.
|
|
260
269
|
*/
|
|
261
|
-
|
|
270
|
+
tools: AssertObjectSchema.optional()
|
|
262
271
|
})
|
|
263
|
-
.optional(),
|
|
272
|
+
.optional(),
|
|
273
|
+
/**
|
|
274
|
+
* Present if the client supports eliciting user input.
|
|
275
|
+
*/
|
|
276
|
+
elicitation: ElicitationCapabilitySchema.optional(),
|
|
264
277
|
/**
|
|
265
278
|
* Present if the client supports listing roots.
|
|
266
279
|
*/
|
|
@@ -387,7 +400,9 @@ export const ProgressSchema = z.object({
|
|
|
387
400
|
*/
|
|
388
401
|
message: z.optional(z.string())
|
|
389
402
|
});
|
|
390
|
-
export const ProgressNotificationParamsSchema =
|
|
403
|
+
export const ProgressNotificationParamsSchema = z.object({
|
|
404
|
+
...NotificationsParamsSchema.shape,
|
|
405
|
+
...ProgressSchema.shape,
|
|
391
406
|
/**
|
|
392
407
|
* The progress token which was given in the initial request, used to associate this notification with the request that is proceeding.
|
|
393
408
|
*/
|
|
@@ -470,7 +485,9 @@ export const BlobResourceContentsSchema = ResourceContentsSchema.extend({
|
|
|
470
485
|
/**
|
|
471
486
|
* A known resource that the server is capable of reading.
|
|
472
487
|
*/
|
|
473
|
-
export const ResourceSchema =
|
|
488
|
+
export const ResourceSchema = z.object({
|
|
489
|
+
...BaseMetadataSchema.shape,
|
|
490
|
+
...IconsSchema.shape,
|
|
474
491
|
/**
|
|
475
492
|
* The URI of this resource.
|
|
476
493
|
*/
|
|
@@ -489,12 +506,14 @@ export const ResourceSchema = BaseMetadataSchema.extend({
|
|
|
489
506
|
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
490
507
|
* for notes on _meta usage.
|
|
491
508
|
*/
|
|
492
|
-
_meta: z.optional(z.
|
|
493
|
-
})
|
|
509
|
+
_meta: z.optional(z.looseObject({}))
|
|
510
|
+
});
|
|
494
511
|
/**
|
|
495
512
|
* A template description for resources available on the server.
|
|
496
513
|
*/
|
|
497
|
-
export const ResourceTemplateSchema =
|
|
514
|
+
export const ResourceTemplateSchema = z.object({
|
|
515
|
+
...BaseMetadataSchema.shape,
|
|
516
|
+
...IconsSchema.shape,
|
|
498
517
|
/**
|
|
499
518
|
* A URI template (according to RFC 6570) that can be used to construct resource URIs.
|
|
500
519
|
*/
|
|
@@ -513,8 +532,8 @@ export const ResourceTemplateSchema = BaseMetadataSchema.extend({
|
|
|
513
532
|
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
514
533
|
* for notes on _meta usage.
|
|
515
534
|
*/
|
|
516
|
-
_meta: z.optional(z.
|
|
517
|
-
})
|
|
535
|
+
_meta: z.optional(z.looseObject({}))
|
|
536
|
+
});
|
|
518
537
|
/**
|
|
519
538
|
* Sent from the client to request a list of resources the server has.
|
|
520
539
|
*/
|
|
@@ -623,7 +642,9 @@ export const PromptArgumentSchema = z.object({
|
|
|
623
642
|
/**
|
|
624
643
|
* A prompt or prompt template that the server offers.
|
|
625
644
|
*/
|
|
626
|
-
export const PromptSchema =
|
|
645
|
+
export const PromptSchema = z.object({
|
|
646
|
+
...BaseMetadataSchema.shape,
|
|
647
|
+
...IconsSchema.shape,
|
|
627
648
|
/**
|
|
628
649
|
* An optional description of what this prompt provides
|
|
629
650
|
*/
|
|
@@ -636,8 +657,8 @@ export const PromptSchema = BaseMetadataSchema.extend({
|
|
|
636
657
|
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
637
658
|
* for notes on _meta usage.
|
|
638
659
|
*/
|
|
639
|
-
_meta: z.optional(z.
|
|
640
|
-
})
|
|
660
|
+
_meta: z.optional(z.looseObject({}))
|
|
661
|
+
});
|
|
641
662
|
/**
|
|
642
663
|
* Sent from the client to request a list of prompts and prompt templates the server has.
|
|
643
664
|
*/
|
|
@@ -723,6 +744,35 @@ export const AudioContentSchema = z.object({
|
|
|
723
744
|
*/
|
|
724
745
|
_meta: z.record(z.string(), z.unknown()).optional()
|
|
725
746
|
});
|
|
747
|
+
/**
|
|
748
|
+
* A tool call request from an assistant (LLM).
|
|
749
|
+
* Represents the assistant's request to use a tool.
|
|
750
|
+
*/
|
|
751
|
+
export const ToolUseContentSchema = z
|
|
752
|
+
.object({
|
|
753
|
+
type: z.literal('tool_use'),
|
|
754
|
+
/**
|
|
755
|
+
* The name of the tool to invoke.
|
|
756
|
+
* Must match a tool name from the request's tools array.
|
|
757
|
+
*/
|
|
758
|
+
name: z.string(),
|
|
759
|
+
/**
|
|
760
|
+
* Unique identifier for this tool call.
|
|
761
|
+
* Used to correlate with ToolResultContent in subsequent messages.
|
|
762
|
+
*/
|
|
763
|
+
id: z.string(),
|
|
764
|
+
/**
|
|
765
|
+
* Arguments to pass to the tool.
|
|
766
|
+
* Must conform to the tool's inputSchema.
|
|
767
|
+
*/
|
|
768
|
+
input: z.object({}).passthrough(),
|
|
769
|
+
/**
|
|
770
|
+
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
771
|
+
* for notes on _meta usage.
|
|
772
|
+
*/
|
|
773
|
+
_meta: z.optional(z.object({}).passthrough())
|
|
774
|
+
})
|
|
775
|
+
.passthrough();
|
|
726
776
|
/**
|
|
727
777
|
* The contents of a resource, embedded into a prompt or tool call result.
|
|
728
778
|
*/
|
|
@@ -829,7 +879,9 @@ export const ToolAnnotationsSchema = z.object({
|
|
|
829
879
|
/**
|
|
830
880
|
* Definition for a tool the client can call.
|
|
831
881
|
*/
|
|
832
|
-
export const ToolSchema =
|
|
882
|
+
export const ToolSchema = z.object({
|
|
883
|
+
...BaseMetadataSchema.shape,
|
|
884
|
+
...IconsSchema.shape,
|
|
833
885
|
/**
|
|
834
886
|
* A human-readable description of the tool.
|
|
835
887
|
*/
|
|
@@ -851,9 +903,6 @@ export const ToolSchema = BaseMetadataSchema.extend({
|
|
|
851
903
|
type: z.literal('object'),
|
|
852
904
|
properties: z.record(z.string(), AssertObjectSchema).optional(),
|
|
853
905
|
required: z.optional(z.array(z.string())),
|
|
854
|
-
/**
|
|
855
|
-
* Not in the MCP specification, but added to support the Ajv validator while removing .passthrough() which previously allowed additionalProperties to be passed through.
|
|
856
|
-
*/
|
|
857
906
|
additionalProperties: z.optional(z.boolean())
|
|
858
907
|
})
|
|
859
908
|
.optional(),
|
|
@@ -866,7 +915,7 @@ export const ToolSchema = BaseMetadataSchema.extend({
|
|
|
866
915
|
* for notes on _meta usage.
|
|
867
916
|
*/
|
|
868
917
|
_meta: z.record(z.string(), z.unknown()).optional()
|
|
869
|
-
})
|
|
918
|
+
});
|
|
870
919
|
/**
|
|
871
920
|
* Sent from the client to request a list of tools the server has.
|
|
872
921
|
*/
|
|
@@ -1020,13 +1069,61 @@ export const ModelPreferencesSchema = z.object({
|
|
|
1020
1069
|
*/
|
|
1021
1070
|
intelligencePriority: z.optional(z.number().min(0).max(1))
|
|
1022
1071
|
});
|
|
1072
|
+
/**
|
|
1073
|
+
* Controls tool usage behavior in sampling requests.
|
|
1074
|
+
*/
|
|
1075
|
+
export const ToolChoiceSchema = z.object({
|
|
1076
|
+
/**
|
|
1077
|
+
* Controls when tools are used:
|
|
1078
|
+
* - "auto": Model decides whether to use tools (default)
|
|
1079
|
+
* - "required": Model MUST use at least one tool before completing
|
|
1080
|
+
* - "none": Model MUST NOT use any tools
|
|
1081
|
+
*/
|
|
1082
|
+
mode: z.optional(z.enum(['auto', 'required', 'none']))
|
|
1083
|
+
});
|
|
1084
|
+
/**
|
|
1085
|
+
* The result of a tool execution, provided by the user (server).
|
|
1086
|
+
* Represents the outcome of invoking a tool requested via ToolUseContent.
|
|
1087
|
+
*/
|
|
1088
|
+
export const ToolResultContentSchema = z
|
|
1089
|
+
.object({
|
|
1090
|
+
type: z.literal('tool_result'),
|
|
1091
|
+
toolUseId: z.string().describe('The unique identifier for the corresponding tool call.'),
|
|
1092
|
+
content: z.array(ContentBlockSchema).default([]),
|
|
1093
|
+
structuredContent: z.object({}).passthrough().optional(),
|
|
1094
|
+
isError: z.optional(z.boolean()),
|
|
1095
|
+
/**
|
|
1096
|
+
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
1097
|
+
* for notes on _meta usage.
|
|
1098
|
+
*/
|
|
1099
|
+
_meta: z.optional(z.object({}).passthrough())
|
|
1100
|
+
})
|
|
1101
|
+
.passthrough();
|
|
1102
|
+
/**
|
|
1103
|
+
* Content block types allowed in sampling messages.
|
|
1104
|
+
* This includes text, image, audio, tool use requests, and tool results.
|
|
1105
|
+
*/
|
|
1106
|
+
export const SamplingMessageContentBlockSchema = z.discriminatedUnion('type', [
|
|
1107
|
+
TextContentSchema,
|
|
1108
|
+
ImageContentSchema,
|
|
1109
|
+
AudioContentSchema,
|
|
1110
|
+
ToolUseContentSchema,
|
|
1111
|
+
ToolResultContentSchema
|
|
1112
|
+
]);
|
|
1023
1113
|
/**
|
|
1024
1114
|
* Describes a message issued to or received from an LLM API.
|
|
1025
1115
|
*/
|
|
1026
|
-
export const SamplingMessageSchema = z
|
|
1116
|
+
export const SamplingMessageSchema = z
|
|
1117
|
+
.object({
|
|
1027
1118
|
role: z.enum(['user', 'assistant']),
|
|
1028
|
-
content: z.union([
|
|
1029
|
-
|
|
1119
|
+
content: z.union([SamplingMessageContentBlockSchema, z.array(SamplingMessageContentBlockSchema)]),
|
|
1120
|
+
/**
|
|
1121
|
+
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
1122
|
+
* for notes on _meta usage.
|
|
1123
|
+
*/
|
|
1124
|
+
_meta: z.optional(z.object({}).passthrough())
|
|
1125
|
+
})
|
|
1126
|
+
.passthrough();
|
|
1030
1127
|
/**
|
|
1031
1128
|
* Parameters for a `sampling/createMessage` request.
|
|
1032
1129
|
*/
|
|
@@ -1041,7 +1138,11 @@ export const CreateMessageRequestParamsSchema = BaseRequestParamsSchema.extend({
|
|
|
1041
1138
|
*/
|
|
1042
1139
|
systemPrompt: z.string().optional(),
|
|
1043
1140
|
/**
|
|
1044
|
-
* A request to include context from one or more MCP servers (including the caller), to be attached to the prompt.
|
|
1141
|
+
* A request to include context from one or more MCP servers (including the caller), to be attached to the prompt.
|
|
1142
|
+
* The client MAY ignore this request.
|
|
1143
|
+
*
|
|
1144
|
+
* Default is "none". Values "thisServer" and "allServers" are soft-deprecated. Servers SHOULD only use these values if the client
|
|
1145
|
+
* declares ClientCapabilities.sampling.context. These values may be removed in future spec releases.
|
|
1045
1146
|
*/
|
|
1046
1147
|
includeContext: z.enum(['none', 'thisServer', 'allServers']).optional(),
|
|
1047
1148
|
temperature: z.number().optional(),
|
|
@@ -1055,7 +1156,18 @@ export const CreateMessageRequestParamsSchema = BaseRequestParamsSchema.extend({
|
|
|
1055
1156
|
/**
|
|
1056
1157
|
* Optional metadata to pass through to the LLM provider. The format of this metadata is provider-specific.
|
|
1057
1158
|
*/
|
|
1058
|
-
metadata: AssertObjectSchema.optional()
|
|
1159
|
+
metadata: AssertObjectSchema.optional(),
|
|
1160
|
+
/**
|
|
1161
|
+
* Tools that the model may use during generation.
|
|
1162
|
+
* The client MUST return an error if this field is provided but ClientCapabilities.sampling.tools is not declared.
|
|
1163
|
+
*/
|
|
1164
|
+
tools: z.optional(z.array(ToolSchema)),
|
|
1165
|
+
/**
|
|
1166
|
+
* Controls how the model uses tools.
|
|
1167
|
+
* The client MUST return an error if this field is provided but ClientCapabilities.sampling.tools is not declared.
|
|
1168
|
+
* Default is `{ mode: "auto" }`.
|
|
1169
|
+
*/
|
|
1170
|
+
toolChoice: z.optional(ToolChoiceSchema)
|
|
1059
1171
|
});
|
|
1060
1172
|
/**
|
|
1061
1173
|
* A request from the server to sample an LLM via the client. The client has full discretion over which model to select. The client should also inform the user before beginning sampling, to allow them to inspect the request (human in the loop) and decide whether to approve it.
|
|
@@ -1073,11 +1185,22 @@ export const CreateMessageResultSchema = ResultSchema.extend({
|
|
|
1073
1185
|
*/
|
|
1074
1186
|
model: z.string(),
|
|
1075
1187
|
/**
|
|
1076
|
-
* The reason why sampling stopped.
|
|
1188
|
+
* The reason why sampling stopped, if known.
|
|
1189
|
+
*
|
|
1190
|
+
* Standard values:
|
|
1191
|
+
* - "endTurn": Natural end of the assistant's turn
|
|
1192
|
+
* - "stopSequence": A stop sequence was encountered
|
|
1193
|
+
* - "maxTokens": Maximum token limit was reached
|
|
1194
|
+
* - "toolUse": The model wants to use one or more tools
|
|
1195
|
+
*
|
|
1196
|
+
* This field is an open string to allow for provider-specific stop reasons.
|
|
1077
1197
|
*/
|
|
1078
|
-
stopReason: z.optional(z.enum(['endTurn', 'stopSequence', 'maxTokens']).or(z.string())),
|
|
1198
|
+
stopReason: z.optional(z.enum(['endTurn', 'stopSequence', 'maxTokens', 'toolUse']).or(z.string())),
|
|
1079
1199
|
role: z.enum(['user', 'assistant']),
|
|
1080
|
-
|
|
1200
|
+
/**
|
|
1201
|
+
* Response content. May be ToolUseContent if stopReason is "toolUse".
|
|
1202
|
+
*/
|
|
1203
|
+
content: z.union([SamplingMessageContentBlockSchema, z.array(SamplingMessageContentBlockSchema)])
|
|
1081
1204
|
});
|
|
1082
1205
|
/* Elicitation */
|
|
1083
1206
|
/**
|
|
@@ -1194,11 +1317,15 @@ export const EnumSchemaSchema = z.union([LegacyTitledEnumSchemaSchema, SingleSel
|
|
|
1194
1317
|
*/
|
|
1195
1318
|
export const PrimitiveSchemaDefinitionSchema = z.union([EnumSchemaSchema, BooleanSchemaSchema, StringSchemaSchema, NumberSchemaSchema]);
|
|
1196
1319
|
/**
|
|
1197
|
-
* Parameters for an `elicitation/create` request.
|
|
1320
|
+
* Parameters for an `elicitation/create` request for form-based elicitation.
|
|
1198
1321
|
*/
|
|
1199
|
-
export const
|
|
1322
|
+
export const ElicitRequestFormParamsSchema = BaseRequestParamsSchema.extend({
|
|
1323
|
+
/**
|
|
1324
|
+
* The elicitation mode.
|
|
1325
|
+
*/
|
|
1326
|
+
mode: z.literal('form'),
|
|
1200
1327
|
/**
|
|
1201
|
-
* The message to present to the user.
|
|
1328
|
+
* The message to present to the user describing what information is being requested.
|
|
1202
1329
|
*/
|
|
1203
1330
|
message: z.string(),
|
|
1204
1331
|
/**
|
|
@@ -1211,14 +1338,61 @@ export const ElicitRequestParamsSchema = BaseRequestParamsSchema.extend({
|
|
|
1211
1338
|
required: z.array(z.string()).optional()
|
|
1212
1339
|
})
|
|
1213
1340
|
});
|
|
1341
|
+
/**
|
|
1342
|
+
* Parameters for an `elicitation/create` request for URL-based elicitation.
|
|
1343
|
+
*/
|
|
1344
|
+
export const ElicitRequestURLParamsSchema = BaseRequestParamsSchema.extend({
|
|
1345
|
+
/**
|
|
1346
|
+
* The elicitation mode.
|
|
1347
|
+
*/
|
|
1348
|
+
mode: z.literal('url'),
|
|
1349
|
+
/**
|
|
1350
|
+
* The message to present to the user explaining why the interaction is needed.
|
|
1351
|
+
*/
|
|
1352
|
+
message: z.string(),
|
|
1353
|
+
/**
|
|
1354
|
+
* The ID of the elicitation, which must be unique within the context of the server.
|
|
1355
|
+
* The client MUST treat this ID as an opaque value.
|
|
1356
|
+
*/
|
|
1357
|
+
elicitationId: z.string(),
|
|
1358
|
+
/**
|
|
1359
|
+
* The URL that the user should navigate to.
|
|
1360
|
+
*/
|
|
1361
|
+
url: z.string().url()
|
|
1362
|
+
});
|
|
1363
|
+
/**
|
|
1364
|
+
* The parameters for a request to elicit additional information from the user via the client.
|
|
1365
|
+
*/
|
|
1366
|
+
export const ElicitRequestParamsSchema = z.union([ElicitRequestFormParamsSchema, ElicitRequestURLParamsSchema]);
|
|
1214
1367
|
/**
|
|
1215
1368
|
* A request from the server to elicit user input via the client.
|
|
1216
|
-
* The client should present the message and form fields to the user
|
|
1369
|
+
* The client should present the message and form fields to the user (form mode)
|
|
1370
|
+
* or navigate to a URL (URL mode).
|
|
1217
1371
|
*/
|
|
1218
1372
|
export const ElicitRequestSchema = RequestSchema.extend({
|
|
1219
1373
|
method: z.literal('elicitation/create'),
|
|
1220
1374
|
params: ElicitRequestParamsSchema
|
|
1221
1375
|
});
|
|
1376
|
+
/**
|
|
1377
|
+
* Parameters for a `notifications/elicitation/complete` notification.
|
|
1378
|
+
*
|
|
1379
|
+
* @category notifications/elicitation/complete
|
|
1380
|
+
*/
|
|
1381
|
+
export const ElicitationCompleteNotificationParamsSchema = NotificationsParamsSchema.extend({
|
|
1382
|
+
/**
|
|
1383
|
+
* The ID of the elicitation that completed.
|
|
1384
|
+
*/
|
|
1385
|
+
elicitationId: z.string()
|
|
1386
|
+
});
|
|
1387
|
+
/**
|
|
1388
|
+
* A notification from the server to the client, informing it of a completion of an out-of-band elicitation request.
|
|
1389
|
+
*
|
|
1390
|
+
* @category notifications/elicitation/complete
|
|
1391
|
+
*/
|
|
1392
|
+
export const ElicitationCompleteNotificationSchema = NotificationSchema.extend({
|
|
1393
|
+
method: z.literal('notifications/elicitation/complete'),
|
|
1394
|
+
params: ElicitationCompleteNotificationParamsSchema
|
|
1395
|
+
});
|
|
1222
1396
|
/**
|
|
1223
1397
|
* The client's response to an elicitation/create request from the server.
|
|
1224
1398
|
*/
|
|
@@ -1234,7 +1408,7 @@ export const ElicitResultSchema = ResultSchema.extend({
|
|
|
1234
1408
|
* The submitted form data, only present when action is "accept".
|
|
1235
1409
|
* Contains values matching the requested schema.
|
|
1236
1410
|
*/
|
|
1237
|
-
content: z.record(z.union([z.string(), z.number(), z.boolean(), z.array(z.string())])).optional()
|
|
1411
|
+
content: z.record(z.string(), z.union([z.string(), z.number(), z.boolean(), z.array(z.string())])).optional()
|
|
1238
1412
|
});
|
|
1239
1413
|
/* Autocomplete */
|
|
1240
1414
|
/**
|
|
@@ -1299,18 +1473,19 @@ export function assertCompleteRequestPrompt(request) {
|
|
|
1299
1473
|
if (request.params.ref.type !== 'ref/prompt') {
|
|
1300
1474
|
throw new TypeError(`Expected CompleteRequestPrompt, but got ${request.params.ref.type}`);
|
|
1301
1475
|
}
|
|
1476
|
+
void request;
|
|
1302
1477
|
}
|
|
1303
1478
|
export function assertCompleteRequestResourceTemplate(request) {
|
|
1304
1479
|
if (request.params.ref.type !== 'ref/resource') {
|
|
1305
1480
|
throw new TypeError(`Expected CompleteRequestResourceTemplate, but got ${request.params.ref.type}`);
|
|
1306
1481
|
}
|
|
1482
|
+
void request;
|
|
1307
1483
|
}
|
|
1308
1484
|
/**
|
|
1309
1485
|
* The server's response to a completion/complete request
|
|
1310
1486
|
*/
|
|
1311
1487
|
export const CompleteResultSchema = ResultSchema.extend({
|
|
1312
|
-
completion: z
|
|
1313
|
-
.object({
|
|
1488
|
+
completion: z.looseObject({
|
|
1314
1489
|
/**
|
|
1315
1490
|
* An array of completion values. Must not exceed 100 items.
|
|
1316
1491
|
*/
|
|
@@ -1324,7 +1499,6 @@ export const CompleteResultSchema = ResultSchema.extend({
|
|
|
1324
1499
|
*/
|
|
1325
1500
|
hasMore: z.optional(z.boolean())
|
|
1326
1501
|
})
|
|
1327
|
-
.passthrough()
|
|
1328
1502
|
});
|
|
1329
1503
|
/* Roots */
|
|
1330
1504
|
/**
|
|
@@ -1395,7 +1569,8 @@ export const ServerNotificationSchema = z.union([
|
|
|
1395
1569
|
ResourceUpdatedNotificationSchema,
|
|
1396
1570
|
ResourceListChangedNotificationSchema,
|
|
1397
1571
|
ToolListChangedNotificationSchema,
|
|
1398
|
-
PromptListChangedNotificationSchema
|
|
1572
|
+
PromptListChangedNotificationSchema,
|
|
1573
|
+
ElicitationCompleteNotificationSchema
|
|
1399
1574
|
]);
|
|
1400
1575
|
export const ServerResultSchema = z.union([
|
|
1401
1576
|
EmptyResultSchema,
|
|
@@ -1416,5 +1591,34 @@ export class McpError extends Error {
|
|
|
1416
1591
|
this.data = data;
|
|
1417
1592
|
this.name = 'McpError';
|
|
1418
1593
|
}
|
|
1594
|
+
/**
|
|
1595
|
+
* Factory method to create the appropriate error type based on the error code and data
|
|
1596
|
+
*/
|
|
1597
|
+
static fromError(code, message, data) {
|
|
1598
|
+
// Check for specific error types
|
|
1599
|
+
if (code === ErrorCode.UrlElicitationRequired && data) {
|
|
1600
|
+
const errorData = data;
|
|
1601
|
+
if (errorData.elicitations) {
|
|
1602
|
+
return new UrlElicitationRequiredError(errorData.elicitations, message);
|
|
1603
|
+
}
|
|
1604
|
+
}
|
|
1605
|
+
// Default to generic McpError
|
|
1606
|
+
return new McpError(code, message, data);
|
|
1607
|
+
}
|
|
1608
|
+
}
|
|
1609
|
+
/**
|
|
1610
|
+
* Specialized error type when a tool requires a URL mode elicitation.
|
|
1611
|
+
* This makes it nicer for the client to handle since there is specific data to work with instead of just a code to check against.
|
|
1612
|
+
*/
|
|
1613
|
+
export class UrlElicitationRequiredError extends McpError {
|
|
1614
|
+
constructor(elicitations, message = `URL elicitation${elicitations.length > 1 ? 's' : ''} required`) {
|
|
1615
|
+
super(ErrorCode.UrlElicitationRequired, message, {
|
|
1616
|
+
elicitations: elicitations
|
|
1617
|
+
});
|
|
1618
|
+
}
|
|
1619
|
+
get elicitations() {
|
|
1620
|
+
var _a, _b;
|
|
1621
|
+
return (_b = (_a = this.data) === null || _a === void 0 ? void 0 : _a.elicitations) !== null && _b !== void 0 ? _b : [];
|
|
1622
|
+
}
|
|
1419
1623
|
}
|
|
1420
1624
|
//# sourceMappingURL=types.js.map
|