@modelcontextprotocol/sdk 1.24.3 → 1.25.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 (233) hide show
  1. package/dist/cjs/client/auth-extensions.js +5 -9
  2. package/dist/cjs/client/auth-extensions.js.map +1 -1
  3. package/dist/cjs/client/auth.js +30 -37
  4. package/dist/cjs/client/auth.js.map +1 -1
  5. package/dist/cjs/client/index.d.ts +61 -14
  6. package/dist/cjs/client/index.d.ts.map +1 -1
  7. package/dist/cjs/client/index.js +117 -36
  8. package/dist/cjs/client/index.js.map +1 -1
  9. package/dist/cjs/client/middleware.js +3 -3
  10. package/dist/cjs/client/middleware.js.map +1 -1
  11. package/dist/cjs/client/sse.js +19 -27
  12. package/dist/cjs/client/sse.js.map +1 -1
  13. package/dist/cjs/client/stdio.js +18 -28
  14. package/dist/cjs/client/stdio.js.map +1 -1
  15. package/dist/cjs/client/streamableHttp.d.ts.map +1 -1
  16. package/dist/cjs/client/streamableHttp.js +39 -49
  17. package/dist/cjs/client/streamableHttp.js.map +1 -1
  18. package/dist/cjs/client/websocket.js +6 -11
  19. package/dist/cjs/client/websocket.js.map +1 -1
  20. package/dist/cjs/examples/client/elicitationUrlExample.js +4 -5
  21. package/dist/cjs/examples/client/elicitationUrlExample.js.map +1 -1
  22. package/dist/cjs/examples/client/simpleOAuthClient.js +3 -3
  23. package/dist/cjs/examples/client/simpleOAuthClient.js.map +1 -1
  24. package/dist/cjs/examples/client/simpleStreamableHttp.js +7 -9
  25. package/dist/cjs/examples/client/simpleStreamableHttp.js.map +1 -1
  26. package/dist/cjs/examples/client/simpleTaskInteractiveClient.js +1 -2
  27. package/dist/cjs/examples/client/simpleTaskInteractiveClient.js.map +1 -1
  28. package/dist/cjs/examples/server/honoWebStandardStreamableHttp.d.ts +10 -0
  29. package/dist/cjs/examples/server/honoWebStandardStreamableHttp.d.ts.map +1 -0
  30. package/dist/cjs/examples/server/honoWebStandardStreamableHttp.js +81 -0
  31. package/dist/cjs/examples/server/honoWebStandardStreamableHttp.js.map +1 -0
  32. package/dist/cjs/examples/server/jsonResponseStreamableHttp.js +10 -4
  33. package/dist/cjs/examples/server/jsonResponseStreamableHttp.js.map +1 -1
  34. package/dist/cjs/examples/server/simpleSseServer.js +6 -3
  35. package/dist/cjs/examples/server/simpleSseServer.js.map +1 -1
  36. package/dist/cjs/examples/server/simpleStatelessStreamableHttp.js +12 -6
  37. package/dist/cjs/examples/server/simpleStatelessStreamableHttp.js.map +1 -1
  38. package/dist/cjs/examples/server/simpleStreamableHttp.js +21 -11
  39. package/dist/cjs/examples/server/simpleStreamableHttp.js.map +1 -1
  40. package/dist/cjs/examples/server/simpleTaskInteractive.js +7 -11
  41. package/dist/cjs/examples/server/simpleTaskInteractive.js.map +1 -1
  42. package/dist/cjs/examples/server/sseAndStreamableHttpCompatibleServer.js +10 -7
  43. package/dist/cjs/examples/server/sseAndStreamableHttpCompatibleServer.js.map +1 -1
  44. package/dist/cjs/examples/server/standaloneSseWithGetStreamableHttp.js +1 -1
  45. package/dist/cjs/examples/server/standaloneSseWithGetStreamableHttp.js.map +1 -1
  46. package/dist/cjs/experimental/tasks/client.js +1 -2
  47. package/dist/cjs/experimental/tasks/client.js.map +1 -1
  48. package/dist/cjs/experimental/tasks/helpers.js +3 -5
  49. package/dist/cjs/experimental/tasks/helpers.js.map +1 -1
  50. package/dist/cjs/experimental/tasks/interfaces.d.ts +3 -3
  51. package/dist/cjs/experimental/tasks/interfaces.d.ts.map +1 -1
  52. package/dist/cjs/experimental/tasks/stores/in-memory.d.ts +1 -1
  53. package/dist/cjs/experimental/tasks/stores/in-memory.d.ts.map +1 -1
  54. package/dist/cjs/experimental/tasks/stores/in-memory.js +3 -5
  55. package/dist/cjs/experimental/tasks/stores/in-memory.js.map +1 -1
  56. package/dist/cjs/inMemory.js +5 -7
  57. package/dist/cjs/inMemory.js.map +1 -1
  58. package/dist/cjs/server/auth/handlers/token.js +1 -1
  59. package/dist/cjs/server/auth/handlers/token.js.map +1 -1
  60. package/dist/cjs/server/auth/providers/proxyProvider.js +11 -17
  61. package/dist/cjs/server/auth/providers/proxyProvider.js.map +1 -1
  62. package/dist/cjs/server/auth/router.js +3 -6
  63. package/dist/cjs/server/auth/router.js.map +1 -1
  64. package/dist/cjs/server/completable.js +1 -1
  65. package/dist/cjs/server/completable.js.map +1 -1
  66. package/dist/cjs/server/index.d.ts +3 -3
  67. package/dist/cjs/server/index.d.ts.map +1 -1
  68. package/dist/cjs/server/index.js +20 -30
  69. package/dist/cjs/server/index.js.map +1 -1
  70. package/dist/cjs/server/mcp.d.ts.map +1 -1
  71. package/dist/cjs/server/mcp.js +25 -11
  72. package/dist/cjs/server/mcp.js.map +1 -1
  73. package/dist/cjs/server/middleware/hostHeaderValidation.js +1 -1
  74. package/dist/cjs/server/middleware/hostHeaderValidation.js.map +1 -1
  75. package/dist/cjs/server/sse.js +14 -17
  76. package/dist/cjs/server/sse.js.map +1 -1
  77. package/dist/cjs/server/stdio.js +4 -7
  78. package/dist/cjs/server/stdio.js.map +1 -1
  79. package/dist/cjs/server/streamableHttp.d.ts +52 -154
  80. package/dist/cjs/server/streamableHttp.d.ts.map +1 -1
  81. package/dist/cjs/server/streamableHttp.js +78 -653
  82. package/dist/cjs/server/streamableHttp.js.map +1 -1
  83. package/dist/cjs/server/webStandardStreamableHttp.d.ts +267 -0
  84. package/dist/cjs/server/webStandardStreamableHttp.d.ts.map +1 -0
  85. package/dist/cjs/server/webStandardStreamableHttp.js +729 -0
  86. package/dist/cjs/server/webStandardStreamableHttp.js.map +1 -0
  87. package/dist/cjs/server/zod-compat.d.ts +3 -1
  88. package/dist/cjs/server/zod-compat.d.ts.map +1 -1
  89. package/dist/cjs/server/zod-compat.js +11 -19
  90. package/dist/cjs/server/zod-compat.js.map +1 -1
  91. package/dist/cjs/server/zod-json-schema-compat.js +5 -6
  92. package/dist/cjs/server/zod-json-schema-compat.js.map +1 -1
  93. package/dist/cjs/shared/metadataUtils.js +1 -2
  94. package/dist/cjs/shared/metadataUtils.js.map +1 -1
  95. package/dist/cjs/shared/protocol.d.ts +1 -1
  96. package/dist/cjs/shared/protocol.d.ts.map +1 -1
  97. package/dist/cjs/shared/protocol.js +76 -88
  98. package/dist/cjs/shared/protocol.js.map +1 -1
  99. package/dist/cjs/shared/transport.js +1 -1
  100. package/dist/cjs/shared/transport.js.map +1 -1
  101. package/dist/cjs/spec.types.d.ts +315 -26
  102. package/dist/cjs/spec.types.d.ts.map +1 -1
  103. package/dist/cjs/spec.types.js +2 -2
  104. package/dist/cjs/spec.types.js.map +1 -1
  105. package/dist/cjs/types.d.ts +1392 -1248
  106. package/dist/cjs/types.d.ts.map +1 -1
  107. package/dist/cjs/types.js +201 -136
  108. package/dist/cjs/types.js.map +1 -1
  109. package/dist/cjs/validation/ajv-provider.d.ts +1 -1
  110. package/dist/cjs/validation/ajv-provider.d.ts.map +1 -1
  111. package/dist/cjs/validation/ajv-provider.js +4 -5
  112. package/dist/cjs/validation/ajv-provider.js.map +1 -1
  113. package/dist/cjs/validation/cfworker-provider.js +4 -5
  114. package/dist/cjs/validation/cfworker-provider.js.map +1 -1
  115. package/dist/cjs/validation/types.d.ts +12 -2
  116. package/dist/cjs/validation/types.d.ts.map +1 -1
  117. package/dist/esm/client/auth-extensions.js +5 -9
  118. package/dist/esm/client/auth-extensions.js.map +1 -1
  119. package/dist/esm/client/auth.js +30 -37
  120. package/dist/esm/client/auth.js.map +1 -1
  121. package/dist/esm/client/index.d.ts +61 -14
  122. package/dist/esm/client/index.d.ts.map +1 -1
  123. package/dist/esm/client/index.js +118 -37
  124. package/dist/esm/client/index.js.map +1 -1
  125. package/dist/esm/client/middleware.js +3 -3
  126. package/dist/esm/client/middleware.js.map +1 -1
  127. package/dist/esm/client/sse.js +19 -27
  128. package/dist/esm/client/sse.js.map +1 -1
  129. package/dist/esm/client/stdio.js +18 -28
  130. package/dist/esm/client/stdio.js.map +1 -1
  131. package/dist/esm/client/streamableHttp.d.ts.map +1 -1
  132. package/dist/esm/client/streamableHttp.js +40 -50
  133. package/dist/esm/client/streamableHttp.js.map +1 -1
  134. package/dist/esm/client/websocket.js +6 -11
  135. package/dist/esm/client/websocket.js.map +1 -1
  136. package/dist/esm/examples/client/elicitationUrlExample.js +4 -5
  137. package/dist/esm/examples/client/elicitationUrlExample.js.map +1 -1
  138. package/dist/esm/examples/client/simpleOAuthClient.js +3 -3
  139. package/dist/esm/examples/client/simpleOAuthClient.js.map +1 -1
  140. package/dist/esm/examples/client/simpleStreamableHttp.js +7 -9
  141. package/dist/esm/examples/client/simpleStreamableHttp.js.map +1 -1
  142. package/dist/esm/examples/client/simpleTaskInteractiveClient.js +1 -2
  143. package/dist/esm/examples/client/simpleTaskInteractiveClient.js.map +1 -1
  144. package/dist/esm/examples/server/honoWebStandardStreamableHttp.d.ts +10 -0
  145. package/dist/esm/examples/server/honoWebStandardStreamableHttp.d.ts.map +1 -0
  146. package/dist/esm/examples/server/honoWebStandardStreamableHttp.js +56 -0
  147. package/dist/esm/examples/server/honoWebStandardStreamableHttp.js.map +1 -0
  148. package/dist/esm/examples/server/jsonResponseStreamableHttp.js +10 -4
  149. package/dist/esm/examples/server/jsonResponseStreamableHttp.js.map +1 -1
  150. package/dist/esm/examples/server/simpleSseServer.js +6 -3
  151. package/dist/esm/examples/server/simpleSseServer.js.map +1 -1
  152. package/dist/esm/examples/server/simpleStatelessStreamableHttp.js +12 -6
  153. package/dist/esm/examples/server/simpleStatelessStreamableHttp.js.map +1 -1
  154. package/dist/esm/examples/server/simpleStreamableHttp.js +21 -11
  155. package/dist/esm/examples/server/simpleStreamableHttp.js.map +1 -1
  156. package/dist/esm/examples/server/simpleTaskInteractive.js +7 -11
  157. package/dist/esm/examples/server/simpleTaskInteractive.js.map +1 -1
  158. package/dist/esm/examples/server/sseAndStreamableHttpCompatibleServer.js +10 -7
  159. package/dist/esm/examples/server/sseAndStreamableHttpCompatibleServer.js.map +1 -1
  160. package/dist/esm/examples/server/standaloneSseWithGetStreamableHttp.js +1 -1
  161. package/dist/esm/examples/server/standaloneSseWithGetStreamableHttp.js.map +1 -1
  162. package/dist/esm/experimental/tasks/client.js +1 -2
  163. package/dist/esm/experimental/tasks/client.js.map +1 -1
  164. package/dist/esm/experimental/tasks/helpers.js +3 -5
  165. package/dist/esm/experimental/tasks/helpers.js.map +1 -1
  166. package/dist/esm/experimental/tasks/interfaces.d.ts +3 -3
  167. package/dist/esm/experimental/tasks/interfaces.d.ts.map +1 -1
  168. package/dist/esm/experimental/tasks/stores/in-memory.d.ts +1 -1
  169. package/dist/esm/experimental/tasks/stores/in-memory.d.ts.map +1 -1
  170. package/dist/esm/experimental/tasks/stores/in-memory.js +3 -5
  171. package/dist/esm/experimental/tasks/stores/in-memory.js.map +1 -1
  172. package/dist/esm/inMemory.js +5 -7
  173. package/dist/esm/inMemory.js.map +1 -1
  174. package/dist/esm/server/auth/handlers/token.js +1 -1
  175. package/dist/esm/server/auth/handlers/token.js.map +1 -1
  176. package/dist/esm/server/auth/providers/proxyProvider.js +11 -17
  177. package/dist/esm/server/auth/providers/proxyProvider.js.map +1 -1
  178. package/dist/esm/server/auth/router.js +3 -6
  179. package/dist/esm/server/auth/router.js.map +1 -1
  180. package/dist/esm/server/completable.js +1 -1
  181. package/dist/esm/server/completable.js.map +1 -1
  182. package/dist/esm/server/index.d.ts +3 -3
  183. package/dist/esm/server/index.d.ts.map +1 -1
  184. package/dist/esm/server/index.js +20 -30
  185. package/dist/esm/server/index.js.map +1 -1
  186. package/dist/esm/server/mcp.d.ts.map +1 -1
  187. package/dist/esm/server/mcp.js +25 -11
  188. package/dist/esm/server/mcp.js.map +1 -1
  189. package/dist/esm/server/middleware/hostHeaderValidation.js +1 -1
  190. package/dist/esm/server/middleware/hostHeaderValidation.js.map +1 -1
  191. package/dist/esm/server/sse.js +14 -17
  192. package/dist/esm/server/sse.js.map +1 -1
  193. package/dist/esm/server/stdio.js +4 -7
  194. package/dist/esm/server/stdio.js.map +1 -1
  195. package/dist/esm/server/streamableHttp.d.ts +52 -154
  196. package/dist/esm/server/streamableHttp.d.ts.map +1 -1
  197. package/dist/esm/server/streamableHttp.js +78 -650
  198. package/dist/esm/server/streamableHttp.js.map +1 -1
  199. package/dist/esm/server/webStandardStreamableHttp.d.ts +267 -0
  200. package/dist/esm/server/webStandardStreamableHttp.d.ts.map +1 -0
  201. package/dist/esm/server/webStandardStreamableHttp.js +725 -0
  202. package/dist/esm/server/webStandardStreamableHttp.js.map +1 -0
  203. package/dist/esm/server/zod-compat.d.ts +3 -1
  204. package/dist/esm/server/zod-compat.d.ts.map +1 -1
  205. package/dist/esm/server/zod-compat.js +11 -19
  206. package/dist/esm/server/zod-compat.js.map +1 -1
  207. package/dist/esm/server/zod-json-schema-compat.js +5 -6
  208. package/dist/esm/server/zod-json-schema-compat.js.map +1 -1
  209. package/dist/esm/shared/metadataUtils.js +1 -2
  210. package/dist/esm/shared/metadataUtils.js.map +1 -1
  211. package/dist/esm/shared/protocol.d.ts +1 -1
  212. package/dist/esm/shared/protocol.d.ts.map +1 -1
  213. package/dist/esm/shared/protocol.js +77 -89
  214. package/dist/esm/shared/protocol.js.map +1 -1
  215. package/dist/esm/shared/transport.js +1 -1
  216. package/dist/esm/shared/transport.js.map +1 -1
  217. package/dist/esm/spec.types.d.ts +315 -26
  218. package/dist/esm/spec.types.d.ts.map +1 -1
  219. package/dist/esm/spec.types.js +2 -2
  220. package/dist/esm/spec.types.js.map +1 -1
  221. package/dist/esm/types.d.ts +1392 -1248
  222. package/dist/esm/types.d.ts.map +1 -1
  223. package/dist/esm/types.js +194 -130
  224. package/dist/esm/types.js.map +1 -1
  225. package/dist/esm/validation/ajv-provider.d.ts +1 -1
  226. package/dist/esm/validation/ajv-provider.d.ts.map +1 -1
  227. package/dist/esm/validation/ajv-provider.js +3 -4
  228. package/dist/esm/validation/ajv-provider.js.map +1 -1
  229. package/dist/esm/validation/cfworker-provider.js +4 -5
  230. package/dist/esm/validation/cfworker-provider.js.map +1 -1
  231. package/dist/esm/validation/types.d.ts +12 -2
  232. package/dist/esm/validation/types.d.ts.map +1 -1
  233. package/package.json +3 -1
