@modelcontextprotocol/sdk 1.22.0 → 1.23.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 (258) 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 +122 -662
  7. package/dist/cjs/client/index.d.ts.map +1 -1
  8. package/dist/cjs/client/index.js +72 -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 +14 -2
  15. package/dist/cjs/client/streamableHttp.d.ts.map +1 -1
  16. package/dist/cjs/client/streamableHttp.js +79 -19
  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/client/ssePollingClient.d.ts +2 -0
  31. package/dist/cjs/examples/client/ssePollingClient.d.ts.map +1 -0
  32. package/dist/cjs/examples/client/ssePollingClient.js +95 -0
  33. package/dist/cjs/examples/client/ssePollingClient.js.map +1 -0
  34. package/dist/cjs/examples/server/demoInMemoryOAuthProvider.d.ts +4 -4
  35. package/dist/cjs/examples/server/demoInMemoryOAuthProvider.d.ts.map +1 -1
  36. package/dist/cjs/examples/server/demoInMemoryOAuthProvider.js +16 -0
  37. package/dist/cjs/examples/server/demoInMemoryOAuthProvider.js.map +1 -1
  38. package/dist/cjs/examples/server/elicitationFormExample.d.ts +2 -0
  39. package/dist/cjs/examples/server/elicitationFormExample.d.ts.map +1 -0
  40. package/dist/cjs/examples/server/{elicitationExample.js → elicitationFormExample.js} +14 -8
  41. package/dist/cjs/examples/server/elicitationFormExample.js.map +1 -0
  42. package/dist/cjs/examples/server/elicitationUrlExample.d.ts +2 -0
  43. package/dist/cjs/examples/server/elicitationUrlExample.d.ts.map +1 -0
  44. package/dist/cjs/examples/server/elicitationUrlExample.js +655 -0
  45. package/dist/cjs/examples/server/elicitationUrlExample.js.map +1 -0
  46. package/dist/cjs/examples/server/jsonResponseStreamableHttp.js +26 -3
  47. package/dist/cjs/examples/server/jsonResponseStreamableHttp.js.map +1 -1
  48. package/dist/cjs/examples/server/mcpServerOutputSchema.js +34 -11
  49. package/dist/cjs/examples/server/mcpServerOutputSchema.js.map +1 -1
  50. package/dist/cjs/examples/server/simpleSseServer.js +26 -3
  51. package/dist/cjs/examples/server/simpleSseServer.js.map +1 -1
  52. package/dist/cjs/examples/server/simpleStatelessStreamableHttp.js +27 -4
  53. package/dist/cjs/examples/server/simpleStatelessStreamableHttp.js.map +1 -1
  54. package/dist/cjs/examples/server/simpleStreamableHttp.js +34 -10
  55. package/dist/cjs/examples/server/simpleStreamableHttp.js.map +1 -1
  56. package/dist/cjs/examples/server/sseAndStreamableHttpCompatibleServer.js +26 -3
  57. package/dist/cjs/examples/server/sseAndStreamableHttpCompatibleServer.js.map +1 -1
  58. package/dist/cjs/examples/server/ssePollingExample.d.ts +2 -0
  59. package/dist/cjs/examples/server/ssePollingExample.d.ts.map +1 -0
  60. package/dist/cjs/examples/server/ssePollingExample.js +116 -0
  61. package/dist/cjs/examples/server/ssePollingExample.js.map +1 -0
  62. package/dist/cjs/examples/server/toolWithSampleServer.js +30 -8
  63. package/dist/cjs/examples/server/toolWithSampleServer.js.map +1 -1
  64. package/dist/cjs/server/auth/handlers/authorize.js +34 -11
  65. package/dist/cjs/server/auth/handlers/authorize.js.map +1 -1
  66. package/dist/cjs/server/auth/handlers/token.js +35 -12
  67. package/dist/cjs/server/auth/handlers/token.js.map +1 -1
  68. package/dist/cjs/server/auth/middleware/bearerAuth.d.ts.map +1 -1
  69. package/dist/cjs/server/auth/middleware/bearerAuth.js +13 -8
  70. package/dist/cjs/server/auth/middleware/bearerAuth.js.map +1 -1
  71. package/dist/cjs/server/auth/middleware/clientAuth.js +27 -4
  72. package/dist/cjs/server/auth/middleware/clientAuth.js.map +1 -1
  73. package/dist/cjs/server/auth/router.js +1 -1
  74. package/dist/cjs/server/auth/router.js.map +1 -1
  75. package/dist/cjs/server/completable.d.ts +30 -16
  76. package/dist/cjs/server/completable.d.ts.map +1 -1
  77. package/dist/cjs/server/completable.js +38 -55
  78. package/dist/cjs/server/completable.js.map +1 -1
  79. package/dist/cjs/server/index.d.ts +176 -50
  80. package/dist/cjs/server/index.d.ts.map +1 -1
  81. package/dist/cjs/server/index.js +99 -13
  82. package/dist/cjs/server/index.js.map +1 -1
  83. package/dist/cjs/server/mcp.d.ts +14 -16
  84. package/dist/cjs/server/mcp.d.ts.map +1 -1
  85. package/dist/cjs/server/mcp.js +83 -40
  86. package/dist/cjs/server/mcp.js.map +1 -1
  87. package/dist/cjs/server/streamableHttp.d.ts +27 -0
  88. package/dist/cjs/server/streamableHttp.d.ts.map +1 -1
  89. package/dist/cjs/server/streamableHttp.js +70 -5
  90. package/dist/cjs/server/streamableHttp.js.map +1 -1
  91. package/dist/cjs/server/zod-compat.d.ts +82 -0
  92. package/dist/cjs/server/zod-compat.d.ts.map +1 -0
  93. package/dist/cjs/server/zod-compat.js +252 -0
  94. package/dist/cjs/server/zod-compat.js.map +1 -0
  95. package/dist/cjs/server/zod-json-schema-compat.d.ts +12 -0
  96. package/dist/cjs/server/zod-json-schema-compat.d.ts.map +1 -0
  97. package/dist/cjs/server/zod-json-schema-compat.js +80 -0
  98. package/dist/cjs/server/zod-json-schema-compat.js.map +1 -0
  99. package/dist/cjs/shared/auth.d.ts +116 -502
  100. package/dist/cjs/shared/auth.d.ts.map +1 -1
  101. package/dist/cjs/shared/auth.js +133 -112
  102. package/dist/cjs/shared/auth.js.map +1 -1
  103. package/dist/cjs/shared/protocol.d.ts +5 -9
  104. package/dist/cjs/shared/protocol.d.ts.map +1 -1
  105. package/dist/cjs/shared/protocol.js +24 -10
  106. package/dist/cjs/shared/protocol.js.map +1 -1
  107. package/dist/cjs/shared/transport.d.ts +14 -0
  108. package/dist/cjs/shared/transport.d.ts.map +1 -1
  109. package/dist/cjs/shared/transport.js +40 -0
  110. package/dist/cjs/shared/transport.js.map +1 -1
  111. package/dist/cjs/shared/zodTestMatrix.d.ts +16 -0
  112. package/dist/cjs/shared/zodTestMatrix.d.ts.map +1 -0
  113. package/dist/cjs/shared/zodTestMatrix.js +43 -0
  114. package/dist/cjs/shared/zodTestMatrix.js.map +1 -0
  115. package/dist/cjs/spec.types.d.ts +393 -70
  116. package/dist/cjs/spec.types.d.ts.map +1 -1
  117. package/dist/cjs/spec.types.js +5 -7
  118. package/dist/cjs/spec.types.js.map +1 -1
  119. package/dist/cjs/types.d.ts +3580 -23866
  120. package/dist/cjs/types.d.ts.map +1 -1
  121. package/dist/cjs/types.js +574 -340
  122. package/dist/cjs/types.js.map +1 -1
  123. package/dist/cjs/validation/cfworker-provider.d.ts +0 -1
  124. package/dist/cjs/validation/cfworker-provider.d.ts.map +1 -1
  125. package/dist/cjs/validation/cfworker-provider.js +0 -1
  126. package/dist/cjs/validation/cfworker-provider.js.map +1 -1
  127. package/dist/esm/client/auth.d.ts +11 -1
  128. package/dist/esm/client/auth.d.ts.map +1 -1
  129. package/dist/esm/client/auth.js +71 -20
  130. package/dist/esm/client/auth.js.map +1 -1
  131. package/dist/esm/client/index.d.ts +122 -662
  132. package/dist/esm/client/index.d.ts.map +1 -1
  133. package/dist/esm/client/index.js +71 -15
  134. package/dist/esm/client/index.js.map +1 -1
  135. package/dist/esm/client/sse.d.ts +1 -0
  136. package/dist/esm/client/sse.d.ts.map +1 -1
  137. package/dist/esm/client/sse.js +5 -3
  138. package/dist/esm/client/sse.js.map +1 -1
  139. package/dist/esm/client/streamableHttp.d.ts +14 -2
  140. package/dist/esm/client/streamableHttp.d.ts.map +1 -1
  141. package/dist/esm/client/streamableHttp.js +79 -19
  142. package/dist/esm/client/streamableHttp.js.map +1 -1
  143. package/dist/esm/examples/client/elicitationUrlExample.d.ts +2 -0
  144. package/dist/esm/examples/client/elicitationUrlExample.d.ts.map +1 -0
  145. package/dist/esm/examples/client/elicitationUrlExample.js +691 -0
  146. package/dist/esm/examples/client/elicitationUrlExample.js.map +1 -0
  147. package/dist/esm/examples/client/simpleOAuthClient.js +12 -51
  148. package/dist/esm/examples/client/simpleOAuthClient.js.map +1 -1
  149. package/dist/esm/examples/client/simpleOAuthClientProvider.d.ts +26 -0
  150. package/dist/esm/examples/client/simpleOAuthClientProvider.d.ts.map +1 -0
  151. package/dist/esm/examples/client/simpleOAuthClientProvider.js +47 -0
  152. package/dist/esm/examples/client/simpleOAuthClientProvider.js.map +1 -0
  153. package/dist/esm/examples/client/simpleStreamableHttp.js +11 -6
  154. package/dist/esm/examples/client/simpleStreamableHttp.js.map +1 -1
  155. package/dist/esm/examples/client/ssePollingClient.d.ts +2 -0
  156. package/dist/esm/examples/client/ssePollingClient.d.ts.map +1 -0
  157. package/dist/esm/examples/client/ssePollingClient.js +93 -0
  158. package/dist/esm/examples/client/ssePollingClient.js.map +1 -0
  159. package/dist/esm/examples/server/demoInMemoryOAuthProvider.d.ts +4 -4
  160. package/dist/esm/examples/server/demoInMemoryOAuthProvider.d.ts.map +1 -1
  161. package/dist/esm/examples/server/demoInMemoryOAuthProvider.js +16 -0
  162. package/dist/esm/examples/server/demoInMemoryOAuthProvider.js.map +1 -1
  163. package/dist/esm/examples/server/elicitationFormExample.d.ts +2 -0
  164. package/dist/esm/examples/server/elicitationFormExample.d.ts.map +1 -0
  165. package/dist/esm/examples/server/{elicitationExample.js → elicitationFormExample.js} +14 -8
  166. package/dist/esm/examples/server/elicitationFormExample.js.map +1 -0
  167. package/dist/esm/examples/server/elicitationUrlExample.d.ts +2 -0
  168. package/dist/esm/examples/server/elicitationUrlExample.d.ts.map +1 -0
  169. package/dist/esm/examples/server/elicitationUrlExample.js +650 -0
  170. package/dist/esm/examples/server/elicitationUrlExample.js.map +1 -0
  171. package/dist/esm/examples/server/jsonResponseStreamableHttp.js +1 -1
  172. package/dist/esm/examples/server/jsonResponseStreamableHttp.js.map +1 -1
  173. package/dist/esm/examples/server/mcpServerOutputSchema.js +1 -1
  174. package/dist/esm/examples/server/mcpServerOutputSchema.js.map +1 -1
  175. package/dist/esm/examples/server/simpleSseServer.js +1 -1
  176. package/dist/esm/examples/server/simpleSseServer.js.map +1 -1
  177. package/dist/esm/examples/server/simpleStatelessStreamableHttp.js +1 -1
  178. package/dist/esm/examples/server/simpleStatelessStreamableHttp.js.map +1 -1
  179. package/dist/esm/examples/server/simpleStreamableHttp.js +4 -3
  180. package/dist/esm/examples/server/simpleStreamableHttp.js.map +1 -1
  181. package/dist/esm/examples/server/sseAndStreamableHttpCompatibleServer.js +1 -1
  182. package/dist/esm/examples/server/sseAndStreamableHttpCompatibleServer.js.map +1 -1
  183. package/dist/esm/examples/server/ssePollingExample.d.ts +2 -0
  184. package/dist/esm/examples/server/ssePollingExample.d.ts.map +1 -0
  185. package/dist/esm/examples/server/ssePollingExample.js +111 -0
  186. package/dist/esm/examples/server/ssePollingExample.js.map +1 -0
  187. package/dist/esm/examples/server/toolWithSampleServer.js +6 -7
  188. package/dist/esm/examples/server/toolWithSampleServer.js.map +1 -1
  189. package/dist/esm/server/auth/handlers/authorize.js +1 -1
  190. package/dist/esm/server/auth/handlers/authorize.js.map +1 -1
  191. package/dist/esm/server/auth/handlers/token.js +1 -1
  192. package/dist/esm/server/auth/handlers/token.js.map +1 -1
  193. package/dist/esm/server/auth/middleware/bearerAuth.d.ts.map +1 -1
  194. package/dist/esm/server/auth/middleware/bearerAuth.js +13 -8
  195. package/dist/esm/server/auth/middleware/bearerAuth.js.map +1 -1
  196. package/dist/esm/server/auth/middleware/clientAuth.js +1 -1
  197. package/dist/esm/server/auth/middleware/clientAuth.js.map +1 -1
  198. package/dist/esm/server/auth/router.js +1 -1
  199. package/dist/esm/server/auth/router.js.map +1 -1
  200. package/dist/esm/server/completable.d.ts +30 -16
  201. package/dist/esm/server/completable.d.ts.map +1 -1
  202. package/dist/esm/server/completable.js +34 -53
  203. package/dist/esm/server/completable.js.map +1 -1
  204. package/dist/esm/server/index.d.ts +176 -50
  205. package/dist/esm/server/index.d.ts.map +1 -1
  206. package/dist/esm/server/index.js +99 -13
  207. package/dist/esm/server/index.js.map +1 -1
  208. package/dist/esm/server/mcp.d.ts +14 -16
  209. package/dist/esm/server/mcp.d.ts.map +1 -1
  210. package/dist/esm/server/mcp.js +84 -41
  211. package/dist/esm/server/mcp.js.map +1 -1
  212. package/dist/esm/server/streamableHttp.d.ts +27 -0
  213. package/dist/esm/server/streamableHttp.d.ts.map +1 -1
  214. package/dist/esm/server/streamableHttp.js +70 -5
  215. package/dist/esm/server/streamableHttp.js.map +1 -1
  216. package/dist/esm/server/zod-compat.d.ts +82 -0
  217. package/dist/esm/server/zod-compat.d.ts.map +1 -0
  218. package/dist/esm/server/zod-compat.js +217 -0
  219. package/dist/esm/server/zod-compat.js.map +1 -0
  220. package/dist/esm/server/zod-json-schema-compat.d.ts +12 -0
  221. package/dist/esm/server/zod-json-schema-compat.d.ts.map +1 -0
  222. package/dist/esm/server/zod-json-schema-compat.js +52 -0
  223. package/dist/esm/server/zod-json-schema-compat.js.map +1 -0
  224. package/dist/esm/shared/auth.d.ts +116 -502
  225. package/dist/esm/shared/auth.d.ts.map +1 -1
  226. package/dist/esm/shared/auth.js +17 -19
  227. package/dist/esm/shared/auth.js.map +1 -1
  228. package/dist/esm/shared/protocol.d.ts +5 -9
  229. package/dist/esm/shared/protocol.d.ts.map +1 -1
  230. package/dist/esm/shared/protocol.js +24 -10
  231. package/dist/esm/shared/protocol.js.map +1 -1
  232. package/dist/esm/shared/transport.d.ts +14 -0
  233. package/dist/esm/shared/transport.d.ts.map +1 -1
  234. package/dist/esm/shared/transport.js +38 -1
  235. package/dist/esm/shared/transport.js.map +1 -1
  236. package/dist/esm/shared/zodTestMatrix.d.ts +16 -0
  237. package/dist/esm/shared/zodTestMatrix.d.ts.map +1 -0
  238. package/dist/esm/shared/zodTestMatrix.js +17 -0
  239. package/dist/esm/shared/zodTestMatrix.js.map +1 -0
  240. package/dist/esm/spec.types.d.ts +393 -70
  241. package/dist/esm/spec.types.d.ts.map +1 -1
  242. package/dist/esm/spec.types.js +4 -6
  243. package/dist/esm/spec.types.js.map +1 -1
  244. package/dist/esm/types.d.ts +3580 -23866
  245. package/dist/esm/types.d.ts.map +1 -1
  246. package/dist/esm/types.js +282 -72
  247. package/dist/esm/types.js.map +1 -1
  248. package/dist/esm/validation/cfworker-provider.d.ts +0 -1
  249. package/dist/esm/validation/cfworker-provider.d.ts.map +1 -1
  250. package/dist/esm/validation/cfworker-provider.js +0 -1
  251. package/dist/esm/validation/cfworker-provider.js.map +1 -1
  252. package/package.json +13 -12
  253. package/dist/cjs/examples/server/elicitationExample.d.ts +0 -2
  254. package/dist/cjs/examples/server/elicitationExample.d.ts.map +0 -1
  255. package/dist/cjs/examples/server/elicitationExample.js.map +0 -1
  256. package/dist/esm/examples/server/elicitationExample.d.ts +0 -2
  257. package/dist/esm/examples/server/elicitationExample.d.ts.map +0 -1
  258. 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).
