@modelcontextprotocol/sdk 1.21.2 → 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 +252 -1478
- package/dist/cjs/client/index.d.ts.map +1 -1
- package/dist/cjs/client/index.js +130 -0
- 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 +11 -6
- 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} +16 -12
- 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 +213 -71
- package/dist/cjs/server/index.d.ts.map +1 -1
- package/dist/cjs/server/index.js +61 -16
- 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 +105 -41
- 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/metadataUtils.d.ts +5 -1
- package/dist/cjs/shared/metadataUtils.d.ts.map +1 -1
- package/dist/cjs/shared/metadataUtils.js +2 -5
- package/dist/cjs/shared/metadataUtils.js.map +1 -1
- package/dist/cjs/shared/protocol.d.ts +7 -10
- package/dist/cjs/shared/protocol.d.ts.map +1 -1
- package/dist/cjs/shared/protocol.js +39 -16
- package/dist/cjs/shared/protocol.js.map +1 -1
- package/dist/cjs/shared/toolNameValidation.d.ts +31 -0
- package/dist/cjs/shared/toolNameValidation.d.ts.map +1 -0
- package/dist/cjs/shared/toolNameValidation.js +97 -0
- package/dist/cjs/shared/toolNameValidation.js.map +1 -0
- package/dist/cjs/shared/transport.d.ts +15 -1
- 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 +823 -261
- package/dist/cjs/spec.types.d.ts.map +1 -1
- package/dist/cjs/spec.types.js +5 -8
- package/dist/cjs/spec.types.js.map +1 -1
- package/dist/cjs/types.d.ts +3828 -59205
- package/dist/cjs/types.d.ts.map +1 -1
- package/dist/cjs/types.js +817 -487
- 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 +252 -1478
- package/dist/esm/client/index.d.ts.map +1 -1
- package/dist/esm/client/index.js +130 -1
- 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 +12 -7
- 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} +16 -12
- 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 +213 -71
- package/dist/esm/server/index.d.ts.map +1 -1
- package/dist/esm/server/index.js +61 -16
- 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 +107 -43
- 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/metadataUtils.d.ts +5 -1
- package/dist/esm/shared/metadataUtils.d.ts.map +1 -1
- package/dist/esm/shared/metadataUtils.js +2 -5
- package/dist/esm/shared/metadataUtils.js.map +1 -1
- package/dist/esm/shared/protocol.d.ts +7 -10
- package/dist/esm/shared/protocol.d.ts.map +1 -1
- package/dist/esm/shared/protocol.js +39 -16
- package/dist/esm/shared/protocol.js.map +1 -1
- package/dist/esm/shared/toolNameValidation.d.ts +31 -0
- package/dist/esm/shared/toolNameValidation.d.ts.map +1 -0
- package/dist/esm/shared/toolNameValidation.js +92 -0
- package/dist/esm/shared/toolNameValidation.js.map +1 -0
- package/dist/esm/shared/transport.d.ts +15 -1
- 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 +823 -261
- package/dist/esm/spec.types.d.ts.map +1 -1
- package/dist/esm/spec.types.js +4 -7
- package/dist/esm/spec.types.js.map +1 -1
- package/dist/esm/types.d.ts +3828 -59205
- package/dist/esm/types.d.ts.map +1 -1
- package/dist/esm/types.js +664 -360
- 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/cjs/types.js
CHANGED
|
@@ -1,94 +1,123 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.
|
|
5
|
-
exports.McpError = exports.ServerResultSchema = exports.ServerNotificationSchema = exports.ServerRequestSchema = exports.ClientResultSchema = exports.ClientNotificationSchema = void 0;
|
|
6
|
-
|
|
26
|
+
exports.ListResourceTemplatesRequestSchema = exports.ListResourcesResultSchema = exports.ListResourcesRequestSchema = exports.ResourceTemplateSchema = exports.ResourceSchema = exports.BlobResourceContentsSchema = exports.TextResourceContentsSchema = exports.ResourceContentsSchema = exports.PaginatedResultSchema = exports.PaginatedRequestSchema = exports.PaginatedRequestParamsSchema = exports.ProgressNotificationSchema = exports.ProgressNotificationParamsSchema = exports.ProgressSchema = exports.PingRequestSchema = exports.isInitializedNotification = exports.InitializedNotificationSchema = exports.InitializeResultSchema = exports.ServerCapabilitiesSchema = exports.isInitializeRequest = exports.InitializeRequestSchema = exports.InitializeRequestParamsSchema = exports.ClientCapabilitiesSchema = exports.ImplementationSchema = exports.BaseMetadataSchema = exports.IconsSchema = exports.IconSchema = exports.CancelledNotificationSchema = exports.CancelledNotificationParamsSchema = exports.EmptyResultSchema = exports.JSONRPCMessageSchema = exports.isJSONRPCError = exports.JSONRPCErrorSchema = exports.ErrorCode = exports.isJSONRPCResponse = exports.JSONRPCResponseSchema = exports.isJSONRPCNotification = exports.JSONRPCNotificationSchema = exports.isJSONRPCRequest = exports.JSONRPCRequestSchema = exports.RequestIdSchema = exports.ResultSchema = exports.NotificationSchema = exports.RequestSchema = exports.CursorSchema = exports.ProgressTokenSchema = exports.JSONRPC_VERSION = exports.SUPPORTED_PROTOCOL_VERSIONS = exports.DEFAULT_NEGOTIATED_PROTOCOL_VERSION = exports.LATEST_PROTOCOL_VERSION = void 0;
|
|
27
|
+
exports.CreateMessageRequestSchema = exports.CreateMessageRequestParamsSchema = exports.SamplingMessageSchema = exports.SamplingMessageContentBlockSchema = exports.ToolResultContentSchema = exports.ToolChoiceSchema = exports.ModelPreferencesSchema = exports.ModelHintSchema = exports.LoggingMessageNotificationSchema = exports.LoggingMessageNotificationParamsSchema = exports.SetLevelRequestSchema = exports.SetLevelRequestParamsSchema = exports.LoggingLevelSchema = exports.ToolListChangedNotificationSchema = exports.CallToolRequestSchema = exports.CallToolRequestParamsSchema = exports.CompatibilityCallToolResultSchema = exports.CallToolResultSchema = exports.ListToolsResultSchema = exports.ListToolsRequestSchema = exports.ToolSchema = exports.ToolAnnotationsSchema = exports.PromptListChangedNotificationSchema = exports.GetPromptResultSchema = exports.PromptMessageSchema = exports.ContentBlockSchema = exports.ResourceLinkSchema = exports.EmbeddedResourceSchema = exports.ToolUseContentSchema = exports.AudioContentSchema = exports.ImageContentSchema = exports.TextContentSchema = exports.GetPromptRequestSchema = exports.GetPromptRequestParamsSchema = exports.ListPromptsResultSchema = exports.ListPromptsRequestSchema = exports.PromptSchema = exports.PromptArgumentSchema = exports.ResourceUpdatedNotificationSchema = exports.ResourceUpdatedNotificationParamsSchema = exports.UnsubscribeRequestSchema = exports.UnsubscribeRequestParamsSchema = exports.SubscribeRequestSchema = exports.SubscribeRequestParamsSchema = exports.ResourceListChangedNotificationSchema = exports.ReadResourceResultSchema = exports.ReadResourceRequestSchema = exports.ReadResourceRequestParamsSchema = exports.ResourceRequestParamsSchema = exports.ListResourceTemplatesResultSchema = void 0;
|
|
28
|
+
exports.UrlElicitationRequiredError = exports.McpError = exports.ServerResultSchema = exports.ServerNotificationSchema = exports.ServerRequestSchema = exports.ClientResultSchema = exports.ClientNotificationSchema = exports.ClientRequestSchema = exports.RootsListChangedNotificationSchema = exports.ListRootsResultSchema = exports.ListRootsRequestSchema = exports.RootSchema = exports.CompleteResultSchema = exports.CompleteRequestSchema = exports.CompleteRequestParamsSchema = exports.PromptReferenceSchema = exports.ResourceReferenceSchema = exports.ResourceTemplateReferenceSchema = exports.ElicitResultSchema = exports.ElicitationCompleteNotificationSchema = exports.ElicitationCompleteNotificationParamsSchema = exports.ElicitRequestSchema = exports.ElicitRequestParamsSchema = exports.ElicitRequestURLParamsSchema = exports.ElicitRequestFormParamsSchema = exports.PrimitiveSchemaDefinitionSchema = exports.EnumSchemaSchema = exports.MultiSelectEnumSchemaSchema = exports.TitledMultiSelectEnumSchemaSchema = exports.UntitledMultiSelectEnumSchemaSchema = exports.SingleSelectEnumSchemaSchema = exports.LegacyTitledEnumSchemaSchema = exports.TitledSingleSelectEnumSchemaSchema = exports.UntitledSingleSelectEnumSchemaSchema = exports.NumberSchemaSchema = exports.StringSchemaSchema = exports.BooleanSchemaSchema = exports.CreateMessageResultSchema = void 0;
|
|
29
|
+
exports.assertCompleteRequestPrompt = assertCompleteRequestPrompt;
|
|
30
|
+
exports.assertCompleteRequestResourceTemplate = assertCompleteRequestResourceTemplate;
|
|
31
|
+
const z = __importStar(require("zod/v4"));
|
|
7
32
|
exports.LATEST_PROTOCOL_VERSION = '2025-06-18';
|
|
8
33
|
exports.DEFAULT_NEGOTIATED_PROTOCOL_VERSION = '2025-03-26';
|
|
9
34
|
exports.SUPPORTED_PROTOCOL_VERSIONS = [exports.LATEST_PROTOCOL_VERSION, '2025-03-26', '2024-11-05', '2024-10-07'];
|
|
10
35
|
/* JSON-RPC types */
|
|
11
36
|
exports.JSONRPC_VERSION = '2.0';
|
|
37
|
+
/**
|
|
38
|
+
* Assert 'object' type schema.
|
|
39
|
+
*
|
|
40
|
+
* @internal
|
|
41
|
+
*/
|
|
42
|
+
const AssertObjectSchema = z.custom((v) => v !== null && (typeof v === 'object' || typeof v === 'function'));
|
|
12
43
|
/**
|
|
13
44
|
* A progress token, used to associate progress notifications with the original request.
|
|
14
45
|
*/
|
|
15
|
-
exports.ProgressTokenSchema =
|
|
46
|
+
exports.ProgressTokenSchema = z.union([z.string(), z.number().int()]);
|
|
16
47
|
/**
|
|
17
48
|
* An opaque token used to represent a cursor for pagination.
|
|
18
49
|
*/
|
|
19
|
-
exports.CursorSchema =
|
|
20
|
-
const RequestMetaSchema =
|
|
21
|
-
.object({
|
|
50
|
+
exports.CursorSchema = z.string();
|
|
51
|
+
const RequestMetaSchema = z.looseObject({
|
|
22
52
|
/**
|
|
23
53
|
* 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.
|
|
24
54
|
*/
|
|
25
|
-
progressToken:
|
|
26
|
-
})
|
|
27
|
-
.passthrough();
|
|
28
|
-
const BaseRequestParamsSchema = zod_1.z
|
|
29
|
-
.object({
|
|
30
|
-
_meta: zod_1.z.optional(RequestMetaSchema)
|
|
31
|
-
})
|
|
32
|
-
.passthrough();
|
|
33
|
-
exports.RequestSchema = zod_1.z.object({
|
|
34
|
-
method: zod_1.z.string(),
|
|
35
|
-
params: zod_1.z.optional(BaseRequestParamsSchema)
|
|
55
|
+
progressToken: exports.ProgressTokenSchema.optional()
|
|
36
56
|
});
|
|
37
|
-
|
|
38
|
-
|
|
57
|
+
/**
|
|
58
|
+
* Common params for any request.
|
|
59
|
+
*/
|
|
60
|
+
const BaseRequestParamsSchema = z.looseObject({
|
|
61
|
+
/**
|
|
62
|
+
* See [General fields: `_meta`](/specification/draft/basic/index#meta) for notes on `_meta` usage.
|
|
63
|
+
*/
|
|
64
|
+
_meta: RequestMetaSchema.optional()
|
|
65
|
+
});
|
|
66
|
+
exports.RequestSchema = z.object({
|
|
67
|
+
method: z.string(),
|
|
68
|
+
params: BaseRequestParamsSchema.optional()
|
|
69
|
+
});
|
|
70
|
+
const NotificationsParamsSchema = z.looseObject({
|
|
39
71
|
/**
|
|
40
72
|
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
41
73
|
* for notes on _meta usage.
|
|
42
74
|
*/
|
|
43
|
-
_meta:
|
|
44
|
-
})
|
|
45
|
-
.passthrough();
|
|
46
|
-
exports.NotificationSchema = zod_1.z.object({
|
|
47
|
-
method: zod_1.z.string(),
|
|
48
|
-
params: zod_1.z.optional(BaseNotificationParamsSchema)
|
|
75
|
+
_meta: z.record(z.string(), z.unknown()).optional()
|
|
49
76
|
});
|
|
50
|
-
exports.
|
|
51
|
-
.
|
|
77
|
+
exports.NotificationSchema = z.object({
|
|
78
|
+
method: z.string(),
|
|
79
|
+
params: NotificationsParamsSchema.optional()
|
|
80
|
+
});
|
|
81
|
+
exports.ResultSchema = z.looseObject({
|
|
52
82
|
/**
|
|
53
83
|
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
54
84
|
* for notes on _meta usage.
|
|
55
85
|
*/
|
|
56
|
-
_meta:
|
|
57
|
-
})
|
|
58
|
-
.passthrough();
|
|
86
|
+
_meta: z.record(z.string(), z.unknown()).optional()
|
|
87
|
+
});
|
|
59
88
|
/**
|
|
60
89
|
* A uniquely identifying ID for a request in JSON-RPC.
|
|
61
90
|
*/
|
|
62
|
-
exports.RequestIdSchema =
|
|
91
|
+
exports.RequestIdSchema = z.union([z.string(), z.number().int()]);
|
|
63
92
|
/**
|
|
64
93
|
* A request that expects a response.
|
|
65
94
|
*/
|
|
66
|
-
exports.JSONRPCRequestSchema =
|
|
95
|
+
exports.JSONRPCRequestSchema = z
|
|
67
96
|
.object({
|
|
68
|
-
jsonrpc:
|
|
69
|
-
id: exports.RequestIdSchema
|
|
97
|
+
jsonrpc: z.literal(exports.JSONRPC_VERSION),
|
|
98
|
+
id: exports.RequestIdSchema,
|
|
99
|
+
...exports.RequestSchema.shape
|
|
70
100
|
})
|
|
71
|
-
.merge(exports.RequestSchema)
|
|
72
101
|
.strict();
|
|
73
102
|
const isJSONRPCRequest = (value) => exports.JSONRPCRequestSchema.safeParse(value).success;
|
|
74
103
|
exports.isJSONRPCRequest = isJSONRPCRequest;
|
|
75
104
|
/**
|
|
76
105
|
* A notification which does not expect a response.
|
|
77
106
|
*/
|
|
78
|
-
exports.JSONRPCNotificationSchema =
|
|
107
|
+
exports.JSONRPCNotificationSchema = z
|
|
79
108
|
.object({
|
|
80
|
-
jsonrpc:
|
|
109
|
+
jsonrpc: z.literal(exports.JSONRPC_VERSION),
|
|
110
|
+
...exports.NotificationSchema.shape
|
|
81
111
|
})
|
|
82
|
-
.merge(exports.NotificationSchema)
|
|
83
112
|
.strict();
|
|
84
113
|
const isJSONRPCNotification = (value) => exports.JSONRPCNotificationSchema.safeParse(value).success;
|
|
85
114
|
exports.isJSONRPCNotification = isJSONRPCNotification;
|
|
86
115
|
/**
|
|
87
116
|
* A successful (non-error) response to a request.
|
|
88
117
|
*/
|
|
89
|
-
exports.JSONRPCResponseSchema =
|
|
118
|
+
exports.JSONRPCResponseSchema = z
|
|
90
119
|
.object({
|
|
91
|
-
jsonrpc:
|
|
120
|
+
jsonrpc: z.literal(exports.JSONRPC_VERSION),
|
|
92
121
|
id: exports.RequestIdSchema,
|
|
93
122
|
result: exports.ResultSchema
|
|
94
123
|
})
|
|
@@ -109,38 +138,52 @@ var ErrorCode;
|
|
|
109
138
|
ErrorCode[ErrorCode["MethodNotFound"] = -32601] = "MethodNotFound";
|
|
110
139
|
ErrorCode[ErrorCode["InvalidParams"] = -32602] = "InvalidParams";
|
|
111
140
|
ErrorCode[ErrorCode["InternalError"] = -32603] = "InternalError";
|
|
141
|
+
// MCP-specific error codes
|
|
142
|
+
ErrorCode[ErrorCode["UrlElicitationRequired"] = -32042] = "UrlElicitationRequired";
|
|
112
143
|
})(ErrorCode || (exports.ErrorCode = ErrorCode = {}));
|
|
113
144
|
/**
|
|
114
145
|
* A response to a request that indicates an error occurred.
|
|
115
146
|
*/
|
|
116
|
-
exports.JSONRPCErrorSchema =
|
|
147
|
+
exports.JSONRPCErrorSchema = z
|
|
117
148
|
.object({
|
|
118
|
-
jsonrpc:
|
|
149
|
+
jsonrpc: z.literal(exports.JSONRPC_VERSION),
|
|
119
150
|
id: exports.RequestIdSchema,
|
|
120
|
-
error:
|
|
151
|
+
error: z.object({
|
|
121
152
|
/**
|
|
122
153
|
* The error type that occurred.
|
|
123
154
|
*/
|
|
124
|
-
code:
|
|
155
|
+
code: z.number().int(),
|
|
125
156
|
/**
|
|
126
157
|
* A short description of the error. The message SHOULD be limited to a concise single sentence.
|
|
127
158
|
*/
|
|
128
|
-
message:
|
|
159
|
+
message: z.string(),
|
|
129
160
|
/**
|
|
130
161
|
* Additional information about the error. The value of this member is defined by the sender (e.g. detailed error information, nested errors etc.).
|
|
131
162
|
*/
|
|
132
|
-
data:
|
|
163
|
+
data: z.optional(z.unknown())
|
|
133
164
|
})
|
|
134
165
|
})
|
|
135
166
|
.strict();
|
|
136
167
|
const isJSONRPCError = (value) => exports.JSONRPCErrorSchema.safeParse(value).success;
|
|
137
168
|
exports.isJSONRPCError = isJSONRPCError;
|
|
138
|
-
exports.JSONRPCMessageSchema =
|
|
169
|
+
exports.JSONRPCMessageSchema = z.union([exports.JSONRPCRequestSchema, exports.JSONRPCNotificationSchema, exports.JSONRPCResponseSchema, exports.JSONRPCErrorSchema]);
|
|
139
170
|
/* Empty result */
|
|
140
171
|
/**
|
|
141
172
|
* A response that indicates success but carries no data.
|
|
142
173
|
*/
|
|
143
174
|
exports.EmptyResultSchema = exports.ResultSchema.strict();
|
|
175
|
+
exports.CancelledNotificationParamsSchema = NotificationsParamsSchema.extend({
|
|
176
|
+
/**
|
|
177
|
+
* The ID of the request to cancel.
|
|
178
|
+
*
|
|
179
|
+
* This MUST correspond to the ID of a request previously issued in the same direction.
|
|
180
|
+
*/
|
|
181
|
+
requestId: exports.RequestIdSchema,
|
|
182
|
+
/**
|
|
183
|
+
* An optional string describing the reason for the cancellation. This MAY be logged or presented to the user.
|
|
184
|
+
*/
|
|
185
|
+
reason: z.string().optional()
|
|
186
|
+
});
|
|
144
187
|
/* Cancellation */
|
|
145
188
|
/**
|
|
146
189
|
* This notification can be sent by either side to indicate that it is cancelling a previously-issued request.
|
|
@@ -152,49 +195,35 @@ exports.EmptyResultSchema = exports.ResultSchema.strict();
|
|
|
152
195
|
* A client MUST NOT attempt to cancel its `initialize` request.
|
|
153
196
|
*/
|
|
154
197
|
exports.CancelledNotificationSchema = exports.NotificationSchema.extend({
|
|
155
|
-
method:
|
|
156
|
-
params:
|
|
157
|
-
/**
|
|
158
|
-
* The ID of the request to cancel.
|
|
159
|
-
*
|
|
160
|
-
* This MUST correspond to the ID of a request previously issued in the same direction.
|
|
161
|
-
*/
|
|
162
|
-
requestId: exports.RequestIdSchema,
|
|
163
|
-
/**
|
|
164
|
-
* An optional string describing the reason for the cancellation. This MAY be logged or presented to the user.
|
|
165
|
-
*/
|
|
166
|
-
reason: zod_1.z.string().optional()
|
|
167
|
-
})
|
|
198
|
+
method: z.literal('notifications/cancelled'),
|
|
199
|
+
params: exports.CancelledNotificationParamsSchema
|
|
168
200
|
});
|
|
169
201
|
/* Base Metadata */
|
|
170
202
|
/**
|
|
171
203
|
* Icon schema for use in tools, prompts, resources, and implementations.
|
|
172
204
|
*/
|
|
173
|
-
exports.IconSchema =
|
|
174
|
-
.object({
|
|
205
|
+
exports.IconSchema = z.object({
|
|
175
206
|
/**
|
|
176
207
|
* URL or data URI for the icon.
|
|
177
208
|
*/
|
|
178
|
-
src:
|
|
209
|
+
src: z.string(),
|
|
179
210
|
/**
|
|
180
211
|
* Optional MIME type for the icon.
|
|
181
212
|
*/
|
|
182
|
-
mimeType:
|
|
213
|
+
mimeType: z.string().optional(),
|
|
183
214
|
/**
|
|
184
215
|
* Optional array of strings that specify sizes at which the icon can be used.
|
|
185
216
|
* Each string should be in WxH format (e.g., `"48x48"`, `"96x96"`) or `"any"` for scalable formats like SVG.
|
|
186
217
|
*
|
|
187
218
|
* If not provided, the client should assume that the icon can be used at any size.
|
|
188
219
|
*/
|
|
189
|
-
sizes:
|
|
190
|
-
})
|
|
191
|
-
.passthrough();
|
|
220
|
+
sizes: z.array(z.string()).optional()
|
|
221
|
+
});
|
|
192
222
|
/**
|
|
193
223
|
* Base schema to add `icons` property.
|
|
194
224
|
*
|
|
195
225
|
*/
|
|
196
|
-
exports.IconsSchema =
|
|
197
|
-
.object({
|
|
226
|
+
exports.IconsSchema = z.object({
|
|
198
227
|
/**
|
|
199
228
|
* Optional set of sized icons that the client can display in a user interface.
|
|
200
229
|
*
|
|
@@ -206,16 +235,14 @@ exports.IconsSchema = zod_1.z
|
|
|
206
235
|
* - `image/svg+xml` - SVG images (scalable but requires security precautions)
|
|
207
236
|
* - `image/webp` - WebP images (modern, efficient format)
|
|
208
237
|
*/
|
|
209
|
-
icons:
|
|
210
|
-
})
|
|
211
|
-
.passthrough();
|
|
238
|
+
icons: z.array(exports.IconSchema).optional()
|
|
239
|
+
});
|
|
212
240
|
/**
|
|
213
241
|
* Base metadata interface for common properties across resources, tools, prompts, and implementations.
|
|
214
242
|
*/
|
|
215
|
-
exports.BaseMetadataSchema =
|
|
216
|
-
.object({
|
|
243
|
+
exports.BaseMetadataSchema = z.object({
|
|
217
244
|
/** Intended for programmatic or logical use, but used as a display name in past specs or fallback */
|
|
218
|
-
name:
|
|
245
|
+
name: z.string(),
|
|
219
246
|
/**
|
|
220
247
|
* Intended for UI and end-user contexts — optimized to be human-readable and easily understood,
|
|
221
248
|
* even by those unfamiliar with domain-specific terminology.
|
|
@@ -224,122 +251,144 @@ exports.BaseMetadataSchema = zod_1.z
|
|
|
224
251
|
* where `annotations.title` should be given precedence over using `name`,
|
|
225
252
|
* if present).
|
|
226
253
|
*/
|
|
227
|
-
title:
|
|
228
|
-
})
|
|
229
|
-
.passthrough();
|
|
254
|
+
title: z.string().optional()
|
|
255
|
+
});
|
|
230
256
|
/* Initialization */
|
|
231
257
|
/**
|
|
232
258
|
* Describes the name and version of an MCP implementation.
|
|
233
259
|
*/
|
|
234
260
|
exports.ImplementationSchema = exports.BaseMetadataSchema.extend({
|
|
235
|
-
|
|
261
|
+
...exports.BaseMetadataSchema.shape,
|
|
262
|
+
...exports.IconsSchema.shape,
|
|
263
|
+
version: z.string(),
|
|
236
264
|
/**
|
|
237
265
|
* An optional URL of the website for this implementation.
|
|
238
266
|
*/
|
|
239
|
-
websiteUrl:
|
|
240
|
-
})
|
|
267
|
+
websiteUrl: z.string().optional()
|
|
268
|
+
});
|
|
269
|
+
const FormElicitationCapabilitySchema = z.intersection(z.object({
|
|
270
|
+
applyDefaults: z.boolean().optional()
|
|
271
|
+
}), z.record(z.string(), z.unknown()));
|
|
272
|
+
const ElicitationCapabilitySchema = z.preprocess(value => {
|
|
273
|
+
if (value && typeof value === 'object' && !Array.isArray(value)) {
|
|
274
|
+
if (Object.keys(value).length === 0) {
|
|
275
|
+
return { form: {} };
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
return value;
|
|
279
|
+
}, z.intersection(z.object({
|
|
280
|
+
form: FormElicitationCapabilitySchema.optional(),
|
|
281
|
+
url: AssertObjectSchema.optional()
|
|
282
|
+
}), z.record(z.string(), z.unknown()).optional()));
|
|
241
283
|
/**
|
|
242
284
|
* 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
285
|
*/
|
|
244
|
-
exports.ClientCapabilitiesSchema =
|
|
245
|
-
.object({
|
|
286
|
+
exports.ClientCapabilitiesSchema = z.object({
|
|
246
287
|
/**
|
|
247
288
|
* Experimental, non-standard capabilities that the client supports.
|
|
248
289
|
*/
|
|
249
|
-
experimental:
|
|
290
|
+
experimental: z.record(z.string(), AssertObjectSchema).optional(),
|
|
250
291
|
/**
|
|
251
292
|
* Present if the client supports sampling from an LLM.
|
|
252
293
|
*/
|
|
253
|
-
sampling:
|
|
294
|
+
sampling: z
|
|
295
|
+
.object({
|
|
296
|
+
/**
|
|
297
|
+
* Present if the client supports context inclusion via includeContext parameter.
|
|
298
|
+
* If not declared, servers SHOULD only use `includeContext: "none"` (or omit it).
|
|
299
|
+
*/
|
|
300
|
+
context: AssertObjectSchema.optional(),
|
|
301
|
+
/**
|
|
302
|
+
* Present if the client supports tool use via tools and toolChoice parameters.
|
|
303
|
+
*/
|
|
304
|
+
tools: AssertObjectSchema.optional()
|
|
305
|
+
})
|
|
306
|
+
.optional(),
|
|
254
307
|
/**
|
|
255
308
|
* Present if the client supports eliciting user input.
|
|
256
309
|
*/
|
|
257
|
-
elicitation:
|
|
310
|
+
elicitation: ElicitationCapabilitySchema.optional(),
|
|
258
311
|
/**
|
|
259
312
|
* Present if the client supports listing roots.
|
|
260
313
|
*/
|
|
261
|
-
roots:
|
|
314
|
+
roots: z
|
|
262
315
|
.object({
|
|
263
316
|
/**
|
|
264
317
|
* Whether the client supports issuing notifications for changes to the roots list.
|
|
265
318
|
*/
|
|
266
|
-
listChanged:
|
|
319
|
+
listChanged: z.boolean().optional()
|
|
267
320
|
})
|
|
268
|
-
.
|
|
269
|
-
})
|
|
270
|
-
|
|
321
|
+
.optional()
|
|
322
|
+
});
|
|
323
|
+
exports.InitializeRequestParamsSchema = BaseRequestParamsSchema.extend({
|
|
324
|
+
/**
|
|
325
|
+
* The latest version of the Model Context Protocol that the client supports. The client MAY decide to support older versions as well.
|
|
326
|
+
*/
|
|
327
|
+
protocolVersion: z.string(),
|
|
328
|
+
capabilities: exports.ClientCapabilitiesSchema,
|
|
329
|
+
clientInfo: exports.ImplementationSchema
|
|
330
|
+
});
|
|
271
331
|
/**
|
|
272
332
|
* This request is sent from the client to the server when it first connects, asking it to begin initialization.
|
|
273
333
|
*/
|
|
274
334
|
exports.InitializeRequestSchema = exports.RequestSchema.extend({
|
|
275
|
-
method:
|
|
276
|
-
params:
|
|
277
|
-
/**
|
|
278
|
-
* The latest version of the Model Context Protocol that the client supports. The client MAY decide to support older versions as well.
|
|
279
|
-
*/
|
|
280
|
-
protocolVersion: zod_1.z.string(),
|
|
281
|
-
capabilities: exports.ClientCapabilitiesSchema,
|
|
282
|
-
clientInfo: exports.ImplementationSchema
|
|
283
|
-
})
|
|
335
|
+
method: z.literal('initialize'),
|
|
336
|
+
params: exports.InitializeRequestParamsSchema
|
|
284
337
|
});
|
|
285
338
|
const isInitializeRequest = (value) => exports.InitializeRequestSchema.safeParse(value).success;
|
|
286
339
|
exports.isInitializeRequest = isInitializeRequest;
|
|
287
340
|
/**
|
|
288
341
|
* 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.
|
|
289
342
|
*/
|
|
290
|
-
exports.ServerCapabilitiesSchema =
|
|
291
|
-
.object({
|
|
343
|
+
exports.ServerCapabilitiesSchema = z.object({
|
|
292
344
|
/**
|
|
293
345
|
* Experimental, non-standard capabilities that the server supports.
|
|
294
346
|
*/
|
|
295
|
-
experimental:
|
|
347
|
+
experimental: z.record(z.string(), AssertObjectSchema).optional(),
|
|
296
348
|
/**
|
|
297
349
|
* Present if the server supports sending log messages to the client.
|
|
298
350
|
*/
|
|
299
|
-
logging:
|
|
351
|
+
logging: AssertObjectSchema.optional(),
|
|
300
352
|
/**
|
|
301
353
|
* Present if the server supports sending completions to the client.
|
|
302
354
|
*/
|
|
303
|
-
completions:
|
|
355
|
+
completions: AssertObjectSchema.optional(),
|
|
304
356
|
/**
|
|
305
357
|
* Present if the server offers any prompt templates.
|
|
306
358
|
*/
|
|
307
|
-
prompts:
|
|
308
|
-
.object({
|
|
359
|
+
prompts: z.optional(z.object({
|
|
309
360
|
/**
|
|
310
361
|
* Whether this server supports issuing notifications for changes to the prompt list.
|
|
311
362
|
*/
|
|
312
|
-
listChanged:
|
|
313
|
-
})
|
|
314
|
-
.passthrough()),
|
|
363
|
+
listChanged: z.optional(z.boolean())
|
|
364
|
+
})),
|
|
315
365
|
/**
|
|
316
366
|
* Present if the server offers any resources to read.
|
|
317
367
|
*/
|
|
318
|
-
resources:
|
|
368
|
+
resources: z
|
|
319
369
|
.object({
|
|
320
370
|
/**
|
|
321
371
|
* Whether this server supports clients subscribing to resource updates.
|
|
322
372
|
*/
|
|
323
|
-
subscribe:
|
|
373
|
+
subscribe: z.boolean().optional(),
|
|
324
374
|
/**
|
|
325
375
|
* Whether this server supports issuing notifications for changes to the resource list.
|
|
326
376
|
*/
|
|
327
|
-
listChanged:
|
|
377
|
+
listChanged: z.boolean().optional()
|
|
328
378
|
})
|
|
329
|
-
.
|
|
379
|
+
.optional(),
|
|
330
380
|
/**
|
|
331
381
|
* Present if the server offers any tools to call.
|
|
332
382
|
*/
|
|
333
|
-
tools:
|
|
383
|
+
tools: z
|
|
334
384
|
.object({
|
|
335
385
|
/**
|
|
336
386
|
* Whether this server supports issuing notifications for changes to the tool list.
|
|
337
387
|
*/
|
|
338
|
-
listChanged:
|
|
388
|
+
listChanged: z.boolean().optional()
|
|
339
389
|
})
|
|
340
|
-
.
|
|
341
|
-
})
|
|
342
|
-
.passthrough();
|
|
390
|
+
.optional()
|
|
391
|
+
});
|
|
343
392
|
/**
|
|
344
393
|
* After receiving an initialize request from the client, the server sends this response.
|
|
345
394
|
*/
|
|
@@ -347,7 +396,7 @@ exports.InitializeResultSchema = exports.ResultSchema.extend({
|
|
|
347
396
|
/**
|
|
348
397
|
* The version of the Model Context Protocol that the server wants to use. This may not match the version that the client requested. If the client cannot support this version, it MUST disconnect.
|
|
349
398
|
*/
|
|
350
|
-
protocolVersion:
|
|
399
|
+
protocolVersion: z.string(),
|
|
351
400
|
capabilities: exports.ServerCapabilitiesSchema,
|
|
352
401
|
serverInfo: exports.ImplementationSchema,
|
|
353
402
|
/**
|
|
@@ -355,13 +404,13 @@ exports.InitializeResultSchema = exports.ResultSchema.extend({
|
|
|
355
404
|
*
|
|
356
405
|
* This can be used by clients to improve the LLM's understanding of available tools, resources, etc. It can be thought of like a "hint" to the model. For example, this information MAY be added to the system prompt.
|
|
357
406
|
*/
|
|
358
|
-
instructions:
|
|
407
|
+
instructions: z.string().optional()
|
|
359
408
|
});
|
|
360
409
|
/**
|
|
361
410
|
* This notification is sent from the client to the server after initialization has finished.
|
|
362
411
|
*/
|
|
363
412
|
exports.InitializedNotificationSchema = exports.NotificationSchema.extend({
|
|
364
|
-
method:
|
|
413
|
+
method: z.literal('notifications/initialized')
|
|
365
414
|
});
|
|
366
415
|
const isInitializedNotification = (value) => exports.InitializedNotificationSchema.safeParse(value).success;
|
|
367
416
|
exports.isInitializedNotification = isInitializedNotification;
|
|
@@ -370,87 +419,89 @@ exports.isInitializedNotification = isInitializedNotification;
|
|
|
370
419
|
* A ping, issued by either the server or the client, to check that the other party is still alive. The receiver must promptly respond, or else may be disconnected.
|
|
371
420
|
*/
|
|
372
421
|
exports.PingRequestSchema = exports.RequestSchema.extend({
|
|
373
|
-
method:
|
|
422
|
+
method: z.literal('ping')
|
|
374
423
|
});
|
|
375
424
|
/* Progress notifications */
|
|
376
|
-
exports.ProgressSchema =
|
|
377
|
-
.object({
|
|
425
|
+
exports.ProgressSchema = z.object({
|
|
378
426
|
/**
|
|
379
427
|
* The progress thus far. This should increase every time progress is made, even if the total is unknown.
|
|
380
428
|
*/
|
|
381
|
-
progress:
|
|
429
|
+
progress: z.number(),
|
|
382
430
|
/**
|
|
383
431
|
* Total number of items to process (or total progress required), if known.
|
|
384
432
|
*/
|
|
385
|
-
total:
|
|
433
|
+
total: z.optional(z.number()),
|
|
386
434
|
/**
|
|
387
435
|
* An optional message describing the current progress.
|
|
388
436
|
*/
|
|
389
|
-
message:
|
|
390
|
-
})
|
|
391
|
-
|
|
437
|
+
message: z.optional(z.string())
|
|
438
|
+
});
|
|
439
|
+
exports.ProgressNotificationParamsSchema = z.object({
|
|
440
|
+
...NotificationsParamsSchema.shape,
|
|
441
|
+
...exports.ProgressSchema.shape,
|
|
442
|
+
/**
|
|
443
|
+
* The progress token which was given in the initial request, used to associate this notification with the request that is proceeding.
|
|
444
|
+
*/
|
|
445
|
+
progressToken: exports.ProgressTokenSchema
|
|
446
|
+
});
|
|
392
447
|
/**
|
|
393
448
|
* An out-of-band notification used to inform the receiver of a progress update for a long-running request.
|
|
449
|
+
*
|
|
450
|
+
* @category notifications/progress
|
|
394
451
|
*/
|
|
395
452
|
exports.ProgressNotificationSchema = exports.NotificationSchema.extend({
|
|
396
|
-
method:
|
|
397
|
-
params:
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
453
|
+
method: z.literal('notifications/progress'),
|
|
454
|
+
params: exports.ProgressNotificationParamsSchema
|
|
455
|
+
});
|
|
456
|
+
exports.PaginatedRequestParamsSchema = BaseRequestParamsSchema.extend({
|
|
457
|
+
/**
|
|
458
|
+
* An opaque token representing the current pagination position.
|
|
459
|
+
* If provided, the server should return results starting after this cursor.
|
|
460
|
+
*/
|
|
461
|
+
cursor: exports.CursorSchema.optional()
|
|
403
462
|
});
|
|
404
463
|
/* Pagination */
|
|
405
464
|
exports.PaginatedRequestSchema = exports.RequestSchema.extend({
|
|
406
|
-
params:
|
|
407
|
-
/**
|
|
408
|
-
* An opaque token representing the current pagination position.
|
|
409
|
-
* If provided, the server should return results starting after this cursor.
|
|
410
|
-
*/
|
|
411
|
-
cursor: zod_1.z.optional(exports.CursorSchema)
|
|
412
|
-
}).optional()
|
|
465
|
+
params: exports.PaginatedRequestParamsSchema.optional()
|
|
413
466
|
});
|
|
414
467
|
exports.PaginatedResultSchema = exports.ResultSchema.extend({
|
|
415
468
|
/**
|
|
416
469
|
* An opaque token representing the pagination position after the last returned result.
|
|
417
470
|
* If present, there may be more results available.
|
|
418
471
|
*/
|
|
419
|
-
nextCursor:
|
|
472
|
+
nextCursor: z.optional(exports.CursorSchema)
|
|
420
473
|
});
|
|
421
474
|
/* Resources */
|
|
422
475
|
/**
|
|
423
476
|
* The contents of a specific resource or sub-resource.
|
|
424
477
|
*/
|
|
425
|
-
exports.ResourceContentsSchema =
|
|
426
|
-
.object({
|
|
478
|
+
exports.ResourceContentsSchema = z.object({
|
|
427
479
|
/**
|
|
428
480
|
* The URI of this resource.
|
|
429
481
|
*/
|
|
430
|
-
uri:
|
|
482
|
+
uri: z.string(),
|
|
431
483
|
/**
|
|
432
484
|
* The MIME type of this resource, if known.
|
|
433
485
|
*/
|
|
434
|
-
mimeType:
|
|
486
|
+
mimeType: z.optional(z.string()),
|
|
435
487
|
/**
|
|
436
488
|
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
437
489
|
* for notes on _meta usage.
|
|
438
490
|
*/
|
|
439
|
-
_meta:
|
|
440
|
-
})
|
|
441
|
-
.passthrough();
|
|
491
|
+
_meta: z.record(z.string(), z.unknown()).optional()
|
|
492
|
+
});
|
|
442
493
|
exports.TextResourceContentsSchema = exports.ResourceContentsSchema.extend({
|
|
443
494
|
/**
|
|
444
495
|
* The text of the item. This must only be set if the item can actually be represented as text (not binary data).
|
|
445
496
|
*/
|
|
446
|
-
text:
|
|
497
|
+
text: z.string()
|
|
447
498
|
});
|
|
448
499
|
/**
|
|
449
500
|
* A Zod schema for validating Base64 strings that is more performant and
|
|
450
501
|
* robust for very large inputs than the default regex-based check. It avoids
|
|
451
502
|
* stack overflows by using the native `atob` function for validation.
|
|
452
503
|
*/
|
|
453
|
-
const Base64Schema =
|
|
504
|
+
const Base64Schema = z.string().refine(val => {
|
|
454
505
|
try {
|
|
455
506
|
// atob throws a DOMException if the string contains characters
|
|
456
507
|
// that are not part of the Base64 character set.
|
|
@@ -470,224 +521,232 @@ exports.BlobResourceContentsSchema = exports.ResourceContentsSchema.extend({
|
|
|
470
521
|
/**
|
|
471
522
|
* A known resource that the server is capable of reading.
|
|
472
523
|
*/
|
|
473
|
-
exports.ResourceSchema =
|
|
524
|
+
exports.ResourceSchema = z.object({
|
|
525
|
+
...exports.BaseMetadataSchema.shape,
|
|
526
|
+
...exports.IconsSchema.shape,
|
|
474
527
|
/**
|
|
475
528
|
* The URI of this resource.
|
|
476
529
|
*/
|
|
477
|
-
uri:
|
|
530
|
+
uri: z.string(),
|
|
478
531
|
/**
|
|
479
532
|
* A description of what this resource represents.
|
|
480
533
|
*
|
|
481
534
|
* 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.
|
|
482
535
|
*/
|
|
483
|
-
description:
|
|
536
|
+
description: z.optional(z.string()),
|
|
484
537
|
/**
|
|
485
538
|
* The MIME type of this resource, if known.
|
|
486
539
|
*/
|
|
487
|
-
mimeType:
|
|
540
|
+
mimeType: z.optional(z.string()),
|
|
488
541
|
/**
|
|
489
542
|
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
490
543
|
* for notes on _meta usage.
|
|
491
544
|
*/
|
|
492
|
-
_meta:
|
|
493
|
-
})
|
|
545
|
+
_meta: z.optional(z.looseObject({}))
|
|
546
|
+
});
|
|
494
547
|
/**
|
|
495
548
|
* A template description for resources available on the server.
|
|
496
549
|
*/
|
|
497
|
-
exports.ResourceTemplateSchema =
|
|
550
|
+
exports.ResourceTemplateSchema = z.object({
|
|
551
|
+
...exports.BaseMetadataSchema.shape,
|
|
552
|
+
...exports.IconsSchema.shape,
|
|
498
553
|
/**
|
|
499
554
|
* A URI template (according to RFC 6570) that can be used to construct resource URIs.
|
|
500
555
|
*/
|
|
501
|
-
uriTemplate:
|
|
556
|
+
uriTemplate: z.string(),
|
|
502
557
|
/**
|
|
503
558
|
* A description of what this template is for.
|
|
504
559
|
*
|
|
505
560
|
* 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.
|
|
506
561
|
*/
|
|
507
|
-
description:
|
|
562
|
+
description: z.optional(z.string()),
|
|
508
563
|
/**
|
|
509
564
|
* The MIME type for all resources that match this template. This should only be included if all resources matching this template have the same type.
|
|
510
565
|
*/
|
|
511
|
-
mimeType:
|
|
566
|
+
mimeType: z.optional(z.string()),
|
|
512
567
|
/**
|
|
513
568
|
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
514
569
|
* for notes on _meta usage.
|
|
515
570
|
*/
|
|
516
|
-
_meta:
|
|
517
|
-
})
|
|
571
|
+
_meta: z.optional(z.looseObject({}))
|
|
572
|
+
});
|
|
518
573
|
/**
|
|
519
574
|
* Sent from the client to request a list of resources the server has.
|
|
520
575
|
*/
|
|
521
576
|
exports.ListResourcesRequestSchema = exports.PaginatedRequestSchema.extend({
|
|
522
|
-
method:
|
|
577
|
+
method: z.literal('resources/list')
|
|
523
578
|
});
|
|
524
579
|
/**
|
|
525
580
|
* The server's response to a resources/list request from the client.
|
|
526
581
|
*/
|
|
527
582
|
exports.ListResourcesResultSchema = exports.PaginatedResultSchema.extend({
|
|
528
|
-
resources:
|
|
583
|
+
resources: z.array(exports.ResourceSchema)
|
|
529
584
|
});
|
|
530
585
|
/**
|
|
531
586
|
* Sent from the client to request a list of resource templates the server has.
|
|
532
587
|
*/
|
|
533
588
|
exports.ListResourceTemplatesRequestSchema = exports.PaginatedRequestSchema.extend({
|
|
534
|
-
method:
|
|
589
|
+
method: z.literal('resources/templates/list')
|
|
535
590
|
});
|
|
536
591
|
/**
|
|
537
592
|
* The server's response to a resources/templates/list request from the client.
|
|
538
593
|
*/
|
|
539
594
|
exports.ListResourceTemplatesResultSchema = exports.PaginatedResultSchema.extend({
|
|
540
|
-
resourceTemplates:
|
|
595
|
+
resourceTemplates: z.array(exports.ResourceTemplateSchema)
|
|
596
|
+
});
|
|
597
|
+
exports.ResourceRequestParamsSchema = BaseRequestParamsSchema.extend({
|
|
598
|
+
/**
|
|
599
|
+
* The URI of the resource to read. The URI can use any protocol; it is up to the server how to interpret it.
|
|
600
|
+
*
|
|
601
|
+
* @format uri
|
|
602
|
+
*/
|
|
603
|
+
uri: z.string()
|
|
541
604
|
});
|
|
605
|
+
/**
|
|
606
|
+
* Parameters for a `resources/read` request.
|
|
607
|
+
*/
|
|
608
|
+
exports.ReadResourceRequestParamsSchema = exports.ResourceRequestParamsSchema;
|
|
542
609
|
/**
|
|
543
610
|
* Sent from the client to the server, to read a specific resource URI.
|
|
544
611
|
*/
|
|
545
612
|
exports.ReadResourceRequestSchema = exports.RequestSchema.extend({
|
|
546
|
-
method:
|
|
547
|
-
params:
|
|
548
|
-
/**
|
|
549
|
-
* The URI of the resource to read. The URI can use any protocol; it is up to the server how to interpret it.
|
|
550
|
-
*/
|
|
551
|
-
uri: zod_1.z.string()
|
|
552
|
-
})
|
|
613
|
+
method: z.literal('resources/read'),
|
|
614
|
+
params: exports.ReadResourceRequestParamsSchema
|
|
553
615
|
});
|
|
554
616
|
/**
|
|
555
617
|
* The server's response to a resources/read request from the client.
|
|
556
618
|
*/
|
|
557
619
|
exports.ReadResourceResultSchema = exports.ResultSchema.extend({
|
|
558
|
-
contents:
|
|
620
|
+
contents: z.array(z.union([exports.TextResourceContentsSchema, exports.BlobResourceContentsSchema]))
|
|
559
621
|
});
|
|
560
622
|
/**
|
|
561
623
|
* An optional notification from the server to the client, informing it that the list of resources it can read from has changed. This may be issued by servers without any previous subscription from the client.
|
|
562
624
|
*/
|
|
563
625
|
exports.ResourceListChangedNotificationSchema = exports.NotificationSchema.extend({
|
|
564
|
-
method:
|
|
626
|
+
method: z.literal('notifications/resources/list_changed')
|
|
565
627
|
});
|
|
628
|
+
exports.SubscribeRequestParamsSchema = exports.ResourceRequestParamsSchema;
|
|
566
629
|
/**
|
|
567
630
|
* Sent from the client to request resources/updated notifications from the server whenever a particular resource changes.
|
|
568
631
|
*/
|
|
569
632
|
exports.SubscribeRequestSchema = exports.RequestSchema.extend({
|
|
570
|
-
method:
|
|
571
|
-
params:
|
|
572
|
-
/**
|
|
573
|
-
* The URI of the resource to subscribe to. The URI can use any protocol; it is up to the server how to interpret it.
|
|
574
|
-
*/
|
|
575
|
-
uri: zod_1.z.string()
|
|
576
|
-
})
|
|
633
|
+
method: z.literal('resources/subscribe'),
|
|
634
|
+
params: exports.SubscribeRequestParamsSchema
|
|
577
635
|
});
|
|
636
|
+
exports.UnsubscribeRequestParamsSchema = exports.ResourceRequestParamsSchema;
|
|
578
637
|
/**
|
|
579
638
|
* Sent from the client to request cancellation of resources/updated notifications from the server. This should follow a previous resources/subscribe request.
|
|
580
639
|
*/
|
|
581
640
|
exports.UnsubscribeRequestSchema = exports.RequestSchema.extend({
|
|
582
|
-
method:
|
|
583
|
-
params:
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
641
|
+
method: z.literal('resources/unsubscribe'),
|
|
642
|
+
params: exports.UnsubscribeRequestParamsSchema
|
|
643
|
+
});
|
|
644
|
+
/**
|
|
645
|
+
* Parameters for a `notifications/resources/updated` notification.
|
|
646
|
+
*/
|
|
647
|
+
exports.ResourceUpdatedNotificationParamsSchema = NotificationsParamsSchema.extend({
|
|
648
|
+
/**
|
|
649
|
+
* The URI of the resource that has been updated. This might be a sub-resource of the one that the client actually subscribed to.
|
|
650
|
+
*/
|
|
651
|
+
uri: z.string()
|
|
589
652
|
});
|
|
590
653
|
/**
|
|
591
654
|
* A notification from the server to the client, informing it that a resource has changed and may need to be read again. This should only be sent if the client previously sent a resources/subscribe request.
|
|
592
655
|
*/
|
|
593
656
|
exports.ResourceUpdatedNotificationSchema = exports.NotificationSchema.extend({
|
|
594
|
-
method:
|
|
595
|
-
params:
|
|
596
|
-
/**
|
|
597
|
-
* The URI of the resource that has been updated. This might be a sub-resource of the one that the client actually subscribed to.
|
|
598
|
-
*/
|
|
599
|
-
uri: zod_1.z.string()
|
|
600
|
-
})
|
|
657
|
+
method: z.literal('notifications/resources/updated'),
|
|
658
|
+
params: exports.ResourceUpdatedNotificationParamsSchema
|
|
601
659
|
});
|
|
602
660
|
/* Prompts */
|
|
603
661
|
/**
|
|
604
662
|
* Describes an argument that a prompt can accept.
|
|
605
663
|
*/
|
|
606
|
-
exports.PromptArgumentSchema =
|
|
607
|
-
.object({
|
|
664
|
+
exports.PromptArgumentSchema = z.object({
|
|
608
665
|
/**
|
|
609
666
|
* The name of the argument.
|
|
610
667
|
*/
|
|
611
|
-
name:
|
|
668
|
+
name: z.string(),
|
|
612
669
|
/**
|
|
613
670
|
* A human-readable description of the argument.
|
|
614
671
|
*/
|
|
615
|
-
description:
|
|
672
|
+
description: z.optional(z.string()),
|
|
616
673
|
/**
|
|
617
674
|
* Whether this argument must be provided.
|
|
618
675
|
*/
|
|
619
|
-
required:
|
|
620
|
-
})
|
|
621
|
-
.passthrough();
|
|
676
|
+
required: z.optional(z.boolean())
|
|
677
|
+
});
|
|
622
678
|
/**
|
|
623
679
|
* A prompt or prompt template that the server offers.
|
|
624
680
|
*/
|
|
625
|
-
exports.PromptSchema =
|
|
681
|
+
exports.PromptSchema = z.object({
|
|
682
|
+
...exports.BaseMetadataSchema.shape,
|
|
683
|
+
...exports.IconsSchema.shape,
|
|
626
684
|
/**
|
|
627
685
|
* An optional description of what this prompt provides
|
|
628
686
|
*/
|
|
629
|
-
description:
|
|
687
|
+
description: z.optional(z.string()),
|
|
630
688
|
/**
|
|
631
689
|
* A list of arguments to use for templating the prompt.
|
|
632
690
|
*/
|
|
633
|
-
arguments:
|
|
691
|
+
arguments: z.optional(z.array(exports.PromptArgumentSchema)),
|
|
634
692
|
/**
|
|
635
693
|
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
636
694
|
* for notes on _meta usage.
|
|
637
695
|
*/
|
|
638
|
-
_meta:
|
|
639
|
-
})
|
|
696
|
+
_meta: z.optional(z.looseObject({}))
|
|
697
|
+
});
|
|
640
698
|
/**
|
|
641
699
|
* Sent from the client to request a list of prompts and prompt templates the server has.
|
|
642
700
|
*/
|
|
643
701
|
exports.ListPromptsRequestSchema = exports.PaginatedRequestSchema.extend({
|
|
644
|
-
method:
|
|
702
|
+
method: z.literal('prompts/list')
|
|
645
703
|
});
|
|
646
704
|
/**
|
|
647
705
|
* The server's response to a prompts/list request from the client.
|
|
648
706
|
*/
|
|
649
707
|
exports.ListPromptsResultSchema = exports.PaginatedResultSchema.extend({
|
|
650
|
-
prompts:
|
|
708
|
+
prompts: z.array(exports.PromptSchema)
|
|
709
|
+
});
|
|
710
|
+
/**
|
|
711
|
+
* Parameters for a `prompts/get` request.
|
|
712
|
+
*/
|
|
713
|
+
exports.GetPromptRequestParamsSchema = BaseRequestParamsSchema.extend({
|
|
714
|
+
/**
|
|
715
|
+
* The name of the prompt or prompt template.
|
|
716
|
+
*/
|
|
717
|
+
name: z.string(),
|
|
718
|
+
/**
|
|
719
|
+
* Arguments to use for templating the prompt.
|
|
720
|
+
*/
|
|
721
|
+
arguments: z.record(z.string(), z.string()).optional()
|
|
651
722
|
});
|
|
652
723
|
/**
|
|
653
724
|
* Used by the client to get a prompt provided by the server.
|
|
654
725
|
*/
|
|
655
726
|
exports.GetPromptRequestSchema = exports.RequestSchema.extend({
|
|
656
|
-
method:
|
|
657
|
-
params:
|
|
658
|
-
/**
|
|
659
|
-
* The name of the prompt or prompt template.
|
|
660
|
-
*/
|
|
661
|
-
name: zod_1.z.string(),
|
|
662
|
-
/**
|
|
663
|
-
* Arguments to use for templating the prompt.
|
|
664
|
-
*/
|
|
665
|
-
arguments: zod_1.z.optional(zod_1.z.record(zod_1.z.string()))
|
|
666
|
-
})
|
|
727
|
+
method: z.literal('prompts/get'),
|
|
728
|
+
params: exports.GetPromptRequestParamsSchema
|
|
667
729
|
});
|
|
668
730
|
/**
|
|
669
731
|
* Text provided to or from an LLM.
|
|
670
732
|
*/
|
|
671
|
-
exports.TextContentSchema =
|
|
672
|
-
.
|
|
673
|
-
type: zod_1.z.literal('text'),
|
|
733
|
+
exports.TextContentSchema = z.object({
|
|
734
|
+
type: z.literal('text'),
|
|
674
735
|
/**
|
|
675
736
|
* The text content of the message.
|
|
676
737
|
*/
|
|
677
|
-
text:
|
|
738
|
+
text: z.string(),
|
|
678
739
|
/**
|
|
679
740
|
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
680
741
|
* for notes on _meta usage.
|
|
681
742
|
*/
|
|
682
|
-
_meta:
|
|
683
|
-
})
|
|
684
|
-
.passthrough();
|
|
743
|
+
_meta: z.record(z.string(), z.unknown()).optional()
|
|
744
|
+
});
|
|
685
745
|
/**
|
|
686
746
|
* An image provided to or from an LLM.
|
|
687
747
|
*/
|
|
688
|
-
exports.ImageContentSchema =
|
|
689
|
-
.
|
|
690
|
-
type: zod_1.z.literal('image'),
|
|
748
|
+
exports.ImageContentSchema = z.object({
|
|
749
|
+
type: z.literal('image'),
|
|
691
750
|
/**
|
|
692
751
|
* The base64-encoded image data.
|
|
693
752
|
*/
|
|
@@ -695,20 +754,18 @@ exports.ImageContentSchema = zod_1.z
|
|
|
695
754
|
/**
|
|
696
755
|
* The MIME type of the image. Different providers may support different image types.
|
|
697
756
|
*/
|
|
698
|
-
mimeType:
|
|
757
|
+
mimeType: z.string(),
|
|
699
758
|
/**
|
|
700
759
|
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
701
760
|
* for notes on _meta usage.
|
|
702
761
|
*/
|
|
703
|
-
_meta:
|
|
704
|
-
})
|
|
705
|
-
.passthrough();
|
|
762
|
+
_meta: z.record(z.string(), z.unknown()).optional()
|
|
763
|
+
});
|
|
706
764
|
/**
|
|
707
765
|
* An Audio provided to or from an LLM.
|
|
708
766
|
*/
|
|
709
|
-
exports.AudioContentSchema =
|
|
710
|
-
.
|
|
711
|
-
type: zod_1.z.literal('audio'),
|
|
767
|
+
exports.AudioContentSchema = z.object({
|
|
768
|
+
type: z.literal('audio'),
|
|
712
769
|
/**
|
|
713
770
|
* The base64-encoded audio data.
|
|
714
771
|
*/
|
|
@@ -716,40 +773,66 @@ exports.AudioContentSchema = zod_1.z
|
|
|
716
773
|
/**
|
|
717
774
|
* The MIME type of the audio. Different providers may support different audio types.
|
|
718
775
|
*/
|
|
719
|
-
mimeType:
|
|
776
|
+
mimeType: z.string(),
|
|
720
777
|
/**
|
|
721
778
|
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
722
779
|
* for notes on _meta usage.
|
|
723
780
|
*/
|
|
724
|
-
_meta:
|
|
725
|
-
})
|
|
726
|
-
.passthrough();
|
|
781
|
+
_meta: z.record(z.string(), z.unknown()).optional()
|
|
782
|
+
});
|
|
727
783
|
/**
|
|
728
|
-
*
|
|
784
|
+
* A tool call request from an assistant (LLM).
|
|
785
|
+
* Represents the assistant's request to use a tool.
|
|
729
786
|
*/
|
|
730
|
-
exports.
|
|
787
|
+
exports.ToolUseContentSchema = z
|
|
731
788
|
.object({
|
|
732
|
-
type:
|
|
733
|
-
|
|
789
|
+
type: z.literal('tool_use'),
|
|
790
|
+
/**
|
|
791
|
+
* The name of the tool to invoke.
|
|
792
|
+
* Must match a tool name from the request's tools array.
|
|
793
|
+
*/
|
|
794
|
+
name: z.string(),
|
|
795
|
+
/**
|
|
796
|
+
* Unique identifier for this tool call.
|
|
797
|
+
* Used to correlate with ToolResultContent in subsequent messages.
|
|
798
|
+
*/
|
|
799
|
+
id: z.string(),
|
|
800
|
+
/**
|
|
801
|
+
* Arguments to pass to the tool.
|
|
802
|
+
* Must conform to the tool's inputSchema.
|
|
803
|
+
*/
|
|
804
|
+
input: z.object({}).passthrough(),
|
|
734
805
|
/**
|
|
735
806
|
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
736
807
|
* for notes on _meta usage.
|
|
737
808
|
*/
|
|
738
|
-
_meta:
|
|
809
|
+
_meta: z.optional(z.object({}).passthrough())
|
|
739
810
|
})
|
|
740
811
|
.passthrough();
|
|
812
|
+
/**
|
|
813
|
+
* The contents of a resource, embedded into a prompt or tool call result.
|
|
814
|
+
*/
|
|
815
|
+
exports.EmbeddedResourceSchema = z.object({
|
|
816
|
+
type: z.literal('resource'),
|
|
817
|
+
resource: z.union([exports.TextResourceContentsSchema, exports.BlobResourceContentsSchema]),
|
|
818
|
+
/**
|
|
819
|
+
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
820
|
+
* for notes on _meta usage.
|
|
821
|
+
*/
|
|
822
|
+
_meta: z.record(z.string(), z.unknown()).optional()
|
|
823
|
+
});
|
|
741
824
|
/**
|
|
742
825
|
* A resource that the server is capable of reading, included in a prompt or tool call result.
|
|
743
826
|
*
|
|
744
827
|
* Note: resource links returned by tools are not guaranteed to appear in the results of `resources/list` requests.
|
|
745
828
|
*/
|
|
746
829
|
exports.ResourceLinkSchema = exports.ResourceSchema.extend({
|
|
747
|
-
type:
|
|
830
|
+
type: z.literal('resource_link')
|
|
748
831
|
});
|
|
749
832
|
/**
|
|
750
833
|
* A content block that can be used in prompts and tool results.
|
|
751
834
|
*/
|
|
752
|
-
exports.ContentBlockSchema =
|
|
835
|
+
exports.ContentBlockSchema = z.union([
|
|
753
836
|
exports.TextContentSchema,
|
|
754
837
|
exports.ImageContentSchema,
|
|
755
838
|
exports.AudioContentSchema,
|
|
@@ -759,12 +842,10 @@ exports.ContentBlockSchema = zod_1.z.union([
|
|
|
759
842
|
/**
|
|
760
843
|
* Describes a message returned as part of a prompt.
|
|
761
844
|
*/
|
|
762
|
-
exports.PromptMessageSchema =
|
|
763
|
-
.
|
|
764
|
-
role: zod_1.z.enum(['user', 'assistant']),
|
|
845
|
+
exports.PromptMessageSchema = z.object({
|
|
846
|
+
role: z.enum(['user', 'assistant']),
|
|
765
847
|
content: exports.ContentBlockSchema
|
|
766
|
-
})
|
|
767
|
-
.passthrough();
|
|
848
|
+
});
|
|
768
849
|
/**
|
|
769
850
|
* The server's response to a prompts/get request from the client.
|
|
770
851
|
*/
|
|
@@ -772,14 +853,14 @@ exports.GetPromptResultSchema = exports.ResultSchema.extend({
|
|
|
772
853
|
/**
|
|
773
854
|
* An optional description for the prompt.
|
|
774
855
|
*/
|
|
775
|
-
description:
|
|
776
|
-
messages:
|
|
856
|
+
description: z.optional(z.string()),
|
|
857
|
+
messages: z.array(exports.PromptMessageSchema)
|
|
777
858
|
});
|
|
778
859
|
/**
|
|
779
860
|
* An optional notification from the server to the client, informing it that the list of prompts it offers has changed. This may be issued by servers without any previous subscription from the client.
|
|
780
861
|
*/
|
|
781
862
|
exports.PromptListChangedNotificationSchema = exports.NotificationSchema.extend({
|
|
782
|
-
method:
|
|
863
|
+
method: z.literal('notifications/prompts/list_changed')
|
|
783
864
|
});
|
|
784
865
|
/* Tools */
|
|
785
866
|
/**
|
|
@@ -792,18 +873,17 @@ exports.PromptListChangedNotificationSchema = exports.NotificationSchema.extend(
|
|
|
792
873
|
* Clients should never make tool use decisions based on ToolAnnotations
|
|
793
874
|
* received from untrusted servers.
|
|
794
875
|
*/
|
|
795
|
-
exports.ToolAnnotationsSchema =
|
|
796
|
-
.object({
|
|
876
|
+
exports.ToolAnnotationsSchema = z.object({
|
|
797
877
|
/**
|
|
798
878
|
* A human-readable title for the tool.
|
|
799
879
|
*/
|
|
800
|
-
title:
|
|
880
|
+
title: z.string().optional(),
|
|
801
881
|
/**
|
|
802
882
|
* If true, the tool does not modify its environment.
|
|
803
883
|
*
|
|
804
884
|
* Default: false
|
|
805
885
|
*/
|
|
806
|
-
readOnlyHint:
|
|
886
|
+
readOnlyHint: z.boolean().optional(),
|
|
807
887
|
/**
|
|
808
888
|
* If true, the tool may perform destructive updates to its environment.
|
|
809
889
|
* If false, the tool performs only additive updates.
|
|
@@ -812,7 +892,7 @@ exports.ToolAnnotationsSchema = zod_1.z
|
|
|
812
892
|
*
|
|
813
893
|
* Default: true
|
|
814
894
|
*/
|
|
815
|
-
destructiveHint:
|
|
895
|
+
destructiveHint: z.boolean().optional(),
|
|
816
896
|
/**
|
|
817
897
|
* If true, calling the tool repeatedly with the same arguments
|
|
818
898
|
* will have no additional effect on the its environment.
|
|
@@ -821,7 +901,7 @@ exports.ToolAnnotationsSchema = zod_1.z
|
|
|
821
901
|
*
|
|
822
902
|
* Default: false
|
|
823
903
|
*/
|
|
824
|
-
idempotentHint:
|
|
904
|
+
idempotentHint: z.boolean().optional(),
|
|
825
905
|
/**
|
|
826
906
|
* If true, this tool may interact with an "open world" of external
|
|
827
907
|
* entities. If false, the tool's domain of interaction is closed.
|
|
@@ -830,59 +910,59 @@ exports.ToolAnnotationsSchema = zod_1.z
|
|
|
830
910
|
*
|
|
831
911
|
* Default: true
|
|
832
912
|
*/
|
|
833
|
-
openWorldHint:
|
|
834
|
-
})
|
|
835
|
-
.passthrough();
|
|
913
|
+
openWorldHint: z.boolean().optional()
|
|
914
|
+
});
|
|
836
915
|
/**
|
|
837
916
|
* Definition for a tool the client can call.
|
|
838
917
|
*/
|
|
839
|
-
exports.ToolSchema =
|
|
918
|
+
exports.ToolSchema = z.object({
|
|
919
|
+
...exports.BaseMetadataSchema.shape,
|
|
920
|
+
...exports.IconsSchema.shape,
|
|
840
921
|
/**
|
|
841
922
|
* A human-readable description of the tool.
|
|
842
923
|
*/
|
|
843
|
-
description:
|
|
924
|
+
description: z.string().optional(),
|
|
844
925
|
/**
|
|
845
926
|
* A JSON Schema object defining the expected parameters for the tool.
|
|
846
927
|
*/
|
|
847
|
-
inputSchema:
|
|
848
|
-
.object
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
})
|
|
853
|
-
.passthrough(),
|
|
928
|
+
inputSchema: z.object({
|
|
929
|
+
type: z.literal('object'),
|
|
930
|
+
properties: z.record(z.string(), AssertObjectSchema).optional(),
|
|
931
|
+
required: z.optional(z.array(z.string()))
|
|
932
|
+
}),
|
|
854
933
|
/**
|
|
855
934
|
* An optional JSON Schema object defining the structure of the tool's output returned in
|
|
856
935
|
* the structuredContent field of a CallToolResult.
|
|
857
936
|
*/
|
|
858
|
-
outputSchema:
|
|
937
|
+
outputSchema: z
|
|
859
938
|
.object({
|
|
860
|
-
type:
|
|
861
|
-
properties:
|
|
862
|
-
required:
|
|
939
|
+
type: z.literal('object'),
|
|
940
|
+
properties: z.record(z.string(), AssertObjectSchema).optional(),
|
|
941
|
+
required: z.optional(z.array(z.string())),
|
|
942
|
+
additionalProperties: z.optional(z.boolean())
|
|
863
943
|
})
|
|
864
|
-
.
|
|
944
|
+
.optional(),
|
|
865
945
|
/**
|
|
866
946
|
* Optional additional tool information.
|
|
867
947
|
*/
|
|
868
|
-
annotations:
|
|
948
|
+
annotations: z.optional(exports.ToolAnnotationsSchema),
|
|
869
949
|
/**
|
|
870
950
|
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
871
951
|
* for notes on _meta usage.
|
|
872
952
|
*/
|
|
873
|
-
_meta:
|
|
874
|
-
})
|
|
953
|
+
_meta: z.record(z.string(), z.unknown()).optional()
|
|
954
|
+
});
|
|
875
955
|
/**
|
|
876
956
|
* Sent from the client to request a list of tools the server has.
|
|
877
957
|
*/
|
|
878
958
|
exports.ListToolsRequestSchema = exports.PaginatedRequestSchema.extend({
|
|
879
|
-
method:
|
|
959
|
+
method: z.literal('tools/list')
|
|
880
960
|
});
|
|
881
961
|
/**
|
|
882
962
|
* The server's response to a tools/list request from the client.
|
|
883
963
|
*/
|
|
884
964
|
exports.ListToolsResultSchema = exports.PaginatedResultSchema.extend({
|
|
885
|
-
tools:
|
|
965
|
+
tools: z.array(exports.ToolSchema)
|
|
886
966
|
});
|
|
887
967
|
/**
|
|
888
968
|
* The server's response to a tool call.
|
|
@@ -894,13 +974,13 @@ exports.CallToolResultSchema = exports.ResultSchema.extend({
|
|
|
894
974
|
* If the Tool does not define an outputSchema, this field MUST be present in the result.
|
|
895
975
|
* For backwards compatibility, this field is always present, but it may be empty.
|
|
896
976
|
*/
|
|
897
|
-
content:
|
|
977
|
+
content: z.array(exports.ContentBlockSchema).default([]),
|
|
898
978
|
/**
|
|
899
979
|
* An object containing structured tool output.
|
|
900
980
|
*
|
|
901
981
|
* If the Tool defines an outputSchema, this field MUST be present in the result, and contain a JSON object that matches the schema.
|
|
902
982
|
*/
|
|
903
|
-
structuredContent:
|
|
983
|
+
structuredContent: z.record(z.string(), z.unknown()).optional(),
|
|
904
984
|
/**
|
|
905
985
|
* Whether the tool call ended in an error.
|
|
906
986
|
*
|
|
@@ -915,141 +995,222 @@ exports.CallToolResultSchema = exports.ResultSchema.extend({
|
|
|
915
995
|
* server does not support tool calls, or any other exceptional conditions,
|
|
916
996
|
* should be reported as an MCP error response.
|
|
917
997
|
*/
|
|
918
|
-
isError:
|
|
998
|
+
isError: z.optional(z.boolean())
|
|
919
999
|
});
|
|
920
1000
|
/**
|
|
921
1001
|
* CallToolResultSchema extended with backwards compatibility to protocol version 2024-10-07.
|
|
922
1002
|
*/
|
|
923
1003
|
exports.CompatibilityCallToolResultSchema = exports.CallToolResultSchema.or(exports.ResultSchema.extend({
|
|
924
|
-
toolResult:
|
|
1004
|
+
toolResult: z.unknown()
|
|
925
1005
|
}));
|
|
1006
|
+
/**
|
|
1007
|
+
* Parameters for a `tools/call` request.
|
|
1008
|
+
*/
|
|
1009
|
+
exports.CallToolRequestParamsSchema = BaseRequestParamsSchema.extend({
|
|
1010
|
+
/**
|
|
1011
|
+
* The name of the tool to call.
|
|
1012
|
+
*/
|
|
1013
|
+
name: z.string(),
|
|
1014
|
+
/**
|
|
1015
|
+
* Arguments to pass to the tool.
|
|
1016
|
+
*/
|
|
1017
|
+
arguments: z.optional(z.record(z.string(), z.unknown()))
|
|
1018
|
+
});
|
|
926
1019
|
/**
|
|
927
1020
|
* Used by the client to invoke a tool provided by the server.
|
|
928
1021
|
*/
|
|
929
1022
|
exports.CallToolRequestSchema = exports.RequestSchema.extend({
|
|
930
|
-
method:
|
|
931
|
-
params:
|
|
932
|
-
name: zod_1.z.string(),
|
|
933
|
-
arguments: zod_1.z.optional(zod_1.z.record(zod_1.z.unknown()))
|
|
934
|
-
})
|
|
1023
|
+
method: z.literal('tools/call'),
|
|
1024
|
+
params: exports.CallToolRequestParamsSchema
|
|
935
1025
|
});
|
|
936
1026
|
/**
|
|
937
1027
|
* An optional notification from the server to the client, informing it that the list of tools it offers has changed. This may be issued by servers without any previous subscription from the client.
|
|
938
1028
|
*/
|
|
939
1029
|
exports.ToolListChangedNotificationSchema = exports.NotificationSchema.extend({
|
|
940
|
-
method:
|
|
1030
|
+
method: z.literal('notifications/tools/list_changed')
|
|
941
1031
|
});
|
|
942
1032
|
/* Logging */
|
|
943
1033
|
/**
|
|
944
1034
|
* The severity of a log message.
|
|
945
1035
|
*/
|
|
946
|
-
exports.LoggingLevelSchema =
|
|
1036
|
+
exports.LoggingLevelSchema = z.enum(['debug', 'info', 'notice', 'warning', 'error', 'critical', 'alert', 'emergency']);
|
|
1037
|
+
/**
|
|
1038
|
+
* Parameters for a `logging/setLevel` request.
|
|
1039
|
+
*/
|
|
1040
|
+
exports.SetLevelRequestParamsSchema = BaseRequestParamsSchema.extend({
|
|
1041
|
+
/**
|
|
1042
|
+
* The level of logging that the client wants to receive from the server. The server should send all logs at this level and higher (i.e., more severe) to the client as notifications/logging/message.
|
|
1043
|
+
*/
|
|
1044
|
+
level: exports.LoggingLevelSchema
|
|
1045
|
+
});
|
|
947
1046
|
/**
|
|
948
1047
|
* A request from the client to the server, to enable or adjust logging.
|
|
949
1048
|
*/
|
|
950
1049
|
exports.SetLevelRequestSchema = exports.RequestSchema.extend({
|
|
951
|
-
method:
|
|
952
|
-
params:
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
1050
|
+
method: z.literal('logging/setLevel'),
|
|
1051
|
+
params: exports.SetLevelRequestParamsSchema
|
|
1052
|
+
});
|
|
1053
|
+
/**
|
|
1054
|
+
* Parameters for a `notifications/message` notification.
|
|
1055
|
+
*/
|
|
1056
|
+
exports.LoggingMessageNotificationParamsSchema = NotificationsParamsSchema.extend({
|
|
1057
|
+
/**
|
|
1058
|
+
* The severity of this log message.
|
|
1059
|
+
*/
|
|
1060
|
+
level: exports.LoggingLevelSchema,
|
|
1061
|
+
/**
|
|
1062
|
+
* An optional name of the logger issuing this message.
|
|
1063
|
+
*/
|
|
1064
|
+
logger: z.string().optional(),
|
|
1065
|
+
/**
|
|
1066
|
+
* The data to be logged, such as a string message or an object. Any JSON serializable type is allowed here.
|
|
1067
|
+
*/
|
|
1068
|
+
data: z.unknown()
|
|
958
1069
|
});
|
|
959
1070
|
/**
|
|
960
1071
|
* Notification of a log message passed from server to client. If no logging/setLevel request has been sent from the client, the server MAY decide which messages to send automatically.
|
|
961
1072
|
*/
|
|
962
1073
|
exports.LoggingMessageNotificationSchema = exports.NotificationSchema.extend({
|
|
963
|
-
method:
|
|
964
|
-
params:
|
|
965
|
-
/**
|
|
966
|
-
* The severity of this log message.
|
|
967
|
-
*/
|
|
968
|
-
level: exports.LoggingLevelSchema,
|
|
969
|
-
/**
|
|
970
|
-
* An optional name of the logger issuing this message.
|
|
971
|
-
*/
|
|
972
|
-
logger: zod_1.z.optional(zod_1.z.string()),
|
|
973
|
-
/**
|
|
974
|
-
* The data to be logged, such as a string message or an object. Any JSON serializable type is allowed here.
|
|
975
|
-
*/
|
|
976
|
-
data: zod_1.z.unknown()
|
|
977
|
-
})
|
|
1074
|
+
method: z.literal('notifications/message'),
|
|
1075
|
+
params: exports.LoggingMessageNotificationParamsSchema
|
|
978
1076
|
});
|
|
979
1077
|
/* Sampling */
|
|
980
1078
|
/**
|
|
981
1079
|
* Hints to use for model selection.
|
|
982
1080
|
*/
|
|
983
|
-
exports.ModelHintSchema =
|
|
984
|
-
.object({
|
|
1081
|
+
exports.ModelHintSchema = z.object({
|
|
985
1082
|
/**
|
|
986
1083
|
* A hint for a model name.
|
|
987
1084
|
*/
|
|
988
|
-
name:
|
|
989
|
-
})
|
|
990
|
-
.passthrough();
|
|
1085
|
+
name: z.string().optional()
|
|
1086
|
+
});
|
|
991
1087
|
/**
|
|
992
1088
|
* The server's preferences for model selection, requested of the client during sampling.
|
|
993
1089
|
*/
|
|
994
|
-
exports.ModelPreferencesSchema =
|
|
995
|
-
.object({
|
|
1090
|
+
exports.ModelPreferencesSchema = z.object({
|
|
996
1091
|
/**
|
|
997
1092
|
* Optional hints to use for model selection.
|
|
998
1093
|
*/
|
|
999
|
-
hints:
|
|
1094
|
+
hints: z.optional(z.array(exports.ModelHintSchema)),
|
|
1000
1095
|
/**
|
|
1001
1096
|
* How much to prioritize cost when selecting a model.
|
|
1002
1097
|
*/
|
|
1003
|
-
costPriority:
|
|
1098
|
+
costPriority: z.optional(z.number().min(0).max(1)),
|
|
1004
1099
|
/**
|
|
1005
1100
|
* How much to prioritize sampling speed (latency) when selecting a model.
|
|
1006
1101
|
*/
|
|
1007
|
-
speedPriority:
|
|
1102
|
+
speedPriority: z.optional(z.number().min(0).max(1)),
|
|
1008
1103
|
/**
|
|
1009
1104
|
* How much to prioritize intelligence and capabilities when selecting a model.
|
|
1010
1105
|
*/
|
|
1011
|
-
intelligencePriority:
|
|
1106
|
+
intelligencePriority: z.optional(z.number().min(0).max(1))
|
|
1107
|
+
});
|
|
1108
|
+
/**
|
|
1109
|
+
* Controls tool usage behavior in sampling requests.
|
|
1110
|
+
*/
|
|
1111
|
+
exports.ToolChoiceSchema = z.object({
|
|
1112
|
+
/**
|
|
1113
|
+
* Controls when tools are used:
|
|
1114
|
+
* - "auto": Model decides whether to use tools (default)
|
|
1115
|
+
* - "required": Model MUST use at least one tool before completing
|
|
1116
|
+
* - "none": Model MUST NOT use any tools
|
|
1117
|
+
*/
|
|
1118
|
+
mode: z.optional(z.enum(['auto', 'required', 'none']))
|
|
1119
|
+
});
|
|
1120
|
+
/**
|
|
1121
|
+
* The result of a tool execution, provided by the user (server).
|
|
1122
|
+
* Represents the outcome of invoking a tool requested via ToolUseContent.
|
|
1123
|
+
*/
|
|
1124
|
+
exports.ToolResultContentSchema = z
|
|
1125
|
+
.object({
|
|
1126
|
+
type: z.literal('tool_result'),
|
|
1127
|
+
toolUseId: z.string().describe('The unique identifier for the corresponding tool call.'),
|
|
1128
|
+
content: z.array(exports.ContentBlockSchema).default([]),
|
|
1129
|
+
structuredContent: z.object({}).passthrough().optional(),
|
|
1130
|
+
isError: z.optional(z.boolean()),
|
|
1131
|
+
/**
|
|
1132
|
+
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
1133
|
+
* for notes on _meta usage.
|
|
1134
|
+
*/
|
|
1135
|
+
_meta: z.optional(z.object({}).passthrough())
|
|
1012
1136
|
})
|
|
1013
1137
|
.passthrough();
|
|
1138
|
+
/**
|
|
1139
|
+
* Content block types allowed in sampling messages.
|
|
1140
|
+
* This includes text, image, audio, tool use requests, and tool results.
|
|
1141
|
+
*/
|
|
1142
|
+
exports.SamplingMessageContentBlockSchema = z.discriminatedUnion('type', [
|
|
1143
|
+
exports.TextContentSchema,
|
|
1144
|
+
exports.ImageContentSchema,
|
|
1145
|
+
exports.AudioContentSchema,
|
|
1146
|
+
exports.ToolUseContentSchema,
|
|
1147
|
+
exports.ToolResultContentSchema
|
|
1148
|
+
]);
|
|
1014
1149
|
/**
|
|
1015
1150
|
* Describes a message issued to or received from an LLM API.
|
|
1016
1151
|
*/
|
|
1017
|
-
exports.SamplingMessageSchema =
|
|
1152
|
+
exports.SamplingMessageSchema = z
|
|
1018
1153
|
.object({
|
|
1019
|
-
role:
|
|
1020
|
-
content:
|
|
1154
|
+
role: z.enum(['user', 'assistant']),
|
|
1155
|
+
content: z.union([exports.SamplingMessageContentBlockSchema, z.array(exports.SamplingMessageContentBlockSchema)]),
|
|
1156
|
+
/**
|
|
1157
|
+
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
1158
|
+
* for notes on _meta usage.
|
|
1159
|
+
*/
|
|
1160
|
+
_meta: z.optional(z.object({}).passthrough())
|
|
1021
1161
|
})
|
|
1022
1162
|
.passthrough();
|
|
1163
|
+
/**
|
|
1164
|
+
* Parameters for a `sampling/createMessage` request.
|
|
1165
|
+
*/
|
|
1166
|
+
exports.CreateMessageRequestParamsSchema = BaseRequestParamsSchema.extend({
|
|
1167
|
+
messages: z.array(exports.SamplingMessageSchema),
|
|
1168
|
+
/**
|
|
1169
|
+
* The server's preferences for which model to select. The client MAY modify or omit this request.
|
|
1170
|
+
*/
|
|
1171
|
+
modelPreferences: exports.ModelPreferencesSchema.optional(),
|
|
1172
|
+
/**
|
|
1173
|
+
* An optional system prompt the server wants to use for sampling. The client MAY modify or omit this prompt.
|
|
1174
|
+
*/
|
|
1175
|
+
systemPrompt: z.string().optional(),
|
|
1176
|
+
/**
|
|
1177
|
+
* A request to include context from one or more MCP servers (including the caller), to be attached to the prompt.
|
|
1178
|
+
* The client MAY ignore this request.
|
|
1179
|
+
*
|
|
1180
|
+
* Default is "none". Values "thisServer" and "allServers" are soft-deprecated. Servers SHOULD only use these values if the client
|
|
1181
|
+
* declares ClientCapabilities.sampling.context. These values may be removed in future spec releases.
|
|
1182
|
+
*/
|
|
1183
|
+
includeContext: z.enum(['none', 'thisServer', 'allServers']).optional(),
|
|
1184
|
+
temperature: z.number().optional(),
|
|
1185
|
+
/**
|
|
1186
|
+
* The requested maximum number of tokens to sample (to prevent runaway completions).
|
|
1187
|
+
*
|
|
1188
|
+
* The client MAY choose to sample fewer tokens than the requested maximum.
|
|
1189
|
+
*/
|
|
1190
|
+
maxTokens: z.number().int(),
|
|
1191
|
+
stopSequences: z.array(z.string()).optional(),
|
|
1192
|
+
/**
|
|
1193
|
+
* Optional metadata to pass through to the LLM provider. The format of this metadata is provider-specific.
|
|
1194
|
+
*/
|
|
1195
|
+
metadata: AssertObjectSchema.optional(),
|
|
1196
|
+
/**
|
|
1197
|
+
* Tools that the model may use during generation.
|
|
1198
|
+
* The client MUST return an error if this field is provided but ClientCapabilities.sampling.tools is not declared.
|
|
1199
|
+
*/
|
|
1200
|
+
tools: z.optional(z.array(exports.ToolSchema)),
|
|
1201
|
+
/**
|
|
1202
|
+
* Controls how the model uses tools.
|
|
1203
|
+
* The client MUST return an error if this field is provided but ClientCapabilities.sampling.tools is not declared.
|
|
1204
|
+
* Default is `{ mode: "auto" }`.
|
|
1205
|
+
*/
|
|
1206
|
+
toolChoice: z.optional(exports.ToolChoiceSchema)
|
|
1207
|
+
});
|
|
1023
1208
|
/**
|
|
1024
1209
|
* 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.
|
|
1025
1210
|
*/
|
|
1026
1211
|
exports.CreateMessageRequestSchema = exports.RequestSchema.extend({
|
|
1027
|
-
method:
|
|
1028
|
-
params:
|
|
1029
|
-
messages: zod_1.z.array(exports.SamplingMessageSchema),
|
|
1030
|
-
/**
|
|
1031
|
-
* An optional system prompt the server wants to use for sampling. The client MAY modify or omit this prompt.
|
|
1032
|
-
*/
|
|
1033
|
-
systemPrompt: zod_1.z.optional(zod_1.z.string()),
|
|
1034
|
-
/**
|
|
1035
|
-
* A request to include context from one or more MCP servers (including the caller), to be attached to the prompt. The client MAY ignore this request.
|
|
1036
|
-
*/
|
|
1037
|
-
includeContext: zod_1.z.optional(zod_1.z.enum(['none', 'thisServer', 'allServers'])),
|
|
1038
|
-
temperature: zod_1.z.optional(zod_1.z.number()),
|
|
1039
|
-
/**
|
|
1040
|
-
* The maximum number of tokens to sample, as requested by the server. The client MAY choose to sample fewer tokens than requested.
|
|
1041
|
-
*/
|
|
1042
|
-
maxTokens: zod_1.z.number().int(),
|
|
1043
|
-
stopSequences: zod_1.z.optional(zod_1.z.array(zod_1.z.string())),
|
|
1044
|
-
/**
|
|
1045
|
-
* Optional metadata to pass through to the LLM provider. The format of this metadata is provider-specific.
|
|
1046
|
-
*/
|
|
1047
|
-
metadata: zod_1.z.optional(zod_1.z.object({}).passthrough()),
|
|
1048
|
-
/**
|
|
1049
|
-
* The server's preferences for which model to select.
|
|
1050
|
-
*/
|
|
1051
|
-
modelPreferences: zod_1.z.optional(exports.ModelPreferencesSchema)
|
|
1052
|
-
})
|
|
1212
|
+
method: z.literal('sampling/createMessage'),
|
|
1213
|
+
params: exports.CreateMessageRequestParamsSchema
|
|
1053
1214
|
});
|
|
1054
1215
|
/**
|
|
1055
1216
|
* The client's response to a sampling/create_message request from the server. The client should inform the user before returning the sampled message, to allow them to inspect the response (human in the loop) and decide whether to allow the server to see it.
|
|
@@ -1058,116 +1219,244 @@ exports.CreateMessageResultSchema = exports.ResultSchema.extend({
|
|
|
1058
1219
|
/**
|
|
1059
1220
|
* The name of the model that generated the message.
|
|
1060
1221
|
*/
|
|
1061
|
-
model:
|
|
1222
|
+
model: z.string(),
|
|
1062
1223
|
/**
|
|
1063
|
-
* The reason why sampling stopped.
|
|
1224
|
+
* The reason why sampling stopped, if known.
|
|
1225
|
+
*
|
|
1226
|
+
* Standard values:
|
|
1227
|
+
* - "endTurn": Natural end of the assistant's turn
|
|
1228
|
+
* - "stopSequence": A stop sequence was encountered
|
|
1229
|
+
* - "maxTokens": Maximum token limit was reached
|
|
1230
|
+
* - "toolUse": The model wants to use one or more tools
|
|
1231
|
+
*
|
|
1232
|
+
* This field is an open string to allow for provider-specific stop reasons.
|
|
1233
|
+
*/
|
|
1234
|
+
stopReason: z.optional(z.enum(['endTurn', 'stopSequence', 'maxTokens', 'toolUse']).or(z.string())),
|
|
1235
|
+
role: z.enum(['user', 'assistant']),
|
|
1236
|
+
/**
|
|
1237
|
+
* Response content. May be ToolUseContent if stopReason is "toolUse".
|
|
1064
1238
|
*/
|
|
1065
|
-
|
|
1066
|
-
role: zod_1.z.enum(['user', 'assistant']),
|
|
1067
|
-
content: zod_1.z.discriminatedUnion('type', [exports.TextContentSchema, exports.ImageContentSchema, exports.AudioContentSchema])
|
|
1239
|
+
content: z.union([exports.SamplingMessageContentBlockSchema, z.array(exports.SamplingMessageContentBlockSchema)])
|
|
1068
1240
|
});
|
|
1069
1241
|
/* Elicitation */
|
|
1070
1242
|
/**
|
|
1071
1243
|
* Primitive schema definition for boolean fields.
|
|
1072
1244
|
*/
|
|
1073
|
-
exports.BooleanSchemaSchema =
|
|
1074
|
-
.
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
})
|
|
1080
|
-
.passthrough();
|
|
1245
|
+
exports.BooleanSchemaSchema = z.object({
|
|
1246
|
+
type: z.literal('boolean'),
|
|
1247
|
+
title: z.string().optional(),
|
|
1248
|
+
description: z.string().optional(),
|
|
1249
|
+
default: z.boolean().optional()
|
|
1250
|
+
});
|
|
1081
1251
|
/**
|
|
1082
1252
|
* Primitive schema definition for string fields.
|
|
1083
1253
|
*/
|
|
1084
|
-
exports.StringSchemaSchema =
|
|
1085
|
-
.
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
})
|
|
1093
|
-
.passthrough();
|
|
1254
|
+
exports.StringSchemaSchema = z.object({
|
|
1255
|
+
type: z.literal('string'),
|
|
1256
|
+
title: z.string().optional(),
|
|
1257
|
+
description: z.string().optional(),
|
|
1258
|
+
minLength: z.number().optional(),
|
|
1259
|
+
maxLength: z.number().optional(),
|
|
1260
|
+
format: z.enum(['email', 'uri', 'date', 'date-time']).optional(),
|
|
1261
|
+
default: z.string().optional()
|
|
1262
|
+
});
|
|
1094
1263
|
/**
|
|
1095
1264
|
* Primitive schema definition for number fields.
|
|
1096
1265
|
*/
|
|
1097
|
-
exports.NumberSchemaSchema =
|
|
1098
|
-
.
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
})
|
|
1105
|
-
|
|
1266
|
+
exports.NumberSchemaSchema = z.object({
|
|
1267
|
+
type: z.enum(['number', 'integer']),
|
|
1268
|
+
title: z.string().optional(),
|
|
1269
|
+
description: z.string().optional(),
|
|
1270
|
+
minimum: z.number().optional(),
|
|
1271
|
+
maximum: z.number().optional(),
|
|
1272
|
+
default: z.number().optional()
|
|
1273
|
+
});
|
|
1274
|
+
/**
|
|
1275
|
+
* Schema for single-selection enumeration without display titles for options.
|
|
1276
|
+
*/
|
|
1277
|
+
exports.UntitledSingleSelectEnumSchemaSchema = z.object({
|
|
1278
|
+
type: z.literal('string'),
|
|
1279
|
+
title: z.string().optional(),
|
|
1280
|
+
description: z.string().optional(),
|
|
1281
|
+
enum: z.array(z.string()),
|
|
1282
|
+
default: z.string().optional()
|
|
1283
|
+
});
|
|
1284
|
+
/**
|
|
1285
|
+
* Schema for single-selection enumeration with display titles for each option.
|
|
1286
|
+
*/
|
|
1287
|
+
exports.TitledSingleSelectEnumSchemaSchema = z.object({
|
|
1288
|
+
type: z.literal('string'),
|
|
1289
|
+
title: z.string().optional(),
|
|
1290
|
+
description: z.string().optional(),
|
|
1291
|
+
oneOf: z.array(z.object({
|
|
1292
|
+
const: z.string(),
|
|
1293
|
+
title: z.string()
|
|
1294
|
+
})),
|
|
1295
|
+
default: z.string().optional()
|
|
1296
|
+
});
|
|
1297
|
+
/**
|
|
1298
|
+
* Use TitledSingleSelectEnumSchema instead.
|
|
1299
|
+
* This interface will be removed in a future version.
|
|
1300
|
+
*/
|
|
1301
|
+
exports.LegacyTitledEnumSchemaSchema = z.object({
|
|
1302
|
+
type: z.literal('string'),
|
|
1303
|
+
title: z.string().optional(),
|
|
1304
|
+
description: z.string().optional(),
|
|
1305
|
+
enum: z.array(z.string()),
|
|
1306
|
+
enumNames: z.array(z.string()).optional(),
|
|
1307
|
+
default: z.string().optional()
|
|
1308
|
+
});
|
|
1309
|
+
// Combined single selection enumeration
|
|
1310
|
+
exports.SingleSelectEnumSchemaSchema = z.union([exports.UntitledSingleSelectEnumSchemaSchema, exports.TitledSingleSelectEnumSchemaSchema]);
|
|
1311
|
+
/**
|
|
1312
|
+
* Schema for multiple-selection enumeration without display titles for options.
|
|
1313
|
+
*/
|
|
1314
|
+
exports.UntitledMultiSelectEnumSchemaSchema = z.object({
|
|
1315
|
+
type: z.literal('array'),
|
|
1316
|
+
title: z.string().optional(),
|
|
1317
|
+
description: z.string().optional(),
|
|
1318
|
+
minItems: z.number().optional(),
|
|
1319
|
+
maxItems: z.number().optional(),
|
|
1320
|
+
items: z.object({
|
|
1321
|
+
type: z.literal('string'),
|
|
1322
|
+
enum: z.array(z.string())
|
|
1323
|
+
}),
|
|
1324
|
+
default: z.array(z.string()).optional()
|
|
1325
|
+
});
|
|
1326
|
+
/**
|
|
1327
|
+
* Schema for multiple-selection enumeration with display titles for each option.
|
|
1328
|
+
*/
|
|
1329
|
+
exports.TitledMultiSelectEnumSchemaSchema = z.object({
|
|
1330
|
+
type: z.literal('array'),
|
|
1331
|
+
title: z.string().optional(),
|
|
1332
|
+
description: z.string().optional(),
|
|
1333
|
+
minItems: z.number().optional(),
|
|
1334
|
+
maxItems: z.number().optional(),
|
|
1335
|
+
items: z.object({
|
|
1336
|
+
anyOf: z.array(z.object({
|
|
1337
|
+
const: z.string(),
|
|
1338
|
+
title: z.string()
|
|
1339
|
+
}))
|
|
1340
|
+
}),
|
|
1341
|
+
default: z.array(z.string()).optional()
|
|
1342
|
+
});
|
|
1343
|
+
/**
|
|
1344
|
+
* Combined schema for multiple-selection enumeration
|
|
1345
|
+
*/
|
|
1346
|
+
exports.MultiSelectEnumSchemaSchema = z.union([exports.UntitledMultiSelectEnumSchemaSchema, exports.TitledMultiSelectEnumSchemaSchema]);
|
|
1106
1347
|
/**
|
|
1107
1348
|
* Primitive schema definition for enum fields.
|
|
1108
1349
|
*/
|
|
1109
|
-
exports.EnumSchemaSchema =
|
|
1110
|
-
.object({
|
|
1111
|
-
type: zod_1.z.literal('string'),
|
|
1112
|
-
title: zod_1.z.optional(zod_1.z.string()),
|
|
1113
|
-
description: zod_1.z.optional(zod_1.z.string()),
|
|
1114
|
-
enum: zod_1.z.array(zod_1.z.string()),
|
|
1115
|
-
enumNames: zod_1.z.optional(zod_1.z.array(zod_1.z.string()))
|
|
1116
|
-
})
|
|
1117
|
-
.passthrough();
|
|
1350
|
+
exports.EnumSchemaSchema = z.union([exports.LegacyTitledEnumSchemaSchema, exports.SingleSelectEnumSchemaSchema, exports.MultiSelectEnumSchemaSchema]);
|
|
1118
1351
|
/**
|
|
1119
1352
|
* Union of all primitive schema definitions.
|
|
1120
1353
|
*/
|
|
1121
|
-
exports.PrimitiveSchemaDefinitionSchema =
|
|
1354
|
+
exports.PrimitiveSchemaDefinitionSchema = z.union([exports.EnumSchemaSchema, exports.BooleanSchemaSchema, exports.StringSchemaSchema, exports.NumberSchemaSchema]);
|
|
1355
|
+
/**
|
|
1356
|
+
* Parameters for an `elicitation/create` request for form-based elicitation.
|
|
1357
|
+
*/
|
|
1358
|
+
exports.ElicitRequestFormParamsSchema = BaseRequestParamsSchema.extend({
|
|
1359
|
+
/**
|
|
1360
|
+
* The elicitation mode.
|
|
1361
|
+
*/
|
|
1362
|
+
mode: z.literal('form'),
|
|
1363
|
+
/**
|
|
1364
|
+
* The message to present to the user describing what information is being requested.
|
|
1365
|
+
*/
|
|
1366
|
+
message: z.string(),
|
|
1367
|
+
/**
|
|
1368
|
+
* A restricted subset of JSON Schema.
|
|
1369
|
+
* Only top-level properties are allowed, without nesting.
|
|
1370
|
+
*/
|
|
1371
|
+
requestedSchema: z.object({
|
|
1372
|
+
type: z.literal('object'),
|
|
1373
|
+
properties: z.record(z.string(), exports.PrimitiveSchemaDefinitionSchema),
|
|
1374
|
+
required: z.array(z.string()).optional()
|
|
1375
|
+
})
|
|
1376
|
+
});
|
|
1377
|
+
/**
|
|
1378
|
+
* Parameters for an `elicitation/create` request for URL-based elicitation.
|
|
1379
|
+
*/
|
|
1380
|
+
exports.ElicitRequestURLParamsSchema = BaseRequestParamsSchema.extend({
|
|
1381
|
+
/**
|
|
1382
|
+
* The elicitation mode.
|
|
1383
|
+
*/
|
|
1384
|
+
mode: z.literal('url'),
|
|
1385
|
+
/**
|
|
1386
|
+
* The message to present to the user explaining why the interaction is needed.
|
|
1387
|
+
*/
|
|
1388
|
+
message: z.string(),
|
|
1389
|
+
/**
|
|
1390
|
+
* The ID of the elicitation, which must be unique within the context of the server.
|
|
1391
|
+
* The client MUST treat this ID as an opaque value.
|
|
1392
|
+
*/
|
|
1393
|
+
elicitationId: z.string(),
|
|
1394
|
+
/**
|
|
1395
|
+
* The URL that the user should navigate to.
|
|
1396
|
+
*/
|
|
1397
|
+
url: z.string().url()
|
|
1398
|
+
});
|
|
1399
|
+
/**
|
|
1400
|
+
* The parameters for a request to elicit additional information from the user via the client.
|
|
1401
|
+
*/
|
|
1402
|
+
exports.ElicitRequestParamsSchema = z.union([exports.ElicitRequestFormParamsSchema, exports.ElicitRequestURLParamsSchema]);
|
|
1122
1403
|
/**
|
|
1123
1404
|
* A request from the server to elicit user input via the client.
|
|
1124
|
-
* The client should present the message and form fields to the user
|
|
1405
|
+
* The client should present the message and form fields to the user (form mode)
|
|
1406
|
+
* or navigate to a URL (URL mode).
|
|
1125
1407
|
*/
|
|
1126
1408
|
exports.ElicitRequestSchema = exports.RequestSchema.extend({
|
|
1127
|
-
method:
|
|
1128
|
-
params:
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1409
|
+
method: z.literal('elicitation/create'),
|
|
1410
|
+
params: exports.ElicitRequestParamsSchema
|
|
1411
|
+
});
|
|
1412
|
+
/**
|
|
1413
|
+
* Parameters for a `notifications/elicitation/complete` notification.
|
|
1414
|
+
*
|
|
1415
|
+
* @category notifications/elicitation/complete
|
|
1416
|
+
*/
|
|
1417
|
+
exports.ElicitationCompleteNotificationParamsSchema = NotificationsParamsSchema.extend({
|
|
1418
|
+
/**
|
|
1419
|
+
* The ID of the elicitation that completed.
|
|
1420
|
+
*/
|
|
1421
|
+
elicitationId: z.string()
|
|
1422
|
+
});
|
|
1423
|
+
/**
|
|
1424
|
+
* A notification from the server to the client, informing it of a completion of an out-of-band elicitation request.
|
|
1425
|
+
*
|
|
1426
|
+
* @category notifications/elicitation/complete
|
|
1427
|
+
*/
|
|
1428
|
+
exports.ElicitationCompleteNotificationSchema = exports.NotificationSchema.extend({
|
|
1429
|
+
method: z.literal('notifications/elicitation/complete'),
|
|
1430
|
+
params: exports.ElicitationCompleteNotificationParamsSchema
|
|
1144
1431
|
});
|
|
1145
1432
|
/**
|
|
1146
1433
|
* The client's response to an elicitation/create request from the server.
|
|
1147
1434
|
*/
|
|
1148
1435
|
exports.ElicitResultSchema = exports.ResultSchema.extend({
|
|
1149
1436
|
/**
|
|
1150
|
-
* The user
|
|
1437
|
+
* The user action in response to the elicitation.
|
|
1438
|
+
* - "accept": User submitted the form/confirmed the action
|
|
1439
|
+
* - "decline": User explicitly decline the action
|
|
1440
|
+
* - "cancel": User dismissed without making an explicit choice
|
|
1151
1441
|
*/
|
|
1152
|
-
action:
|
|
1442
|
+
action: z.enum(['accept', 'decline', 'cancel']),
|
|
1153
1443
|
/**
|
|
1154
|
-
* The
|
|
1444
|
+
* The submitted form data, only present when action is "accept".
|
|
1445
|
+
* Contains values matching the requested schema.
|
|
1155
1446
|
*/
|
|
1156
|
-
content:
|
|
1447
|
+
content: z.record(z.string(), z.union([z.string(), z.number(), z.boolean(), z.array(z.string())])).optional()
|
|
1157
1448
|
});
|
|
1158
1449
|
/* Autocomplete */
|
|
1159
1450
|
/**
|
|
1160
1451
|
* A reference to a resource or resource template definition.
|
|
1161
1452
|
*/
|
|
1162
|
-
exports.ResourceTemplateReferenceSchema =
|
|
1163
|
-
.
|
|
1164
|
-
type: zod_1.z.literal('ref/resource'),
|
|
1453
|
+
exports.ResourceTemplateReferenceSchema = z.object({
|
|
1454
|
+
type: z.literal('ref/resource'),
|
|
1165
1455
|
/**
|
|
1166
1456
|
* The URI or URI template of the resource.
|
|
1167
1457
|
*/
|
|
1168
|
-
uri:
|
|
1169
|
-
})
|
|
1170
|
-
.passthrough();
|
|
1458
|
+
uri: z.string()
|
|
1459
|
+
});
|
|
1171
1460
|
/**
|
|
1172
1461
|
* @deprecated Use ResourceTemplateReferenceSchema instead
|
|
1173
1462
|
*/
|
|
@@ -1175,107 +1464,117 @@ exports.ResourceReferenceSchema = exports.ResourceTemplateReferenceSchema;
|
|
|
1175
1464
|
/**
|
|
1176
1465
|
* Identifies a prompt.
|
|
1177
1466
|
*/
|
|
1178
|
-
exports.PromptReferenceSchema =
|
|
1179
|
-
.
|
|
1180
|
-
type: zod_1.z.literal('ref/prompt'),
|
|
1467
|
+
exports.PromptReferenceSchema = z.object({
|
|
1468
|
+
type: z.literal('ref/prompt'),
|
|
1181
1469
|
/**
|
|
1182
1470
|
* The name of the prompt or prompt template
|
|
1183
1471
|
*/
|
|
1184
|
-
name:
|
|
1185
|
-
})
|
|
1186
|
-
.passthrough();
|
|
1472
|
+
name: z.string()
|
|
1473
|
+
});
|
|
1187
1474
|
/**
|
|
1188
|
-
*
|
|
1475
|
+
* Parameters for a `completion/complete` request.
|
|
1189
1476
|
*/
|
|
1190
|
-
exports.
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1477
|
+
exports.CompleteRequestParamsSchema = BaseRequestParamsSchema.extend({
|
|
1478
|
+
ref: z.union([exports.PromptReferenceSchema, exports.ResourceTemplateReferenceSchema]),
|
|
1479
|
+
/**
|
|
1480
|
+
* The argument's information
|
|
1481
|
+
*/
|
|
1482
|
+
argument: z.object({
|
|
1194
1483
|
/**
|
|
1195
|
-
* The argument
|
|
1484
|
+
* The name of the argument
|
|
1196
1485
|
*/
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
context: zod_1.z.optional(zod_1.z.object({
|
|
1210
|
-
/**
|
|
1211
|
-
* Previously-resolved variables in a URI template or prompt.
|
|
1212
|
-
*/
|
|
1213
|
-
arguments: zod_1.z.optional(zod_1.z.record(zod_1.z.string(), zod_1.z.string()))
|
|
1214
|
-
}))
|
|
1486
|
+
name: z.string(),
|
|
1487
|
+
/**
|
|
1488
|
+
* The value of the argument to use for completion matching.
|
|
1489
|
+
*/
|
|
1490
|
+
value: z.string()
|
|
1491
|
+
}),
|
|
1492
|
+
context: z
|
|
1493
|
+
.object({
|
|
1494
|
+
/**
|
|
1495
|
+
* Previously-resolved variables in a URI template or prompt.
|
|
1496
|
+
*/
|
|
1497
|
+
arguments: z.record(z.string(), z.string()).optional()
|
|
1215
1498
|
})
|
|
1499
|
+
.optional()
|
|
1500
|
+
});
|
|
1501
|
+
/**
|
|
1502
|
+
* A request from the client to the server, to ask for completion options.
|
|
1503
|
+
*/
|
|
1504
|
+
exports.CompleteRequestSchema = exports.RequestSchema.extend({
|
|
1505
|
+
method: z.literal('completion/complete'),
|
|
1506
|
+
params: exports.CompleteRequestParamsSchema
|
|
1216
1507
|
});
|
|
1508
|
+
function assertCompleteRequestPrompt(request) {
|
|
1509
|
+
if (request.params.ref.type !== 'ref/prompt') {
|
|
1510
|
+
throw new TypeError(`Expected CompleteRequestPrompt, but got ${request.params.ref.type}`);
|
|
1511
|
+
}
|
|
1512
|
+
void request;
|
|
1513
|
+
}
|
|
1514
|
+
function assertCompleteRequestResourceTemplate(request) {
|
|
1515
|
+
if (request.params.ref.type !== 'ref/resource') {
|
|
1516
|
+
throw new TypeError(`Expected CompleteRequestResourceTemplate, but got ${request.params.ref.type}`);
|
|
1517
|
+
}
|
|
1518
|
+
void request;
|
|
1519
|
+
}
|
|
1217
1520
|
/**
|
|
1218
1521
|
* The server's response to a completion/complete request
|
|
1219
1522
|
*/
|
|
1220
1523
|
exports.CompleteResultSchema = exports.ResultSchema.extend({
|
|
1221
|
-
completion:
|
|
1222
|
-
.object({
|
|
1524
|
+
completion: z.looseObject({
|
|
1223
1525
|
/**
|
|
1224
1526
|
* An array of completion values. Must not exceed 100 items.
|
|
1225
1527
|
*/
|
|
1226
|
-
values:
|
|
1528
|
+
values: z.array(z.string()).max(100),
|
|
1227
1529
|
/**
|
|
1228
1530
|
* The total number of completion options available. This can exceed the number of values actually sent in the response.
|
|
1229
1531
|
*/
|
|
1230
|
-
total:
|
|
1532
|
+
total: z.optional(z.number().int()),
|
|
1231
1533
|
/**
|
|
1232
1534
|
* Indicates whether there are additional completion options beyond those provided in the current response, even if the exact total is unknown.
|
|
1233
1535
|
*/
|
|
1234
|
-
hasMore:
|
|
1536
|
+
hasMore: z.optional(z.boolean())
|
|
1235
1537
|
})
|
|
1236
|
-
.passthrough()
|
|
1237
1538
|
});
|
|
1238
1539
|
/* Roots */
|
|
1239
1540
|
/**
|
|
1240
1541
|
* Represents a root directory or file that the server can operate on.
|
|
1241
1542
|
*/
|
|
1242
|
-
exports.RootSchema =
|
|
1243
|
-
.object({
|
|
1543
|
+
exports.RootSchema = z.object({
|
|
1244
1544
|
/**
|
|
1245
1545
|
* The URI identifying the root. This *must* start with file:// for now.
|
|
1246
1546
|
*/
|
|
1247
|
-
uri:
|
|
1547
|
+
uri: z.string().startsWith('file://'),
|
|
1248
1548
|
/**
|
|
1249
1549
|
* An optional name for the root.
|
|
1250
1550
|
*/
|
|
1251
|
-
name:
|
|
1551
|
+
name: z.string().optional(),
|
|
1252
1552
|
/**
|
|
1253
1553
|
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
1254
1554
|
* for notes on _meta usage.
|
|
1255
1555
|
*/
|
|
1256
|
-
_meta:
|
|
1257
|
-
})
|
|
1258
|
-
.passthrough();
|
|
1556
|
+
_meta: z.record(z.string(), z.unknown()).optional()
|
|
1557
|
+
});
|
|
1259
1558
|
/**
|
|
1260
1559
|
* Sent from the server to request a list of root URIs from the client.
|
|
1261
1560
|
*/
|
|
1262
1561
|
exports.ListRootsRequestSchema = exports.RequestSchema.extend({
|
|
1263
|
-
method:
|
|
1562
|
+
method: z.literal('roots/list')
|
|
1264
1563
|
});
|
|
1265
1564
|
/**
|
|
1266
1565
|
* The client's response to a roots/list request from the server.
|
|
1267
1566
|
*/
|
|
1268
1567
|
exports.ListRootsResultSchema = exports.ResultSchema.extend({
|
|
1269
|
-
roots:
|
|
1568
|
+
roots: z.array(exports.RootSchema)
|
|
1270
1569
|
});
|
|
1271
1570
|
/**
|
|
1272
1571
|
* A notification from the client to the server, informing it that the list of roots has changed.
|
|
1273
1572
|
*/
|
|
1274
1573
|
exports.RootsListChangedNotificationSchema = exports.NotificationSchema.extend({
|
|
1275
|
-
method:
|
|
1574
|
+
method: z.literal('notifications/roots/list_changed')
|
|
1276
1575
|
});
|
|
1277
1576
|
/* Client messages */
|
|
1278
|
-
exports.ClientRequestSchema =
|
|
1577
|
+
exports.ClientRequestSchema = z.union([
|
|
1279
1578
|
exports.PingRequestSchema,
|
|
1280
1579
|
exports.InitializeRequestSchema,
|
|
1281
1580
|
exports.CompleteRequestSchema,
|
|
@@ -1290,25 +1589,26 @@ exports.ClientRequestSchema = zod_1.z.union([
|
|
|
1290
1589
|
exports.CallToolRequestSchema,
|
|
1291
1590
|
exports.ListToolsRequestSchema
|
|
1292
1591
|
]);
|
|
1293
|
-
exports.ClientNotificationSchema =
|
|
1592
|
+
exports.ClientNotificationSchema = z.union([
|
|
1294
1593
|
exports.CancelledNotificationSchema,
|
|
1295
1594
|
exports.ProgressNotificationSchema,
|
|
1296
1595
|
exports.InitializedNotificationSchema,
|
|
1297
1596
|
exports.RootsListChangedNotificationSchema
|
|
1298
1597
|
]);
|
|
1299
|
-
exports.ClientResultSchema =
|
|
1598
|
+
exports.ClientResultSchema = z.union([exports.EmptyResultSchema, exports.CreateMessageResultSchema, exports.ElicitResultSchema, exports.ListRootsResultSchema]);
|
|
1300
1599
|
/* Server messages */
|
|
1301
|
-
exports.ServerRequestSchema =
|
|
1302
|
-
exports.ServerNotificationSchema =
|
|
1600
|
+
exports.ServerRequestSchema = z.union([exports.PingRequestSchema, exports.CreateMessageRequestSchema, exports.ElicitRequestSchema, exports.ListRootsRequestSchema]);
|
|
1601
|
+
exports.ServerNotificationSchema = z.union([
|
|
1303
1602
|
exports.CancelledNotificationSchema,
|
|
1304
1603
|
exports.ProgressNotificationSchema,
|
|
1305
1604
|
exports.LoggingMessageNotificationSchema,
|
|
1306
1605
|
exports.ResourceUpdatedNotificationSchema,
|
|
1307
1606
|
exports.ResourceListChangedNotificationSchema,
|
|
1308
1607
|
exports.ToolListChangedNotificationSchema,
|
|
1309
|
-
exports.PromptListChangedNotificationSchema
|
|
1608
|
+
exports.PromptListChangedNotificationSchema,
|
|
1609
|
+
exports.ElicitationCompleteNotificationSchema
|
|
1310
1610
|
]);
|
|
1311
|
-
exports.ServerResultSchema =
|
|
1611
|
+
exports.ServerResultSchema = z.union([
|
|
1312
1612
|
exports.EmptyResultSchema,
|
|
1313
1613
|
exports.InitializeResultSchema,
|
|
1314
1614
|
exports.CompleteResultSchema,
|
|
@@ -1327,6 +1627,36 @@ class McpError extends Error {
|
|
|
1327
1627
|
this.data = data;
|
|
1328
1628
|
this.name = 'McpError';
|
|
1329
1629
|
}
|
|
1630
|
+
/**
|
|
1631
|
+
* Factory method to create the appropriate error type based on the error code and data
|
|
1632
|
+
*/
|
|
1633
|
+
static fromError(code, message, data) {
|
|
1634
|
+
// Check for specific error types
|
|
1635
|
+
if (code === ErrorCode.UrlElicitationRequired && data) {
|
|
1636
|
+
const errorData = data;
|
|
1637
|
+
if (errorData.elicitations) {
|
|
1638
|
+
return new UrlElicitationRequiredError(errorData.elicitations, message);
|
|
1639
|
+
}
|
|
1640
|
+
}
|
|
1641
|
+
// Default to generic McpError
|
|
1642
|
+
return new McpError(code, message, data);
|
|
1643
|
+
}
|
|
1330
1644
|
}
|
|
1331
1645
|
exports.McpError = McpError;
|
|
1646
|
+
/**
|
|
1647
|
+
* Specialized error type when a tool requires a URL mode elicitation.
|
|
1648
|
+
* 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.
|
|
1649
|
+
*/
|
|
1650
|
+
class UrlElicitationRequiredError extends McpError {
|
|
1651
|
+
constructor(elicitations, message = `URL elicitation${elicitations.length > 1 ? 's' : ''} required`) {
|
|
1652
|
+
super(ErrorCode.UrlElicitationRequired, message, {
|
|
1653
|
+
elicitations: elicitations
|
|
1654
|
+
});
|
|
1655
|
+
}
|
|
1656
|
+
get elicitations() {
|
|
1657
|
+
var _a, _b;
|
|
1658
|
+
return (_b = (_a = this.data) === null || _a === void 0 ? void 0 : _a.elicitations) !== null && _b !== void 0 ? _b : [];
|
|
1659
|
+
}
|
|
1660
|
+
}
|
|
1661
|
+
exports.UrlElicitationRequiredError = UrlElicitationRequiredError;
|
|
1332
1662
|
//# sourceMappingURL=types.js.map
|