effect 4.0.0-beta.10 → 4.0.0-beta.12

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 (189) hide show
  1. package/dist/Channel.d.ts +7 -7
  2. package/dist/Config.d.ts +157 -0
  3. package/dist/Config.d.ts.map +1 -1
  4. package/dist/Config.js +56 -1
  5. package/dist/Config.js.map +1 -1
  6. package/dist/Effect.d.ts +296 -8
  7. package/dist/Effect.d.ts.map +1 -1
  8. package/dist/Effect.js +72 -0
  9. package/dist/Effect.js.map +1 -1
  10. package/dist/ErrorReporter.d.ts +376 -0
  11. package/dist/ErrorReporter.d.ts.map +1 -0
  12. package/dist/ErrorReporter.js +246 -0
  13. package/dist/ErrorReporter.js.map +1 -0
  14. package/dist/Fiber.d.ts +2 -2
  15. package/dist/Fiber.d.ts.map +1 -1
  16. package/dist/Fiber.js.map +1 -1
  17. package/dist/Graph.d.ts.map +1 -1
  18. package/dist/Graph.js +3 -6
  19. package/dist/Graph.js.map +1 -1
  20. package/dist/LogLevel.d.ts +5 -0
  21. package/dist/LogLevel.d.ts.map +1 -1
  22. package/dist/LogLevel.js.map +1 -1
  23. package/dist/Logger.d.ts +25 -91
  24. package/dist/Logger.d.ts.map +1 -1
  25. package/dist/Logger.js +2 -3
  26. package/dist/Logger.js.map +1 -1
  27. package/dist/Queue.d.ts.map +1 -1
  28. package/dist/Queue.js +0 -1
  29. package/dist/Queue.js.map +1 -1
  30. package/dist/Random.d.ts +17 -0
  31. package/dist/Random.d.ts.map +1 -1
  32. package/dist/Random.js +17 -0
  33. package/dist/Random.js.map +1 -1
  34. package/dist/References.d.ts +3 -3
  35. package/dist/References.d.ts.map +1 -1
  36. package/dist/Schema.d.ts +3 -1
  37. package/dist/Schema.d.ts.map +1 -1
  38. package/dist/SchemaAST.d.ts.map +1 -1
  39. package/dist/SchemaAST.js +2 -1
  40. package/dist/SchemaAST.js.map +1 -1
  41. package/dist/Stream.d.ts +5 -5
  42. package/dist/index.d.ts +4 -0
  43. package/dist/index.d.ts.map +1 -1
  44. package/dist/index.js +4 -0
  45. package/dist/index.js.map +1 -1
  46. package/dist/internal/effect.js +98 -33
  47. package/dist/internal/effect.js.map +1 -1
  48. package/dist/internal/hashMap.js +2 -2
  49. package/dist/internal/hashMap.js.map +1 -1
  50. package/dist/unstable/ai/LanguageModel.d.ts.map +1 -1
  51. package/dist/unstable/ai/LanguageModel.js +86 -14
  52. package/dist/unstable/ai/LanguageModel.js.map +1 -1
  53. package/dist/unstable/ai/McpSchema.d.ts +112 -36
  54. package/dist/unstable/ai/McpSchema.d.ts.map +1 -1
  55. package/dist/unstable/ai/McpSchema.js +47 -10
  56. package/dist/unstable/ai/McpSchema.js.map +1 -1
  57. package/dist/unstable/ai/McpServer.d.ts.map +1 -1
  58. package/dist/unstable/ai/McpServer.js +33 -6
  59. package/dist/unstable/ai/McpServer.js.map +1 -1
  60. package/dist/unstable/ai/Tool.d.ts +16 -0
  61. package/dist/unstable/ai/Tool.d.ts.map +1 -1
  62. package/dist/unstable/ai/Tool.js +14 -0
  63. package/dist/unstable/ai/Tool.js.map +1 -1
  64. package/dist/unstable/cli/CliOutput.js +37 -6
  65. package/dist/unstable/cli/CliOutput.js.map +1 -1
  66. package/dist/unstable/cli/Command.d.ts +199 -7
  67. package/dist/unstable/cli/Command.d.ts.map +1 -1
  68. package/dist/unstable/cli/Command.js +116 -6
  69. package/dist/unstable/cli/Command.js.map +1 -1
  70. package/dist/unstable/cli/HelpDoc.d.ts +60 -2
  71. package/dist/unstable/cli/HelpDoc.d.ts.map +1 -1
  72. package/dist/unstable/cli/internal/command.d.ts +11 -1
  73. package/dist/unstable/cli/internal/command.d.ts.map +1 -1
  74. package/dist/unstable/cli/internal/command.js +33 -8
  75. package/dist/unstable/cli/internal/command.js.map +1 -1
  76. package/dist/unstable/cli/internal/completions/CommandDescriptor.js +7 -2
  77. package/dist/unstable/cli/internal/completions/CommandDescriptor.js.map +1 -1
  78. package/dist/unstable/cli/internal/parser.js +10 -2
  79. package/dist/unstable/cli/internal/parser.js.map +1 -1
  80. package/dist/unstable/cluster/ClusterWorkflowEngine.d.ts.map +1 -1
  81. package/dist/unstable/cluster/ClusterWorkflowEngine.js +2 -2
  82. package/dist/unstable/cluster/ClusterWorkflowEngine.js.map +1 -1
  83. package/dist/unstable/http/Headers.d.ts.map +1 -1
  84. package/dist/unstable/http/Headers.js +27 -10
  85. package/dist/unstable/http/Headers.js.map +1 -1
  86. package/dist/unstable/http/HttpClient.d.ts +28 -4
  87. package/dist/unstable/http/HttpClient.d.ts.map +1 -1
  88. package/dist/unstable/http/HttpClient.js.map +1 -1
  89. package/dist/unstable/http/HttpEffect.d.ts +3 -8
  90. package/dist/unstable/http/HttpEffect.d.ts.map +1 -1
  91. package/dist/unstable/http/HttpEffect.js +25 -31
  92. package/dist/unstable/http/HttpEffect.js.map +1 -1
  93. package/dist/unstable/http/HttpMiddleware.d.ts.map +1 -1
  94. package/dist/unstable/http/HttpMiddleware.js +4 -8
  95. package/dist/unstable/http/HttpMiddleware.js.map +1 -1
  96. package/dist/unstable/http/HttpServerError.d.ts +14 -27
  97. package/dist/unstable/http/HttpServerError.d.ts.map +1 -1
  98. package/dist/unstable/http/HttpServerError.js +37 -44
  99. package/dist/unstable/http/HttpServerError.js.map +1 -1
  100. package/dist/unstable/http/HttpServerRespondable.d.ts +2 -2
  101. package/dist/unstable/http/HttpServerRespondable.d.ts.map +1 -1
  102. package/dist/unstable/http/HttpServerRespondable.js +5 -5
  103. package/dist/unstable/http/HttpServerRespondable.js.map +1 -1
  104. package/dist/unstable/http/HttpServerResponse.d.ts +2 -1
  105. package/dist/unstable/http/HttpServerResponse.d.ts.map +1 -1
  106. package/dist/unstable/http/HttpServerResponse.js +2 -0
  107. package/dist/unstable/http/HttpServerResponse.js.map +1 -1
  108. package/dist/unstable/http/internal/preResponseHandler.d.ts +2 -0
  109. package/dist/unstable/http/internal/preResponseHandler.d.ts.map +1 -0
  110. package/dist/unstable/http/internal/preResponseHandler.js +10 -0
  111. package/dist/unstable/http/internal/preResponseHandler.js.map +1 -0
  112. package/dist/unstable/httpapi/HttpApiBuilder.d.ts +1 -1
  113. package/dist/unstable/httpapi/HttpApiBuilder.d.ts.map +1 -1
  114. package/dist/unstable/httpapi/HttpApiBuilder.js +1 -1
  115. package/dist/unstable/httpapi/HttpApiBuilder.js.map +1 -1
  116. package/dist/unstable/httpapi/HttpApiError.d.ts +11 -0
  117. package/dist/unstable/httpapi/HttpApiError.d.ts.map +1 -1
  118. package/dist/unstable/httpapi/HttpApiError.js +29 -9
  119. package/dist/unstable/httpapi/HttpApiError.js.map +1 -1
  120. package/dist/unstable/observability/OtlpLogger.d.ts.map +1 -1
  121. package/dist/unstable/observability/OtlpLogger.js +7 -4
  122. package/dist/unstable/observability/OtlpLogger.js.map +1 -1
  123. package/dist/unstable/reactivity/Atom.js +1 -1
  124. package/dist/unstable/reactivity/Atom.js.map +1 -1
  125. package/dist/unstable/reactivity/AtomRegistry.d.ts +6 -0
  126. package/dist/unstable/reactivity/AtomRegistry.d.ts.map +1 -1
  127. package/dist/unstable/reactivity/AtomRegistry.js +22 -1
  128. package/dist/unstable/reactivity/AtomRegistry.js.map +1 -1
  129. package/dist/unstable/rpc/RpcSchema.d.ts +13 -0
  130. package/dist/unstable/rpc/RpcSchema.d.ts.map +1 -1
  131. package/dist/unstable/rpc/RpcSchema.js +14 -0
  132. package/dist/unstable/rpc/RpcSchema.js.map +1 -1
  133. package/dist/unstable/rpc/RpcSerialization.d.ts.map +1 -1
  134. package/dist/unstable/rpc/RpcSerialization.js +34 -9
  135. package/dist/unstable/rpc/RpcSerialization.js.map +1 -1
  136. package/dist/unstable/rpc/RpcServer.d.ts +0 -7
  137. package/dist/unstable/rpc/RpcServer.d.ts.map +1 -1
  138. package/dist/unstable/rpc/RpcServer.js +9 -10
  139. package/dist/unstable/rpc/RpcServer.js.map +1 -1
  140. package/dist/unstable/workflow/WorkflowEngine.d.ts +6 -0
  141. package/dist/unstable/workflow/WorkflowEngine.d.ts.map +1 -1
  142. package/dist/unstable/workflow/WorkflowEngine.js +131 -0
  143. package/dist/unstable/workflow/WorkflowEngine.js.map +1 -1
  144. package/package.json +1 -1
  145. package/src/Channel.ts +9 -9
  146. package/src/Config.ts +171 -9
  147. package/src/Effect.ts +315 -8
  148. package/src/ErrorReporter.ts +459 -0
  149. package/src/Fiber.ts +9 -2
  150. package/src/Graph.ts +16 -6
  151. package/src/LogLevel.ts +6 -0
  152. package/src/Logger.ts +28 -95
  153. package/src/Queue.ts +0 -1
  154. package/src/Random.ts +18 -0
  155. package/src/References.ts +4 -4
  156. package/src/Schema.ts +1 -1
  157. package/src/SchemaAST.ts +2 -1
  158. package/src/Stream.ts +7 -7
  159. package/src/index.ts +5 -0
  160. package/src/internal/effect.ts +205 -49
  161. package/src/internal/hashMap.ts +2 -2
  162. package/src/unstable/ai/LanguageModel.ts +117 -16
  163. package/src/unstable/ai/McpSchema.ts +57 -11
  164. package/src/unstable/ai/McpServer.ts +44 -6
  165. package/src/unstable/ai/Tool.ts +15 -0
  166. package/src/unstable/cli/CliOutput.ts +45 -6
  167. package/src/unstable/cli/Command.ts +298 -11
  168. package/src/unstable/cli/HelpDoc.ts +68 -2
  169. package/src/unstable/cli/internal/command.ts +47 -11
  170. package/src/unstable/cli/internal/completions/CommandDescriptor.ts +7 -2
  171. package/src/unstable/cli/internal/parser.ts +11 -3
  172. package/src/unstable/cluster/ClusterWorkflowEngine.ts +2 -2
  173. package/src/unstable/http/Headers.ts +28 -13
  174. package/src/unstable/http/HttpClient.ts +45 -10
  175. package/src/unstable/http/HttpEffect.ts +30 -44
  176. package/src/unstable/http/HttpMiddleware.ts +4 -14
  177. package/src/unstable/http/HttpServerError.ts +42 -45
  178. package/src/unstable/http/HttpServerRespondable.ts +6 -6
  179. package/src/unstable/http/HttpServerResponse.ts +3 -1
  180. package/src/unstable/http/internal/preResponseHandler.ts +15 -0
  181. package/src/unstable/httpapi/HttpApiBuilder.ts +2 -1
  182. package/src/unstable/httpapi/HttpApiError.ts +30 -9
  183. package/src/unstable/observability/OtlpLogger.ts +9 -5
  184. package/src/unstable/reactivity/Atom.ts +1 -1
  185. package/src/unstable/reactivity/AtomRegistry.ts +29 -1
  186. package/src/unstable/rpc/RpcSchema.ts +17 -0
  187. package/src/unstable/rpc/RpcSerialization.ts +44 -9
  188. package/src/unstable/rpc/RpcServer.ts +14 -19
  189. package/src/unstable/workflow/WorkflowEngine.ts +178 -0