271
299
  */
272
- applyDefaults: zod_1.z.boolean().optional()
300
+ context: AssertObjectSchema.optional(),
301
+ /**
302
+ * Present if the client supports tool use via tools and toolChoice parameters.
303
+ */
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,63 @@ 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
- * A JSON Schema object defining the expected parameters for the tool.
926
+ * A JSON Schema 2020-12 object defining the expected parameters for the tool.
927
+ * Must have type: 'object' at the root level per MCP spec.
852
928
  */
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()))
857
- }),
929
+ inputSchema: z
930
+ .object({
931
+ type: z.literal('object'),
932
+ properties: z.record(z.string(), AssertObjectSchema).optional(),
933
+ required: z.array(z.string()).optional()
934
+ })
935
+ .catchall(z.unknown()),
858
936
  /**
859
- * An optional JSON Schema object defining the structure of the tool's output returned in
860
- * the structuredContent field of a CallToolResult.
937
+ * An optional JSON Schema 2020-12 object defining the structure of the tool's output
938
+ * returned in the structuredContent field of a CallToolResult.
939
+ * Must have type: 'object' at the root level per MCP spec.
861
940
  */
862
- outputSchema: zod_1.z
941
+ outputSchema: z
863
942
  .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())
943
+ type: z.literal('object'),
944
+ properties: z.record(z.string(), AssertObjectSchema).optional(),
945
+ required: z.array(z.string()).optional()
871
946
  })
