@contextvm/mcp-sdk 1.27.1-contextvm.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 (261) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +141 -0
  3. package/dist/cjs/client/index.d.ts +588 -0
  4. package/dist/cjs/client/index.d.ts.map +1 -0
  5. package/dist/cjs/client/index.js +629 -0
  6. package/dist/cjs/client/index.js.map +1 -0
  7. package/dist/cjs/client/stdio.d.ts +77 -0
  8. package/dist/cjs/client/stdio.d.ts.map +1 -0
  9. package/dist/cjs/client/stdio.js +199 -0
  10. package/dist/cjs/client/stdio.js.map +1 -0
  11. package/dist/cjs/experimental/index.d.ts +13 -0
  12. package/dist/cjs/experimental/index.d.ts.map +1 -0
  13. package/dist/cjs/experimental/index.js +29 -0
  14. package/dist/cjs/experimental/index.js.map +1 -0
  15. package/dist/cjs/experimental/tasks/client.d.ts +121 -0
  16. package/dist/cjs/experimental/tasks/client.d.ts.map +1 -0
  17. package/dist/cjs/experimental/tasks/client.js +188 -0
  18. package/dist/cjs/experimental/tasks/client.js.map +1 -0
  19. package/dist/cjs/experimental/tasks/helpers.d.ts +47 -0
  20. package/dist/cjs/experimental/tasks/helpers.d.ts.map +1 -0
  21. package/dist/cjs/experimental/tasks/helpers.js +68 -0
  22. package/dist/cjs/experimental/tasks/helpers.js.map +1 -0
  23. package/dist/cjs/experimental/tasks/index.d.ts +16 -0
  24. package/dist/cjs/experimental/tasks/index.d.ts.map +1 -0
  25. package/dist/cjs/experimental/tasks/index.js +39 -0
  26. package/dist/cjs/experimental/tasks/index.js.map +1 -0
  27. package/dist/cjs/experimental/tasks/interfaces.d.ts +232 -0
  28. package/dist/cjs/experimental/tasks/interfaces.d.ts.map +1 -0
  29. package/dist/cjs/experimental/tasks/interfaces.js +19 -0
  30. package/dist/cjs/experimental/tasks/interfaces.js.map +1 -0
  31. package/dist/cjs/experimental/tasks/mcp-server.d.ts +77 -0
  32. package/dist/cjs/experimental/tasks/mcp-server.d.ts.map +1 -0
  33. package/dist/cjs/experimental/tasks/mcp-server.js +36 -0
  34. package/dist/cjs/experimental/tasks/mcp-server.js.map +1 -0
  35. package/dist/cjs/experimental/tasks/server.d.ts +170 -0
  36. package/dist/cjs/experimental/tasks/server.d.ts.map +1 -0
  37. package/dist/cjs/experimental/tasks/server.js +250 -0
  38. package/dist/cjs/experimental/tasks/server.js.map +1 -0
  39. package/dist/cjs/experimental/tasks/stores/in-memory.d.ts +94 -0
  40. package/dist/cjs/experimental/tasks/stores/in-memory.d.ts.map +1 -0
  41. package/dist/cjs/experimental/tasks/stores/in-memory.js +251 -0
  42. package/dist/cjs/experimental/tasks/stores/in-memory.js.map +1 -0
  43. package/dist/cjs/experimental/tasks/types.d.ts +10 -0
  44. package/dist/cjs/experimental/tasks/types.d.ts.map +1 -0
  45. package/dist/cjs/experimental/tasks/types.js +28 -0
  46. package/dist/cjs/experimental/tasks/types.js.map +1 -0
  47. package/dist/cjs/inMemory.d.ts +31 -0
  48. package/dist/cjs/inMemory.d.ts.map +1 -0
  49. package/dist/cjs/inMemory.js +51 -0
  50. package/dist/cjs/inMemory.js.map +1 -0
  51. package/dist/cjs/package.json +1 -0
  52. package/dist/cjs/server/completable.d.ts +38 -0
  53. package/dist/cjs/server/completable.d.ts.map +1 -0
  54. package/dist/cjs/server/completable.js +48 -0
  55. package/dist/cjs/server/completable.js.map +1 -0
  56. package/dist/cjs/server/index.d.ts +196 -0
  57. package/dist/cjs/server/index.d.ts.map +1 -0
  58. package/dist/cjs/server/index.js +444 -0
  59. package/dist/cjs/server/index.js.map +1 -0
  60. package/dist/cjs/server/mcp.d.ts +364 -0
  61. package/dist/cjs/server/mcp.d.ts.map +1 -0
  62. package/dist/cjs/server/mcp.js +918 -0
  63. package/dist/cjs/server/mcp.js.map +1 -0
  64. package/dist/cjs/server/stdio.d.ts +28 -0
  65. package/dist/cjs/server/stdio.d.ts.map +1 -0
  66. package/dist/cjs/server/stdio.js +82 -0
  67. package/dist/cjs/server/stdio.js.map +1 -0
  68. package/dist/cjs/server/zod-compat.d.ts +84 -0
  69. package/dist/cjs/server/zod-compat.d.ts.map +1 -0
  70. package/dist/cjs/server/zod-compat.js +244 -0
  71. package/dist/cjs/server/zod-compat.js.map +1 -0
  72. package/dist/cjs/server/zod-json-schema-compat.d.ts +12 -0
  73. package/dist/cjs/server/zod-json-schema-compat.d.ts.map +1 -0
  74. package/dist/cjs/server/zod-json-schema-compat.js +79 -0
  75. package/dist/cjs/server/zod-json-schema-compat.js.map +1 -0
  76. package/dist/cjs/shared/auth-info.d.ts +32 -0
  77. package/dist/cjs/shared/auth-info.d.ts.map +1 -0
  78. package/dist/cjs/shared/auth-info.js +3 -0
  79. package/dist/cjs/shared/auth-info.js.map +1 -0
  80. package/dist/cjs/shared/metadataUtils.d.ts +16 -0
  81. package/dist/cjs/shared/metadataUtils.d.ts.map +1 -0
  82. package/dist/cjs/shared/metadataUtils.js +25 -0
  83. package/dist/cjs/shared/metadataUtils.js.map +1 -0
  84. package/dist/cjs/shared/protocol.d.ts +443 -0
  85. package/dist/cjs/shared/protocol.d.ts.map +1 -0
  86. package/dist/cjs/shared/protocol.js +1104 -0
  87. package/dist/cjs/shared/protocol.js.map +1 -0
  88. package/dist/cjs/shared/responseMessage.d.ts +45 -0
  89. package/dist/cjs/shared/responseMessage.d.ts.map +1 -0
  90. package/dist/cjs/shared/responseMessage.js +23 -0
  91. package/dist/cjs/shared/responseMessage.js.map +1 -0
  92. package/dist/cjs/shared/stdio.d.ts +13 -0
  93. package/dist/cjs/shared/stdio.d.ts.map +1 -0
  94. package/dist/cjs/shared/stdio.js +37 -0
  95. package/dist/cjs/shared/stdio.js.map +1 -0
  96. package/dist/cjs/shared/toolNameValidation.d.ts +31 -0
  97. package/dist/cjs/shared/toolNameValidation.d.ts.map +1 -0
  98. package/dist/cjs/shared/toolNameValidation.js +97 -0
  99. package/dist/cjs/shared/toolNameValidation.js.map +1 -0
  100. package/dist/cjs/shared/transport.d.ts +89 -0
  101. package/dist/cjs/shared/transport.d.ts.map +1 -0
  102. package/dist/cjs/shared/transport.js +43 -0
  103. package/dist/cjs/shared/transport.js.map +1 -0
  104. package/dist/cjs/shared/uriTemplate.d.ts +25 -0
  105. package/dist/cjs/shared/uriTemplate.d.ts.map +1 -0
  106. package/dist/cjs/shared/uriTemplate.js +243 -0
  107. package/dist/cjs/shared/uriTemplate.js.map +1 -0
  108. package/dist/cjs/spec.types.d.ts +2299 -0
  109. package/dist/cjs/spec.types.d.ts.map +1 -0
  110. package/dist/cjs/spec.types.js +27 -0
  111. package/dist/cjs/spec.types.js.map +1 -0
  112. package/dist/cjs/types.d.ts +8137 -0
  113. package/dist/cjs/types.d.ts.map +1 -0
  114. package/dist/cjs/types.js +2092 -0
  115. package/dist/cjs/types.js.map +1 -0
  116. package/dist/cjs/validation/ajv-provider.d.ts +53 -0
  117. package/dist/cjs/validation/ajv-provider.d.ts.map +1 -0
  118. package/dist/cjs/validation/ajv-provider.js +94 -0
  119. package/dist/cjs/validation/ajv-provider.js.map +1 -0
  120. package/dist/cjs/validation/cfworker-provider.d.ts +51 -0
  121. package/dist/cjs/validation/cfworker-provider.d.ts.map +1 -0
  122. package/dist/cjs/validation/cfworker-provider.js +69 -0
  123. package/dist/cjs/validation/cfworker-provider.js.map +1 -0
  124. package/dist/cjs/validation/index.d.ts +29 -0
  125. package/dist/cjs/validation/index.d.ts.map +1 -0
  126. package/dist/cjs/validation/index.js +30 -0
  127. package/dist/cjs/validation/index.js.map +1 -0
  128. package/dist/cjs/validation/types.d.ts +65 -0
  129. package/dist/cjs/validation/types.d.ts.map +1 -0
  130. package/dist/cjs/validation/types.js +3 -0
  131. package/dist/cjs/validation/types.js.map +1 -0
  132. package/dist/esm/client/index.d.ts +588 -0
  133. package/dist/esm/client/index.d.ts.map +1 -0
  134. package/dist/esm/client/index.js +624 -0
  135. package/dist/esm/client/index.js.map +1 -0
  136. package/dist/esm/client/stdio.d.ts +77 -0
  137. package/dist/esm/client/stdio.d.ts.map +1 -0
  138. package/dist/esm/client/stdio.js +191 -0
  139. package/dist/esm/client/stdio.js.map +1 -0
  140. package/dist/esm/experimental/index.d.ts +13 -0
  141. package/dist/esm/experimental/index.d.ts.map +1 -0
  142. package/dist/esm/experimental/index.js +13 -0
  143. package/dist/esm/experimental/index.js.map +1 -0
  144. package/dist/esm/experimental/tasks/client.d.ts +121 -0
  145. package/dist/esm/experimental/tasks/client.d.ts.map +1 -0
  146. package/dist/esm/experimental/tasks/client.js +184 -0
  147. package/dist/esm/experimental/tasks/client.js.map +1 -0
  148. package/dist/esm/experimental/tasks/helpers.d.ts +47 -0
  149. package/dist/esm/experimental/tasks/helpers.d.ts.map +1 -0
  150. package/dist/esm/experimental/tasks/helpers.js +64 -0
  151. package/dist/esm/experimental/tasks/helpers.js.map +1 -0
  152. package/dist/esm/experimental/tasks/index.d.ts +16 -0
  153. package/dist/esm/experimental/tasks/index.d.ts.map +1 -0
  154. package/dist/esm/experimental/tasks/index.js +20 -0
  155. package/dist/esm/experimental/tasks/index.js.map +1 -0
  156. package/dist/esm/experimental/tasks/interfaces.d.ts +232 -0
  157. package/dist/esm/experimental/tasks/interfaces.d.ts.map +1 -0
  158. package/dist/esm/experimental/tasks/interfaces.js +16 -0
  159. package/dist/esm/experimental/tasks/interfaces.js.map +1 -0
  160. package/dist/esm/experimental/tasks/mcp-server.d.ts +77 -0
  161. package/dist/esm/experimental/tasks/mcp-server.d.ts.map +1 -0
  162. package/dist/esm/experimental/tasks/mcp-server.js +32 -0
  163. package/dist/esm/experimental/tasks/mcp-server.js.map +1 -0
  164. package/dist/esm/experimental/tasks/server.d.ts +170 -0
  165. package/dist/esm/experimental/tasks/server.d.ts.map +1 -0
  166. package/dist/esm/experimental/tasks/server.js +246 -0
  167. package/dist/esm/experimental/tasks/server.js.map +1 -0
  168. package/dist/esm/experimental/tasks/stores/in-memory.d.ts +94 -0
  169. package/dist/esm/experimental/tasks/stores/in-memory.d.ts.map +1 -0
  170. package/dist/esm/experimental/tasks/stores/in-memory.js +246 -0
  171. package/dist/esm/experimental/tasks/stores/in-memory.js.map +1 -0
  172. package/dist/esm/experimental/tasks/types.d.ts +10 -0
  173. package/dist/esm/experimental/tasks/types.d.ts.map +1 -0
  174. package/dist/esm/experimental/tasks/types.js +10 -0
  175. package/dist/esm/experimental/tasks/types.js.map +1 -0
  176. package/dist/esm/inMemory.d.ts +31 -0
  177. package/dist/esm/inMemory.d.ts.map +1 -0
  178. package/dist/esm/inMemory.js +47 -0
  179. package/dist/esm/inMemory.js.map +1 -0
  180. package/dist/esm/package.json +1 -0
  181. package/dist/esm/server/completable.d.ts +38 -0
  182. package/dist/esm/server/completable.d.ts.map +1 -0
  183. package/dist/esm/server/completable.js +41 -0
  184. package/dist/esm/server/completable.js.map +1 -0
  185. package/dist/esm/server/index.d.ts +196 -0
  186. package/dist/esm/server/index.d.ts.map +1 -0
  187. package/dist/esm/server/index.js +440 -0
  188. package/dist/esm/server/index.js.map +1 -0
  189. package/dist/esm/server/mcp.d.ts +364 -0
  190. package/dist/esm/server/mcp.d.ts.map +1 -0
  191. package/dist/esm/server/mcp.js +913 -0
  192. package/dist/esm/server/mcp.js.map +1 -0
  193. package/dist/esm/server/stdio.d.ts +28 -0
  194. package/dist/esm/server/stdio.d.ts.map +1 -0
  195. package/dist/esm/server/stdio.js +75 -0
  196. package/dist/esm/server/stdio.js.map +1 -0
  197. package/dist/esm/server/zod-compat.d.ts +84 -0
  198. package/dist/esm/server/zod-compat.d.ts.map +1 -0
  199. package/dist/esm/server/zod-compat.js +209 -0
  200. package/dist/esm/server/zod-compat.js.map +1 -0
  201. package/dist/esm/server/zod-json-schema-compat.d.ts +12 -0
  202. package/dist/esm/server/zod-json-schema-compat.d.ts.map +1 -0
  203. package/dist/esm/server/zod-json-schema-compat.js +51 -0
  204. package/dist/esm/server/zod-json-schema-compat.js.map +1 -0
  205. package/dist/esm/shared/auth-info.d.ts +32 -0
  206. package/dist/esm/shared/auth-info.d.ts.map +1 -0
  207. package/dist/esm/shared/auth-info.js +2 -0
  208. package/dist/esm/shared/auth-info.js.map +1 -0
  209. package/dist/esm/shared/metadataUtils.d.ts +16 -0
  210. package/dist/esm/shared/metadataUtils.d.ts.map +1 -0
  211. package/dist/esm/shared/metadataUtils.js +22 -0
  212. package/dist/esm/shared/metadataUtils.js.map +1 -0
  213. package/dist/esm/shared/protocol.d.ts +443 -0
  214. package/dist/esm/shared/protocol.d.ts.map +1 -0
  215. package/dist/esm/shared/protocol.js +1099 -0
  216. package/dist/esm/shared/protocol.js.map +1 -0
  217. package/dist/esm/shared/responseMessage.d.ts +45 -0
  218. package/dist/esm/shared/responseMessage.d.ts.map +1 -0
  219. package/dist/esm/shared/responseMessage.js +19 -0
  220. package/dist/esm/shared/responseMessage.js.map +1 -0
  221. package/dist/esm/shared/stdio.d.ts +13 -0
  222. package/dist/esm/shared/stdio.d.ts.map +1 -0
  223. package/dist/esm/shared/stdio.js +31 -0
  224. package/dist/esm/shared/stdio.js.map +1 -0
  225. package/dist/esm/shared/toolNameValidation.d.ts +31 -0
  226. package/dist/esm/shared/toolNameValidation.d.ts.map +1 -0
  227. package/dist/esm/shared/toolNameValidation.js +92 -0
  228. package/dist/esm/shared/toolNameValidation.js.map +1 -0
  229. package/dist/esm/shared/transport.d.ts +89 -0
  230. package/dist/esm/shared/transport.d.ts.map +1 -0
  231. package/dist/esm/shared/transport.js +39 -0
  232. package/dist/esm/shared/transport.js.map +1 -0
  233. package/dist/esm/shared/uriTemplate.d.ts +25 -0
  234. package/dist/esm/shared/uriTemplate.d.ts.map +1 -0
  235. package/dist/esm/shared/uriTemplate.js +239 -0
  236. package/dist/esm/shared/uriTemplate.js.map +1 -0
  237. package/dist/esm/spec.types.d.ts +2299 -0
  238. package/dist/esm/spec.types.d.ts.map +1 -0
  239. package/dist/esm/spec.types.js +24 -0
  240. package/dist/esm/spec.types.js.map +1 -0
  241. package/dist/esm/types.d.ts +8137 -0
  242. package/dist/esm/types.d.ts.map +1 -0
  243. package/dist/esm/types.js +2052 -0
  244. package/dist/esm/types.js.map +1 -0
  245. package/dist/esm/validation/ajv-provider.d.ts +53 -0
  246. package/dist/esm/validation/ajv-provider.d.ts.map +1 -0
  247. package/dist/esm/validation/ajv-provider.js +87 -0
  248. package/dist/esm/validation/ajv-provider.js.map +1 -0
  249. package/dist/esm/validation/cfworker-provider.d.ts +51 -0
  250. package/dist/esm/validation/cfworker-provider.d.ts.map +1 -0
  251. package/dist/esm/validation/cfworker-provider.js +65 -0
  252. package/dist/esm/validation/cfworker-provider.js.map +1 -0
  253. package/dist/esm/validation/index.d.ts +29 -0
  254. package/dist/esm/validation/index.d.ts.map +1 -0
  255. package/dist/esm/validation/index.js +29 -0
  256. package/dist/esm/validation/index.js.map +1 -0
  257. package/dist/esm/validation/types.d.ts +65 -0
  258. package/dist/esm/validation/types.d.ts.map +1 -0
  259. package/dist/esm/validation/types.js +2 -0
  260. package/dist/esm/validation/types.js.map +1 -0
  261. package/package.json +124 -0