@@ -240,6 +240,11 @@ export class ClientCapabilities extends Schema.Class<ClientCapabilities>(
240
240
  * Experimental, non-standard capabilities that the client supports.
241
241
  */
242
242
  experimental: optional(Schema.Record(Schema.String, Schema.Struct({}))),
243
+ /**
244
+ * Optional extensions capabilities advertised by the client.
245
+ * Keys are extension identifiers following <vendor-prefix>/<extension-name> (e.g. "io.modelcontextprotocol/ui").
246
+ */
247
+ extensions: optional(Schema.Record(Schema.TemplateLiteral([Schema.String, "/", Schema.String]), Schema.Unknown)),
243
248
  /**
244
249
  * Present if the client supports listing roots.
245
250
  */
@@ -272,6 +277,11 @@ export class ServerCapabilities extends Schema.Opaque<ServerCapabilities>()(Sche
272
277
  * Experimental, non-standard capabilities that the server supports.
273
278
  */
274
279
  experimental: optional(Schema.Record(Schema.String, Schema.Struct({}))),
280
+ /**
281
+ * Optional extensions capabilities advertised by the server.
282
+ * Keys are extension identifiers following <vendor-prefix>/<extension-name> (e.g. "io.modelcontextprotocol/ui").
283
+ */
284
+ extensions: optional(Schema.Record(Schema.TemplateLiteral([Schema.String, "/", Schema.String]), Schema.Unknown)),
275
285
  /**
276
286
  * Present if the server supports sending log messages to the client.
277
287
  */
@@ -321,8 +331,8 @@ export class ServerCapabilities extends Schema.Opaque<ServerCapabilities>()(Sche
321
331
  * @since 4.0.0
322
332
  * @category errors
323
333
  */
324
- export class McpError extends Schema.Class<McpError>(
325
- "@effect/ai/McpSchema/McpError"
334
+ export class McpErrorBase extends Schema.Class<McpErrorBase>(
335
+ "@effect/ai/McpSchema/McpErrorBase"
326
336
  )({
327
337
  /**
328
338
  * The error type that occurred.
@@ -371,7 +381,7 @@ export const PARSE_ERROR_CODE = -32700 as const
371
381
  * @category errors
372
382
  */
373
383
  export class ParseError extends Schema.ErrorClass<ParseError>("effect/ai/McpSchema/ParseError")({
374
- ...McpError.fields,
384
+ ...McpErrorBase.fields,
375
385
  _tag: Schema.tag("ParseError"),
376
386
  code: Schema.tag(PARSE_ERROR_CODE)
377
387
  }) {}
@@ -381,7 +391,7 @@ export class ParseError extends Schema.ErrorClass<ParseError>("effect/ai/McpSche
381
391
  * @category errors
382
392
  */
383
393
  export class InvalidRequest extends Schema.ErrorClass<InvalidRequest>("effect/ai/McpSchema/InvalidRequest")({
384
- ...McpError.fields,
394
+ ...McpErrorBase.fields,
385
395
  _tag: Schema.tag("InvalidRequest"),
386
396
  code: Schema.tag(INVALID_REQUEST_ERROR_CODE)
387
397
  }) {}
@@ -391,7 +401,7 @@ export class InvalidRequest extends Schema.ErrorClass<InvalidRequest>("effect/ai
391
401
  * @category errors
392
402
  */
393
403
  export class MethodNotFound extends Schema.ErrorClass<MethodNotFound>("effect/ai/McpSchema/MethodNotFound")({
394
- ...McpError.fields,
404
+ ...McpErrorBase.fields,
395
405
  _tag: Schema.tag("MethodNotFound"),
396
406
  code: Schema.tag(METHOD_NOT_FOUND_ERROR_CODE)
397
407
  }) {}
@@ -401,7 +411,7 @@ export class MethodNotFound extends Schema.ErrorClass<MethodNotFound>("effect/ai
401
411
  * @category errors
402
412
  */
403
413
  export class InvalidParams extends Schema.ErrorClass<InvalidParams>("effect/ai/McpSchema/InvalidParams")({
404
- ...McpError.fields,
414
+ ...McpErrorBase.fields,
405
415
  _tag: Schema.tag("InvalidParams"),
406
416
  code: Schema.tag(INVALID_PARAMS_ERROR_CODE)
407
417
  }) {}
@@ -411,13 +421,26 @@ export class InvalidParams extends Schema.ErrorClass<InvalidParams>("effect/ai/M
411
421
  * @category errors
412
422
  */
413
423
  export class InternalError extends Schema.ErrorClass<InternalError>("effect/ai/McpSchema/InternalError")({
414
- ...McpError.fields,
424
+ ...McpErrorBase.fields,
415
425
  _tag: Schema.tag("InternalError"),
416
426
  code: Schema.tag(INTERNAL_ERROR_CODE)
417
427
  }) {
418
428
  static readonly notImplemented = new InternalError({ message: "Not implemented" })
419
429
  }
420
430
 
431
+ /**
432
+ * @since 4.0.0
433
+ * @category errors
434
+ */
435
+ export const McpError = Schema.Union([
436
+ ParseError,
437
+ InvalidRequest,
438
+ MethodNotFound,
439
+ InvalidParams,
440
+ InternalError,
441
+ McpErrorBase
442
+ ])
443
+
421
444
  // =============================================================================
422
445
  // Ping
423
446
  // =============================================================================
@@ -615,7 +638,14 @@ export class Resource extends Schema.Class<Resource>(
615
638
  * This can be used by Hosts to display file sizes and estimate context
616
639
  * window usage.
617
640
  */
618
- size: optional(Schema.Number)
641
+ size: optional(Schema.Number),
642
+ /**
643
+ * Optional additional metadata for the client.
644
+ *
645
+ * This parameter name is reserved by MCP to allow clients and servers to
646
+ * attach additional metadata to resources.
647
+ */
648
+ _meta: optional(Schema.Record(Schema.String, Schema.Unknown))
619
649
  }) {}
620
650
 
621
651
  /**
@@ -656,7 +686,12 @@ export class ResourceTemplate extends Schema.Class<ResourceTemplate>(
656
686
  /**
657
687
  * Optional annotations for the client.
658
688
  */
659
- annotations: optional(Annotations)
689
+ annotations: optional(Annotations),
690
+
691
+ /**
692
+ * Optional additional metadata for the client.
693
+ */
694
+ _meta: optional(Schema.Record(Schema.String, Schema.Unknown))
660
695
  }) {}
661
696
 
662
697
  /**
@@ -673,7 +708,11 @@ export class ResourceContents extends Schema.Opaque<ResourceContents>()(Schema.S
673
708
  /**
674
709
  * The MIME type of this resource, if known.
675
710
  */
676
- mimeType: optional(Schema.String)
711
+ mimeType: optional(Schema.String),
712
+ /**
713
+ * Optional additional metadata for the client.
714
+ */
715
+ _meta: optional(Schema.Record(Schema.String, Schema.Unknown))
677
716
  })) {}
678
717
 
679
718
  /**
@@ -1183,7 +1222,14 @@ export class Tool extends Schema.Class<Tool>(
1183
1222
  /**
1184
1223
  * Optional additional tool information.
1185
1224
  */
1186
- annotations: optional(ToolAnnotations)
1225
+ annotations: optional(ToolAnnotations),
1226
+ /**
1227
+ * Optional additional metadata for the client.
1228
+ *
1229
+ * This parameter name is reserved by MCP to allow clients and servers to
1230
+ * attach additional metadata to resources.
1231
+ */
1232
+ _meta: optional(Schema.Record(Schema.String, Schema.Unknown))
1187
1233
  }) {}
1188
1234
 
1189
1235
  /**
@@ -9,6 +9,7 @@ import * as Layer from "../../Layer.ts"
9
9
  import * as Option from "../../Option.ts"
10
10
  import * as Queue from "../../Queue.ts"
11
11
  import * as RcMap from "../../RcMap.ts"
12
+ import { CurrentLogLevel } from "../../References.ts"
12
13
  import * as Schema from "../../Schema.ts"
13
14
  import * as AST from "../../SchemaAST.ts"
14
15
  import * as ServiceMap from "../../ServiceMap.ts"
@@ -548,6 +549,7 @@ export const registerToolkit: <Tools extends Record<string, Tool.Any>>(
548
549
  >)
549
550
  const services = yield* Effect.services<never>()
550
551
  for (const tool of Object.values(built.tools)) {
552
+ const toolMeta = ServiceMap.getOrUndefined(tool.annotations, Tool.Meta)
551
553
  const mcpTool = new McpTool({
552
554
  name: tool.name,
553
555
  description: Tool.getDescription(tool),
@@ -561,7 +563,8 @@ export const registerToolkit: <Tools extends Record<string, Tool.Any>>(
561
563
  destructiveHint: ServiceMap.get(tool.annotations, Tool.Destructive),
562
564
  idempotentHint: ServiceMap.get(tool.annotations, Tool.Idempotent),
563
565
  openWorldHint: ServiceMap.get(tool.annotations, Tool.OpenWorld)
564
- }
566
+ },
567
+ _meta: toolMeta
565
568
  })
566
569
  yield* registry.addTool({
567
570
  tool: mcpTool,
@@ -1075,6 +1078,7 @@ const layerHandlers = (serverInfo: {
1075
1078
  ClientRpcs.toLayer(
1076
1079
  Effect.gen(function*() {
1077
1080
  const server = yield* McpServer
1081
+ let currentLogLevel = yield* CurrentLogLevel
1078
1082
 
1079
1083
  return ClientRpcs.of({
1080
1084
  // Requests
@@ -1105,17 +1109,51 @@ const layerHandlers = (serverInfo: {
1105
1109
  : LATEST_PROTOCOL_VERSION
1106
1110
  })
1107
1111
  },
1108
- "completion/complete": server.completion,
1109
- "logging/setLevel": () => InternalError.notImplemented.asEffect(),
1110
- "prompts/get": server.getPromptResult,
1112
+ "completion/complete": (r) =>
1113
+ server.completion(r).pipe(
1114
+ Effect.provideService(CurrentLogLevel, currentLogLevel)
1115
+ ),
1116
+ "logging/setLevel": ({ level }) =>
1117
+ Effect.sync(() => {
1118
+ switch (level) {
1119
+ case "notice":
1120
+ case "info":
1121
+ currentLogLevel = "Info"
1122
+ break
1123
+ case "error":
1124
+ currentLogLevel = "Error"
1125
+ break
1126
+ case "debug":
1127
+ currentLogLevel = "Debug"
1128
+ break
1129
+ case "warning":
1130
+ currentLogLevel = "Warn"
1131
+ break
1132
+ case "critical":
1133
+ case "alert":
1134
+ case "emergency":
1135
+ currentLogLevel = "Fatal"
1136
+ break
1137
+ }
1138
+ }),
1139
+ "prompts/get": (r) =>
1140
+ server.getPromptResult(r).pipe(
1141
+ Effect.provideService(CurrentLogLevel, currentLogLevel)
1142
+ ),
1111
1143
  "prompts/list": () => Effect.sync(() => new ListPromptsResult({ prompts: server.prompts })),
1112
1144
  "resources/list": () => Effect.sync(() => new ListResourcesResult({ resources: server.resources })),
1113
- "resources/read": ({ uri }) => server.findResource(uri),
1145
+ "resources/read": ({ uri }) =>
1146
+ server.findResource(uri).pipe(
1147
+ Effect.provideService(CurrentLogLevel, currentLogLevel)
1148
+ ),
1114
1149
  "resources/subscribe": () => InternalError.notImplemented.asEffect(),
1115
1150
  "resources/unsubscribe": () => InternalError.notImplemented.asEffect(),
1116
1151
  "resources/templates/list": () =>
1117
1152
  Effect.sync(() => new ListResourceTemplatesResult({ resourceTemplates: server.resourceTemplates })),
1118
- "tools/call": server.callTool,
1153
+ "tools/call": (r) =>
1154
+ server.callTool(r).pipe(
1155
+ Effect.provideService(CurrentLogLevel, currentLogLevel)
1156
+ ),
1119
1157
  "tools/list": () => Effect.sync(() => new ListToolsResult({ tools: server.tools })),
1120
1158
 
1121
1159
  // Notifications
@@ -1661,6 +1661,21 @@ export const getJsonSchemaFromSchema = <S extends Schema.Top>(schema: S, options
1661
1661
  */
1662
1662
  export class Title extends ServiceMap.Service<Title, string>()("effect/ai/Tool/Title") {}
1663
1663
 
1664
+ /**
1665
+ * Annotation for providing tool metadata for MCP.
1666
+ *
1667
+ * @example
1668
+ * ```ts
1669
+ * import { Tool } from "effect/unstable/ai"
1670
+ *
1671
+ * const myCalculatorUi = Tool.make("calculator_ui", {})
1672
+ * .annotate(Tool.Meta, { ui: { resourceUri: "ui://example/calculator-ui" } })
1673
+ * ```
1674
+ * @since 1.0.0
1675
+ * @category annotations
1676
+ */
1677
+ export class Meta extends ServiceMap.Service<Meta, Record<string, unknown>>()("effect/ai/Tool/Meta") {}
1678
+
1664
1679
  /**
1665
1680
  * Annotation indicating whether a tool only reads data without making changes.
1666
1681
  *
@@ -499,14 +499,53 @@ const formatHelpDocImpl = (doc: HelpDoc, colors: ColorFunctions): string => {
499
499
 
500
500
  // Subcommands section
501
501
  if (doc.subcommands && doc.subcommands.length > 0) {
502
- sections.push(colors.bold("SUBCOMMANDS"))
502
+ const ungrouped = doc.subcommands.find((group) => group.group === undefined)
503
+
504
+ if (ungrouped) {
505
+ sections.push(colors.bold("SUBCOMMANDS"))
506
+ sections.push(renderTable(
507
+ ungrouped.commands.map((sub) => ({
508
+ left: colors.cyan(sub.name),
509
+ right: sub.shortDescription ?? sub.description
510
+ })),
511
+ 20
512
+ ))
513
+ if (doc.subcommands.length > 1) {
514
+ sections.push("")
515
+ }
516
+ }
503
517
 
504
- const subcommandRows: Array<Row> = doc.subcommands.map((sub) => ({
505
- left: colors.cyan(sub.name),
506
- right: sub.description
507
- }))
518
+ for (const group of doc.subcommands) {
519
+ if (group.group === undefined) continue
520
+ sections.push(colors.bold(`${group.group}:`))
521
+ sections.push(renderTable(
522
+ group.commands.map((sub) => ({
523
+ left: colors.cyan(sub.name),
524
+ right: sub.shortDescription ?? sub.description
525
+ })),
526
+ 20
527
+ ))
528
+ sections.push("")
529
+ }
530
+ }
508
531
 
509
- sections.push(renderTable(subcommandRows, 20))
532
+ // Examples section
533
+ if (doc.examples && doc.examples.length > 0) {
534
+ sections.push(colors.bold("EXAMPLES"))
535
+
536
+ let first = true
537
+ let previousHadDescription = false
538
+ for (const example of doc.examples) {
539
+ if (example.description) {
540
+ if (!first) sections.push("")
541
+ sections.push(` ${colors.dim(`# ${example.description}`)}`)
542
+ } else if (previousHadDescription) {
543
+ sections.push("")
544
+ }
545
+ sections.push(` ${colors.cyan(example.command)}`)
546
+ first = false
547
+ previousHadDescription = !!example.description
548
+ }
510
549
  sections.push("")
511
550
  }
512
551