947
+ .catchall(z.unknown())
872
948
  .optional(),
873
949
  /**
874
950
  * Optional additional tool information.
875
951
  */
876
- annotations: zod_1.z.optional(exports.ToolAnnotationsSchema),
952
+ annotations: z.optional(exports.ToolAnnotationsSchema),
877
953
  /**
878
954
  * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
879
955
  * for notes on _meta usage.
880
956
  */
881
- _meta: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()).optional()
882
- }).merge(exports.IconsSchema);
957
+ _meta: z.record(z.string(), z.unknown()).optional()
958
+ });
883
959
  /**
884
960
  * Sent from the client to request a list of tools the server has.
885
961
  */
886
962
  exports.ListToolsRequestSchema = exports.PaginatedRequestSchema.extend({
887
- method: zod_1.z.literal('tools/list')
963
+ method: z.literal('tools/list')
888
964
  });
889
965
  /**
890
966
  * The server's response to a tools/list request from the client.
891
967
  */
892
968
  exports.ListToolsResultSchema = exports.PaginatedResultSchema.extend({
893
- tools: zod_1.z.array(exports.ToolSchema)
969
+ tools: z.array(exports.ToolSchema)
894
970
  });
895
971
  /**
896
972
  * The server's response to a tool call.
@@ -902,13 +978,13 @@ exports.CallToolResultSchema = exports.ResultSchema.extend({
902
978
  * If the Tool does not define an outputSchema, this field MUST be present in the result.
903
979
  * For backwards compatibility, this field is always present, but it may be empty.
904
980
  */
905
- content: zod_1.z.array(exports.ContentBlockSchema).default([]),
981
+ content: z.array(exports.ContentBlockSchema).default([]),
906
982
  /**
907
983
  * An object containing structured tool output.
908
984
  *
909
985
  * If the Tool defines an outputSchema, this field MUST be present in the result, and contain a JSON object that matches the schema.
910
986
  */