@@ -0,0 +1,2092 @@
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
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.ProgressNotificationParamsSchema = exports.ProgressSchema = exports.PingRequestSchema = exports.isInitializedNotification = exports.InitializedNotificationSchema = exports.InitializeResultSchema = exports.ServerCapabilitiesSchema = exports.isInitializeRequest = exports.InitializeRequestSchema = exports.InitializeRequestParamsSchema = exports.ClientCapabilitiesSchema = exports.ServerTasksCapabilitySchema = exports.ClientTasksCapabilitySchema = exports.ImplementationSchema = exports.BaseMetadataSchema = exports.IconsSchema = exports.IconSchema = exports.CancelledNotificationSchema = exports.CancelledNotificationParamsSchema = exports.EmptyResultSchema = exports.JSONRPCResponseSchema = exports.JSONRPCMessageSchema = exports.isJSONRPCError = exports.isJSONRPCErrorResponse = exports.JSONRPCErrorSchema = exports.JSONRPCErrorResponseSchema = exports.ErrorCode = exports.isJSONRPCResponse = exports.isJSONRPCResultResponse = exports.JSONRPCResultResponseSchema = exports.isJSONRPCNotification = exports.JSONRPCNotificationSchema = exports.isJSONRPCRequest = exports.JSONRPCRequestSchema = exports.RequestIdSchema = exports.ResultSchema = exports.NotificationSchema = exports.RequestSchema = exports.isTaskAugmentedRequestParams = exports.TaskAugmentedRequestParamsSchema = exports.RelatedTaskMetadataSchema = exports.TaskMetadataSchema = exports.TaskCreationParamsSchema = exports.CursorSchema = exports.ProgressTokenSchema = exports.JSONRPC_VERSION = exports.RELATED_TASK_META_KEY = exports.SUPPORTED_PROTOCOL_VERSIONS = exports.DEFAULT_NEGOTIATED_PROTOCOL_VERSION = exports.LATEST_PROTOCOL_VERSION = void 0;
27
+ 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 = exports.ListResourceTemplatesRequestSchema = exports.ListResourcesResultSchema = exports.ListResourcesRequestSchema = exports.ResourceTemplateSchema = exports.ResourceSchema = exports.AnnotationsSchema = exports.RoleSchema = exports.BlobResourceContentsSchema = exports.TextResourceContentsSchema = exports.ResourceContentsSchema = exports.CancelTaskResultSchema = exports.CancelTaskRequestSchema = exports.ListTasksResultSchema = exports.ListTasksRequestSchema = exports.GetTaskPayloadResultSchema = exports.GetTaskPayloadRequestSchema = exports.GetTaskResultSchema = exports.GetTaskRequestSchema = exports.TaskStatusNotificationSchema = exports.TaskStatusNotificationParamsSchema = exports.CreateTaskResultSchema = exports.TaskSchema = exports.TaskStatusSchema = exports.PaginatedResultSchema = exports.PaginatedRequestSchema = exports.PaginatedRequestParamsSchema = exports.ProgressNotificationSchema = void 0;
28
+ 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.CreateMessageResultWithToolsSchema = exports.CreateMessageResultSchema = exports.CreateMessageRequestSchema = exports.CreateMessageRequestParamsSchema = exports.SamplingMessageSchema = exports.SamplingMessageContentBlockSchema = exports.SamplingContentSchema = exports.ToolResultContentSchema = exports.ToolChoiceSchema = exports.ModelPreferencesSchema = exports.ModelHintSchema = exports.LoggingMessageNotificationSchema = exports.LoggingMessageNotificationParamsSchema = exports.SetLevelRequestSchema = exports.SetLevelRequestParamsSchema = exports.LoggingLevelSchema = exports.ListChangedOptionsBaseSchema = exports.ToolListChangedNotificationSchema = exports.CallToolRequestSchema = exports.CallToolRequestParamsSchema = exports.CompatibilityCallToolResultSchema = exports.CallToolResultSchema = exports.ListToolsResultSchema = exports.ListToolsRequestSchema = exports.ToolSchema = exports.ToolExecutionSchema = exports.ToolAnnotationsSchema = exports.PromptListChangedNotificationSchema = exports.GetPromptResultSchema = exports.PromptMessageSchema = exports.ContentBlockSchema = exports.ResourceLinkSchema = void 0;
29
+ 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 = void 0;
30
+ exports.assertCompleteRequestPrompt = assertCompleteRequestPrompt;
31
+ exports.assertCompleteRequestResourceTemplate = assertCompleteRequestResourceTemplate;
32
+ const z = __importStar(require("zod/v4"));
33
+ exports.LATEST_PROTOCOL_VERSION = '2025-11-25';
34
+ exports.DEFAULT_NEGOTIATED_PROTOCOL_VERSION = '2025-03-26';
35
+ exports.SUPPORTED_PROTOCOL_VERSIONS = [exports.LATEST_PROTOCOL_VERSION, '2025-06-18', '2025-03-26', '2024-11-05', '2024-10-07'];
36
+ exports.RELATED_TASK_META_KEY = 'io.modelcontextprotocol/related-task';
37
+ /* JSON-RPC types */
38
+ exports.JSONRPC_VERSION = '2.0';
39
+ /**
40
+ * Assert 'object' type schema.
41
+ *
42
+ * @internal
43
+ */
44
+ const AssertObjectSchema = z.custom((v) => v !== null && (typeof v === 'object' || typeof v === 'function'));
45
+ /**
46
+ * A progress token, used to associate progress notifications with the original request.
47
+ */
48
+ exports.ProgressTokenSchema = z.union([z.string(), z.number().int()]);
49
+ /**
50
+ * An opaque token used to represent a cursor for pagination.
51
+ */
52
+ exports.CursorSchema = z.string();
53
+ /**
54
+ * Task creation parameters, used to ask that the server create a task to represent a request.
55
+ */
56
+ exports.TaskCreationParamsSchema = z.looseObject({
57
+ /**
58
+ * Time in milliseconds to keep task results available after completion.
59
+ * If null, the task has unlimited lifetime until manually cleaned up.
60
+ */
61
+ ttl: z.union([z.number(), z.null()]).optional(),
62
+ /**
63
+ * Time in milliseconds to wait between task status requests.
64
+ */
65
+ pollInterval: z.number().optional()
66
+ });
67
+ exports.TaskMetadataSchema = z.object({
68
+ ttl: z.number().optional()
69
+ });
70
+ /**
71
+ * Metadata for associating messages with a task.
72
+ * Include this in the `_meta` field under the key `io.modelcontextprotocol/related-task`.
73
+ */
74
+ exports.RelatedTaskMetadataSchema = z.object({
75
+ taskId: z.string()
76
+ });
77
+ const RequestMetaSchema = z.looseObject({
78
+ /**
79
+ * 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.
80
+ */
81
+ progressToken: exports.ProgressTokenSchema.optional(),
82
+ /**
83
+ * If specified, this request is related to the provided task.
84
+ */
85
+ [exports.RELATED_TASK_META_KEY]: exports.RelatedTaskMetadataSchema.optional()
86
+ });
87
+ /**
88
+ * Common params for any request.
89
+ */
90
+ const BaseRequestParamsSchema = z.object({
91
+ /**
92
+ * See [General fields: `_meta`](/specification/draft/basic/index#meta) for notes on `_meta` usage.
93
+ */
94
+ _meta: RequestMetaSchema.optional()
95
+ });
96
+ /**
97
+ * Common params for any task-augmented request.
98
+ */
99
+ exports.TaskAugmentedRequestParamsSchema = BaseRequestParamsSchema.extend({
100
+ /**
101
+ * If specified, the caller is requesting task-augmented execution for this request.
102
+ * The request will return a CreateTaskResult immediately, and the actual result can be
103
+ * retrieved later via tasks/result.
104
+ *
105
+ * Task augmentation is subject to capability negotiation - receivers MUST declare support
106
+ * for task augmentation of specific request types in their capabilities.
107
+ */
108
+ task: exports.TaskMetadataSchema.optional()
109
+ });
110
+ /**
111
+ * Checks if a value is a valid TaskAugmentedRequestParams.
112
+ * @param value - The value to check.
113
+ *
114
+ * @returns True if the value is a valid TaskAugmentedRequestParams, false otherwise.
115
+ */
116
+ const isTaskAugmentedRequestParams = (value) => exports.TaskAugmentedRequestParamsSchema.safeParse(value).success;
117
+ exports.isTaskAugmentedRequestParams = isTaskAugmentedRequestParams;
118
+ exports.RequestSchema = z.object({
119
+ method: z.string(),
120
+ params: BaseRequestParamsSchema.loose().optional()
121
+ });
122
+ const NotificationsParamsSchema = z.object({
123
+ /**
124
+ * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
125
+ * for notes on _meta usage.
126
+ */
127
+ _meta: RequestMetaSchema.optional()
128
+ });
129
+ exports.NotificationSchema = z.object({
130
+ method: z.string(),
131
+ params: NotificationsParamsSchema.loose().optional()
132
+ });
133
+ exports.ResultSchema = z.looseObject({
134
+ /**
135
+ * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
136
+ * for notes on _meta usage.
137
+ */
138
+ _meta: RequestMetaSchema.optional()
139
+ });
140
+ /**
141
+ * A uniquely identifying ID for a request in JSON-RPC.
142
+ */
143
+ exports.RequestIdSchema = z.union([z.string(), z.number().int()]);
144
+ /**
145
+ * A request that expects a response.
146
+ */
147
+ exports.JSONRPCRequestSchema = z
148
+ .object({
149
+ jsonrpc: z.literal(exports.JSONRPC_VERSION),
150
+ id: exports.RequestIdSchema,
151
+ ...exports.RequestSchema.shape
152
+ })
153
+ .strict();
154
+ const isJSONRPCRequest = (value) => exports.JSONRPCRequestSchema.safeParse(value).success;
155
+ exports.isJSONRPCRequest = isJSONRPCRequest;
156
+ /**
157
+ * A notification which does not expect a response.
158
+ */
159
+ exports.JSONRPCNotificationSchema = z
160
+ .object({
161
+ jsonrpc: z.literal(exports.JSONRPC_VERSION),
162
+ ...exports.NotificationSchema.shape
163
+ })
164
+ .strict();
165
+ const isJSONRPCNotification = (value) => exports.JSONRPCNotificationSchema.safeParse(value).success;
166
+ exports.isJSONRPCNotification = isJSONRPCNotification;
167
+ /**
168
+ * A successful (non-error) response to a request.
169
+ */
170
+ exports.JSONRPCResultResponseSchema = z
171
+ .object({
172
+ jsonrpc: z.literal(exports.JSONRPC_VERSION),
173
+ id: exports.RequestIdSchema,
174
+ result: exports.ResultSchema
175
+ })
176
+ .strict();
177
+ /**
178
+ * Checks if a value is a valid JSONRPCResultResponse.
179
+ * @param value - The value to check.
180
+ *
181
+ * @returns True if the value is a valid JSONRPCResultResponse, false otherwise.
182
+ */
183
+ const isJSONRPCResultResponse = (value) => exports.JSONRPCResultResponseSchema.safeParse(value).success;
184
+ exports.isJSONRPCResultResponse = isJSONRPCResultResponse;
185
+ /**
186
+ * @deprecated Use {@link isJSONRPCResultResponse} instead.
187
+ *
188
+ * Please note that {@link JSONRPCResponse} is a union of {@link JSONRPCResultResponse} and {@link JSONRPCErrorResponse} as per the updated JSON-RPC specification. (was previously just {@link JSONRPCResultResponse})
189
+ */
190
+ exports.isJSONRPCResponse = exports.isJSONRPCResultResponse;
191
+ /**
192
+ * Error codes defined by the JSON-RPC specification.
193
+ */
194
+ var ErrorCode;
195
+ (function (ErrorCode) {
196
+ // SDK error codes
197
+ ErrorCode[ErrorCode["ConnectionClosed"] = -32000] = "ConnectionClosed";
198
+ ErrorCode[ErrorCode["RequestTimeout"] = -32001] = "RequestTimeout";
199
+ // Standard JSON-RPC error codes
200
+ ErrorCode[ErrorCode["ParseError"] = -32700] = "ParseError";
201
+ ErrorCode[ErrorCode["InvalidRequest"] = -32600] = "InvalidRequest";
202
+ ErrorCode[ErrorCode["MethodNotFound"] = -32601] = "MethodNotFound";
203
+ ErrorCode[ErrorCode["InvalidParams"] = -32602] = "InvalidParams";
204
+ ErrorCode[ErrorCode["InternalError"] = -32603] = "InternalError";
205
+ // MCP-specific error codes
206
+ ErrorCode[ErrorCode["UrlElicitationRequired"] = -32042] = "UrlElicitationRequired";
207
+ })(ErrorCode || (exports.ErrorCode = ErrorCode = {}));
208
+ /**
209
+ * A response to a request that indicates an error occurred.
210
+ */
211
+ exports.JSONRPCErrorResponseSchema = z
212
+ .object({
213
+ jsonrpc: z.literal(exports.JSONRPC_VERSION),
214
+ id: exports.RequestIdSchema.optional(),
215
+ error: z.object({
216
+ /**
217
+ * The error type that occurred.
218
+ */
219
+ code: z.number().int(),
220
+ /**
221
+ * A short description of the error. The message SHOULD be limited to a concise single sentence.
222
+ */
223
+ message: z.string(),
224
+ /**
225
+ * Additional information about the error. The value of this member is defined by the sender (e.g. detailed error information, nested errors etc.).
226
+ */
227
+ data: z.unknown().optional()
228
+ })
229
+ })
230
+ .strict();
231
+ /**
232
+ * @deprecated Use {@link JSONRPCErrorResponseSchema} instead.
233
+ */
234
+ exports.JSONRPCErrorSchema = exports.JSONRPCErrorResponseSchema;
235
+ /**
236
+ * Checks if a value is a valid JSONRPCErrorResponse.
237
+ * @param value - The value to check.
238
+ *
239
+ * @returns True if the value is a valid JSONRPCErrorResponse, false otherwise.
240
+ */
241
+ const isJSONRPCErrorResponse = (value) => exports.JSONRPCErrorResponseSchema.safeParse(value).success;
242
+ exports.isJSONRPCErrorResponse = isJSONRPCErrorResponse;
243
+ /**
244
+ * @deprecated Use {@link isJSONRPCErrorResponse} instead.
245
+ */
246
+ exports.isJSONRPCError = exports.isJSONRPCErrorResponse;
247
+ exports.JSONRPCMessageSchema = z.union([
248
+ exports.JSONRPCRequestSchema,
249
+ exports.JSONRPCNotificationSchema,
250
+ exports.JSONRPCResultResponseSchema,
251
+ exports.JSONRPCErrorResponseSchema
252
+ ]);
253
+ exports.JSONRPCResponseSchema = z.union([exports.JSONRPCResultResponseSchema, exports.JSONRPCErrorResponseSchema]);
254
+ /* Empty result */
255
+ /**
256
+ * A response that indicates success but carries no data.
257
+ */
258
+ exports.EmptyResultSchema = exports.ResultSchema.strict();
259
+ exports.CancelledNotificationParamsSchema = NotificationsParamsSchema.extend({
260
+ /**
261
+ * The ID of the request to cancel.
262
+ *
263
+ * This MUST correspond to the ID of a request previously issued in the same direction.
264
+ */
265
+ requestId: exports.RequestIdSchema.optional(),
266
+ /**
267
+ * An optional string describing the reason for the cancellation. This MAY be logged or presented to the user.
268
+ */
269
+ reason: z.string().optional()
270
+ });
271
+ /* Cancellation */
272
+ /**
273
+ * This notification can be sent by either side to indicate that it is cancelling a previously-issued request.
274
+ *
275
+ * The request SHOULD still be in-flight, but due to communication latency, it is always possible that this notification MAY arrive after the request has already finished.
276
+ *
277
+ * This notification indicates that the result will be unused, so any associated processing SHOULD cease.
278
+ *
279
+ * A client MUST NOT attempt to cancel its `initialize` request.
280
+ */
281
+ exports.CancelledNotificationSchema = exports.NotificationSchema.extend({
282
+ method: z.literal('notifications/cancelled'),
283
+ params: exports.CancelledNotificationParamsSchema
284
+ });
285
+ /* Base Metadata */
286
+ /**
287
+ * Icon schema for use in tools, prompts, resources, and implementations.
288
+ */
289
+ exports.IconSchema = z.object({
290
+ /**
291
+ * URL or data URI for the icon.
292
+ */
293
+ src: z.string(),
294
+ /**
295
+ * Optional MIME type for the icon.
296
+ */
297
+ mimeType: z.string().optional(),
298
+ /**
299
+ * Optional array of strings that specify sizes at which the icon can be used.
300
+ * Each string should be in WxH format (e.g., `"48x48"`, `"96x96"`) or `"any"` for scalable formats like SVG.
301
+ *
302
+ * If not provided, the client should assume that the icon can be used at any size.
303
+ */
304
+ sizes: z.array(z.string()).optional(),
305
+ /**
306
+ * Optional specifier for the theme this icon is designed for. `light` indicates
307
+ * the icon is designed to be used with a light background, and `dark` indicates
308
+ * the icon is designed to be used with a dark background.
309
+ *
310
+ * If not provided, the client should assume the icon can be used with any theme.
311
+ */
312
+ theme: z.enum(['light', 'dark']).optional()
313
+ });
314
+ /**
315
+ * Base schema to add `icons` property.
316
+ *
317
+ */
318
+ exports.IconsSchema = z.object({
319
+ /**
320
+ * Optional set of sized icons that the client can display in a user interface.
321
+ *
322
+ * Clients that support rendering icons MUST support at least the following MIME types:
323
+ * - `image/png` - PNG images (safe, universal compatibility)
324
+ * - `image/jpeg` (and `image/jpg`) - JPEG images (safe, universal compatibility)
325
+ *
326
+ * Clients that support rendering icons SHOULD also support:
327
+ * - `image/svg+xml` - SVG images (scalable but requires security precautions)
328
+ * - `image/webp` - WebP images (modern, efficient format)
329
+ */
330
+ icons: z.array(exports.IconSchema).optional()
331
+ });
332
+ /**
333
+ * Base metadata interface for common properties across resources, tools, prompts, and implementations.
334
+ */
335
+ exports.BaseMetadataSchema = z.object({
336
+ /** Intended for programmatic or logical use, but used as a display name in past specs or fallback */
337
+ name: z.string(),
338
+ /**
339
+ * Intended for UI and end-user contexts — optimized to be human-readable and easily understood,
340
+ * even by those unfamiliar with domain-specific terminology.
341
+ *
342
+ * If not provided, the name should be used for display (except for Tool,
343
+ * where `annotations.title` should be given precedence over using `name`,
344
+ * if present).
345
+ */
346
+ title: z.string().optional()
347
+ });
348
+ /* Initialization */
349
+ /**
350
+ * Describes the name and version of an MCP implementation.
351
+ */
352
+ exports.ImplementationSchema = exports.BaseMetadataSchema.extend({
353
+ ...exports.BaseMetadataSchema.shape,
354
+ ...exports.IconsSchema.shape,
355
+ version: z.string(),
356
+ /**
357
+ * An optional URL of the website for this implementation.
358
+ */
359
+ websiteUrl: z.string().optional(),
360
+ /**
361
+ * An optional human-readable description of what this implementation does.
362
+ *
363
+ * This can be used by clients or servers to provide context about their purpose
364
+ * and capabilities. For example, a server might describe the types of resources
365
+ * or tools it provides, while a client might describe its intended use case.
366
+ */
367
+ description: z.string().optional()
368
+ });
369
+ const FormElicitationCapabilitySchema = z.intersection(z.object({
370
+ applyDefaults: z.boolean().optional()
371
+ }), z.record(z.string(), z.unknown()));
372
+ const ElicitationCapabilitySchema = z.preprocess(value => {
373
+ if (value && typeof value === 'object' && !Array.isArray(value)) {
374
+ if (Object.keys(value).length === 0) {
375
+ return { form: {} };
376
+ }
377
+ }
378
+ return value;
379
+ }, z.intersection(z.object({
380
+ form: FormElicitationCapabilitySchema.optional(),
381
+ url: AssertObjectSchema.optional()
382
+ }), z.record(z.string(), z.unknown()).optional()));
383
+ /**
384
+ * Task capabilities for clients, indicating which request types support task creation.
385
+ */
386
+ exports.ClientTasksCapabilitySchema = z.looseObject({
387
+ /**
388
+ * Present if the client supports listing tasks.
389
+ */
390
+ list: AssertObjectSchema.optional(),
391
+ /**
392
+ * Present if the client supports cancelling tasks.
393
+ */
394
+ cancel: AssertObjectSchema.optional(),
395
+ /**
396
+ * Capabilities for task creation on specific request types.
397
+ */
398
+ requests: z
399
+ .looseObject({
400
+ /**
401
+ * Task support for sampling requests.
402
+ */
403
+ sampling: z
404
+ .looseObject({
405
+ createMessage: AssertObjectSchema.optional()
406
+ })
407
+ .optional(),
408
+ /**
409
+ * Task support for elicitation requests.
410
+ */
411
+ elicitation: z
412
+ .looseObject({
413
+ create: AssertObjectSchema.optional()
414
+ })
415
+ .optional()
416
+ })
417
+ .optional()
418
+ });
419
+ /**
420
+ * Task capabilities for servers, indicating which request types support task creation.
421
+ */
422
+ exports.ServerTasksCapabilitySchema = z.looseObject({
423
+ /**
424
+ * Present if the server supports listing tasks.
425
+ */
426
+ list: AssertObjectSchema.optional(),
427
+ /**
428
+ * Present if the server supports cancelling tasks.
429
+ */
430
+ cancel: AssertObjectSchema.optional(),
431
+ /**
432
+ * Capabilities for task creation on specific request types.
433
+ */
434
+ requests: z
435
+ .looseObject({
436
+ /**
437
+ * Task support for tool requests.
438
+ */
439
+ tools: z
440
+ .looseObject({
441
+ call: AssertObjectSchema.optional()
442
+ })
443
+ .optional()
444
+ })
445
+ .optional()
446
+ });
447
+ /**
448
+ * 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.
449
+ */
450
+ exports.ClientCapabilitiesSchema = z.object({
451
+ /**
452
+ * Experimental, non-standard capabilities that the client supports.
453
+ */
454
+ experimental: z.record(z.string(), AssertObjectSchema).optional(),
455
+ /**
456
+ * Present if the client supports sampling from an LLM.
457
+ */
458
+ sampling: z
459
+ .object({
460
+ /**
461
+ * Present if the client supports context inclusion via includeContext parameter.
462
+ * If not declared, servers SHOULD only use `includeContext: "none"` (or omit it).
463
+ */
464
+ context: AssertObjectSchema.optional(),
465
+ /**
466
+ * Present if the client supports tool use via tools and toolChoice parameters.
467
+ */
468
+ tools: AssertObjectSchema.optional()
469
+ })
470
+ .optional(),
471
+ /**
472
+ * Present if the client supports eliciting user input.
473
+ */
474
+ elicitation: ElicitationCapabilitySchema.optional(),
475
+ /**
476
+ * Present if the client supports listing roots.
477
+ */
478
+ roots: z
479
+ .object({
480
+ /**
481
+ * Whether the client supports issuing notifications for changes to the roots list.
482
+ */
483
+ listChanged: z.boolean().optional()
484
+ })
485
+ .optional(),
486
+ /**
487
+ * Present if the client supports task creation.
488
+ */
489
+ tasks: exports.ClientTasksCapabilitySchema.optional()
490
+ });
491
+ exports.InitializeRequestParamsSchema = BaseRequestParamsSchema.extend({
492
+ /**
493
+ * The latest version of the Model Context Protocol that the client supports. The client MAY decide to support older versions as well.
494
+ */
495
+ protocolVersion: z.string(),
496
+ capabilities: exports.ClientCapabilitiesSchema,
497
+ clientInfo: exports.ImplementationSchema
498
+ });
499
+ /**
500
+ * This request is sent from the client to the server when it first connects, asking it to begin initialization.
501
+ */
502
+ exports.InitializeRequestSchema = exports.RequestSchema.extend({
503
+ method: z.literal('initialize'),
504
+ params: exports.InitializeRequestParamsSchema
505
+ });
506
+ const isInitializeRequest = (value) => exports.InitializeRequestSchema.safeParse(value).success;
507
+ exports.isInitializeRequest = isInitializeRequest;
508
+ /**
509
+ * 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.
510
+ */
511
+ exports.ServerCapabilitiesSchema = z.object({
512
+ /**
513
+ * Experimental, non-standard capabilities that the server supports.
514
+ */
515
+ experimental: z.record(z.string(), AssertObjectSchema).optional(),
516
+ /**
517
+ * Present if the server supports sending log messages to the client.
518
+ */
519
+ logging: AssertObjectSchema.optional(),
520
+ /**
521
+ * Present if the server supports sending completions to the client.
522
+ */
523
+ completions: AssertObjectSchema.optional(),
524
+ /**
525
+ * Present if the server offers any prompt templates.
526
+ */
527
+ prompts: z
528
+ .object({
529
+ /**
530
+ * Whether this server supports issuing notifications for changes to the prompt list.
531
+ */
532
+ listChanged: z.boolean().optional()
533
+ })
534
+ .optional(),
535
+ /**
536
+ * Present if the server offers any resources to read.
537
+ */
538
+ resources: z
539
+ .object({
540
+ /**
541
+ * Whether this server supports clients subscribing to resource updates.
542
+ */
543
+ subscribe: z.boolean().optional(),
544
+ /**
545
+ * Whether this server supports issuing notifications for changes to the resource list.
546
+ */
547
+ listChanged: z.boolean().optional()
548
+ })
549
+ .optional(),
550
+ /**
551
+ * Present if the server offers any tools to call.
552
+ */
553
+ tools: z
554
+ .object({
555
+ /**
556
+ * Whether this server supports issuing notifications for changes to the tool list.
557
+ */
558
+ listChanged: z.boolean().optional()
559
+ })
560
+ .optional(),
561
+ /**
562
+ * Present if the server supports task creation.
563
+ */
564
+ tasks: exports.ServerTasksCapabilitySchema.optional()
565
+ });
566
+ /**
567
+ * After receiving an initialize request from the client, the server sends this response.
568
+ */
569
+ exports.InitializeResultSchema = exports.ResultSchema.extend({
570
+ /**
571
+ * 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.
572
+ */
573
+ protocolVersion: z.string(),
574
+ capabilities: exports.ServerCapabilitiesSchema,
575
+ serverInfo: exports.ImplementationSchema,
576
+ /**
577
+ * Instructions describing how to use the server and its features.
578
+ *
579
+ * 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.
580
+ */
581
+ instructions: z.string().optional()
582
+ });
583
+ /**
584
+ * This notification is sent from the client to the server after initialization has finished.
585
+ */
586
+ exports.InitializedNotificationSchema = exports.NotificationSchema.extend({
587
+ method: z.literal('notifications/initialized'),
588
+ params: NotificationsParamsSchema.optional()
589
+ });
590
+ const isInitializedNotification = (value) => exports.InitializedNotificationSchema.safeParse(value).success;
591
+ exports.isInitializedNotification = isInitializedNotification;
592
+ /* Ping */
593
+ /**
594
+ * 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.
595
+ */
596
+ exports.PingRequestSchema = exports.RequestSchema.extend({
597
+ method: z.literal('ping'),
598
+ params: BaseRequestParamsSchema.optional()
599
+ });
600
+ /* Progress notifications */
601
+ exports.ProgressSchema = z.object({
602
+ /**
603
+ * The progress thus far. This should increase every time progress is made, even if the total is unknown.
604
+ */
605
+ progress: z.number(),
606
+ /**
607
+ * Total number of items to process (or total progress required), if known.
608
+ */
609
+ total: z.optional(z.number()),
610
+ /**
611
+ * An optional message describing the current progress.
612
+ */
613
+ message: z.optional(z.string())
614
+ });
615
+ exports.ProgressNotificationParamsSchema = z.object({
616
+ ...NotificationsParamsSchema.shape,
617
+ ...exports.ProgressSchema.shape,
618
+ /**
619
+ * The progress token which was given in the initial request, used to associate this notification with the request that is proceeding.
620
+ */
621
+ progressToken: exports.ProgressTokenSchema
622
+ });
623
+ /**
624
+ * An out-of-band notification used to inform the receiver of a progress update for a long-running request.
625
+ *
626
+ * @category notifications/progress
627
+ */
628
+ exports.ProgressNotificationSchema = exports.NotificationSchema.extend({
629
+ method: z.literal('notifications/progress'),
630
+ params: exports.ProgressNotificationParamsSchema
631
+ });
632
+ exports.PaginatedRequestParamsSchema = BaseRequestParamsSchema.extend({
633
+ /**
634
+ * An opaque token representing the current pagination position.
635
+ * If provided, the server should return results starting after this cursor.
636
+ */
637
+ cursor: exports.CursorSchema.optional()
638
+ });
639
+ /* Pagination */
640
+ exports.PaginatedRequestSchema = exports.RequestSchema.extend({
641
+ params: exports.PaginatedRequestParamsSchema.optional()
642
+ });
643
+ exports.PaginatedResultSchema = exports.ResultSchema.extend({
644
+ /**
645
+ * An opaque token representing the pagination position after the last returned result.
646
+ * If present, there may be more results available.
647
+ */
648
+ nextCursor: exports.CursorSchema.optional()
649
+ });
650
+ /**
651
+ * The status of a task.
652
+ * */
653
+ exports.TaskStatusSchema = z.enum(['working', 'input_required', 'completed', 'failed', 'cancelled']);
654
+ /* Tasks */
655
+ /**
656
+ * A pollable state object associated with a request.
657
+ */
658
+ exports.TaskSchema = z.object({
659
+ taskId: z.string(),
660
+ status: exports.TaskStatusSchema,
661
+ /**
662
+ * Time in milliseconds to keep task results available after completion.
663
+ * If null, the task has unlimited lifetime until manually cleaned up.
664
+ */
665
+ ttl: z.union([z.number(), z.null()]),
666
+ /**
667
+ * ISO 8601 timestamp when the task was created.
668
+ */
669
+ createdAt: z.string(),
670
+ /**
671
+ * ISO 8601 timestamp when the task was last updated.
672
+ */
673
+ lastUpdatedAt: z.string(),
674
+ pollInterval: z.optional(z.number()),
675
+ /**
676
+ * Optional diagnostic message for failed tasks or other status information.
677
+ */
678
+ statusMessage: z.optional(z.string())
679
+ });
680
+ /**
681
+ * Result returned when a task is created, containing the task data wrapped in a task field.
682
+ */
683
+ exports.CreateTaskResultSchema = exports.ResultSchema.extend({
684
+ task: exports.TaskSchema
685
+ });
686
+ /**
687
+ * Parameters for task status notification.
688
+ */
689
+ exports.TaskStatusNotificationParamsSchema = NotificationsParamsSchema.merge(exports.TaskSchema);
690
+ /**
691
+ * A notification sent when a task's status changes.
692
+ */
693
+ exports.TaskStatusNotificationSchema = exports.NotificationSchema.extend({
694
+ method: z.literal('notifications/tasks/status'),
695
+ params: exports.TaskStatusNotificationParamsSchema
696
+ });
697
+ /**
698
+ * A request to get the state of a specific task.
699
+ */
700
+ exports.GetTaskRequestSchema = exports.RequestSchema.extend({
701
+ method: z.literal('tasks/get'),
702
+ params: BaseRequestParamsSchema.extend({
703
+ taskId: z.string()
704
+ })
705
+ });
706
+ /**
707
+ * The response to a tasks/get request.
708
+ */
709
+ exports.GetTaskResultSchema = exports.ResultSchema.merge(exports.TaskSchema);
710
+ /**
711
+ * A request to get the result of a specific task.
712
+ */
713
+ exports.GetTaskPayloadRequestSchema = exports.RequestSchema.extend({
714
+ method: z.literal('tasks/result'),
715
+ params: BaseRequestParamsSchema.extend({
716
+ taskId: z.string()
717
+ })
718
+ });
719
+ /**
720
+ * The response to a tasks/result request.
721
+ * The structure matches the result type of the original request.
722
+ * For example, a tools/call task would return the CallToolResult structure.
723
+ *
724
+ */
725
+ exports.GetTaskPayloadResultSchema = exports.ResultSchema.loose();
726
+ /**
727
+ * A request to list tasks.
728
+ */
729
+ exports.ListTasksRequestSchema = exports.PaginatedRequestSchema.extend({
730
+ method: z.literal('tasks/list')
731
+ });
732
+ /**
733
+ * The response to a tasks/list request.
734
+ */
735
+ exports.ListTasksResultSchema = exports.PaginatedResultSchema.extend({
736
+ tasks: z.array(exports.TaskSchema)
737
+ });
738
+ /**
739
+ * A request to cancel a specific task.
740
+ */
741
+ exports.CancelTaskRequestSchema = exports.RequestSchema.extend({
742
+ method: z.literal('tasks/cancel'),
743
+ params: BaseRequestParamsSchema.extend({
744
+ taskId: z.string()
745
+ })
746
+ });
747
+ /**
748
+ * The response to a tasks/cancel request.
749
+ */
750
+ exports.CancelTaskResultSchema = exports.ResultSchema.merge(exports.TaskSchema);
751
+ /* Resources */
752
+ /**
753
+ * The contents of a specific resource or sub-resource.
754
+ */
755
+ exports.ResourceContentsSchema = z.object({
756
+ /**
757
+ * The URI of this resource.
758
+ */
759
+ uri: z.string(),
760
+ /**
761
+ * The MIME type of this resource, if known.
762
+ */
763
+ mimeType: z.optional(z.string()),
764
+ /**
765
+ * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
766
+ * for notes on _meta usage.
767
+ */
768
+ _meta: z.record(z.string(), z.unknown()).optional()
769
+ });
770
+ exports.TextResourceContentsSchema = exports.ResourceContentsSchema.extend({
771
+ /**
772
+ * The text of the item. This must only be set if the item can actually be represented as text (not binary data).
773
+ */
774
+ text: z.string()
775
+ });
776
+ /**
777
+ * A Zod schema for validating Base64 strings that is more performant and
778
+ * robust for very large inputs than the default regex-based check. It avoids
779
+ * stack overflows by using the native `atob` function for validation.
780
+ */
781
+ const Base64Schema = z.string().refine(val => {
782
+ try {
783
+ // atob throws a DOMException if the string contains characters
784
+ // that are not part of the Base64 character set.
785
+ atob(val);
786
+ return true;
787
+ }
788
+ catch {
789
+ return false;
790
+ }
791
+ }, { message: 'Invalid Base64 string' });
792
+ exports.BlobResourceContentsSchema = exports.ResourceContentsSchema.extend({
793
+ /**
794
+ * A base64-encoded string representing the binary data of the item.
795
+ */
796
+ blob: Base64Schema
797
+ });
798
+ /**
799
+ * The sender or recipient of messages and data in a conversation.
800
+ */
801
+ exports.RoleSchema = z.enum(['user', 'assistant']);
802
+ /**
803
+ * Optional annotations providing clients additional context about a resource.
804
+ */
805
+ exports.AnnotationsSchema = z.object({
806
+ /**
807
+ * Intended audience(s) for the resource.
808
+ */
809
+ audience: z.array(exports.RoleSchema).optional(),
810
+ /**
811
+ * Importance hint for the resource, from 0 (least) to 1 (most).
812
+ */
813
+ priority: z.number().min(0).max(1).optional(),
814
+ /**
815
+ * ISO 8601 timestamp for the most recent modification.
816
+ */
817
+ lastModified: z.iso.datetime({ offset: true }).optional()
818
+ });
819
+ /**
820
+ * A known resource that the server is capable of reading.
821
+ */
822
+ exports.ResourceSchema = z.object({
823
+ ...exports.BaseMetadataSchema.shape,
824
+ ...exports.IconsSchema.shape,
825
+ /**
826
+ * The URI of this resource.
827
+ */
828
+ uri: z.string(),
829
+ /**
830
+ * A description of what this resource represents.
831
+ *
832
+ * 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.
833
+ */
834
+ description: z.optional(z.string()),
835
+ /**
836
+ * The MIME type of this resource, if known.
837
+ */
838
+ mimeType: z.optional(z.string()),
839
+ /**
840
+ * Optional annotations for the client.
841
+ */
842
+ annotations: exports.AnnotationsSchema.optional(),
843
+ /**
844
+ * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
845
+ * for notes on _meta usage.
846
+ */
847
+ _meta: z.optional(z.looseObject({}))
848
+ });
849
+ /**
850
+ * A template description for resources available on the server.
851
+ */
852
+ exports.ResourceTemplateSchema = z.object({
853
+ ...exports.BaseMetadataSchema.shape,
854
+ ...exports.IconsSchema.shape,
855
+ /**
856
+ * A URI template (according to RFC 6570) that can be used to construct resource URIs.
857
+ */
858
+ uriTemplate: z.string(),
859
+ /**
860
+ * A description of what this template is for.
861
+ *
862
+ * 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.
863
+ */
864
+ description: z.optional(z.string()),
865
+ /**
866
+ * 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.
867
+ */
868
+ mimeType: z.optional(z.string()),
869
+ /**
870
+ * Optional annotations for the client.
871
+ */
872
+ annotations: exports.AnnotationsSchema.optional(),
873
+ /**
874
+ * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
875
+ * for notes on _meta usage.
876
+ */
877
+ _meta: z.optional(z.looseObject({}))
878
+ });
879
+ /**
880
+ * Sent from the client to request a list of resources the server has.
881
+ */
882
+ exports.ListResourcesRequestSchema = exports.PaginatedRequestSchema.extend({
883
+ method: z.literal('resources/list')
884
+ });
885
+ /**
886
+ * The server's response to a resources/list request from the client.
887
+ */
888
+ exports.ListResourcesResultSchema = exports.PaginatedResultSchema.extend({
889
+ resources: z.array(exports.ResourceSchema)
890
+ });
891
+ /**
892
+ * Sent from the client to request a list of resource templates the server has.
893
+ */
894
+ exports.ListResourceTemplatesRequestSchema = exports.PaginatedRequestSchema.extend({
895
+ method: z.literal('resources/templates/list')
896
+ });
897
+ /**
898
+ * The server's response to a resources/templates/list request from the client.
899
+ */
900
+ exports.ListResourceTemplatesResultSchema = exports.PaginatedResultSchema.extend({
901
+ resourceTemplates: z.array(exports.ResourceTemplateSchema)
902
+ });
903
+ exports.ResourceRequestParamsSchema = BaseRequestParamsSchema.extend({
904
+ /**
905
+ * The URI of the resource to read. The URI can use any protocol; it is up to the server how to interpret it.
906
+ *
907
+ * @format uri
908
+ */
909
+ uri: z.string()
910
+ });
911
+ /**
912
+ * Parameters for a `resources/read` request.
913
+ */
914
+ exports.ReadResourceRequestParamsSchema = exports.ResourceRequestParamsSchema;
915
+ /**
916
+ * Sent from the client to the server, to read a specific resource URI.
917
+ */
918
+ exports.ReadResourceRequestSchema = exports.RequestSchema.extend({
919
+ method: z.literal('resources/read'),
920
+ params: exports.ReadResourceRequestParamsSchema
921
+ });
922
+ /**
923
+ * The server's response to a resources/read request from the client.
924
+ */
925
+ exports.ReadResourceResultSchema = exports.ResultSchema.extend({
926
+ contents: z.array(z.union([exports.TextResourceContentsSchema, exports.BlobResourceContentsSchema]))
927
+ });
928
+ /**
929
+ * 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.
930
+ */
931
+ exports.ResourceListChangedNotificationSchema = exports.NotificationSchema.extend({
932
+ method: z.literal('notifications/resources/list_changed'),
933
+ params: NotificationsParamsSchema.optional()
934
+ });
935
+ exports.SubscribeRequestParamsSchema = exports.ResourceRequestParamsSchema;
936
+ /**
937
+ * Sent from the client to request resources/updated notifications from the server whenever a particular resource changes.
938
+ */
939
+ exports.SubscribeRequestSchema = exports.RequestSchema.extend({
940
+ method: z.literal('resources/subscribe'),
941
+ params: exports.SubscribeRequestParamsSchema
942
+ });
943
+ exports.UnsubscribeRequestParamsSchema = exports.ResourceRequestParamsSchema;
944
+ /**
945
+ * Sent from the client to request cancellation of resources/updated notifications from the server. This should follow a previous resources/subscribe request.
946
+ */
947
+ exports.UnsubscribeRequestSchema = exports.RequestSchema.extend({
948
+ method: z.literal('resources/unsubscribe'),
949
+ params: exports.UnsubscribeRequestParamsSchema
950
+ });
951
+ /**
952
+ * Parameters for a `notifications/resources/updated` notification.
953
+ */
954
+ exports.ResourceUpdatedNotificationParamsSchema = NotificationsParamsSchema.extend({
955
+ /**
956
+ * The URI of the resource that has been updated. This might be a sub-resource of the one that the client actually subscribed to.
957
+ */
958
+ uri: z.string()
959
+ });
960
+ /**
961
+ * 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.
962
+ */
963
+ exports.ResourceUpdatedNotificationSchema = exports.NotificationSchema.extend({
964
+ method: z.literal('notifications/resources/updated'),
965
+ params: exports.ResourceUpdatedNotificationParamsSchema
966
+ });
967
+ /* Prompts */
968
+ /**
969
+ * Describes an argument that a prompt can accept.
970
+ */
971
+ exports.PromptArgumentSchema = z.object({
972
+ /**
973
+ * The name of the argument.
974
+ */
975
+ name: z.string(),
976
+ /**
977
+ * A human-readable description of the argument.
978
+ */
979
+ description: z.optional(z.string()),
980
+ /**
981
+ * Whether this argument must be provided.
982
+ */
983
+ required: z.optional(z.boolean())
984
+ });
985
+ /**
986
+ * A prompt or prompt template that the server offers.
987
+ */
988
+ exports.PromptSchema = z.object({
989
+ ...exports.BaseMetadataSchema.shape,
990
+ ...exports.IconsSchema.shape,
991
+ /**
992
+ * An optional description of what this prompt provides
993
+ */
994
+ description: z.optional(z.string()),
995
+ /**
996
+ * A list of arguments to use for templating the prompt.
997
+ */
998
+ arguments: z.optional(z.array(exports.PromptArgumentSchema)),
999
+ /**
1000
+ * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
1001
+ * for notes on _meta usage.
1002
+ */
1003
+ _meta: z.optional(z.looseObject({}))
1004
+ });
1005
+ /**
1006
+ * Sent from the client to request a list of prompts and prompt templates the server has.
1007
+ */
1008
+ exports.ListPromptsRequestSchema = exports.PaginatedRequestSchema.extend({
1009
+ method: z.literal('prompts/list')
1010
+ });
1011
+ /**
1012
+ * The server's response to a prompts/list request from the client.
1013
+ */
1014
+ exports.ListPromptsResultSchema = exports.PaginatedResultSchema.extend({
1015
+ prompts: z.array(exports.PromptSchema)
1016
+ });
1017
+ /**
1018
+ * Parameters for a `prompts/get` request.
1019
+ */
1020
+ exports.GetPromptRequestParamsSchema = BaseRequestParamsSchema.extend({
1021
+ /**
1022
+ * The name of the prompt or prompt template.
1023
+ */
1024
+ name: z.string(),
1025
+ /**
1026
+ * Arguments to use for templating the prompt.
1027
+ */
1028
+ arguments: z.record(z.string(), z.string()).optional()
1029
+ });
1030
+ /**
1031
+ * Used by the client to get a prompt provided by the server.
1032
+ */
1033
+ exports.GetPromptRequestSchema = exports.RequestSchema.extend({
1034
+ method: z.literal('prompts/get'),
1035
+ params: exports.GetPromptRequestParamsSchema
1036
+ });
1037
+ /**
1038
+ * Text provided to or from an LLM.
1039
+ */
1040
+ exports.TextContentSchema = z.object({
1041
+ type: z.literal('text'),
1042
+ /**
1043
+ * The text content of the message.
1044
+ */
1045
+ text: z.string(),
1046
+ /**
1047
+ * Optional annotations for the client.
1048
+ */
1049
+ annotations: exports.AnnotationsSchema.optional(),
1050
+ /**
1051
+ * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
1052
+ * for notes on _meta usage.
1053
+ */
1054
+ _meta: z.record(z.string(), z.unknown()).optional()
1055
+ });
1056
+ /**
1057
+ * An image provided to or from an LLM.
1058
+ */
1059
+ exports.ImageContentSchema = z.object({
1060
+ type: z.literal('image'),
1061
+ /**
1062
+ * The base64-encoded image data.
1063
+ */
1064
+ data: Base64Schema,
1065
+ /**
1066
+ * The MIME type of the image. Different providers may support different image types.
1067
+ */
1068
+ mimeType: z.string(),
1069
+ /**
1070
+ * Optional annotations for the client.
1071
+ */
1072
+ annotations: exports.AnnotationsSchema.optional(),
1073
+ /**
1074
+ * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
1075
+ * for notes on _meta usage.
1076
+ */
1077
+ _meta: z.record(z.string(), z.unknown()).optional()
1078
+ });
1079
+ /**
1080
+ * An Audio provided to or from an LLM.
1081
+ */
1082
+ exports.AudioContentSchema = z.object({
1083
+ type: z.literal('audio'),
1084
+ /**
1085
+ * The base64-encoded audio data.
1086
+ */
1087
+ data: Base64Schema,
1088
+ /**
1089
+ * The MIME type of the audio. Different providers may support different audio types.
1090
+ */
1091
+ mimeType: z.string(),
1092
+ /**
1093
+ * Optional annotations for the client.
1094
+ */
1095
+ annotations: exports.AnnotationsSchema.optional(),
1096
+ /**
1097
+ * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
1098
+ * for notes on _meta usage.
1099
+ */
1100
+ _meta: z.record(z.string(), z.unknown()).optional()
1101
+ });
1102
+ /**
1103
+ * A tool call request from an assistant (LLM).
1104
+ * Represents the assistant's request to use a tool.
1105
+ */
1106
+ exports.ToolUseContentSchema = z.object({
1107
+ type: z.literal('tool_use'),
1108
+ /**
1109
+ * The name of the tool to invoke.
1110
+ * Must match a tool name from the request's tools array.
1111
+ */
1112
+ name: z.string(),
1113
+ /**
1114
+ * Unique identifier for this tool call.
1115
+ * Used to correlate with ToolResultContent in subsequent messages.
1116
+ */
1117
+ id: z.string(),
1118
+ /**
1119
+ * Arguments to pass to the tool.
1120
+ * Must conform to the tool's inputSchema.
1121
+ */
1122
+ input: z.record(z.string(), z.unknown()),
1123
+ /**
1124
+ * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
1125
+ * for notes on _meta usage.
1126
+ */
1127
+ _meta: z.record(z.string(), z.unknown()).optional()
1128
+ });
1129
+ /**
1130
+ * The contents of a resource, embedded into a prompt or tool call result.
1131
+ */
1132
+ exports.EmbeddedResourceSchema = z.object({
1133
+ type: z.literal('resource'),
1134
+ resource: z.union([exports.TextResourceContentsSchema, exports.BlobResourceContentsSchema]),
1135
+ /**
1136
+ * Optional annotations for the client.
1137
+ */
1138
+ annotations: exports.AnnotationsSchema.optional(),
1139
+ /**
1140
+ * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
1141
+ * for notes on _meta usage.
1142
+ */
1143
+ _meta: z.record(z.string(), z.unknown()).optional()
1144
+ });
1145
+ /**
1146
+ * A resource that the server is capable of reading, included in a prompt or tool call result.
1147
+ *
1148
+ * Note: resource links returned by tools are not guaranteed to appear in the results of `resources/list` requests.
1149
+ */
1150
+ exports.ResourceLinkSchema = exports.ResourceSchema.extend({
1151
+ type: z.literal('resource_link')
1152
+ });
1153
+ /**
1154
+ * A content block that can be used in prompts and tool results.
1155
+ */
1156
+ exports.ContentBlockSchema = z.union([
1157
+ exports.TextContentSchema,
1158
+ exports.ImageContentSchema,
1159
+ exports.AudioContentSchema,
1160
+ exports.ResourceLinkSchema,
1161
+ exports.EmbeddedResourceSchema
1162
+ ]);
1163
+ /**
1164
+ * Describes a message returned as part of a prompt.
1165
+ */
1166
+ exports.PromptMessageSchema = z.object({
1167
+ role: exports.RoleSchema,
1168
+ content: exports.ContentBlockSchema
1169
+ });
1170
+ /**
1171
+ * The server's response to a prompts/get request from the client.
1172
+ */
1173
+ exports.GetPromptResultSchema = exports.ResultSchema.extend({
1174
+ /**
1175
+ * An optional description for the prompt.
1176
+ */
1177
+ description: z.string().optional(),
1178
+ messages: z.array(exports.PromptMessageSchema)
1179
+ });
1180
+ /**
1181
+ * 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.
1182
+ */
1183
+ exports.PromptListChangedNotificationSchema = exports.NotificationSchema.extend({
1184
+ method: z.literal('notifications/prompts/list_changed'),
1185
+ params: NotificationsParamsSchema.optional()
1186
+ });
1187
+ /* Tools */
1188
+ /**
1189
+ * Additional properties describing a Tool to clients.
1190
+ *
1191
+ * NOTE: all properties in ToolAnnotations are **hints**.
1192
+ * They are not guaranteed to provide a faithful description of
1193
+ * tool behavior (including descriptive properties like `title`).
1194
+ *
1195
+ * Clients should never make tool use decisions based on ToolAnnotations
1196
+ * received from untrusted servers.
1197
+ */
1198
+ exports.ToolAnnotationsSchema = z.object({
1199
+ /**
1200
+ * A human-readable title for the tool.
1201
+ */
1202
+ title: z.string().optional(),
1203
+ /**
1204
+ * If true, the tool does not modify its environment.
1205
+ *
1206
+ * Default: false
1207
+ */
1208
+ readOnlyHint: z.boolean().optional(),
1209
+ /**
1210
+ * If true, the tool may perform destructive updates to its environment.
1211
+ * If false, the tool performs only additive updates.
1212
+ *
1213
+ * (This property is meaningful only when `readOnlyHint == false`)
1214
+ *
1215
+ * Default: true
1216
+ */
1217
+ destructiveHint: z.boolean().optional(),
1218
+ /**
1219
+ * If true, calling the tool repeatedly with the same arguments
1220
+ * will have no additional effect on the its environment.
1221
+ *
1222
+ * (This property is meaningful only when `readOnlyHint == false`)
1223
+ *
1224
+ * Default: false
1225
+ */
1226
+ idempotentHint: z.boolean().optional(),
1227
+ /**
1228
+ * If true, this tool may interact with an "open world" of external
1229
+ * entities. If false, the tool's domain of interaction is closed.
1230
+ * For example, the world of a web search tool is open, whereas that
1231
+ * of a memory tool is not.
1232
+ *
1233
+ * Default: true
1234
+ */
1235
+ openWorldHint: z.boolean().optional()
1236
+ });
1237
+ /**
1238
+ * Execution-related properties for a tool.
1239
+ */
1240
+ exports.ToolExecutionSchema = z.object({
1241
+ /**
1242
+ * Indicates the tool's preference for task-augmented execution.
1243
+ * - "required": Clients MUST invoke the tool as a task
1244
+ * - "optional": Clients MAY invoke the tool as a task or normal request
1245
+ * - "forbidden": Clients MUST NOT attempt to invoke the tool as a task
1246
+ *
1247
+ * If not present, defaults to "forbidden".
1248
+ */
1249
+ taskSupport: z.enum(['required', 'optional', 'forbidden']).optional()
1250
+ });
1251
+ /**
1252
+ * Definition for a tool the client can call.
1253
+ */
1254
+ exports.ToolSchema = z.object({
1255
+ ...exports.BaseMetadataSchema.shape,
1256
+ ...exports.IconsSchema.shape,
1257
+ /**
1258
+ * A human-readable description of the tool.
1259
+ */
1260
+ description: z.string().optional(),
1261
+ /**
1262
+ * A JSON Schema 2020-12 object defining the expected parameters for the tool.
1263
+ * Must have type: 'object' at the root level per MCP spec.
1264
+ */
1265
+ inputSchema: z
1266
+ .object({
1267
+ type: z.literal('object'),
1268
+ properties: z.record(z.string(), AssertObjectSchema).optional(),
1269
+ required: z.array(z.string()).optional()
1270
+ })
1271
+ .catchall(z.unknown()),
1272
+ /**
1273
+ * An optional JSON Schema 2020-12 object defining the structure of the tool's output
1274
+ * returned in the structuredContent field of a CallToolResult.
1275
+ * Must have type: 'object' at the root level per MCP spec.
1276
+ */
1277
+ outputSchema: z
1278
+ .object({
1279
+ type: z.literal('object'),
1280
+ properties: z.record(z.string(), AssertObjectSchema).optional(),
1281
+ required: z.array(z.string()).optional()
1282
+ })
1283
+ .catchall(z.unknown())
1284
+ .optional(),
1285
+ /**
1286
+ * Optional additional tool information.
1287
+ */
1288
+ annotations: exports.ToolAnnotationsSchema.optional(),
1289
+ /**
1290
+ * Execution-related properties for this tool.
1291
+ */
1292
+ execution: exports.ToolExecutionSchema.optional(),
1293
+ /**
1294
+ * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
1295
+ * for notes on _meta usage.
1296
+ */
1297
+ _meta: z.record(z.string(), z.unknown()).optional()
1298
+ });
1299
+ /**
1300
+ * Sent from the client to request a list of tools the server has.
1301
+ */
1302
+ exports.ListToolsRequestSchema = exports.PaginatedRequestSchema.extend({
1303
+ method: z.literal('tools/list')
1304
+ });
1305
+ /**
1306
+ * The server's response to a tools/list request from the client.
1307
+ */
1308
+ exports.ListToolsResultSchema = exports.PaginatedResultSchema.extend({
1309
+ tools: z.array(exports.ToolSchema)
1310
+ });
1311
+ /**
1312
+ * The server's response to a tool call.
1313
+ */
1314
+ exports.CallToolResultSchema = exports.ResultSchema.extend({
1315
+ /**
1316
+ * A list of content objects that represent the result of the tool call.
1317
+ *
1318
+ * If the Tool does not define an outputSchema, this field MUST be present in the result.
1319
+ * For backwards compatibility, this field is always present, but it may be empty.
1320
+ */
1321
+ content: z.array(exports.ContentBlockSchema).default([]),
1322
+ /**
1323
+ * An object containing structured tool output.
1324
+ *
1325
+ * If the Tool defines an outputSchema, this field MUST be present in the result, and contain a JSON object that matches the schema.
1326
+ */
1327
+ structuredContent: z.record(z.string(), z.unknown()).optional(),
1328
+ /**
1329
+ * Whether the tool call ended in an error.
1330
+ *
1331
+ * If not set, this is assumed to be false (the call was successful).
1332
+ *
1333
+ * Any errors that originate from the tool SHOULD be reported inside the result
1334
+ * object, with `isError` set to true, _not_ as an MCP protocol-level error
1335
+ * response. Otherwise, the LLM would not be able to see that an error occurred
1336
+ * and self-correct.
1337
+ *
1338
+ * However, any errors in _finding_ the tool, an error indicating that the
1339
+ * server does not support tool calls, or any other exceptional conditions,
1340
+ * should be reported as an MCP error response.
1341
+ */
1342
+ isError: z.boolean().optional()
1343
+ });
1344
+ /**
1345
+ * CallToolResultSchema extended with backwards compatibility to protocol version 2024-10-07.
1346
+ */
1347
+ exports.CompatibilityCallToolResultSchema = exports.CallToolResultSchema.or(exports.ResultSchema.extend({
1348
+ toolResult: z.unknown()
1349
+ }));
1350
+ /**
1351
+ * Parameters for a `tools/call` request.
1352
+ */
1353
+ exports.CallToolRequestParamsSchema = exports.TaskAugmentedRequestParamsSchema.extend({
1354
+ /**
1355
+ * The name of the tool to call.
1356
+ */
1357
+ name: z.string(),
1358
+ /**
1359
+ * Arguments to pass to the tool.
1360
+ */
1361
+ arguments: z.record(z.string(), z.unknown()).optional()
1362
+ });
1363
+ /**
1364
+ * Used by the client to invoke a tool provided by the server.
1365
+ */
1366
+ exports.CallToolRequestSchema = exports.RequestSchema.extend({
1367
+ method: z.literal('tools/call'),
1368
+ params: exports.CallToolRequestParamsSchema
1369
+ });
1370
+ /**
1371
+ * 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.
1372
+ */
1373
+ exports.ToolListChangedNotificationSchema = exports.NotificationSchema.extend({
1374
+ method: z.literal('notifications/tools/list_changed'),
1375
+ params: NotificationsParamsSchema.optional()
1376
+ });
1377
+ /**
1378
+ * Base schema for list changed subscription options (without callback).
1379
+ * Used internally for Zod validation of autoRefresh and debounceMs.
1380
+ */
1381
+ exports.ListChangedOptionsBaseSchema = z.object({
1382
+ /**
1383
+ * If true, the list will be refreshed automatically when a list changed notification is received.
1384
+ * The callback will be called with the updated list.
1385
+ *
1386
+ * If false, the callback will be called with null items, allowing manual refresh.
1387
+ *
1388
+ * @default true
1389
+ */
1390
+ autoRefresh: z.boolean().default(true),
1391
+ /**
1392
+ * Debounce time in milliseconds for list changed notification processing.
1393
+ *
1394
+ * Multiple notifications received within this timeframe will only trigger one refresh.
1395
+ * Set to 0 to disable debouncing.
1396
+ *
1397
+ * @default 300
1398
+ */
1399
+ debounceMs: z.number().int().nonnegative().default(300)
1400
+ });
1401
+ /* Logging */
1402
+ /**
1403
+ * The severity of a log message.
1404
+ */
1405
+ exports.LoggingLevelSchema = z.enum(['debug', 'info', 'notice', 'warning', 'error', 'critical', 'alert', 'emergency']);
1406
+ /**
1407
+ * Parameters for a `logging/setLevel` request.
1408
+ */
1409
+ exports.SetLevelRequestParamsSchema = BaseRequestParamsSchema.extend({
1410
+ /**
1411
+ * The level of logging that the client wants to receive from the server. The server should send all logs at this level and higher (i.e., more severe) to the client as notifications/logging/message.
1412
+ */
1413
+ level: exports.LoggingLevelSchema
1414
+ });
1415
+ /**
1416
+ * A request from the client to the server, to enable or adjust logging.
1417
+ */
1418
+ exports.SetLevelRequestSchema = exports.RequestSchema.extend({
1419
+ method: z.literal('logging/setLevel'),
1420
+ params: exports.SetLevelRequestParamsSchema
1421
+ });
1422
+ /**
1423
+ * Parameters for a `notifications/message` notification.
1424
+ */
1425
+ exports.LoggingMessageNotificationParamsSchema = NotificationsParamsSchema.extend({
1426
+ /**
1427
+ * The severity of this log message.
1428
+ */
1429
+ level: exports.LoggingLevelSchema,
1430
+ /**
1431
+ * An optional name of the logger issuing this message.
1432
+ */
1433
+ logger: z.string().optional(),
1434
+ /**
1435
+ * The data to be logged, such as a string message or an object. Any JSON serializable type is allowed here.
1436
+ */
1437
+ data: z.unknown()
1438
+ });
1439
+ /**
1440
+ * 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.
1441
+ */
1442
+ exports.LoggingMessageNotificationSchema = exports.NotificationSchema.extend({
1443
+ method: z.literal('notifications/message'),
1444
+ params: exports.LoggingMessageNotificationParamsSchema
1445
+ });
1446
+ /* Sampling */
1447
+ /**
1448
+ * Hints to use for model selection.
1449
+ */
1450
+ exports.ModelHintSchema = z.object({
1451
+ /**
1452
+ * A hint for a model name.
1453
+ */
1454
+ name: z.string().optional()
1455
+ });
1456
+ /**
1457
+ * The server's preferences for model selection, requested of the client during sampling.
1458
+ */
1459
+ exports.ModelPreferencesSchema = z.object({
1460
+ /**
1461
+ * Optional hints to use for model selection.
1462
+ */
1463
+ hints: z.array(exports.ModelHintSchema).optional(),
1464
+ /**
1465
+ * How much to prioritize cost when selecting a model.
1466
+ */
1467
+ costPriority: z.number().min(0).max(1).optional(),
1468
+ /**
1469
+ * How much to prioritize sampling speed (latency) when selecting a model.
1470
+ */
1471
+ speedPriority: z.number().min(0).max(1).optional(),
1472
+ /**
1473
+ * How much to prioritize intelligence and capabilities when selecting a model.
1474
+ */
1475
+ intelligencePriority: z.number().min(0).max(1).optional()
1476
+ });
1477
+ /**
1478
+ * Controls tool usage behavior in sampling requests.
1479
+ */
1480
+ exports.ToolChoiceSchema = z.object({
1481
+ /**
1482
+ * Controls when tools are used:
1483
+ * - "auto": Model decides whether to use tools (default)
1484
+ * - "required": Model MUST use at least one tool before completing
1485
+ * - "none": Model MUST NOT use any tools
1486
+ */
1487
+ mode: z.enum(['auto', 'required', 'none']).optional()
1488
+ });
1489
+ /**
1490
+ * The result of a tool execution, provided by the user (server).
1491
+ * Represents the outcome of invoking a tool requested via ToolUseContent.
1492
+ */
1493
+ exports.ToolResultContentSchema = z.object({
1494
+ type: z.literal('tool_result'),
1495
+ toolUseId: z.string().describe('The unique identifier for the corresponding tool call.'),
1496
+ content: z.array(exports.ContentBlockSchema).default([]),
1497
+ structuredContent: z.object({}).loose().optional(),
1498
+ isError: z.boolean().optional(),
1499
+ /**
1500
+ * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
1501
+ * for notes on _meta usage.
1502
+ */
1503
+ _meta: z.record(z.string(), z.unknown()).optional()
1504
+ });
1505
+ /**
1506
+ * Basic content types for sampling responses (without tool use).
1507
+ * Used for backwards-compatible CreateMessageResult when tools are not used.
1508
+ */
1509
+ exports.SamplingContentSchema = z.discriminatedUnion('type', [exports.TextContentSchema, exports.ImageContentSchema, exports.AudioContentSchema]);
1510
+ /**
1511
+ * Content block types allowed in sampling messages.
1512
+ * This includes text, image, audio, tool use requests, and tool results.
1513
+ */
1514
+ exports.SamplingMessageContentBlockSchema = z.discriminatedUnion('type', [
1515
+ exports.TextContentSchema,
1516
+ exports.ImageContentSchema,
1517
+ exports.AudioContentSchema,
1518
+ exports.ToolUseContentSchema,
1519
+ exports.ToolResultContentSchema
1520
+ ]);
1521
+ /**
1522
+ * Describes a message issued to or received from an LLM API.
1523
+ */
1524
+ exports.SamplingMessageSchema = z.object({
1525
+ role: exports.RoleSchema,
1526
+ content: z.union([exports.SamplingMessageContentBlockSchema, z.array(exports.SamplingMessageContentBlockSchema)]),
1527
+ /**
1528
+ * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
1529
+ * for notes on _meta usage.
1530
+ */
1531
+ _meta: z.record(z.string(), z.unknown()).optional()
1532
+ });
1533
+ /**
1534
+ * Parameters for a `sampling/createMessage` request.
1535
+ */
1536
+ exports.CreateMessageRequestParamsSchema = exports.TaskAugmentedRequestParamsSchema.extend({
1537
+ messages: z.array(exports.SamplingMessageSchema),
1538
+ /**
1539
+ * The server's preferences for which model to select. The client MAY modify or omit this request.
1540
+ */
1541
+ modelPreferences: exports.ModelPreferencesSchema.optional(),
1542
+ /**
1543
+ * An optional system prompt the server wants to use for sampling. The client MAY modify or omit this prompt.
1544
+ */
1545
+ systemPrompt: z.string().optional(),
1546
+ /**
1547
+ * A request to include context from one or more MCP servers (including the caller), to be attached to the prompt.
1548
+ * The client MAY ignore this request.
1549
+ *
1550
+ * Default is "none". Values "thisServer" and "allServers" are soft-deprecated. Servers SHOULD only use these values if the client
1551
+ * declares ClientCapabilities.sampling.context. These values may be removed in future spec releases.
1552
+ */
1553
+ includeContext: z.enum(['none', 'thisServer', 'allServers']).optional(),
1554
+ temperature: z.number().optional(),
1555
+ /**
1556
+ * The requested maximum number of tokens to sample (to prevent runaway completions).
1557
+ *
1558
+ * The client MAY choose to sample fewer tokens than the requested maximum.
1559
+ */
1560
+ maxTokens: z.number().int(),
1561
+ stopSequences: z.array(z.string()).optional(),
1562
+ /**
1563
+ * Optional metadata to pass through to the LLM provider. The format of this metadata is provider-specific.
1564
+ */
1565
+ metadata: AssertObjectSchema.optional(),
1566
+ /**
1567
+ * Tools that the model may use during generation.
1568
+ * The client MUST return an error if this field is provided but ClientCapabilities.sampling.tools is not declared.
1569
+ */
1570
+ tools: z.array(exports.ToolSchema).optional(),
1571
+ /**
1572
+ * Controls how the model uses tools.
1573
+ * The client MUST return an error if this field is provided but ClientCapabilities.sampling.tools is not declared.
1574
+ * Default is `{ mode: "auto" }`.
1575
+ */
1576
+ toolChoice: exports.ToolChoiceSchema.optional()
1577
+ });
1578
+ /**
1579
+ * 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.
1580
+ */
1581
+ exports.CreateMessageRequestSchema = exports.RequestSchema.extend({
1582
+ method: z.literal('sampling/createMessage'),
1583
+ params: exports.CreateMessageRequestParamsSchema
1584
+ });
1585
+ /**
1586
+ * The client's response to a sampling/create_message request from the server.
1587
+ * This is the backwards-compatible version that returns single content (no arrays).
1588
+ * Used when the request does not include tools.
1589
+ */
1590
+ exports.CreateMessageResultSchema = exports.ResultSchema.extend({
1591
+ /**
1592
+ * The name of the model that generated the message.
1593
+ */
1594
+ model: z.string(),
1595
+ /**
1596
+ * The reason why sampling stopped, if known.
1597
+ *
1598
+ * Standard values:
1599
+ * - "endTurn": Natural end of the assistant's turn
1600
+ * - "stopSequence": A stop sequence was encountered
1601
+ * - "maxTokens": Maximum token limit was reached
1602
+ *
1603
+ * This field is an open string to allow for provider-specific stop reasons.
1604
+ */
1605
+ stopReason: z.optional(z.enum(['endTurn', 'stopSequence', 'maxTokens']).or(z.string())),
1606
+ role: exports.RoleSchema,
1607
+ /**
1608
+ * Response content. Single content block (text, image, or audio).
1609
+ */
1610
+ content: exports.SamplingContentSchema
1611
+ });
1612
+ /**
1613
+ * The client's response to a sampling/create_message request when tools were provided.
1614
+ * This version supports array content for tool use flows.
1615
+ */
1616
+ exports.CreateMessageResultWithToolsSchema = exports.ResultSchema.extend({
1617
+ /**
1618
+ * The name of the model that generated the message.
1619
+ */
1620
+ model: z.string(),
1621
+ /**
1622
+ * The reason why sampling stopped, if known.
1623
+ *
1624
+ * Standard values:
1625
+ * - "endTurn": Natural end of the assistant's turn
1626
+ * - "stopSequence": A stop sequence was encountered
1627
+ * - "maxTokens": Maximum token limit was reached
1628
+ * - "toolUse": The model wants to use one or more tools
1629
+ *
1630
+ * This field is an open string to allow for provider-specific stop reasons.
1631
+ */
1632
+ stopReason: z.optional(z.enum(['endTurn', 'stopSequence', 'maxTokens', 'toolUse']).or(z.string())),
1633
+ role: exports.RoleSchema,
1634
+ /**
1635
+ * Response content. May be a single block or array. May include ToolUseContent if stopReason is "toolUse".
1636
+ */
1637
+ content: z.union([exports.SamplingMessageContentBlockSchema, z.array(exports.SamplingMessageContentBlockSchema)])
1638
+ });
1639
+ /* Elicitation */
1640
+ /**
1641
+ * Primitive schema definition for boolean fields.
1642
+ */
1643
+ exports.BooleanSchemaSchema = z.object({
1644
+ type: z.literal('boolean'),
1645
+ title: z.string().optional(),
1646
+ description: z.string().optional(),
1647
+ default: z.boolean().optional()
1648
+ });
1649
+ /**
1650
+ * Primitive schema definition for string fields.
1651
+ */
1652
+ exports.StringSchemaSchema = z.object({
1653
+ type: z.literal('string'),
1654
+ title: z.string().optional(),
1655
+ description: z.string().optional(),
1656
+ minLength: z.number().optional(),
1657
+ maxLength: z.number().optional(),
1658
+ format: z.enum(['email', 'uri', 'date', 'date-time']).optional(),
1659
+ default: z.string().optional()
1660
+ });
1661
+ /**
1662
+ * Primitive schema definition for number fields.
1663
+ */
1664
+ exports.NumberSchemaSchema = z.object({
1665
+ type: z.enum(['number', 'integer']),
1666
+ title: z.string().optional(),
1667
+ description: z.string().optional(),
1668
+ minimum: z.number().optional(),
1669
+ maximum: z.number().optional(),
1670
+ default: z.number().optional()
1671
+ });
1672
+ /**
1673
+ * Schema for single-selection enumeration without display titles for options.
1674
+ */
1675
+ exports.UntitledSingleSelectEnumSchemaSchema = z.object({
1676
+ type: z.literal('string'),
1677
+ title: z.string().optional(),
1678
+ description: z.string().optional(),
1679
+ enum: z.array(z.string()),
1680
+ default: z.string().optional()
1681
+ });
1682
+ /**
1683
+ * Schema for single-selection enumeration with display titles for each option.
1684
+ */
1685
+ exports.TitledSingleSelectEnumSchemaSchema = z.object({
1686
+ type: z.literal('string'),
1687
+ title: z.string().optional(),
1688
+ description: z.string().optional(),
1689
+ oneOf: z.array(z.object({
1690
+ const: z.string(),
1691
+ title: z.string()
1692
+ })),
1693
+ default: z.string().optional()
1694
+ });
1695
+ /**
1696
+ * Use TitledSingleSelectEnumSchema instead.
1697
+ * This interface will be removed in a future version.
1698
+ */
1699
+ exports.LegacyTitledEnumSchemaSchema = z.object({
1700
+ type: z.literal('string'),
1701
+ title: z.string().optional(),
1702
+ description: z.string().optional(),
1703
+ enum: z.array(z.string()),
1704
+ enumNames: z.array(z.string()).optional(),
1705
+ default: z.string().optional()
1706
+ });
1707
+ // Combined single selection enumeration
1708
+ exports.SingleSelectEnumSchemaSchema = z.union([exports.UntitledSingleSelectEnumSchemaSchema, exports.TitledSingleSelectEnumSchemaSchema]);
1709
+ /**
1710
+ * Schema for multiple-selection enumeration without display titles for options.
1711
+ */
1712
+ exports.UntitledMultiSelectEnumSchemaSchema = z.object({
1713
+ type: z.literal('array'),
1714
+ title: z.string().optional(),
1715
+ description: z.string().optional(),
1716
+ minItems: z.number().optional(),
1717
+ maxItems: z.number().optional(),
1718
+ items: z.object({
1719
+ type: z.literal('string'),
1720
+ enum: z.array(z.string())
1721
+ }),
1722
+ default: z.array(z.string()).optional()
1723
+ });
1724
+ /**
1725
+ * Schema for multiple-selection enumeration with display titles for each option.
1726
+ */
1727
+ exports.TitledMultiSelectEnumSchemaSchema = z.object({
1728
+ type: z.literal('array'),
1729
+ title: z.string().optional(),
1730
+ description: z.string().optional(),
1731
+ minItems: z.number().optional(),
1732
+ maxItems: z.number().optional(),
1733
+ items: z.object({
1734
+ anyOf: z.array(z.object({
1735
+ const: z.string(),
1736
+ title: z.string()
1737
+ }))
1738
+ }),
1739
+ default: z.array(z.string()).optional()
1740
+ });
1741
+ /**
1742
+ * Combined schema for multiple-selection enumeration
1743
+ */
1744
+ exports.MultiSelectEnumSchemaSchema = z.union([exports.UntitledMultiSelectEnumSchemaSchema, exports.TitledMultiSelectEnumSchemaSchema]);
1745
+ /**
1746
+ * Primitive schema definition for enum fields.
1747
+ */
1748
+ exports.EnumSchemaSchema = z.union([exports.LegacyTitledEnumSchemaSchema, exports.SingleSelectEnumSchemaSchema, exports.MultiSelectEnumSchemaSchema]);
1749
+ /**
1750
+ * Union of all primitive schema definitions.
1751
+ */
1752
+ exports.PrimitiveSchemaDefinitionSchema = z.union([exports.EnumSchemaSchema, exports.BooleanSchemaSchema, exports.StringSchemaSchema, exports.NumberSchemaSchema]);
1753
+ /**
1754
+ * Parameters for an `elicitation/create` request for form-based elicitation.
1755
+ */
1756
+ exports.ElicitRequestFormParamsSchema = exports.TaskAugmentedRequestParamsSchema.extend({
1757
+ /**
1758
+ * The elicitation mode.
1759
+ *
1760
+ * Optional for backward compatibility. Clients MUST treat missing mode as "form".
1761
+ */
1762
+ mode: z.literal('form').optional(),
1763
+ /**
1764
+ * The message to present to the user describing what information is being requested.
1765
+ */
1766
+ message: z.string(),
1767
+ /**
1768
+ * A restricted subset of JSON Schema.
1769
+ * Only top-level properties are allowed, without nesting.
1770
+ */
1771
+ requestedSchema: z.object({
1772
+ type: z.literal('object'),
1773
+ properties: z.record(z.string(), exports.PrimitiveSchemaDefinitionSchema),
1774
+ required: z.array(z.string()).optional()
1775
+ })
1776
+ });
1777
+ /**
1778
+ * Parameters for an `elicitation/create` request for URL-based elicitation.
1779
+ */
1780
+ exports.ElicitRequestURLParamsSchema = exports.TaskAugmentedRequestParamsSchema.extend({
1781
+ /**
1782
+ * The elicitation mode.
1783
+ */
1784
+ mode: z.literal('url'),
1785
+ /**
1786
+ * The message to present to the user explaining why the interaction is needed.
1787
+ */
1788
+ message: z.string(),
1789
+ /**
1790
+ * The ID of the elicitation, which must be unique within the context of the server.
1791
+ * The client MUST treat this ID as an opaque value.
1792
+ */
1793
+ elicitationId: z.string(),
1794
+ /**
1795
+ * The URL that the user should navigate to.
1796
+ */
1797
+ url: z.string().url()
1798
+ });
1799
+ /**
1800
+ * The parameters for a request to elicit additional information from the user via the client.
1801
+ */
1802
+ exports.ElicitRequestParamsSchema = z.union([exports.ElicitRequestFormParamsSchema, exports.ElicitRequestURLParamsSchema]);
1803
+ /**
1804
+ * A request from the server to elicit user input via the client.
1805
+ * The client should present the message and form fields to the user (form mode)
1806
+ * or navigate to a URL (URL mode).
1807
+ */
1808
+ exports.ElicitRequestSchema = exports.RequestSchema.extend({
1809
+ method: z.literal('elicitation/create'),
1810
+ params: exports.ElicitRequestParamsSchema
1811
+ });
1812
+ /**
1813
+ * Parameters for a `notifications/elicitation/complete` notification.
1814
+ *
1815
+ * @category notifications/elicitation/complete
1816
+ */
1817
+ exports.ElicitationCompleteNotificationParamsSchema = NotificationsParamsSchema.extend({
1818
+ /**
1819
+ * The ID of the elicitation that completed.
1820
+ */
1821
+ elicitationId: z.string()
1822
+ });
1823
+ /**
1824
+ * A notification from the server to the client, informing it of a completion of an out-of-band elicitation request.
1825
+ *
1826
+ * @category notifications/elicitation/complete
1827
+ */
1828
+ exports.ElicitationCompleteNotificationSchema = exports.NotificationSchema.extend({
1829
+ method: z.literal('notifications/elicitation/complete'),
1830
+ params: exports.ElicitationCompleteNotificationParamsSchema
1831
+ });
1832
+ /**
1833
+ * The client's response to an elicitation/create request from the server.
1834
+ */
1835
+ exports.ElicitResultSchema = exports.ResultSchema.extend({
1836
+ /**
1837
+ * The user action in response to the elicitation.
1838
+ * - "accept": User submitted the form/confirmed the action
1839
+ * - "decline": User explicitly decline the action
1840
+ * - "cancel": User dismissed without making an explicit choice
1841
+ */
1842
+ action: z.enum(['accept', 'decline', 'cancel']),
1843
+ /**
1844
+ * The submitted form data, only present when action is "accept".
1845
+ * Contains values matching the requested schema.
1846
+ * Per MCP spec, content is "typically omitted" for decline/cancel actions.
1847
+ * We normalize null to undefined for leniency while maintaining type compatibility.
1848
+ */
1849
+ content: z.preprocess(val => (val === null ? undefined : val), z.record(z.string(), z.union([z.string(), z.number(), z.boolean(), z.array(z.string())])).optional())
1850
+ });
1851
+ /* Autocomplete */
1852
+ /**
1853
+ * A reference to a resource or resource template definition.
1854
+ */
1855
+ exports.ResourceTemplateReferenceSchema = z.object({
1856
+ type: z.literal('ref/resource'),
1857
+ /**
1858
+ * The URI or URI template of the resource.
1859
+ */
1860
+ uri: z.string()
1861
+ });
1862
+ /**
1863
+ * @deprecated Use ResourceTemplateReferenceSchema instead
1864
+ */
1865
+ exports.ResourceReferenceSchema = exports.ResourceTemplateReferenceSchema;
1866
+ /**
1867
+ * Identifies a prompt.
1868
+ */
1869
+ exports.PromptReferenceSchema = z.object({
1870
+ type: z.literal('ref/prompt'),
1871
+ /**
1872
+ * The name of the prompt or prompt template
1873
+ */
1874
+ name: z.string()
1875
+ });
1876
+ /**
1877
+ * Parameters for a `completion/complete` request.
1878
+ */
1879
+ exports.CompleteRequestParamsSchema = BaseRequestParamsSchema.extend({
1880
+ ref: z.union([exports.PromptReferenceSchema, exports.ResourceTemplateReferenceSchema]),
1881
+ /**
1882
+ * The argument's information
1883
+ */
1884
+ argument: z.object({
1885
+ /**
1886
+ * The name of the argument
1887
+ */
1888
+ name: z.string(),
1889
+ /**
1890
+ * The value of the argument to use for completion matching.
1891
+ */
1892
+ value: z.string()
1893
+ }),
1894
+ context: z
1895
+ .object({
1896
+ /**
1897
+ * Previously-resolved variables in a URI template or prompt.
1898
+ */
1899
+ arguments: z.record(z.string(), z.string()).optional()
1900
+ })
1901
+ .optional()
1902
+ });
1903
+ /**
1904
+ * A request from the client to the server, to ask for completion options.
1905
+ */
1906
+ exports.CompleteRequestSchema = exports.RequestSchema.extend({
1907
+ method: z.literal('completion/complete'),
1908
+ params: exports.CompleteRequestParamsSchema
1909
+ });
1910
+ function assertCompleteRequestPrompt(request) {
1911
+ if (request.params.ref.type !== 'ref/prompt') {
1912
+ throw new TypeError(`Expected CompleteRequestPrompt, but got ${request.params.ref.type}`);
1913
+ }
1914
+ void request;
1915
+ }
1916
+ function assertCompleteRequestResourceTemplate(request) {
1917
+ if (request.params.ref.type !== 'ref/resource') {
1918
+ throw new TypeError(`Expected CompleteRequestResourceTemplate, but got ${request.params.ref.type}`);
1919
+ }
1920
+ void request;
1921
+ }
1922
+ /**
1923
+ * The server's response to a completion/complete request
1924
+ */
1925
+ exports.CompleteResultSchema = exports.ResultSchema.extend({
1926
+ completion: z.looseObject({
1927
+ /**
1928
+ * An array of completion values. Must not exceed 100 items.
1929
+ */
1930
+ values: z.array(z.string()).max(100),
1931
+ /**
1932
+ * The total number of completion options available. This can exceed the number of values actually sent in the response.
1933
+ */
1934
+ total: z.optional(z.number().int()),
1935
+ /**
1936
+ * Indicates whether there are additional completion options beyond those provided in the current response, even if the exact total is unknown.
1937
+ */
1938
+ hasMore: z.optional(z.boolean())
1939
+ })
1940
+ });
1941
+ /* Roots */
1942
+ /**
1943
+ * Represents a root directory or file that the server can operate on.
1944
+ */
1945
+ exports.RootSchema = z.object({
1946
+ /**
1947
+ * The URI identifying the root. This *must* start with file:// for now.
1948
+ */
1949
+ uri: z.string().startsWith('file://'),
1950
+ /**
1951
+ * An optional name for the root.
1952
+ */
1953
+ name: z.string().optional(),
1954
+ /**
1955
+ * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
1956
+ * for notes on _meta usage.
1957
+ */
1958
+ _meta: z.record(z.string(), z.unknown()).optional()
1959
+ });
1960
+ /**
1961
+ * Sent from the server to request a list of root URIs from the client.
1962
+ */
1963
+ exports.ListRootsRequestSchema = exports.RequestSchema.extend({
1964
+ method: z.literal('roots/list'),
1965
+ params: BaseRequestParamsSchema.optional()
1966
+ });
1967
+ /**
1968
+ * The client's response to a roots/list request from the server.
1969
+ */
1970
+ exports.ListRootsResultSchema = exports.ResultSchema.extend({
1971
+ roots: z.array(exports.RootSchema)
1972
+ });
1973
+ /**
1974
+ * A notification from the client to the server, informing it that the list of roots has changed.
1975
+ */
1976
+ exports.RootsListChangedNotificationSchema = exports.NotificationSchema.extend({
1977
+ method: z.literal('notifications/roots/list_changed'),
1978
+ params: NotificationsParamsSchema.optional()
1979
+ });
1980
+ /* Client messages */
1981
+ exports.ClientRequestSchema = z.union([
1982
+ exports.PingRequestSchema,
1983
+ exports.InitializeRequestSchema,
1984
+ exports.CompleteRequestSchema,
1985
+ exports.SetLevelRequestSchema,
1986
+ exports.GetPromptRequestSchema,
1987
+ exports.ListPromptsRequestSchema,
1988
+ exports.ListResourcesRequestSchema,
1989
+ exports.ListResourceTemplatesRequestSchema,
1990
+ exports.ReadResourceRequestSchema,
1991
+ exports.SubscribeRequestSchema,
1992
+ exports.UnsubscribeRequestSchema,
1993
+ exports.CallToolRequestSchema,
1994
+ exports.ListToolsRequestSchema,
1995
+ exports.GetTaskRequestSchema,
1996
+ exports.GetTaskPayloadRequestSchema,
1997
+ exports.ListTasksRequestSchema,
1998
+ exports.CancelTaskRequestSchema
1999
+ ]);
2000
+ exports.ClientNotificationSchema = z.union([
2001
+ exports.CancelledNotificationSchema,
2002
+ exports.ProgressNotificationSchema,
2003
+ exports.InitializedNotificationSchema,
2004
+ exports.RootsListChangedNotificationSchema,
2005
+ exports.TaskStatusNotificationSchema
2006
+ ]);
2007
+ exports.ClientResultSchema = z.union([
2008
+ exports.EmptyResultSchema,
2009
+ exports.CreateMessageResultSchema,
2010
+ exports.CreateMessageResultWithToolsSchema,
2011
+ exports.ElicitResultSchema,
2012
+ exports.ListRootsResultSchema,
2013
+ exports.GetTaskResultSchema,
2014
+ exports.ListTasksResultSchema,
2015
+ exports.CreateTaskResultSchema
2016
+ ]);
2017
+ /* Server messages */
2018
+ exports.ServerRequestSchema = z.union([
2019
+ exports.PingRequestSchema,
2020
+ exports.CreateMessageRequestSchema,
2021
+ exports.ElicitRequestSchema,
2022
+ exports.ListRootsRequestSchema,
2023
+ exports.GetTaskRequestSchema,
2024
+ exports.GetTaskPayloadRequestSchema,
2025
+ exports.ListTasksRequestSchema,
2026
+ exports.CancelTaskRequestSchema
2027
+ ]);
2028
+ exports.ServerNotificationSchema = z.union([
2029
+ exports.CancelledNotificationSchema,
2030
+ exports.ProgressNotificationSchema,
2031
+ exports.LoggingMessageNotificationSchema,
2032
+ exports.ResourceUpdatedNotificationSchema,
2033
+ exports.ResourceListChangedNotificationSchema,
2034
+ exports.ToolListChangedNotificationSchema,
2035
+ exports.PromptListChangedNotificationSchema,
2036
+ exports.TaskStatusNotificationSchema,
2037
+ exports.ElicitationCompleteNotificationSchema
2038
+ ]);
2039
+ exports.ServerResultSchema = z.union([
2040
+ exports.EmptyResultSchema,
2041
+ exports.InitializeResultSchema,
2042
+ exports.CompleteResultSchema,
2043
+ exports.GetPromptResultSchema,
2044
+ exports.ListPromptsResultSchema,
2045
+ exports.ListResourcesResultSchema,
2046
+ exports.ListResourceTemplatesResultSchema,
2047
+ exports.ReadResourceResultSchema,
2048
+ exports.CallToolResultSchema,
2049
+ exports.ListToolsResultSchema,
2050
+ exports.GetTaskResultSchema,
2051
+ exports.ListTasksResultSchema,
2052
+ exports.CreateTaskResultSchema
2053
+ ]);
2054
+ class McpError extends Error {
2055
+ constructor(code, message, data) {
2056
+ super(`MCP error ${code}: ${message}`);
2057
+ this.code = code;
2058
+ this.data = data;
2059
+ this.name = 'McpError';
2060
+ }
2061
+ /**
2062
+ * Factory method to create the appropriate error type based on the error code and data
2063
+ */
2064
+ static fromError(code, message, data) {
2065
+ // Check for specific error types
2066
+ if (code === ErrorCode.UrlElicitationRequired && data) {
2067
+ const errorData = data;
2068
+ if (errorData.elicitations) {
2069
+ return new UrlElicitationRequiredError(errorData.elicitations, message);
2070
+ }
2071
+ }
2072
+ // Default to generic McpError
2073
+ return new McpError(code, message, data);
2074
+ }
2075
+ }
2076
+ exports.McpError = McpError;
2077
+ /**
2078
+ * Specialized error type when a tool requires a URL mode elicitation.
2079
+ * 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.
2080
+ */
2081
+ class UrlElicitationRequiredError extends McpError {
2082
+ constructor(elicitations, message = `URL elicitation${elicitations.length > 1 ? 's' : ''} required`) {
2083
+ super(ErrorCode.UrlElicitationRequired, message, {
2084
+ elicitations: elicitations
2085
+ });
2086
+ }
2087
+ get elicitations() {
2088
+ return this.data?.elicitations ?? [];
2089
+ }
2090
+ }
2091
+ exports.UrlElicitationRequiredError = UrlElicitationRequiredError;
2092
+ //# sourceMappingURL=types.js.map