@modelcontextprotocol/sdk 1.22.0 → 1.23.0-beta.0

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