911
- structuredContent: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()).optional(),
987
+ structuredContent: z.record(z.string(), z.unknown()).optional(),
912
988
  /**
913
989
  * Whether the tool call ended in an error.
914
990
  *
@@ -923,13 +999,13 @@ exports.CallToolResultSchema = exports.ResultSchema.extend({
923
999
  * server does not support tool calls, or any other exceptional conditions,
924
1000
  * should be reported as an MCP error response.
925
1001
  */
926
- isError: zod_1.z.optional(zod_1.z.boolean())
1002
+ isError: z.optional(z.boolean())
927
1003
  });
928
1004
  /**
929
1005
  * CallToolResultSchema extended with backwards compatibility to protocol version 2024-10-07.
930
1006
  */
931
1007
  exports.CompatibilityCallToolResultSchema = exports.CallToolResultSchema.or(exports.ResultSchema.extend({
932
- toolResult: zod_1.z.unknown()
1008
+ toolResult: z.unknown()
933
1009
  }));
934
1010
  /**
935
1011
  * Parameters for a `tools/call` request.
@@ -938,30 +1014,30 @@ exports.CallToolRequestParamsSchema = BaseRequestParamsSchema.extend({
938
1014
  /**
939
1015
  * The name of the tool to call.
940
1016
  */
941
- name: zod_1.z.string(),
1017
+ name: z.string(),
942
1018
  /**
943
1019
  * Arguments to pass to the tool.
944
1020
  */
945
- arguments: zod_1.z.optional(zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()))
1021
+ arguments: z.optional(z.record(z.string(), z.unknown()))
946
1022
  });
947
1023
  /**
948
1024
  * Used by the client to invoke a tool provided by the server.
949
1025
  */
950
1026
  exports.CallToolRequestSchema = exports.RequestSchema.extend({
951
- method: zod_1.z.literal('tools/call'),
1027
+ method: z.literal('tools/call'),
952
1028
  params: exports.CallToolRequestParamsSchema
953
1029
  });
954
1030
  /**
955
1031
  * 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
1032
  */
957
1033
  exports.ToolListChangedNotificationSchema = exports.NotificationSchema.extend({
958
- method: zod_1.z.literal('notifications/tools/list_changed')
1034
+ method: z.literal('notifications/tools/list_changed')
959
1035
  });
960
1036
  /* Logging */
961
1037
  /**
962
1038
  * The severity of a log message.
963
1039
  */
964
- exports.LoggingLevelSchema = zod_1.z.enum(['debug', 'info', 'notice', 'warning', 'error', 'critical', 'alert', 'emergency']);
1040
+ exports.LoggingLevelSchema = z.enum(['debug', 'info', 'notice', 'warning', 'error', 'critical', 'alert', 'emergency']);
965
1041
  /**
966
1042
  * Parameters for a `logging/setLevel` request.
967
1043
  */
@@ -975,7 +1051,7 @@ exports.SetLevelRequestParamsSchema = BaseRequestParamsSchema.extend({
975
1051
  * A request from the client to the server, to enable or adjust logging.
976
1052
  */
977
1053
  exports.SetLevelRequestSchema = exports.RequestSchema.extend({
978
- method: zod_1.z.literal('logging/setLevel'),
1054
+ method: z.literal('logging/setLevel'),
979
1055
  params: exports.SetLevelRequestParamsSchema
980
1056
  });
981
1057
  /**
@@ -989,62 +1065,110 @@ exports.LoggingMessageNotificationParamsSchema = NotificationsParamsSchema.exten
989
1065
  /**
990
1066
  * An optional name of the logger issuing this message.
991
1067
  */
992
- logger: zod_1.z.string().optional(),
1068
+ logger: z.string().optional(),
993
1069
  /**
994
1070
  * The data to be logged, such as a string message or an object. Any JSON serializable type is allowed here.
995
1071
  */
996
- data: zod_1.z.unknown()
1072
+ data: z.unknown()
997
1073
  });
998
1074
  /**
999
1075
  * 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
1076
  */
1001
1077
  exports.LoggingMessageNotificationSchema = exports.NotificationSchema.extend({
1002
- method: zod_1.z.literal('notifications/message'),
1078
+ method: z.literal('notifications/message'),
1003
1079
  params: exports.LoggingMessageNotificationParamsSchema
1004
1080
  });
1005
1081
  /* Sampling */
1006
1082
  /**
1007
1083
  * Hints to use for model selection.
1008
1084
  */