package/dist/esm/types.js CHANGED
@@ -33,10 +33,14 @@ export const TaskCreationParamsSchema = z.looseObject({
33
33
  */
34
34
  pollInterval: z.number().optional()
35
35
  });
36
+ export const TaskMetadataSchema = z.object({
37
+ ttl: z.number().optional()
38
+ });
36
39
  /**
37
- * Task association metadata, used to signal which task a message originated from.
40
+ * Metadata for associating messages with a task.
41
+ * Include this in the `_meta` field under the key `io.modelcontextprotocol/related-task`.
38
42
  */
39
- export const RelatedTaskMetadataSchema = z.looseObject({
43
+ export const RelatedTaskMetadataSchema = z.object({
40
44
  taskId: z.string()
41
45
  });
42
46
  const RequestMetaSchema = z.looseObject({
@@ -52,53 +56,54 @@ const RequestMetaSchema = z.looseObject({
52
56
  /**
53
57
  * Common params for any request.
54
58
  */
55
- const BaseRequestParamsSchema = z.looseObject({
56
- /**
57
- * If specified, the caller is requesting that the receiver create a task to represent the request.
58
- * Task creation parameters are now at the top level instead of in _meta.
59
- */
60
- task: TaskCreationParamsSchema.optional(),
59
+ const BaseRequestParamsSchema = z.object({
61
60
  /**
62
61
  * See [General fields: `_meta`](/specification/draft/basic/index#meta) for notes on `_meta` usage.
63
62
  */
64
63
  _meta: RequestMetaSchema.optional()
65
64
  });
65
+ /**
66
+ * Common params for any task-augmented request.
67
+ */
68
+ export const TaskAugmentedRequestParamsSchema = BaseRequestParamsSchema.extend({
69
+ /**
70
+ * If specified, the caller is requesting task-augmented execution for this request.
71
+ * The request will return a CreateTaskResult immediately, and the actual result can be
72
+ * retrieved later via tasks/result.
73
+ *
74
+ * Task augmentation is subject to capability negotiation - receivers MUST declare support
75
+ * for task augmentation of specific request types in their capabilities.
76
+ */
77
+ task: TaskMetadataSchema.optional()
78
+ });
79
+ /**
80
+ * Checks if a value is a valid TaskAugmentedRequestParams.
81
+ * @param value - The value to check.
82
+ *
83
+ * @returns True if the value is a valid TaskAugmentedRequestParams, false otherwise.
84
+ */
85
+ export const isTaskAugmentedRequestParams = (value) => TaskAugmentedRequestParamsSchema.safeParse(value).success;
66
86
  export const RequestSchema = z.object({
67
87
  method: z.string(),
68
- params: BaseRequestParamsSchema.optional()
88
+ params: BaseRequestParamsSchema.loose().optional()
69
89
  });
70
- const NotificationsParamsSchema = z.looseObject({
90
+ const NotificationsParamsSchema = z.object({
71
91
  /**
72
92
  * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
73
93
  * for notes on _meta usage.
74
94
  */
75
- _meta: z
76
- .object({
77
- /**
78
- * If specified, this notification is related to the provided task.
79
- */
80
- [RELATED_TASK_META_KEY]: z.optional(RelatedTaskMetadataSchema)
81
- })
82
- .passthrough()
83
- .optional()
95
+ _meta: RequestMetaSchema.optional()
84
96
  });
85
97
  export const NotificationSchema = z.object({
86
98
  method: z.string(),
87
- params: NotificationsParamsSchema.optional()
99
+ params: NotificationsParamsSchema.loose().optional()
88
100
  });
89
101
  export const ResultSchema = z.looseObject({
90
102
  /**
91
103
  * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
92
104
  * for notes on _meta usage.
93
105
  */
94
- _meta: z
95
- .looseObject({
96
- /**
97
- * If specified, this result is related to the provided task.
98
- */
99
- [RELATED_TASK_META_KEY]: RelatedTaskMetadataSchema.optional()
100
- })
101
- .optional()
106
+ _meta: RequestMetaSchema.optional()
102
107
  });
103
108
  /**
104
109
  * A uniquely identifying ID for a request in JSON-RPC.
@@ -128,14 +133,14 @@ export const isJSONRPCNotification = (value) => JSONRPCNotificationSchema.safePa
128
133
  /**
129
134
  * A successful (non-error) response to a request.
130
135
  */
131
- export const JSONRPCResponseSchema = z
136
+ export const JSONRPCResultResponseSchema = z
132
137
  .object({
133
138
  jsonrpc: z.literal(JSONRPC_VERSION),
134
139
  id: RequestIdSchema,
135
140
  result: ResultSchema
136
141
  })
137
142
  .strict();
138
- export const isJSONRPCResponse = (value) => JSONRPCResponseSchema.safeParse(value).success;
143
+ export const isJSONRPCResultResponse = (value) => JSONRPCResultResponseSchema.safeParse(value).success;
139
144
  /**
140
145
  * Error codes defined by the JSON-RPC specification.
141
146
  */
@@ -156,10 +161,10 @@ export var ErrorCode;
156
161
  /**
157
162
  * A response to a request that indicates an error occurred.
158
163
  */
159
- export const JSONRPCErrorSchema = z
164
+ export const JSONRPCErrorResponseSchema = z
160
165
  .object({
161
166
  jsonrpc: z.literal(JSONRPC_VERSION),
162
- id: RequestIdSchema,
167
+ id: RequestIdSchema.optional(),
163
168
  error: z.object({
164
169
  /**
165
170
  * The error type that occurred.
@@ -172,12 +177,18 @@ export const JSONRPCErrorSchema = z
172
177
  /**
173
178
  * Additional information about the error. The value of this member is defined by the sender (e.g. detailed error information, nested errors etc.).
174
179
  */
175
- data: z.optional(z.unknown())
180
+ data: z.unknown().optional()
176
181
  })
177
182
  })
178
183
  .strict();
179
- export const isJSONRPCError = (value) => JSONRPCErrorSchema.safeParse(value).success;
180
- export const JSONRPCMessageSchema = z.union([JSONRPCRequestSchema, JSONRPCNotificationSchema, JSONRPCResponseSchema, JSONRPCErrorSchema]);
184
+ export const isJSONRPCErrorResponse = (value) => JSONRPCErrorResponseSchema.safeParse(value).success;
185
+ export const JSONRPCMessageSchema = z.union([
186
+ JSONRPCRequestSchema,
187
+ JSONRPCNotificationSchema,
188
+ JSONRPCResultResponseSchema,
189
+ JSONRPCErrorResponseSchema
190
+ ]);
191
+ export const JSONRPCResponseSchema = z.union([JSONRPCResultResponseSchema, JSONRPCErrorResponseSchema]);
181
192
  /* Empty result */
182
193
  /**
183
194
  * A response that indicates success but carries no data.
@@ -189,7 +200,7 @@ export const CancelledNotificationParamsSchema = NotificationsParamsSchema.exten
189
200
  *
190
201
  * This MUST correspond to the ID of a request previously issued in the same direction.
191
202
  */
192
- requestId: RequestIdSchema,
203
+ requestId: RequestIdSchema.optional(),
193
204
  /**
194
205
  * An optional string describing the reason for the cancellation. This MAY be logged or presented to the user.
195
206
  */
@@ -228,7 +239,15 @@ export const IconSchema = z.object({
228
239
  *
229
240
  * If not provided, the client should assume that the icon can be used at any size.
230
241
  */
231
- sizes: z.array(z.string()).optional()
242
+ sizes: z.array(z.string()).optional(),
243
+ /**
244
+ * Optional specifier for the theme this icon is designed for. `light` indicates
245
+ * the icon is designed to be used with a light background, and `dark` indicates
246
+ * the icon is designed to be used with a dark background.
247
+ *
248
+ * If not provided, the client should assume the icon can be used with any theme.
249
+ */
250
+ theme: z.enum(['light', 'dark']).optional()
232
251
  });
233
252
  /**
234
253
  * Base schema to add `icons` property.
@@ -275,7 +294,15 @@ export const ImplementationSchema = BaseMetadataSchema.extend({
275
294
  /**
276
295
  * An optional URL of the website for this implementation.
277
296
  */
278
- websiteUrl: z.string().optional()
297
+ websiteUrl: z.string().optional(),
298
+ /**
299
+ * An optional human-readable description of what this implementation does.
300
+ *
301
+ * This can be used by clients or servers to provide context about their purpose
302
+ * and capabilities. For example, a server might describe the types of resources
303
+ * or tools it provides, while a client might describe its intended use case.
304
+ */
305
+ description: z.string().optional()
279
306
  });
280
307
  const FormElicitationCapabilitySchema = z.intersection(z.object({
281
308
  applyDefaults: z.boolean().optional()
@@ -294,71 +321,67 @@ const ElicitationCapabilitySchema = z.preprocess(value => {
294
321
  /**
295
322
  * Task capabilities for clients, indicating which request types support task creation.
296
323
  */
297
- export const ClientTasksCapabilitySchema = z
298
- .object({
324
+ export const ClientTasksCapabilitySchema = z.looseObject({
299
325
  /**
300
326
  * Present if the client supports listing tasks.
301
327
  */
302
- list: z.optional(z.object({}).passthrough()),
328
+ list: AssertObjectSchema.optional(),
303
329
  /**
304
330
  * Present if the client supports cancelling tasks.
305
331
  */
306
- cancel: z.optional(z.object({}).passthrough()),
332
+ cancel: AssertObjectSchema.optional(),
307
333
  /**
308
334
  * Capabilities for task creation on specific request types.
309
335
  */
310
- requests: z.optional(z
311
- .object({
336
+ requests: z
337
+ .looseObject({
312
338
  /**
313
339
  * Task support for sampling requests.
314
340
  */
315
- sampling: z.optional(z
316
- .object({
317
- createMessage: z.optional(z.object({}).passthrough())
341
+ sampling: z
342
+ .looseObject({
343
+ createMessage: AssertObjectSchema.optional()
318
344
  })
319
- .passthrough()),
345
+ .optional(),
320
346
  /**
321
347
  * Task support for elicitation requests.
322
348
  */
323
- elicitation: z.optional(z
324
- .object({
325
- create: z.optional(z.object({}).passthrough())
349
+ elicitation: z
350
+ .looseObject({
351
+ create: AssertObjectSchema.optional()
326
352
  })
327
- .passthrough())
353
+ .optional()
328
354
  })
329
- .passthrough())
330
- })
331
- .passthrough();
355
+ .optional()
356
+ });
332
357
  /**
333
358
  * Task capabilities for servers, indicating which request types support task creation.
334
359
  */
335
- export const ServerTasksCapabilitySchema = z
336
- .object({
360
+ export const ServerTasksCapabilitySchema = z.looseObject({
337
361
  /**
338
362
  * Present if the server supports listing tasks.
339
363
  */
340
- list: z.optional(z.object({}).passthrough()),
364
+ list: AssertObjectSchema.optional(),
341
365
  /**
342
366
  * Present if the server supports cancelling tasks.
343
367
  */
344
- cancel: z.optional(z.object({}).passthrough()),
368
+ cancel: AssertObjectSchema.optional(),
345
369
  /**
346
370
  * Capabilities for task creation on specific request types.
347
371
  */
348
- requests: z.optional(z
349
- .object({
372
+ requests: z
373
+ .looseObject({
350
374
  /**
351
375
  * Task support for tool requests.
352
376
  */
353
- tools: z.optional(z
354
- .object({
355
- call: z.optional(z.object({}).passthrough())
377
+ tools: z
378
+ .looseObject({
379
+ call: AssertObjectSchema.optional()
356
380
  })
357
- .passthrough())
381
+ .optional()
358
382
  })
359
- .passthrough())
360
- })
361
- .passthrough();
383
+ .optional()
384
+ });
362
385
  /**
363
386
  * 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.
364
387
  */
@@ -401,7 +424,7 @@ export const ClientCapabilitiesSchema = z.object({
401
424
  /**
402
425
  * Present if the client supports task creation.
403
426
  */
404
- tasks: z.optional(ClientTasksCapabilitySchema)
427
+ tasks: ClientTasksCapabilitySchema.optional()
405
428
  });
406
429
  export const InitializeRequestParamsSchema = BaseRequestParamsSchema.extend({
407
430
  /**
@@ -422,8 +445,7 @@ export const isInitializeRequest = (value) => InitializeRequestSchema.safeParse(
422
445
  /**
423
446
  * 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.
424
447
  */
425
- export const ServerCapabilitiesSchema = z
426
- .object({
448
+ export const ServerCapabilitiesSchema = z.object({
427
449
  /**
428
450
  * Experimental, non-standard capabilities that the server supports.
429
451
  */
@@ -439,12 +461,14 @@ export const ServerCapabilitiesSchema = z
439
461
  /**
440
462
  * Present if the server offers any prompt templates.
441
463
  */
442
- prompts: z.optional(z.object({
464
+ prompts: z
465
+ .object({
443
466
  /**
444
467
  * Whether this server supports issuing notifications for changes to the prompt list.
445
468
  */
446
- listChanged: z.optional(z.boolean())
447
- })),
469
+ listChanged: z.boolean().optional()
470
+ })
471
+ .optional(),
448
472
  /**
449
473
  * Present if the server offers any resources to read.
450
474
  */
@@ -474,9 +498,8 @@ export const ServerCapabilitiesSchema = z
474
498
  /**
475
499
  * Present if the server supports task creation.
476
500
  */
477
- tasks: z.optional(ServerTasksCapabilitySchema)
478
- })
479
- .passthrough();
501
+ tasks: ServerTasksCapabilitySchema.optional()
502
+ });
480
503
  /**
481
504
  * After receiving an initialize request from the client, the server sends this response.
482
505
  */
@@ -498,7 +521,8 @@ export const InitializeResultSchema = ResultSchema.extend({
498
521
  * This notification is sent from the client to the server after initialization has finished.
499
522
  */
500
523
  export const InitializedNotificationSchema = NotificationSchema.extend({
501
- method: z.literal('notifications/initialized')
524
+ method: z.literal('notifications/initialized'),
525
+ params: NotificationsParamsSchema.optional()
502
526
  });
503
527
  export const isInitializedNotification = (value) => InitializedNotificationSchema.safeParse(value).success;
504
528
  /* Ping */
@@ -506,7 +530,8 @@ export const isInitializedNotification = (value) => InitializedNotificationSchem
506
530
  * 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.
507
531
  */
508
532
  export const PingRequestSchema = RequestSchema.extend({
509
- method: z.literal('ping')
533
+ method: z.literal('ping'),
534
+ params: BaseRequestParamsSchema.optional()
510
535
  });
511
536
  /* Progress notifications */
512
537
  export const ProgressSchema = z.object({
@@ -556,15 +581,19 @@ export const PaginatedResultSchema = ResultSchema.extend({
556
581
  * An opaque token representing the pagination position after the last returned result.
557
582
  * If present, there may be more results available.
558
583
  */
559
- nextCursor: z.optional(CursorSchema)
584
+ nextCursor: CursorSchema.optional()
560
585
  });
586
+ /**
587
+ * The status of a task.
588
+ * */
589
+ export const TaskStatusSchema = z.enum(['working', 'input_required', 'completed', 'failed', 'cancelled']);
561
590
  /* Tasks */
562
591
  /**
563
592
  * A pollable state object associated with a request.
564
593
  */
565
594
  export const TaskSchema = z.object({
566
595
  taskId: z.string(),
567
- status: z.enum(['working', 'input_required', 'completed', 'failed', 'cancelled']),
596
+ status: TaskStatusSchema,
568
597
  /**
569
598
  * Time in milliseconds to keep task results available after completion.
570
599
  * If null, the task has unlimited lifetime until manually cleaned up.
@@ -623,6 +652,13 @@ export const GetTaskPayloadRequestSchema = RequestSchema.extend({
623
652
  taskId: z.string()
624
653
  })
625
654
  });
655
+ /**
656
+ * The response to a tasks/result request.
657
+ * The structure matches the result type of the original request.
658
+ * For example, a tools/call task would return the CallToolResult structure.
659
+ *
660
+ */
661
+ export const GetTaskPayloadResultSchema = ResultSchema.loose();
626
662
  /**
627
663
  * A request to list tasks.
628
664
  */
@@ -685,7 +721,7 @@ const Base64Schema = z.string().refine(val => {
685
721
  atob(val);
686
722
  return true;
687
723
  }
688
- catch (_a) {
724
+ catch {
689
725
  return false;
690
726
  }
691
727
  }, { message: 'Invalid Base64 string' });
@@ -695,6 +731,10 @@ export const BlobResourceContentsSchema = ResourceContentsSchema.extend({
695
731
  */
696
732
  blob: Base64Schema
697
733
  });
734
+ /**
735
+ * The sender or recipient of messages and data in a conversation.
736
+ */
737
+ export const RoleSchema = z.enum(['user', 'assistant']);
698
738
  /**
699
739
  * Optional annotations providing clients additional context about a resource.
700
740
  */
@@ -702,7 +742,7 @@ export const AnnotationsSchema = z.object({
702
742
  /**
703
743
  * Intended audience(s) for the resource.
704
744
  */
705
- audience: z.array(z.enum(['user', 'assistant'])).optional(),
745
+ audience: z.array(RoleSchema).optional(),
706
746
  /**
707
747
  * Importance hint for the resource, from 0 (least) to 1 (most).
708
748
  */
@@ -825,7 +865,8 @@ export const ReadResourceResultSchema = ResultSchema.extend({
825
865
  * 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.
826
866
  */
827
867
  export const ResourceListChangedNotificationSchema = NotificationSchema.extend({
828
- method: z.literal('notifications/resources/list_changed')
868
+ method: z.literal('notifications/resources/list_changed'),
869
+ params: NotificationsParamsSchema.optional()
829
870
  });
830
871
  export const SubscribeRequestParamsSchema = ResourceRequestParamsSchema;
831
872
  /**
@@ -998,8 +1039,7 @@ export const AudioContentSchema = z.object({
998
1039
  * A tool call request from an assistant (LLM).
999
1040
  * Represents the assistant's request to use a tool.
1000
1041
  */
1001
- export const ToolUseContentSchema = z
1002
- .object({
1042
+ export const ToolUseContentSchema = z.object({
1003
1043
  type: z.literal('tool_use'),
1004
1044
  /**
1005
1045
  * The name of the tool to invoke.
@@ -1015,14 +1055,13 @@ export const ToolUseContentSchema = z
1015
1055
  * Arguments to pass to the tool.
1016
1056
  * Must conform to the tool's inputSchema.
1017
1057
  */
1018
- input: z.object({}).passthrough(),
1058
+ input: z.record(z.string(), z.unknown()),
1019
1059
  /**
1020
1060
  * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
1021
1061
  * for notes on _meta usage.
1022
1062
  */
1023
- _meta: z.optional(z.object({}).passthrough())
1024
- })
1025
- .passthrough();
1063
+ _meta: z.record(z.string(), z.unknown()).optional()
1064
+ });
1026
1065
  /**
1027
1066
  * The contents of a resource, embedded into a prompt or tool call result.
1028
1067
  */
@@ -1061,7 +1100,7 @@ export const ContentBlockSchema = z.union([
1061
1100
  * Describes a message returned as part of a prompt.
1062
1101
  */
1063
1102
  export const PromptMessageSchema = z.object({
1064
- role: z.enum(['user', 'assistant']),
1103
+ role: RoleSchema,
1065
1104
  content: ContentBlockSchema
1066
1105
  });
1067
1106
  /**
@@ -1071,14 +1110,15 @@ export const GetPromptResultSchema = ResultSchema.extend({
1071
1110
  /**
1072
1111
  * An optional description for the prompt.
1073
1112
  */
1074
- description: z.optional(z.string()),
1113
+ description: z.string().optional(),
1075
1114
  messages: z.array(PromptMessageSchema)
1076
1115
  });
1077
1116
  /**
1078
1117
  * 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.
1079
1118
  */
1080
1119
  export const PromptListChangedNotificationSchema = NotificationSchema.extend({
1081
- method: z.literal('notifications/prompts/list_changed')
1120
+ method: z.literal('notifications/prompts/list_changed'),
1121
+ params: NotificationsParamsSchema.optional()
1082
1122
  });
1083
1123
  /* Tools */
1084
1124
  /**
@@ -1181,11 +1221,11 @@ export const ToolSchema = z.object({
1181
1221
  /**
1182
1222
  * Optional additional tool information.
1183
1223
  */
1184
- annotations: z.optional(ToolAnnotationsSchema),
1224
+ annotations: ToolAnnotationsSchema.optional(),
1185
1225
  /**
1186
1226
  * Execution-related properties for this tool.
1187
1227
  */
1188
- execution: z.optional(ToolExecutionSchema),
1228
+ execution: ToolExecutionSchema.optional(),
1189
1229
  /**
1190
1230
  * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
1191
1231
  * for notes on _meta usage.
@@ -1235,7 +1275,7 @@ export const CallToolResultSchema = ResultSchema.extend({
1235
1275
  * server does not support tool calls, or any other exceptional conditions,
1236
1276
  * should be reported as an MCP error response.
1237
1277
  */
1238
- isError: z.optional(z.boolean())
1278
+ isError: z.boolean().optional()
1239
1279
  });
1240
1280
  /**
1241
1281
  * CallToolResultSchema extended with backwards compatibility to protocol version 2024-10-07.
@@ -1246,7 +1286,7 @@ export const CompatibilityCallToolResultSchema = CallToolResultSchema.or(ResultS
1246
1286
  /**
1247
1287
  * Parameters for a `tools/call` request.
1248
1288
  */
1249
- export const CallToolRequestParamsSchema = BaseRequestParamsSchema.extend({
1289
+ export const CallToolRequestParamsSchema = TaskAugmentedRequestParamsSchema.extend({
1250
1290
  /**
1251
1291
  * The name of the tool to call.
1252
1292
  */
@@ -1254,7 +1294,7 @@ export const CallToolRequestParamsSchema = BaseRequestParamsSchema.extend({
1254
1294
  /**
1255
1295
  * Arguments to pass to the tool.
1256
1296
  */
1257
- arguments: z.optional(z.record(z.string(), z.unknown()))
1297
+ arguments: z.record(z.string(), z.unknown()).optional()
1258
1298
  });
1259
1299
  /**
1260
1300
  * Used by the client to invoke a tool provided by the server.
@@ -1267,7 +1307,32 @@ export const CallToolRequestSchema = RequestSchema.extend({
1267
1307
  * 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.
1268
1308
  */
1269
1309
  export const ToolListChangedNotificationSchema = NotificationSchema.extend({
1270
- method: z.literal('notifications/tools/list_changed')
1310
+ method: z.literal('notifications/tools/list_changed'),
1311
+ params: NotificationsParamsSchema.optional()
1312
+ });
1313
+ /**
1314
+ * Base schema for list changed subscription options (without callback).
1315
+ * Used internally for Zod validation of autoRefresh and debounceMs.
1316
+ */
1317
+ export const ListChangedOptionsBaseSchema = z.object({
1318
+ /**
1319
+ * If true, the list will be refreshed automatically when a list changed notification is received.
1320
+ * The callback will be called with the updated list.
1321
+ *
1322
+ * If false, the callback will be called with null items, allowing manual refresh.
1323
+ *
1324
+ * @default true
1325
+ */
1326
+ autoRefresh: z.boolean().default(true),
1327
+ /**
1328
+ * Debounce time in milliseconds for list changed notification processing.
1329
+ *
1330
+ * Multiple notifications received within this timeframe will only trigger one refresh.
1331
+ * Set to 0 to disable debouncing.
1332
+ *
1333
+ * @default 300
1334
+ */
1335
+ debounceMs: z.number().int().nonnegative().default(300)
1271
1336
  });
1272
1337
  /* Logging */
1273
1338
  /**
@@ -1331,19 +1396,19 @@ export const ModelPreferencesSchema = z.object({
1331
1396
  /**
1332
1397
  * Optional hints to use for model selection.
1333
1398
  */
1334
- hints: z.optional(z.array(ModelHintSchema)),
1399
+ hints: z.array(ModelHintSchema).optional(),
1335
1400
  /**
1336
1401
  * How much to prioritize cost when selecting a model.
1337
1402
  */
1338
- costPriority: z.optional(z.number().min(0).max(1)),
1403
+ costPriority: z.number().min(0).max(1).optional(),
1339
1404
  /**
1340
1405
  * How much to prioritize sampling speed (latency) when selecting a model.
1341
1406
  */
1342
- speedPriority: z.optional(z.number().min(0).max(1)),
1407
+ speedPriority: z.number().min(0).max(1).optional(),
1343
1408
  /**
1344
1409
  * How much to prioritize intelligence and capabilities when selecting a model.
1345
1410
  */
1346
- intelligencePriority: z.optional(z.number().min(0).max(1))
1411
+ intelligencePriority: z.number().min(0).max(1).optional()
1347
1412
  });
1348
1413
  /**
1349
1414
  * Controls tool usage behavior in sampling requests.
@@ -1355,26 +1420,24 @@ export const ToolChoiceSchema = z.object({
1355
1420
  * - "required": Model MUST use at least one tool before completing
1356
1421
  * - "none": Model MUST NOT use any tools
1357
1422
  */
1358
- mode: z.optional(z.enum(['auto', 'required', 'none']))
1423
+ mode: z.enum(['auto', 'required', 'none']).optional()
1359
1424
  });
1360
1425
  /**
1361
1426
  * The result of a tool execution, provided by the user (server).
1362
1427
  * Represents the outcome of invoking a tool requested via ToolUseContent.
1363
1428
  */
1364
- export const ToolResultContentSchema = z
1365
- .object({
1429
+ export const ToolResultContentSchema = z.object({
1366
1430
  type: z.literal('tool_result'),
1367
1431
  toolUseId: z.string().describe('The unique identifier for the corresponding tool call.'),
1368
1432
  content: z.array(ContentBlockSchema).default([]),
1369
- structuredContent: z.object({}).passthrough().optional(),
1370
- isError: z.optional(z.boolean()),
1433
+ structuredContent: z.object({}).loose().optional(),
1434
+ isError: z.boolean().optional(),
1371
1435
  /**
1372
1436
  * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
1373
1437
  * for notes on _meta usage.
1374
1438
  */
1375
- _meta: z.optional(z.object({}).passthrough())
1376
- })
1377
- .passthrough();
1439
+ _meta: z.record(z.string(), z.unknown()).optional()
1440
+ });
1378
1441
  /**
1379
1442
  * Basic content types for sampling responses (without tool use).
1380
1443
  * Used for backwards-compatible CreateMessageResult when tools are not used.
@@ -1394,21 +1457,19 @@ export const SamplingMessageContentBlockSchema = z.discriminatedUnion('type', [
1394
1457
  /**
1395
1458
  * Describes a message issued to or received from an LLM API.
1396
1459
  */
1397
- export const SamplingMessageSchema = z
1398
- .object({
1399
- role: z.enum(['user', 'assistant']),
1460
+ export const SamplingMessageSchema = z.object({
1461
+ role: RoleSchema,
1400
1462
  content: z.union([SamplingMessageContentBlockSchema, z.array(SamplingMessageContentBlockSchema)]),
1401
1463
  /**
1402
1464
  * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
1403
1465
  * for notes on _meta usage.
1404
1466
  */
1405
- _meta: z.optional(z.object({}).passthrough())
1406
- })
1407
- .passthrough();
1467
+ _meta: z.record(z.string(), z.unknown()).optional()
1468
+ });
1408
1469
  /**
1409
1470
  * Parameters for a `sampling/createMessage` request.
1410
1471
  */
1411
- export const CreateMessageRequestParamsSchema = BaseRequestParamsSchema.extend({
1472
+ export const CreateMessageRequestParamsSchema = TaskAugmentedRequestParamsSchema.extend({
1412
1473
  messages: z.array(SamplingMessageSchema),
1413
1474
  /**
1414
1475
  * The server's preferences for which model to select. The client MAY modify or omit this request.
@@ -1442,13 +1503,13 @@ export const CreateMessageRequestParamsSchema = BaseRequestParamsSchema.extend({
1442
1503
  * Tools that the model may use during generation.
1443
1504
  * The client MUST return an error if this field is provided but ClientCapabilities.sampling.tools is not declared.
1444
1505
  */
1445
- tools: z.optional(z.array(ToolSchema)),
1506
+ tools: z.array(ToolSchema).optional(),
1446
1507
  /**
1447
1508
  * Controls how the model uses tools.
1448
1509
  * The client MUST return an error if this field is provided but ClientCapabilities.sampling.tools is not declared.
1449
1510
  * Default is `{ mode: "auto" }`.
1450
1511
  */
1451
- toolChoice: z.optional(ToolChoiceSchema)
1512
+ toolChoice: ToolChoiceSchema.optional()
1452
1513
  });
1453
1514
  /**
1454
1515
  * 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.
@@ -1478,7 +1539,7 @@ export const CreateMessageResultSchema = ResultSchema.extend({
1478
1539
  * This field is an open string to allow for provider-specific stop reasons.
1479
1540
  */
1480
1541
  stopReason: z.optional(z.enum(['endTurn', 'stopSequence', 'maxTokens']).or(z.string())),
1481
- role: z.enum(['user', 'assistant']),
1542
+ role: RoleSchema,
1482
1543
  /**
1483
1544
  * Response content. Single content block (text, image, or audio).
1484
1545
  */
@@ -1505,7 +1566,7 @@ export const CreateMessageResultWithToolsSchema = ResultSchema.extend({
1505
1566
  * This field is an open string to allow for provider-specific stop reasons.
1506
1567
  */
1507
1568
  stopReason: z.optional(z.enum(['endTurn', 'stopSequence', 'maxTokens', 'toolUse']).or(z.string())),
1508
- role: z.enum(['user', 'assistant']),
1569
+ role: RoleSchema,
1509
1570
  /**
1510
1571
  * Response content. May be a single block or array. May include ToolUseContent if stopReason is "toolUse".
1511
1572
  */
@@ -1628,7 +1689,7 @@ export const PrimitiveSchemaDefinitionSchema = z.union([EnumSchemaSchema, Boolea
1628
1689
  /**
1629
1690
  * Parameters for an `elicitation/create` request for form-based elicitation.
1630
1691
  */
1631
- export const ElicitRequestFormParamsSchema = BaseRequestParamsSchema.extend({
1692
+ export const ElicitRequestFormParamsSchema = TaskAugmentedRequestParamsSchema.extend({
1632
1693
  /**
1633
1694
  * The elicitation mode.
1634
1695
  *
@@ -1652,7 +1713,7 @@ export const ElicitRequestFormParamsSchema = BaseRequestParamsSchema.extend({
1652
1713
  /**
1653
1714
  * Parameters for an `elicitation/create` request for URL-based elicitation.
1654
1715
  */
1655
- export const ElicitRequestURLParamsSchema = BaseRequestParamsSchema.extend({
1716
+ export const ElicitRequestURLParamsSchema = TaskAugmentedRequestParamsSchema.extend({
1656
1717
  /**
1657
1718
  * The elicitation mode.
1658
1719
  */
@@ -1836,7 +1897,8 @@ export const RootSchema = z.object({
1836
1897
  * Sent from the server to request a list of root URIs from the client.
1837
1898
  */
1838
1899
  export const ListRootsRequestSchema = RequestSchema.extend({
1839
- method: z.literal('roots/list')
1900
+ method: z.literal('roots/list'),
1901
+ params: BaseRequestParamsSchema.optional()
1840
1902
  });
1841
1903
  /**
1842
1904
  * The client's response to a roots/list request from the server.
@@ -1848,7 +1910,8 @@ export const ListRootsResultSchema = ResultSchema.extend({
1848
1910
  * A notification from the client to the server, informing it that the list of roots has changed.
1849
1911
  */
1850
1912
  export const RootsListChangedNotificationSchema = NotificationSchema.extend({
1851
- method: z.literal('notifications/roots/list_changed')
1913
+ method: z.literal('notifications/roots/list_changed'),
1914
+ params: NotificationsParamsSchema.optional()
1852
1915
  });
1853
1916
  /* Client messages */
1854
1917
  export const ClientRequestSchema = z.union([
@@ -1867,7 +1930,8 @@ export const ClientRequestSchema = z.union([
1867
1930
  ListToolsRequestSchema,
1868
1931
  GetTaskRequestSchema,
1869
1932
  GetTaskPayloadRequestSchema,
1870
- ListTasksRequestSchema
1933
+ ListTasksRequestSchema,
1934
+ CancelTaskRequestSchema
1871
1935
  ]);
1872
1936
  export const ClientNotificationSchema = z.union([
1873
1937
  CancelledNotificationSchema,
@@ -1894,7 +1958,8 @@ export const ServerRequestSchema = z.union([
1894
1958
  ListRootsRequestSchema,
1895
1959
  GetTaskRequestSchema,
1896
1960
  GetTaskPayloadRequestSchema,
1897
- ListTasksRequestSchema
1961
+ ListTasksRequestSchema,
1962
+ CancelTaskRequestSchema
1898
1963
  ]);
1899
1964
  export const ServerNotificationSchema = z.union([
1900
1965
  CancelledNotificationSchema,
@@ -1955,8 +2020,7 @@ export class UrlElicitationRequiredError extends McpError {
1955
2020
  });
1956
2021
  }
1957
2022
  get elicitations() {
1958
- var _a, _b;
1959
- return (_b = (_a = this.data) === null || _a === void 0 ? void 0 : _a.elicitations) !== null && _b !== void 0 ? _b : [];
2023
+ return this.data?.elicitations ?? [];
1960
2024
  }
1961
2025
  }
1962
2026
  //# sourceMappingURL=types.js.map