1009
- exports.ModelHintSchema = zod_1.z.object({
1085
+ exports.ModelHintSchema = z.object({
1010
1086
  /**
1011
1087
  * A hint for a model name.
1012
1088
  */
1013
- name: zod_1.z.string().optional()
1089
+ name: z.string().optional()
1014
1090
  });
1015
1091
  /**
1016
1092
  * The server's preferences for model selection, requested of the client during sampling.
1017
1093
  */
1018
- exports.ModelPreferencesSchema = zod_1.z.object({
1094
+ exports.ModelPreferencesSchema = z.object({
1019
1095
  /**
1020
1096
  * Optional hints to use for model selection.
1021
1097
  */
1022
- hints: zod_1.z.optional(zod_1.z.array(exports.ModelHintSchema)),
1098
+ hints: z.optional(z.array(exports.ModelHintSchema)),
1023
1099
  /**
1024
1100
  * How much to prioritize cost when selecting a model.
1025
1101
  */
1026
- costPriority: zod_1.z.optional(zod_1.z.number().min(0).max(1)),
1102
+ costPriority: z.optional(z.number().min(0).max(1)),
1027
1103
  /**
1028
1104
  * How much to prioritize sampling speed (latency) when selecting a model.
1029
1105
  */
1030
- speedPriority: zod_1.z.optional(zod_1.z.number().min(0).max(1)),
1106
+ speedPriority: z.optional(z.number().min(0).max(1)),
1031
1107
  /**
1032
1108
  * How much to prioritize intelligence and capabilities when selecting a model.
1033
1109
  */
1034
- intelligencePriority: zod_1.z.optional(zod_1.z.number().min(0).max(1))
1110
+ intelligencePriority: z.optional(z.number().min(0).max(1))
1035
1111
  });
1036
1112
  /**
1037
- * Describes a message issued to or received from an LLM API.
1113
+ * Controls tool usage behavior in sampling requests.
1038
1114
  */
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])
1115
+ exports.ToolChoiceSchema = z.object({
1116
+ /**
1117
+ * Controls when tools are used:
1118
+ * - "auto": Model decides whether to use tools (default)
1119
+ * - "required": Model MUST use at least one tool before completing
1120
+ * - "none": Model MUST NOT use any tools
1121
+ */
1122
+ mode: z.optional(z.enum(['auto', 'required', 'none']))
1042
1123
  });
1124
+ /**
1125
+ * The result of a tool execution, provided by the user (server).
1126
+ * Represents the outcome of invoking a tool requested via ToolUseContent.
1127
+ */
1128
+ exports.ToolResultContentSchema = z
1129
+ .object({
1130
+ type: z.literal('tool_result'),
1131
+ toolUseId: z.string().describe('The unique identifier for the corresponding tool call.'),
1132
+ content: z.array(exports.ContentBlockSchema).default([]),
1133
+ structuredContent: z.object({}).passthrough().optional(),
1134
+ isError: z.optional(z.boolean()),
1135
+ /**
1136
+ * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
1137
+ * for notes on _meta usage.
1138
+ */
1139
+ _meta: z.optional(z.object({}).passthrough())
1140
+ })
1141
+ .passthrough();
1142
+ /**
1143
+ * Content block types allowed in sampling messages.
1144
+ * This includes text, image, audio, tool use requests, and tool results.
1145
+ */
1146
+ exports.SamplingMessageContentBlockSchema = z.discriminatedUnion('type', [
1147
+ exports.TextContentSchema,
1148
+ exports.ImageContentSchema,
1149
+ exports.AudioContentSchema,
1150
+ exports.ToolUseContentSchema,
1151
+ exports.ToolResultContentSchema
1152
+ ]);
1153
+ /**
1154
+ * Describes a message issued to or received from an LLM API.
1155
+ */
1156
+ exports.SamplingMessageSchema = z
1157
+ .object({
1158
+ role: z.enum(['user', 'assistant']),
1159
+ content: z.union([exports.SamplingMessageContentBlockSchema, z.array(exports.SamplingMessageContentBlockSchema)]),
1160
+ /**
1161
+ * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
1162
+ * for notes on _meta usage.
1163
+ */
1164
+ _meta: z.optional(z.object({}).passthrough())
1165
+ })
1166
+ .passthrough();
1043
1167
  /**
1044
1168
  * Parameters for a `sampling/createMessage` request.
1045
1169
  */
1046
1170
  exports.CreateMessageRequestParamsSchema = BaseRequestParamsSchema.extend({
1047
- messages: zod_1.z.array(exports.SamplingMessageSchema),
1171
+ messages: z.array(exports.SamplingMessageSchema),
1048
1172
  /**
1049
1173
  * The server's preferences for which model to select. The client MAY modify or omit this request.
1050
1174
  */
@@ -1052,29 +1176,44 @@ exports.CreateMessageRequestParamsSchema = BaseRequestParamsSchema.extend({
1052
1176
  /**
1053
1177
  * An optional system prompt the server wants to use for sampling. The client MAY modify or omit this prompt.
1054
1178
  */
1055
- systemPrompt: zod_1.z.string().optional(),
1179
+ systemPrompt: z.string().optional(),
1056
1180
  /**
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.
1181
+ * A request to include context from one or more MCP servers (including the caller), to be attached to the prompt.
1182
+ * The client MAY ignore this request.
1183
+ *
1184
+ * Default is "none". Values "thisServer" and "allServers" are soft-deprecated. Servers SHOULD only use these values if the client
1185
+ * declares ClientCapabilities.sampling.context. These values may be removed in future spec releases.
1058
1186
  */
1059
- includeContext: zod_1.z.enum(['none', 'thisServer', 'allServers']).optional(),
1060
- temperature: zod_1.z.number().optional(),
1187
+ includeContext: z.enum(['none', 'thisServer', 'allServers']).optional(),
1188
+ temperature: z.number().optional(),
1061
1189
  /**
1062
1190
  * The requested maximum number of tokens to sample (to prevent runaway completions).
1063
1191
  *
1064
1192
  * The client MAY choose to sample fewer tokens than the requested maximum.
1065
1193
  */
1066
- maxTokens: zod_1.z.number().int(),
1067
- stopSequences: zod_1.z.array(zod_1.z.string()).optional(),
1194
+ maxTokens: z.number().int(),
1195
+ stopSequences: z.array(z.string()).optional(),
1068
1196
  /**
1069
1197
  * Optional metadata to pass through to the LLM provider. The format of this metadata is provider-specific.
1070
1198
  */
1071
- metadata: AssertObjectSchema.optional()
1199
+ metadata: AssertObjectSchema.optional(),
1200
+ /**
1201
+ * Tools that the model may use during generation.
1202
+ * The client MUST return an error if this field is provided but ClientCapabilities.sampling.tools is not declared.
1203
+ */
1204
+ tools: z.optional(z.array(exports.ToolSchema)),
1205
+ /**
1206
+ * Controls how the model uses tools.
1207
+ * The client MUST return an error if this field is provided but ClientCapabilities.sampling.tools is not declared.
1208
+ * Default is `{ mode: "auto" }`.
1209
+ */
1210
+ toolChoice: z.optional(exports.ToolChoiceSchema)
1072
1211
  });
1073
1212
  /**
1074
1213
  * 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
1214
  */
1076
1215
  exports.CreateMessageRequestSchema = exports.RequestSchema.extend({
1077
- method: zod_1.z.literal('sampling/createMessage'),
1216
+ method: z.literal('sampling/createMessage'),
1078
1217
  params: exports.CreateMessageRequestParamsSchema
1079
1218
  });
1080
1219
  /**
@@ -1084,154 +1223,218 @@ exports.CreateMessageResultSchema = exports.ResultSchema.extend({
1084
1223
  /**
1085
1224
  * The name of the model that generated the message.
1086
1225
  */
1087
- model: zod_1.z.string(),
1226
+ model: z.string(),
1088
1227
  /**
1089
- * The reason why sampling stopped.
1228
+ * The reason why sampling stopped, if known.
1229
+ *
1230
+ * Standard values:
1231
+ * - "endTurn": Natural end of the assistant's turn
1232
+ * - "stopSequence": A stop sequence was encountered
1233
+ * - "maxTokens": Maximum token limit was reached
1234
+ * - "toolUse": The model wants to use one or more tools
1235
+ *
1236
+ * This field is an open string to allow for provider-specific stop reasons.
1237
+ */
1238
+ stopReason: z.optional(z.enum(['endTurn', 'stopSequence', 'maxTokens', 'toolUse']).or(z.string())),
1239
+ role: z.enum(['user', 'assistant']),
1240
+ /**
1241
+ * Response content. May be ToolUseContent if stopReason is "toolUse".
1090
1242
  */
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])
1243
+ content: z.union([exports.SamplingMessageContentBlockSchema, z.array(exports.SamplingMessageContentBlockSchema)])
1094
1244
  });
1095
1245
  /* Elicitation */
1096
1246
  /**
1097
1247
  * Primitive schema definition for boolean fields.
1098
1248
  */
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()
1249
+ exports.BooleanSchemaSchema = z.object({
1250
+ type: z.literal('boolean'),
1251
+ title: z.string().optional(),
1252
+ description: z.string().optional(),
1253
+ default: z.boolean().optional()
1104
1254
  });
1105
1255
  /**
1106
1256
  * Primitive schema definition for string fields.
1107
1257
  */
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()
1258
+ exports.StringSchemaSchema = z.object({
1259
+ type: z.literal('string'),
1260
+ title: z.string().optional(),
1261
+ description: z.string().optional(),
1262
+ minLength: z.number().optional(),
1263
+ maxLength: z.number().optional(),
1264
+ format: z.enum(['email', 'uri', 'date', 'date-time']).optional(),
1265
+ default: z.string().optional()
1116
1266
  });
1117
1267
  /**
1118
1268
  * Primitive schema definition for number fields.
1119
1269
  */
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()
1270
+ exports.NumberSchemaSchema = z.object({
1271
+ type: z.enum(['number', 'integer']),
1272
+ title: z.string().optional(),
1273
+ description: z.string().optional(),
1274
+ minimum: z.number().optional(),
1275
+ maximum: z.number().optional(),
1276
+ default: z.number().optional()
1127
1277
  });
1128
1278
  /**
1129
1279
  * Schema for single-selection enumeration without display titles for options.
1130
1280
  */
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()
1281
+ exports.UntitledSingleSelectEnumSchemaSchema = z.object({
1282
+ type: z.literal('string'),
1283
+ title: z.string().optional(),
1284
+ description: z.string().optional(),
1285
+ enum: z.array(z.string()),
1286
+ default: z.string().optional()
1137
1287
  });
1138
1288
  /**
1139
1289
  * Schema for single-selection enumeration with display titles for each option.
1140
1290
  */
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()
1291
+ exports.TitledSingleSelectEnumSchemaSchema = z.object({
1292
+ type: z.literal('string'),
1293
+ title: z.string().optional(),
1294
+ description: z.string().optional(),
1295
+ oneOf: z.array(z.object({
1296
+ const: z.string(),
1297
+ title: z.string()
1148
1298
  })),
1149
- default: zod_1.z.string().optional()
1299
+ default: z.string().optional()
1150
1300
  });
1151
1301
  /**
1152
1302
  * Use TitledSingleSelectEnumSchema instead.
1153
1303
  * This interface will be removed in a future version.
1154
1304
  */
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()
1305
+ exports.LegacyTitledEnumSchemaSchema = z.object({
1306
+ type: z.literal('string'),
1307
+ title: z.string().optional(),
1308
+ description: z.string().optional(),
1309
+ enum: z.array(z.string()),
1310
+ enumNames: z.array(z.string()).optional(),
1311
+ default: z.string().optional()
1162
1312
  });
1163
1313
  // Combined single selection enumeration
1164
- exports.SingleSelectEnumSchemaSchema = zod_1.z.union([exports.UntitledSingleSelectEnumSchemaSchema, exports.TitledSingleSelectEnumSchemaSchema]);
1314
+ exports.SingleSelectEnumSchemaSchema = z.union([exports.UntitledSingleSelectEnumSchemaSchema, exports.TitledSingleSelectEnumSchemaSchema]);
1165
1315
  /**
1166
1316
  * Schema for multiple-selection enumeration without display titles for options.
1167
1317
  */
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())
1318
+ exports.UntitledMultiSelectEnumSchemaSchema = z.object({
1319
+ type: z.literal('array'),
1320
+ title: z.string().optional(),
1321
+ description: z.string().optional(),
1322
+ minItems: z.number().optional(),
1323
+ maxItems: z.number().optional(),
1324
+ items: z.object({
1325
+ type: z.literal('string'),
1326
+ enum: z.array(z.string())
1177
1327
  }),
1178
- default: zod_1.z.array(zod_1.z.string()).optional()
1328
+ default: z.array(z.string()).optional()
1179
1329
  });
1180
1330
  /**
1181
1331
  * Schema for multiple-selection enumeration with display titles for each option.
1182
1332
  */
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()
1333
+ exports.TitledMultiSelectEnumSchemaSchema = z.object({
1334
+ type: z.literal('array'),
1335
+ title: z.string().optional(),
1336
+ description: z.string().optional(),
1337
+ minItems: z.number().optional(),
1338
+ maxItems: z.number().optional(),
1339
+ items: z.object({
1340
+ anyOf: z.array(z.object({
1341
+ const: z.string(),
1342
+ title: z.string()
1193
1343
  }))
1194
1344
  }),
1195
- default: zod_1.z.array(zod_1.z.string()).optional()
1345
+ default: z.array(z.string()).optional()
1196
1346
  });
1197
1347
  /**
1198
1348
  * Combined schema for multiple-selection enumeration
1199
1349
  */
1200
- exports.MultiSelectEnumSchemaSchema = zod_1.z.union([exports.UntitledMultiSelectEnumSchemaSchema, exports.TitledMultiSelectEnumSchemaSchema]);
1350
+ exports.MultiSelectEnumSchemaSchema = z.union([exports.UntitledMultiSelectEnumSchemaSchema, exports.TitledMultiSelectEnumSchemaSchema]);
1201
1351
  /**
1202
1352
  * Primitive schema definition for enum fields.
1203
1353
  */
1204
- exports.EnumSchemaSchema = zod_1.z.union([exports.LegacyTitledEnumSchemaSchema, exports.SingleSelectEnumSchemaSchema, exports.MultiSelectEnumSchemaSchema]);
1354
+ exports.EnumSchemaSchema = z.union([exports.LegacyTitledEnumSchemaSchema, exports.SingleSelectEnumSchemaSchema, exports.MultiSelectEnumSchemaSchema]);
1205
1355
  /**
1206
1356
  * Union of all primitive schema definitions.
1207
1357
  */
1208
- exports.PrimitiveSchemaDefinitionSchema = zod_1.z.union([exports.EnumSchemaSchema, exports.BooleanSchemaSchema, exports.StringSchemaSchema, exports.NumberSchemaSchema]);
1358
+ exports.PrimitiveSchemaDefinitionSchema = z.union([exports.EnumSchemaSchema, exports.BooleanSchemaSchema, exports.StringSchemaSchema, exports.NumberSchemaSchema]);
1209
1359
  /**
1210
- * Parameters for an `elicitation/create` request.
1360
+ * Parameters for an `elicitation/create` request for form-based elicitation.
1211
1361
  */
1212
- exports.ElicitRequestParamsSchema = BaseRequestParamsSchema.extend({
1362
+ exports.ElicitRequestFormParamsSchema = BaseRequestParamsSchema.extend({
1213
1363
  /**
1214
- * The message to present to the user.
1364
+ * The elicitation mode.
1365
+ *
1366
+ * Optional for backward compatibility. Clients MUST treat missing mode as "form".
1215
1367
  */
1216
- message: zod_1.z.string(),
1368
+ mode: z.literal('form').optional(),
1369
+ /**
1370
+ * The message to present to the user describing what information is being requested.
1371
+ */
1372
+ message: z.string(),
1217
1373
  /**
1218
1374
  * A restricted subset of JSON Schema.
1219
1375
  * Only top-level properties are allowed, without nesting.
1220
1376
  */
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()
1377
+ requestedSchema: z.object({
1378
+ type: z.literal('object'),
1379
+ properties: z.record(z.string(), exports.PrimitiveSchemaDefinitionSchema),
1380
+ required: z.array(z.string()).optional()
1225
1381
  })
1226
1382
  });
1383
+ /**
1384
+ * Parameters for an `elicitation/create` request for URL-based elicitation.
1385
+ */
1386
+ exports.ElicitRequestURLParamsSchema = BaseRequestParamsSchema.extend({
1387
+ /**
1388
+ * The elicitation mode.
1389
+ */
1390
+ mode: z.literal('url'),
1391
+ /**
1392
+ * The message to present to the user explaining why the interaction is needed.
1393
+ */
1394
+ message: z.string(),
1395
+ /**
1396
+ * The ID of the elicitation, which must be unique within the context of the server.
1397
+ * The client MUST treat this ID as an opaque value.
1398
+ */
1399
+ elicitationId: z.string(),
1400
+ /**
1401
+ * The URL that the user should navigate to.
1402
+ */
1403
+ url: z.string().url()
1404
+ });
1405
+ /**
1406
+ * The parameters for a request to elicit additional information from the user via the client.
1407
+ */
1408
+ exports.ElicitRequestParamsSchema = z.union([exports.ElicitRequestFormParamsSchema, exports.ElicitRequestURLParamsSchema]);
1227
1409
  /**
1228
1410
  * 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.
1411
+ * The client should present the message and form fields to the user (form mode)
1412
+ * or navigate to a URL (URL mode).
1230
1413
  */
1231
1414
  exports.ElicitRequestSchema = exports.RequestSchema.extend({
1232
- method: zod_1.z.literal('elicitation/create'),
1415
+ method: z.literal('elicitation/create'),
1233
1416
  params: exports.ElicitRequestParamsSchema
1234
1417
  });
1418
+ /**
1419
+ * Parameters for a `notifications/elicitation/complete` notification.
1420
+ *
1421
+ * @category notifications/elicitation/complete
1422
+ */
1423
+ exports.ElicitationCompleteNotificationParamsSchema = NotificationsParamsSchema.extend({
1424
+ /**
1425
+ * The ID of the elicitation that completed.
1426
+ */
1427
+ elicitationId: z.string()
1428
+ });
1429
+ /**
1430
+ * A notification from the server to the client, informing it of a completion of an out-of-band elicitation request.
1431
+ *
1432
+ * @category notifications/elicitation/complete
1433
+ */
1434
+ exports.ElicitationCompleteNotificationSchema = exports.NotificationSchema.extend({
1435
+ method: z.literal('notifications/elicitation/complete'),
1436
+ params: exports.ElicitationCompleteNotificationParamsSchema
1437
+ });
1235
1438
  /**
1236
1439
  * The client's response to an elicitation/create request from the server.
1237
1440
  */
@@ -1242,23 +1445,23 @@ exports.ElicitResultSchema = exports.ResultSchema.extend({
1242
1445
  * - "decline": User explicitly decline the action
1243
1446
  * - "cancel": User dismissed without making an explicit choice
1244
1447
  */
1245
- action: zod_1.z.enum(['accept', 'decline', 'cancel']),
1448
+ action: z.enum(['accept', 'decline', 'cancel']),
1246
1449
  /**
1247
1450
  * The submitted form data, only present when action is "accept".
1248
1451
  * Contains values matching the requested schema.
1249
1452
  */
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()
1453
+ content: z.record(z.string(), z.union([z.string(), z.number(), z.boolean(), z.array(z.string())])).optional()
1251
1454
  });
1252
1455
  /* Autocomplete */
1253
1456
  /**
1254
1457
  * A reference to a resource or resource template definition.
1255
1458
  */
1256
- exports.ResourceTemplateReferenceSchema = zod_1.z.object({
1257
- type: zod_1.z.literal('ref/resource'),
1459
+ exports.ResourceTemplateReferenceSchema = z.object({
1460
+ type: z.literal('ref/resource'),
1258
1461
  /**
1259
1462
  * The URI or URI template of the resource.
1260
1463
  */
1261
- uri: zod_1.z.string()
1464
+ uri: z.string()
1262
1465
  });
1263
1466
  /**
1264
1467
  * @deprecated Use ResourceTemplateReferenceSchema instead
@@ -1267,37 +1470,37 @@ exports.ResourceReferenceSchema = exports.ResourceTemplateReferenceSchema;
1267
1470
  /**
1268
1471
  * Identifies a prompt.
1269
1472
  */
1270
- exports.PromptReferenceSchema = zod_1.z.object({
1271
- type: zod_1.z.literal('ref/prompt'),
1473
+ exports.PromptReferenceSchema = z.object({
1474
+ type: z.literal('ref/prompt'),
1272
1475
  /**
1273
1476
  * The name of the prompt or prompt template
1274
1477
  */
1275
- name: zod_1.z.string()
1478
+ name: z.string()
1276
1479
  });
1277
1480
  /**
1278
1481
  * Parameters for a `completion/complete` request.
1279
1482
  */
1280
1483
  exports.CompleteRequestParamsSchema = BaseRequestParamsSchema.extend({
1281
- ref: zod_1.z.union([exports.PromptReferenceSchema, exports.ResourceTemplateReferenceSchema]),
1484
+ ref: z.union([exports.PromptReferenceSchema, exports.ResourceTemplateReferenceSchema]),
1282
1485
  /**
1283
1486
  * The argument's information
1284
1487
  */
1285
- argument: zod_1.z.object({
1488
+ argument: z.object({
1286
1489
  /**
1287
1490
  * The name of the argument
1288
1491
  */
1289
- name: zod_1.z.string(),
1492
+ name: z.string(),
1290
1493
  /**
1291
1494
  * The value of the argument to use for completion matching.
1292
1495
  */
1293
- value: zod_1.z.string()
1496
+ value: z.string()
1294
1497
  }),
1295
- context: zod_1.z
1498
+ context: z
1296
1499
  .object({
1297
1500
  /**
1298
1501
  * Previously-resolved variables in a URI template or prompt.
1299
1502
  */
1300
- arguments: zod_1.z.record(zod_1.z.string(), zod_1.z.string()).optional()
1503
+ arguments: z.record(z.string(), z.string()).optional()
1301
1504
  })
1302
1505
  .optional()
1303
1506
  });
@@ -1305,79 +1508,79 @@ exports.CompleteRequestParamsSchema = BaseRequestParamsSchema.extend({
1305
1508
  * A request from the client to the server, to ask for completion options.
1306
1509
  */
1307
1510
  exports.CompleteRequestSchema = exports.RequestSchema.extend({
1308
- method: zod_1.z.literal('completion/complete'),
1511
+ method: z.literal('completion/complete'),
1309
1512
  params: exports.CompleteRequestParamsSchema
1310
1513
  });
1311
1514
  function assertCompleteRequestPrompt(request) {
1312
1515
  if (request.params.ref.type !== 'ref/prompt') {
1313
1516
  throw new TypeError(`Expected CompleteRequestPrompt, but got ${request.params.ref.type}`);
1314
1517
  }
1518
+ void request;
1315
1519
  }
1316
1520
  function assertCompleteRequestResourceTemplate(request) {
1317
1521
  if (request.params.ref.type !== 'ref/resource') {
1318
1522
  throw new TypeError(`Expected CompleteRequestResourceTemplate, but got ${request.params.ref.type}`);
1319
1523
  }
1524
+ void request;
1320
1525
  }
1321
1526
  /**
1322
1527
  * The server's response to a completion/complete request
1323
1528
  */
1324
1529
  exports.CompleteResultSchema = exports.ResultSchema.extend({
1325
- completion: zod_1.z
1326
- .object({
1530
+ completion: z.looseObject({
1327
1531
  /**
1328
1532
  * An array of completion values. Must not exceed 100 items.
1329
1533
  */
1330
- values: zod_1.z.array(zod_1.z.string()).max(100),
1534
+ values: z.array(z.string()).max(100),
1331
1535
  /**
1332
1536
  * The total number of completion options available. This can exceed the number of values actually sent in the response.
1333
1537
  */
1334
- total: zod_1.z.optional(zod_1.z.number().int()),
1538
+ total: z.optional(z.number().int()),
1335
1539
  /**
1336
1540
  * Indicates whether there are additional completion options beyond those provided in the current response, even if the exact total is unknown.
1337
1541
  */
1338
- hasMore: zod_1.z.optional(zod_1.z.boolean())
1542
+ hasMore: z.optional(z.boolean())
1339
1543
  })
1340
- .passthrough()
1341
1544
  });
1342
1545
  /* Roots */
1343
1546
  /**
1344
1547
  * Represents a root directory or file that the server can operate on.
1345
1548
  */
1346
- exports.RootSchema = zod_1.z.object({
1549
+ exports.RootSchema = z.object({
1347
1550
  /**
1348
1551
  * The URI identifying the root. This *must* start with file:// for now.
1349
1552
  */
1350
- uri: zod_1.z.string().startsWith('file://'),
1553
+ uri: z.string().startsWith('file://'),
1351
1554
  /**
1352
1555
  * An optional name for the root.
1353
1556
  */
1354
- name: zod_1.z.string().optional(),
1557
+ name: z.string().optional(),
1355
1558
  /**
1356
1559
  * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
1357
1560
  * for notes on _meta usage.
1358
1561
  */
1359
- _meta: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()).optional()
1562
+ _meta: z.record(z.string(), z.unknown()).optional()
1360
1563
  });
1361
1564
  /**
1362
1565
  * Sent from the server to request a list of root URIs from the client.
1363
1566
  */
1364
1567
  exports.ListRootsRequestSchema = exports.RequestSchema.extend({
1365
- method: zod_1.z.literal('roots/list')
1568
+ method: z.literal('roots/list')
1366
1569
  });
1367
1570
  /**
1368
1571
  * The client's response to a roots/list request from the server.
1369
1572
  */
1370
1573
  exports.ListRootsResultSchema = exports.ResultSchema.extend({
1371
- roots: zod_1.z.array(exports.RootSchema)
1574
+ roots: z.array(exports.RootSchema)
1372
1575
  });
1373
1576
  /**
1374
1577
  * A notification from the client to the server, informing it that the list of roots has changed.
1375
1578
  */
1376
1579
  exports.RootsListChangedNotificationSchema = exports.NotificationSchema.extend({
1377
- method: zod_1.z.literal('notifications/roots/list_changed')
1580
+ method: z.literal('notifications/roots/list_changed')
1378
1581
  });
1379
1582
  /* Client messages */
1380
- exports.ClientRequestSchema = zod_1.z.union([
1583
+ exports.ClientRequestSchema = z.union([
1381
1584
  exports.PingRequestSchema,
1382
1585
  exports.InitializeRequestSchema,
1383
1586
  exports.CompleteRequestSchema,
@@ -1392,25 +1595,26 @@ exports.ClientRequestSchema = zod_1.z.union([
1392
1595
  exports.CallToolRequestSchema,
1393
1596
  exports.ListToolsRequestSchema
1394
1597
  ]);
1395
- exports.ClientNotificationSchema = zod_1.z.union([
1598
+ exports.ClientNotificationSchema = z.union([
1396
1599
  exports.CancelledNotificationSchema,
1397
1600
  exports.ProgressNotificationSchema,
1398
1601
  exports.InitializedNotificationSchema,
1399
1602
  exports.RootsListChangedNotificationSchema
1400
1603
  ]);
1401
- exports.ClientResultSchema = zod_1.z.union([exports.EmptyResultSchema, exports.CreateMessageResultSchema, exports.ElicitResultSchema, exports.ListRootsResultSchema]);
1604
+ exports.ClientResultSchema = z.union([exports.EmptyResultSchema, exports.CreateMessageResultSchema, exports.ElicitResultSchema, exports.ListRootsResultSchema]);
1402
1605
  /* Server messages */
1403
- exports.ServerRequestSchema = zod_1.z.union([exports.PingRequestSchema, exports.CreateMessageRequestSchema, exports.ElicitRequestSchema, exports.ListRootsRequestSchema]);
1404
- exports.ServerNotificationSchema = zod_1.z.union([
1606
+ exports.ServerRequestSchema = z.union([exports.PingRequestSchema, exports.CreateMessageRequestSchema, exports.ElicitRequestSchema, exports.ListRootsRequestSchema]);
1607
+ exports.ServerNotificationSchema = z.union([
1405
1608
  exports.CancelledNotificationSchema,
1406
1609
  exports.ProgressNotificationSchema,
1407
1610
  exports.LoggingMessageNotificationSchema,
1408
1611
  exports.ResourceUpdatedNotificationSchema,
1409
1612
  exports.ResourceListChangedNotificationSchema,
1410
1613
  exports.ToolListChangedNotificationSchema,
1411
- exports.PromptListChangedNotificationSchema
1614
+ exports.PromptListChangedNotificationSchema,
1615
+ exports.ElicitationCompleteNotificationSchema
1412
1616
  ]);
1413
- exports.ServerResultSchema = zod_1.z.union([
1617
+ exports.ServerResultSchema = z.union([
1414
1618
  exports.EmptyResultSchema,
1415
1619
  exports.InitializeResultSchema,
1416
1620
  exports.CompleteResultSchema,
@@ -1429,6 +1633,36 @@ class McpError extends Error {
1429
1633
  this.data = data;
1430
1634
  this.name = 'McpError';
1431
1635
  }
1636
+ /**
1637
+ * Factory method to create the appropriate error type based on the error code and data
1638
+ */
1639
+ static fromError(code, message, data) {
1640
+ // Check for specific error types
1641
+ if (code === ErrorCode.UrlElicitationRequired && data) {
1642
+ const errorData = data;
1643
+ if (errorData.elicitations) {
1644
+ return new UrlElicitationRequiredError(errorData.elicitations, message);
1645
+ }
1646
+ }
1647
+ // Default to generic McpError
1648
+ return new McpError(code, message, data);
1649
+ }
1432
1650
  }
1433
1651
  exports.McpError = McpError;
1652
+ /**
1653
+ * Specialized error type when a tool requires a URL mode elicitation.
1654
+ * 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.
1655
+ */
1656
+ class UrlElicitationRequiredError extends McpError {
1657
+ constructor(elicitations, message = `URL elicitation${elicitations.length > 1 ? 's' : ''} required`) {
1658
+ super(ErrorCode.UrlElicitationRequired, message, {
1659
+ elicitations: elicitations
1660
+ });
1661
+ }
1662
+ get elicitations() {
1663
+ var _a, _b;
1664
+ return (_b = (_a = this.data) === null || _a === void 0 ? void 0 : _a.elicitations) !== null && _b !== void 0 ? _b : [];
1665
+ }
1666
+ }
1667
+ exports.UrlElicitationRequiredError = UrlElicitationRequiredError;
1434
1668
  //# sourceMappingURL=types.js.map