@effect/ai 0.26.1 → 0.27.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 (188) hide show
  1. package/Chat/package.json +6 -0
  2. package/EmbeddingModel/package.json +6 -0
  3. package/IdGenerator/package.json +6 -0
  4. package/LanguageModel/package.json +6 -0
  5. package/Model/package.json +6 -0
  6. package/Prompt/package.json +6 -0
  7. package/Response/package.json +6 -0
  8. package/Telemetry/package.json +6 -0
  9. package/Tool/package.json +6 -0
  10. package/Toolkit/package.json +6 -0
  11. package/dist/cjs/AiError.js +575 -11
  12. package/dist/cjs/AiError.js.map +1 -1
  13. package/dist/cjs/Chat.js +302 -0
  14. package/dist/cjs/Chat.js.map +1 -0
  15. package/dist/cjs/EmbeddingModel.js +184 -0
  16. package/dist/cjs/EmbeddingModel.js.map +1 -0
  17. package/dist/cjs/IdGenerator.js +255 -0
  18. package/dist/cjs/IdGenerator.js.map +1 -0
  19. package/dist/cjs/LanguageModel.js +584 -0
  20. package/dist/cjs/LanguageModel.js.map +1 -0
  21. package/dist/cjs/McpServer.js +2 -2
  22. package/dist/cjs/McpServer.js.map +1 -1
  23. package/dist/cjs/Model.js +118 -0
  24. package/dist/cjs/Model.js.map +1 -0
  25. package/dist/cjs/Prompt.js +649 -0
  26. package/dist/cjs/Prompt.js.map +1 -0
  27. package/dist/cjs/Response.js +635 -0
  28. package/dist/cjs/Response.js.map +1 -0
  29. package/dist/cjs/Telemetry.js +176 -0
  30. package/dist/cjs/Telemetry.js.map +1 -0
  31. package/dist/cjs/Tokenizer.js +87 -8
  32. package/dist/cjs/Tokenizer.js.map +1 -1
  33. package/dist/cjs/Tool.js +556 -0
  34. package/dist/cjs/Tool.js.map +1 -0
  35. package/dist/cjs/Toolkit.js +279 -0
  36. package/dist/cjs/Toolkit.js.map +1 -0
  37. package/dist/cjs/index.js +21 -19
  38. package/dist/dts/AiError.d.ts +577 -9
  39. package/dist/dts/AiError.d.ts.map +1 -1
  40. package/dist/dts/Chat.d.ts +356 -0
  41. package/dist/dts/Chat.d.ts.map +1 -0
  42. package/dist/dts/EmbeddingModel.d.ts +153 -0
  43. package/dist/dts/EmbeddingModel.d.ts.map +1 -0
  44. package/dist/dts/IdGenerator.d.ts +272 -0
  45. package/dist/dts/IdGenerator.d.ts.map +1 -0
  46. package/dist/dts/LanguageModel.d.ts +458 -0
  47. package/dist/dts/LanguageModel.d.ts.map +1 -0
  48. package/dist/dts/McpSchema.d.ts +25 -25
  49. package/dist/dts/McpServer.d.ts +4 -4
  50. package/dist/dts/McpServer.d.ts.map +1 -1
  51. package/dist/dts/Model.d.ts +124 -0
  52. package/dist/dts/Model.d.ts.map +1 -0
  53. package/dist/dts/Prompt.d.ts +1119 -0
  54. package/dist/dts/Prompt.d.ts.map +1 -0
  55. package/dist/dts/Response.d.ts +1519 -0
  56. package/dist/dts/Response.d.ts.map +1 -0
  57. package/dist/dts/Telemetry.d.ts +520 -0
  58. package/dist/dts/Telemetry.d.ts.map +1 -0
  59. package/dist/dts/Tokenizer.d.ts +131 -13
  60. package/dist/dts/Tokenizer.d.ts.map +1 -1
  61. package/dist/dts/Tool.d.ts +876 -0
  62. package/dist/dts/Tool.d.ts.map +1 -0
  63. package/dist/dts/Toolkit.d.ts +310 -0
  64. package/dist/dts/Toolkit.d.ts.map +1 -0
  65. package/dist/dts/index.d.ts +498 -13
  66. package/dist/dts/index.d.ts.map +1 -1
  67. package/dist/esm/AiError.js +570 -10
  68. package/dist/esm/AiError.js.map +1 -1
  69. package/dist/esm/Chat.js +291 -0
  70. package/dist/esm/Chat.js.map +1 -0
  71. package/dist/esm/EmbeddingModel.js +173 -0
  72. package/dist/esm/EmbeddingModel.js.map +1 -0
  73. package/dist/esm/IdGenerator.js +245 -0
  74. package/dist/esm/IdGenerator.js.map +1 -0
  75. package/dist/esm/LanguageModel.js +572 -0
  76. package/dist/esm/LanguageModel.js.map +1 -0
  77. package/dist/esm/McpServer.js +2 -2
  78. package/dist/esm/McpServer.js.map +1 -1
  79. package/dist/esm/Model.js +108 -0
  80. package/dist/esm/Model.js.map +1 -0
  81. package/dist/esm/Prompt.js +633 -0
  82. package/dist/esm/Prompt.js.map +1 -0
  83. package/dist/esm/Response.js +619 -0
  84. package/dist/esm/Response.js.map +1 -0
  85. package/dist/esm/Telemetry.js +166 -0
  86. package/dist/esm/Telemetry.js.map +1 -0
  87. package/dist/esm/Tokenizer.js +87 -8
  88. package/dist/esm/Tokenizer.js.map +1 -1
  89. package/dist/esm/Tool.js +534 -0
  90. package/dist/esm/Tool.js.map +1 -0
  91. package/dist/esm/Toolkit.js +269 -0
  92. package/dist/esm/Toolkit.js.map +1 -0
  93. package/dist/esm/index.js +498 -13
  94. package/dist/esm/index.js.map +1 -1
  95. package/package.json +75 -67
  96. package/src/AiError.ts +739 -9
  97. package/src/Chat.ts +546 -0
  98. package/src/EmbeddingModel.ts +311 -0
  99. package/src/IdGenerator.ts +320 -0
  100. package/src/LanguageModel.ts +1074 -0
  101. package/src/McpServer.ts +328 -192
  102. package/src/Model.ts +155 -0
  103. package/src/Prompt.ts +1616 -0
  104. package/src/Response.ts +2131 -0
  105. package/src/Telemetry.ts +655 -0
  106. package/src/Tokenizer.ts +145 -24
  107. package/src/Tool.ts +1267 -0
  108. package/src/Toolkit.ts +516 -0
  109. package/src/index.ts +499 -13
  110. package/AiChat/package.json +0 -6
  111. package/AiEmbeddingModel/package.json +0 -6
  112. package/AiInput/package.json +0 -6
  113. package/AiLanguageModel/package.json +0 -6
  114. package/AiModel/package.json +0 -6
  115. package/AiResponse/package.json +0 -6
  116. package/AiTelemetry/package.json +0 -6
  117. package/AiTool/package.json +0 -6
  118. package/AiToolkit/package.json +0 -6
  119. package/dist/cjs/AiChat.js +0 -122
  120. package/dist/cjs/AiChat.js.map +0 -1
  121. package/dist/cjs/AiEmbeddingModel.js +0 -109
  122. package/dist/cjs/AiEmbeddingModel.js.map +0 -1
  123. package/dist/cjs/AiInput.js +0 -458
  124. package/dist/cjs/AiInput.js.map +0 -1
  125. package/dist/cjs/AiLanguageModel.js +0 -351
  126. package/dist/cjs/AiLanguageModel.js.map +0 -1
  127. package/dist/cjs/AiModel.js +0 -37
  128. package/dist/cjs/AiModel.js.map +0 -1
  129. package/dist/cjs/AiResponse.js +0 -681
  130. package/dist/cjs/AiResponse.js.map +0 -1
  131. package/dist/cjs/AiTelemetry.js +0 -58
  132. package/dist/cjs/AiTelemetry.js.map +0 -1
  133. package/dist/cjs/AiTool.js +0 -150
  134. package/dist/cjs/AiTool.js.map +0 -1
  135. package/dist/cjs/AiToolkit.js +0 -157
  136. package/dist/cjs/AiToolkit.js.map +0 -1
  137. package/dist/cjs/internal/common.js +0 -21
  138. package/dist/cjs/internal/common.js.map +0 -1
  139. package/dist/dts/AiChat.d.ts +0 -101
  140. package/dist/dts/AiChat.d.ts.map +0 -1
  141. package/dist/dts/AiEmbeddingModel.d.ts +0 -65
  142. package/dist/dts/AiEmbeddingModel.d.ts.map +0 -1
  143. package/dist/dts/AiInput.d.ts +0 -590
  144. package/dist/dts/AiInput.d.ts.map +0 -1
  145. package/dist/dts/AiLanguageModel.d.ts +0 -302
  146. package/dist/dts/AiLanguageModel.d.ts.map +0 -1
  147. package/dist/dts/AiModel.d.ts +0 -25
  148. package/dist/dts/AiModel.d.ts.map +0 -1
  149. package/dist/dts/AiResponse.d.ts +0 -863
  150. package/dist/dts/AiResponse.d.ts.map +0 -1
  151. package/dist/dts/AiTelemetry.d.ts +0 -242
  152. package/dist/dts/AiTelemetry.d.ts.map +0 -1
  153. package/dist/dts/AiTool.d.ts +0 -334
  154. package/dist/dts/AiTool.d.ts.map +0 -1
  155. package/dist/dts/AiToolkit.d.ts +0 -96
  156. package/dist/dts/AiToolkit.d.ts.map +0 -1
  157. package/dist/dts/internal/common.d.ts +0 -2
  158. package/dist/dts/internal/common.d.ts.map +0 -1
  159. package/dist/esm/AiChat.js +0 -111
  160. package/dist/esm/AiChat.js.map +0 -1
  161. package/dist/esm/AiEmbeddingModel.js +0 -98
  162. package/dist/esm/AiEmbeddingModel.js.map +0 -1
  163. package/dist/esm/AiInput.js +0 -433
  164. package/dist/esm/AiInput.js.map +0 -1
  165. package/dist/esm/AiLanguageModel.js +0 -340
  166. package/dist/esm/AiLanguageModel.js.map +0 -1
  167. package/dist/esm/AiModel.js +0 -29
  168. package/dist/esm/AiModel.js.map +0 -1
  169. package/dist/esm/AiResponse.js +0 -657
  170. package/dist/esm/AiResponse.js.map +0 -1
  171. package/dist/esm/AiTelemetry.js +0 -48
  172. package/dist/esm/AiTelemetry.js.map +0 -1
  173. package/dist/esm/AiTool.js +0 -134
  174. package/dist/esm/AiTool.js.map +0 -1
  175. package/dist/esm/AiToolkit.js +0 -147
  176. package/dist/esm/AiToolkit.js.map +0 -1
  177. package/dist/esm/internal/common.js +0 -14
  178. package/dist/esm/internal/common.js.map +0 -1
  179. package/src/AiChat.ts +0 -251
  180. package/src/AiEmbeddingModel.ts +0 -169
  181. package/src/AiInput.ts +0 -602
  182. package/src/AiLanguageModel.ts +0 -685
  183. package/src/AiModel.ts +0 -53
  184. package/src/AiResponse.ts +0 -986
  185. package/src/AiTelemetry.ts +0 -333
  186. package/src/AiTool.ts +0 -579
  187. package/src/AiToolkit.ts +0 -265
  188. package/src/internal/common.ts +0 -12
package/src/McpServer.ts CHANGED
@@ -27,8 +27,6 @@ import type { Sink } from "effect/Sink"
27
27
  import type { Stream } from "effect/Stream"
28
28
  import type * as Types from "effect/Types"
29
29
  import * as FindMyWay from "find-my-way-ts"
30
- import * as AiTool from "./AiTool.js"
31
- import type * as AiToolkit from "./AiToolkit.js"
32
30
  import type {
33
31
  Annotations,
34
32
  CallTool,
@@ -66,6 +64,8 @@ import {
66
64
  Tool,
67
65
  ToolAnnotations
68
66
  } from "./McpSchema.js"
67
+ import * as AiTool from "./Tool.js"
68
+ import type * as Toolkit from "./Toolkit.js"
69
69
 
70
70
  /**
71
71
  * @since 1.0.0
@@ -94,21 +94,22 @@ export class McpServer extends Context.Tag("@effect/ai/McpServer")<
94
94
  ) => Effect.Effect<void>
95
95
 
96
96
  readonly resourceTemplates: ReadonlyArray<ResourceTemplate>
97
- readonly addResourceTemplate: (
98
- options: {
99
- readonly template: ResourceTemplate
100
- readonly routerPath: string
101
- readonly completions: Record<string, (input: string) => Effect.Effect<CompleteResult, InternalError>>
102
- readonly handle: (
103
- uri: string,
104
- params: Array<string>
105
- ) => Effect.Effect<typeof ReadResourceResult.Type, InvalidParams | InternalError, McpServerClient>
106
- }
107
- ) => Effect.Effect<void>
97
+ readonly addResourceTemplate: (options: {
98
+ readonly template: ResourceTemplate
99
+ readonly routerPath: string
100
+ readonly completions: Record<string, (input: string) => Effect.Effect<CompleteResult, InternalError>>
101
+ readonly handle: (uri: string, params: Array<string>) => Effect.Effect<
102
+ typeof ReadResourceResult.Type,
103
+ InvalidParams | InternalError,
104
+ McpServerClient
105
+ >
106
+ }) => Effect.Effect<void>
108
107
 
109
- readonly findResource: (
110
- uri: string
111
- ) => Effect.Effect<typeof ReadResourceResult.Type, InvalidParams | InternalError, McpServerClient>
108
+ readonly findResource: (uri: string) => Effect.Effect<
109
+ typeof ReadResourceResult.Type,
110
+ InvalidParams | InternalError,
111
+ McpServerClient
112
+ >
112
113
 
113
114
  readonly prompts: ReadonlyArray<Prompt>
114
115
  readonly addPrompt: (options: {
@@ -135,19 +136,23 @@ export class McpServer extends Context.Tag("@effect/ai/McpServer")<
135
136
  */
136
137
  static readonly make = Effect.gen(function*() {
137
138
  const matcher = makeUriMatcher<
138
- {
139
+ | {
139
140
  readonly _tag: "ResourceTemplate"
140
141
  readonly handle: (
141
142
  uri: string,
142
143
  params: Array<string>
143
144
  ) => Effect.Effect<typeof ReadResourceResult.Type, InternalError | InvalidParams, McpServerClient>
144
- } | {
145
+ }
146
+ | {
145
147
  readonly _tag: "Resource"
146
148
  readonly effect: Effect.Effect<typeof ReadResourceResult.Type, InternalError, McpServerClient>
147
149
  }
148
150
  >()
149
151
  const tools = Arr.empty<Tool>()
150
- const toolMap = new Map<string, (payload: any) => Effect.Effect<CallToolResult, InternalError, McpServerClient>>()
152
+ const toolMap = new Map<
153
+ string,
154
+ (payload: any) => Effect.Effect<CallToolResult, InternalError, McpServerClient>
155
+ >()
151
156
  const resources: Array<Resource> = []
152
157
  const resourceTemplates: Array<ResourceTemplate> = []
153
158
  const prompts: Array<Prompt> = []
@@ -207,7 +212,11 @@ export class McpServer extends Context.Tag("@effect/ai/McpServer")<
207
212
  Effect.suspend((): Effect.Effect<CallToolResult, InternalError | InvalidParams, McpServerClient> => {
208
213
  const handle = toolMap.get(request.name)
209
214
  if (!handle) {
210
- return Effect.fail(new InvalidParams({ message: `Tool '${request.name}' not found` }))
215
+ return Effect.fail(
216
+ new InvalidParams({
217
+ message: `Tool '${request.name}' not found`
218
+ })
219
+ )
211
220
  }
212
221
  return handle(request.arguments)
213
222
  }),
@@ -221,16 +230,23 @@ export class McpServer extends Context.Tag("@effect/ai/McpServer")<
221
230
  Effect.suspend(() => {
222
231
  resources.push(resource)
223
232
  matcher.add(resource.uri, { _tag: "Resource", effect })
224
- return notifications.client["notifications/resources/list_changed"]({})
233
+ return notifications.client["notifications/resources/list_changed"](
234
+ {}
235
+ )
225
236
  }),
226
237
  addResourceTemplate: ({ completions, handle, routerPath, template }) =>
227
238
  Effect.suspend(() => {
228
239
  resourceTemplates.push(template)
229
240
  matcher.add(routerPath, { _tag: "ResourceTemplate", handle })
230
241
  for (const [param, handle] of Object.entries(completions)) {
231
- completionsMap.set(`ref/resource/${template.uriTemplate}/${param}`, handle)
242
+ completionsMap.set(
243
+ `ref/resource/${template.uriTemplate}/${param}`,
244
+ handle
245
+ )
232
246
  }
233
- return notifications.client["notifications/resources/list_changed"]({})
247
+ return notifications.client["notifications/resources/list_changed"](
248
+ {}
249
+ )
234
250
  }),
235
251
  findResource: (uri) =>
236
252
  Effect.suspend(() => {
@@ -254,14 +270,19 @@ export class McpServer extends Context.Tag("@effect/ai/McpServer")<
254
270
  prompts.push(options.prompt)
255
271
  promptMap.set(options.prompt.name, options.handle)
256
272
  for (const [param, handle] of Object.entries(options.completions)) {
257
- completionsMap.set(`ref/prompt/${options.prompt.name}/${param}`, handle)
273
+ completionsMap.set(
274
+ `ref/prompt/${options.prompt.name}/${param}`,
275
+ handle
276
+ )
258
277
  }
259
278
  return notifications.client["notifications/prompts/list_changed"]({})
260
279
  }),
261
280
  getPromptResult: Effect.fnUntraced(function*({ arguments: params, name }) {
262
281
  const handler = promptMap.get(name)
263
282
  if (!handler) {
264
- return yield* new InvalidParams({ message: `Prompt '${name}' not found` })
283
+ return yield* new InvalidParams({
284
+ message: `Prompt '${name}' not found`
285
+ })
265
286
  }
266
287
  return yield* handler(params ?? {})
267
288
  }),
@@ -271,7 +292,9 @@ export class McpServer extends Context.Tag("@effect/ai/McpServer")<
271
292
  ? `ref/resource/${ref.uri}/${complete.argument.name}`
272
293
  : `ref/prompt/${ref.name}/${complete.argument.name}`
273
294
  const handler = completionsMap.get(key)
274
- return handler ? yield* handler(complete.argument.value) : CompleteResult.empty
295
+ return handler
296
+ ? yield* handler(complete.argument.value)
297
+ : CompleteResult.empty
275
298
  })
276
299
  })
277
300
  })
@@ -294,13 +317,10 @@ const SUPPORTED_PROTOCOL_VERSIONS = [
294
317
  * @since 1.0.0
295
318
  * @category Constructors
296
319
  */
297
- export const run: (
298
- options: { readonly name: string; readonly version: string }
299
- ) => Effect.Effect<
300
- never,
301
- never,
302
- McpServer | RpcServer.Protocol
303
- > = Effect.fnUntraced(function*(options: {
320
+ export const run: (options: {
321
+ readonly name: string
322
+ readonly version: string
323
+ }) => Effect.Effect<never, never, McpServer | RpcServer.Protocol> = Effect.fnUntraced(function*(options: {
304
324
  readonly name: string
305
325
  readonly version: string
306
326
  }) {
@@ -310,28 +330,32 @@ export const run: (
310
330
 
311
331
  const clients = yield* RcMap.make({
312
332
  lookup: Effect.fnUntraced(function*(clientId: number) {
313
- let write!: (message: RpcMessage.FromServerEncoded) => Effect.Effect<void>
333
+ let write!: (
334
+ message: RpcMessage.FromServerEncoded
335
+ ) => Effect.Effect<void>
314
336
  const client = yield* RpcClient.make(ServerRequestRpcs, {
315
337
  spanPrefix: "McpServer/Client"
316
338
  }).pipe(
317
339
  Effect.provideServiceEffect(
318
340
  RpcClient.Protocol,
319
- RpcClient.Protocol.make(Effect.fnUntraced(function*(writeResponse) {
320
- write = writeResponse
321
- return {
322
- send(request, _transferables) {
323
- return protocol.send(clientId, {
324
- ...request,
325
- headers: undefined,
326
- traceId: undefined,
327
- spanId: undefined,
328
- sampled: undefined
329
- } as any)
330
- },
331
- supportsAck: true,
332
- supportsTransferables: false
333
- }
334
- }))
341
+ RpcClient.Protocol.make(
342
+ Effect.fnUntraced(function*(writeResponse) {
343
+ write = writeResponse
344
+ return {
345
+ send(request, _transferables) {
346
+ return protocol.send(clientId, {
347
+ ...request,
348
+ headers: undefined,
349
+ traceId: undefined,
350
+ spanId: undefined,
351
+ sampled: undefined
352
+ } as any)
353
+ },
354
+ supportsAck: true,
355
+ supportsTransferables: false
356
+ }
357
+ })
358
+ )
335
359
  )
336
360
  )
337
361
 
@@ -367,7 +391,9 @@ export const run: (
367
391
  requestId: String((request.payload as any).requestId)
368
392
  })
369
393
  }
370
- const handler = handlers.unsafeMap.get(request.tag) as Rpc.Handler<string>
394
+ const handler = handlers.unsafeMap.get(
395
+ request.tag
396
+ ) as Rpc.Handler<string>
371
397
  return handler
372
398
  ? handler.handler(request.payload, {
373
399
  clientId,
@@ -396,7 +422,12 @@ export const run: (
396
422
  })
397
423
 
398
424
  const encodeNotification = Schema.encode(
399
- Schema.Union(...Array.from(ServerNotificationRpcs.requests.values(), (rpc) => rpc.payloadSchema))
425
+ Schema.Union(
426
+ ...Array.from(
427
+ ServerNotificationRpcs.requests.values(),
428
+ (rpc) => rpc.payloadSchema
429
+ )
430
+ )
400
431
  )
401
432
  yield* server.notificationsMailbox.take.pipe(
402
433
  Effect.flatMap(Effect.fnUntraced(function*(request) {
@@ -506,10 +537,12 @@ export const layerStdio = <EIn, RIn, EOut, ROut>(options: {
506
537
  readonly stdout: Sink<unknown, Uint8Array | string, unknown, EOut, ROut>
507
538
  }): Layer.Layer<McpServer | McpServerClient, never, RIn | ROut> =>
508
539
  layer(options).pipe(
509
- Layer.provide(RpcServer.layerProtocolStdio({
510
- stdin: options.stdin,
511
- stdout: options.stdout
512
- })),
540
+ Layer.provide(
541
+ RpcServer.layerProtocolStdio({
542
+ stdin: options.stdin,
543
+ stdout: options.stdout
544
+ })
545
+ ),
513
546
  Layer.provide(RpcSerialization.layerNdJsonRpc()),
514
547
  // remove stdout loggers
515
548
  Layer.provideMerge(Logger.remove(Logger.defaultLogger)),
@@ -597,7 +630,11 @@ export const layerHttpRouter = (options: {
597
630
  readonly name: string
598
631
  readonly version: string
599
632
  readonly path: HttpRouter.PathInput
600
- }): Layer.Layer<McpServer | McpServerClient, never, HttpLayerRouter.HttpRouter> =>
633
+ }): Layer.Layer<
634
+ McpServer | McpServerClient,
635
+ never,
636
+ HttpLayerRouter.HttpRouter
637
+ > =>
601
638
  layer(options).pipe(
602
639
  Layer.provide(RpcServer.layerProtocolHttpRouter(options)),
603
640
  Layer.provide(RpcSerialization.layerJsonRpc())
@@ -609,30 +646,34 @@ export const layerHttpRouter = (options: {
609
646
  * @since 1.0.0
610
647
  * @category Tools
611
648
  */
612
- export const registerToolkit: <Tools extends AiTool.Any>(toolkit: AiToolkit.AiToolkit<Tools>) => Effect.Effect<
649
+ export const registerToolkit: <Tools extends Record<string, AiTool.Any>>(
650
+ toolkit: Toolkit.Toolkit<Tools>
651
+ ) => Effect.Effect<
613
652
  void,
614
653
  never,
615
- McpServer | AiTool.ToHandler<Tools> | Exclude<AiTool.Context<Tools>, McpServerClient>
616
- > = Effect.fnUntraced(function*<Tools extends AiTool.Any>(
617
- toolkit: AiToolkit.AiToolkit<Tools>
654
+ | McpServer
655
+ | AiTool.HandlersFor<Tools>
656
+ | Exclude<AiTool.Requirements<Tools>, McpServerClient>
657
+ > = Effect.fnUntraced(function*<Tools extends Record<string, AiTool.Any>>(
658
+ toolkit: Toolkit.Toolkit<Tools>
618
659
  ) {
619
660
  const registry = yield* McpServer
620
- const built = yield* (toolkit as any as Effect.Effect<
621
- AiToolkit.ToHandler<Tools>,
661
+ const built = yield* toolkit as any as Effect.Effect<
662
+ Toolkit.WithHandler<Tools>,
622
663
  never,
623
- Exclude<AiTool.ToHandler<Tools>, McpServerClient>
624
- >)
664
+ Exclude<AiTool.HandlersFor<Tools>, McpServerClient>
665
+ >
625
666
  const context = yield* Effect.context<never>()
626
- for (const tool of built.tools) {
667
+ for (const tool of Object.values(built.tools)) {
627
668
  const mcpTool = new Tool({
628
669
  name: tool.name,
629
670
  description: tool.description,
630
671
  inputSchema: makeJsonSchema(tool.parametersSchema.ast),
631
672
  annotations: new ToolAnnotations({
632
- ...(Context.getOption(tool.annotations, AiTool.Title).pipe(
673
+ ...Context.getOption(tool.annotations, AiTool.Title).pipe(
633
674
  Option.map((title) => ({ title })),
634
675
  Option.getOrUndefined
635
- )),
676
+ ),
636
677
  readOnlyHint: Context.get(tool.annotations, AiTool.Readonly),
637
678
  destructiveHint: Context.get(tool.annotations, AiTool.Destructive),
638
679
  idempotentHint: Context.get(tool.annotations, AiTool.Idempotent),
@@ -649,19 +690,25 @@ export const registerToolkit: <Tools extends AiTool.Any>(toolkit: AiToolkit.AiTo
649
690
  new CallToolResult({
650
691
  isError: true,
651
692
  structuredContent: typeof error === "object" ? error : undefined,
652
- content: [{
653
- type: "text",
654
- text: JSON.stringify(error)
655
- }]
693
+ content: [
694
+ {
695
+ type: "text",
696
+ text: JSON.stringify(error)
697
+ }
698
+ ]
656
699
  }),
657
700
  onSuccess: (result) =>
658
701
  new CallToolResult({
659
702
  isError: false,
660
- structuredContent: typeof result.encodedResult === "object" ? result.encodedResult : undefined,
661
- content: [{
662
- type: "text",
663
- text: JSON.stringify(result.encodedResult)
664
- }]
703
+ structuredContent: typeof result.encodedResult === "object"
704
+ ? result.encodedResult
705
+ : undefined,
706
+ content: [
707
+ {
708
+ type: "text",
709
+ text: JSON.stringify(result.encodedResult)
710
+ }
711
+ ]
665
712
  })
666
713
  })
667
714
  ) as any
@@ -676,12 +723,13 @@ export const registerToolkit: <Tools extends AiTool.Any>(toolkit: AiToolkit.AiTo
676
723
  * @since 1.0.0
677
724
  * @category Tools
678
725
  */
679
- export const toolkit = <Tools extends AiTool.Any>(
680
- toolkit: AiToolkit.AiToolkit<Tools>
726
+ export const toolkit = <Tools extends Record<string, AiTool.Any>>(
727
+ toolkit: Toolkit.Toolkit<Tools>
681
728
  ): Layer.Layer<
682
729
  never,
683
730
  never,
684
- AiTool.ToHandler<Tools> | Exclude<AiTool.Context<Tools>, McpServerClient>
731
+ | AiTool.HandlersFor<Tools>
732
+ | Exclude<AiTool.Requirements<Tools>, McpServerClient>
685
733
  > =>
686
734
  Layer.effectDiscard(registerToolkit(toolkit)).pipe(
687
735
  Layer.provide(McpServer.layer)
@@ -690,20 +738,30 @@ export const toolkit = <Tools extends AiTool.Any>(
690
738
  /**
691
739
  * @since 1.0.0
692
740
  */
693
- export type ValidateCompletions<Completions, Keys extends string> =
741
+ export type ValidateCompletions<
742
+ Completions,
743
+ Keys extends string
744
+ > =
694
745
  & Completions
695
746
  & {
696
- readonly [K in keyof Completions]: K extends Keys ? (input: string) => any : never
747
+ readonly [K in keyof Completions]: K extends Keys ? (input: string) => any
748
+ : never
697
749
  }
698
750
 
699
751
  /**
700
752
  * @since 1.0.0
701
753
  */
702
- export type ResourceCompletions<Schemas extends ReadonlyArray<Schema.Schema.Any>> = {
754
+ export type ResourceCompletions<
755
+ Schemas extends ReadonlyArray<Schema.Schema.Any>
756
+ > = {
703
757
  readonly [
704
- K in Extract<keyof Schemas, `${number}`> as Schemas[K] extends Param<infer Id, infer _S> ? Id
705
- : `param${K}`
706
- ]: (input: string) => Effect.Effect<Array<Schema.Schema.Type<Schemas[K]>>, any, any>
758
+ K in Extract<
759
+ keyof Schemas,
760
+ `${number}`
761
+ > as Schemas[K] extends Param<infer Id, infer _S> ? Id : `param${K}`
762
+ ]: (
763
+ input: string
764
+ ) => Effect.Effect<Array<Schema.Schema.Type<Schemas[K]>>, any, any>
707
765
  }
708
766
 
709
767
  /**
@@ -745,7 +803,9 @@ export const registerResource: {
745
803
  ...schemas:
746
804
  & Schemas
747
805
  & {
748
- readonly [K in keyof Schemas]: Schema.Schema.Encoded<Schemas[K]> extends string ? unknown
806
+ readonly [K in keyof Schemas]: Schema.Schema.Encoded<
807
+ Schemas[K]
808
+ > extends string ? unknown
749
809
  : "Schema must be encodable to a string"
750
810
  }
751
811
  ): <
@@ -758,8 +818,13 @@ export const registerResource: {
758
818
  readonly mimeType?: string | undefined
759
819
  readonly audience?: ReadonlyArray<"user" | "assistant"> | undefined
760
820
  readonly priority?: number | undefined
761
- readonly completion?: ValidateCompletions<Completions, keyof ResourceCompletions<Schemas>> | undefined
762
- readonly content: (uri: string, ...params: { readonly [K in keyof Schemas]: Schemas[K]["Type"] }) => Effect.Effect<
821
+ readonly completion?:
822
+ | ValidateCompletions<Completions, keyof ResourceCompletions<Schemas>>
823
+ | undefined
824
+ readonly content: (
825
+ uri: string,
826
+ ...params: { readonly [K in keyof Schemas]: Schemas[K]["Type"] }
827
+ ) => Effect.Effect<
763
828
  typeof ReadResourceResult.Type | string | Uint8Array,
764
829
  E,
765
830
  R
@@ -769,8 +834,9 @@ export const registerResource: {
769
834
  never,
770
835
  | Exclude<
771
836
  | R
772
- | (Completions[keyof Completions] extends (input: string) => infer Ret ?
773
- Ret extends Effect.Effect<infer _A, infer _E, infer _R> ? _R : never
837
+ | (Completions[keyof Completions] extends (input: string) => infer Ret
838
+ ? Ret extends Effect.Effect<infer _A, infer _E, infer _R> ? _R
839
+ : never
774
840
  : never),
775
841
  McpServerClient
776
842
  >
@@ -778,9 +844,14 @@ export const registerResource: {
778
844
  >
779
845
  } = function() {
780
846
  if (arguments.length === 1) {
781
- const options = arguments[0] as Resource & typeof Annotations.Type & {
782
- readonly content: Effect.Effect<typeof ReadResourceResult.Type | string | Uint8Array>
783
- }
847
+ const options = arguments[0] as
848
+ & Resource
849
+ & typeof Annotations.Type
850
+ & {
851
+ readonly content: Effect.Effect<
852
+ typeof ReadResourceResult.Type | string | Uint8Array
853
+ >
854
+ }
784
855
  return Effect.gen(function*() {
785
856
  const context = yield* Effect.context<any>()
786
857
  const registry = yield* McpServer
@@ -800,20 +871,22 @@ export const registerResource: {
800
871
  )
801
872
  })
802
873
  }
803
- const {
804
- params,
805
- routerPath,
806
- schema,
807
- uriPath
808
- } = compileUriTemplate(...(arguments as any as [any, any]))
874
+ const { params, routerPath, schema, uriPath } = compileUriTemplate(
875
+ ...(arguments as any as [any, any])
876
+ )
809
877
  return Effect.fnUntraced(function*<E, R>(options: {
810
878
  readonly name: string
811
879
  readonly description?: string | undefined
812
880
  readonly mimeType?: string | undefined
813
881
  readonly audience?: ReadonlyArray<"user" | "assistant"> | undefined
814
882
  readonly priority?: number | undefined
815
- readonly completion?: Record<string, (input: string) => Effect.Effect<any>> | undefined
816
- readonly content: (uri: string, ...params: Array<any>) => Effect.Effect<
883
+ readonly completion?:
884
+ | Record<string, (input: string) => Effect.Effect<any>>
885
+ | undefined
886
+ readonly content: (
887
+ uri: string,
888
+ ...params: Array<any>
889
+ ) => Effect.Effect<
817
890
  typeof ReadResourceResult.Type | string | Uint8Array,
818
891
  E,
819
892
  R
@@ -827,20 +900,24 @@ export const registerResource: {
827
900
  uriTemplate: uriPath,
828
901
  annotations: options
829
902
  })
830
- const completions: Record<string, (input: string) => Effect.Effect<CompleteResult, InternalError>> = {}
903
+ const completions: Record<
904
+ string,
905
+ (input: string) => Effect.Effect<CompleteResult, InternalError>
906
+ > = {}
831
907
  for (const [param, handle] of Object.entries(options.completion ?? {})) {
832
908
  const encodeArray = Schema.encodeUnknown(Schema.Array(params[param]))
833
909
  const handler = (input: string) =>
834
910
  handle(input).pipe(
835
911
  Effect.flatMap(encodeArray),
836
- Effect.map((values) =>
837
- new CompleteResult({
838
- completion: {
839
- values: values as Array<string>,
840
- total: values.length,
841
- hasMore: false
842
- }
843
- })
912
+ Effect.map(
913
+ (values) =>
914
+ new CompleteResult({
915
+ completion: {
916
+ values: values as Array<string>,
917
+ total: values.length,
918
+ hasMore: false
919
+ }
920
+ })
844
921
  ),
845
922
  Effect.catchAllCause((cause) => {
846
923
  const prettyError = Cause.prettyErrors(cause)[0]
@@ -856,7 +933,9 @@ export const registerResource: {
856
933
  completions,
857
934
  handle: (uri, params) =>
858
935
  decode(params).pipe(
859
- Effect.mapError((error) => new InvalidParams({ message: error.message })),
936
+ Effect.mapError(
937
+ (error) => new InvalidParams({ message: error.message })
938
+ ),
860
939
  Effect.flatMap((params) =>
861
940
  options.content(uri, ...params).pipe(
862
941
  Effect.map((content) => resolveResourceContent(uri, content)),
@@ -911,7 +990,9 @@ export const resource: {
911
990
  ...schemas:
912
991
  & Schemas
913
992
  & {
914
- readonly [K in keyof Schemas]: Schema.Schema.Encoded<Schemas[K]> extends string ? unknown
993
+ readonly [K in keyof Schemas]: Schema.Schema.Encoded<
994
+ Schemas[K]
995
+ > extends string ? unknown
915
996
  : "Schema must be encodable to a string"
916
997
  }
917
998
  ): <
@@ -924,8 +1005,13 @@ export const resource: {
924
1005
  readonly mimeType?: string | undefined
925
1006
  readonly audience?: ReadonlyArray<"user" | "assistant"> | undefined
926
1007
  readonly priority?: number | undefined
927
- readonly completion?: ValidateCompletions<Completions, keyof ResourceCompletions<Schemas>> | undefined
928
- readonly content: (uri: string, ...params: { readonly [K in keyof Schemas]: Schemas[K]["Type"] }) => Effect.Effect<
1008
+ readonly completion?:
1009
+ | ValidateCompletions<Completions, keyof ResourceCompletions<Schemas>>
1010
+ | undefined
1011
+ readonly content: (
1012
+ uri: string,
1013
+ ...params: { readonly [K in keyof Schemas]: Schemas[K]["Type"] }
1014
+ ) => Effect.Effect<
929
1015
  typeof ReadResourceResult.Type | string | Uint8Array,
930
1016
  E,
931
1017
  R
@@ -935,8 +1021,9 @@ export const resource: {
935
1021
  never,
936
1022
  Exclude<
937
1023
  | R
938
- | (Completions[keyof Completions] extends (input: string) => infer Ret ?
939
- Ret extends Effect.Effect<infer _A, infer _E, infer _R> ? _R : never
1024
+ | (Completions[keyof Completions] extends (input: string) => infer Ret
1025
+ ? Ret extends Effect.Effect<infer _A, infer _E, infer _R> ? _R
1026
+ : never
940
1027
  : never),
941
1028
  McpServerClient
942
1029
  >
@@ -948,10 +1035,7 @@ export const resource: {
948
1035
  )
949
1036
  }
950
1037
  const register = registerResource(...(arguments as any as [any, any]))
951
- return (options: any) =>
952
- Layer.effectDiscard(register(options)).pipe(
953
- Layer.provide(McpServer.layer)
954
- )
1038
+ return (options: any) => Layer.effectDiscard(register(options)).pipe(Layer.provide(McpServer.layer))
955
1039
  } as any
956
1040
 
957
1041
  /**
@@ -967,20 +1051,30 @@ export const registerPrompt = <
967
1051
  ParamsI extends Record<string, string> = {},
968
1052
  ParamsR = never,
969
1053
  const Completions extends {
970
- readonly [K in keyof Params]?: (input: string) => Effect.Effect<Array<Params[K]>, any, any>
1054
+ readonly [K in keyof Params]?: (
1055
+ input: string
1056
+ ) => Effect.Effect<Array<Params[K]>, any, any>
971
1057
  } = {}
972
- >(
973
- options: {
974
- readonly name: string
975
- readonly description?: string | undefined
976
- readonly parameters?: Schema.Schema<Params, ParamsI, ParamsR> | undefined
977
- readonly completion?: ValidateCompletions<Completions, Extract<keyof Params, string>> | undefined
978
- readonly content: (params: Params) => Effect.Effect<Array<typeof PromptMessage.Type> | string, E, R>
979
- }
980
- ): Effect.Effect<void, never, Exclude<ParamsR | R, McpServerClient> | McpServer> => {
1058
+ >(options: {
1059
+ readonly name: string
1060
+ readonly description?: string | undefined
1061
+ readonly parameters?: Schema.Schema<Params, ParamsI, ParamsR> | undefined
1062
+ readonly completion?:
1063
+ | ValidateCompletions<Completions, Extract<keyof Params, string>>
1064
+ | undefined
1065
+ readonly content: (
1066
+ params: Params
1067
+ ) => Effect.Effect<Array<typeof PromptMessage.Type> | string, E, R>
1068
+ }): Effect.Effect<
1069
+ void,
1070
+ never,
1071
+ Exclude<ParamsR | R, McpServerClient> | McpServer
1072
+ > => {
981
1073
  const args = Arr.empty<typeof PromptArgument.Type>()
982
1074
  const props: Record<string, Schema.Schema.Any> = {}
983
- const propSignatures = options.parameters ? AST.getPropertySignatures(options.parameters.ast) : []
1075
+ const propSignatures = options.parameters
1076
+ ? AST.getPropertySignatures(options.parameters.ast)
1077
+ : []
984
1078
  for (const prop of propSignatures) {
985
1079
  args.push({
986
1080
  name: prop.name as string,
@@ -994,14 +1088,18 @@ export const registerPrompt = <
994
1088
  description: options.description,
995
1089
  arguments: args
996
1090
  })
997
- const decode = options.parameters ? Schema.decodeUnknown(options.parameters) : () => Effect.succeed({} as Params)
1091
+ const decode = options.parameters
1092
+ ? Schema.decodeUnknown(options.parameters)
1093
+ : () => Effect.succeed({} as Params)
998
1094
  const completion: Record<string, (input: string) => Effect.Effect<any>> = options.completion ?? {}
999
1095
  return Effect.gen(function*() {
1000
1096
  const registry = yield* McpServer
1001
1097
  const context = yield* Effect.context<Exclude<R | ParamsR, McpServerClient>>()
1002
1098
  const completions: Record<
1003
1099
  string,
1004
- (input: string) => Effect.Effect<CompleteResult, InternalError, McpServerClient>
1100
+ (
1101
+ input: string
1102
+ ) => Effect.Effect<CompleteResult, InternalError, McpServerClient>
1005
1103
  > = {}
1006
1104
  for (const [param, handle] of Object.entries(completion)) {
1007
1105
  const encodeArray = Schema.encodeUnknown(Schema.Array(props[param]))
@@ -1028,16 +1126,23 @@ export const registerPrompt = <
1028
1126
  completions,
1029
1127
  handle: (params) =>
1030
1128
  decode(params).pipe(
1031
- Effect.mapError((error) => new InvalidParams({ message: error.message })),
1129
+ Effect.mapError(
1130
+ (error) => new InvalidParams({ message: error.message })
1131
+ ),
1032
1132
  Effect.flatMap((params) => options.content(params)),
1033
1133
  Effect.map((messages) => {
1034
- messages = typeof messages === "string" ?
1035
- [{
1036
- role: "user",
1037
- content: TextContent.make({ text: messages })
1038
- }] :
1039
- messages
1040
- return new GetPromptResult({ messages, description: prompt.description })
1134
+ messages = typeof messages === "string"
1135
+ ? [
1136
+ {
1137
+ role: "user",
1138
+ content: TextContent.make({ text: messages })
1139
+ }
1140
+ ]
1141
+ : messages
1142
+ return new GetPromptResult({
1143
+ messages,
1144
+ description: prompt.description
1145
+ })
1041
1146
  }),
1042
1147
  Effect.catchAllCause((cause) => {
1043
1148
  const prettyError = Cause.prettyErrors(cause)[0]
@@ -1062,17 +1167,21 @@ export const prompt = <
1062
1167
  ParamsI extends Record<string, string> = {},
1063
1168
  ParamsR = never,
1064
1169
  const Completions extends {
1065
- readonly [K in keyof Params]?: (input: string) => Effect.Effect<Array<Params[K]>, any, any>
1170
+ readonly [K in keyof Params]?: (
1171
+ input: string
1172
+ ) => Effect.Effect<Array<Params[K]>, any, any>
1066
1173
  } = {}
1067
- >(
1068
- options: {
1069
- readonly name: string
1070
- readonly description?: string | undefined
1071
- readonly parameters?: Schema.Schema<Params, ParamsI, ParamsR> | undefined
1072
- readonly completion?: ValidateCompletions<Completions, Extract<keyof Params, string>> | undefined
1073
- readonly content: (params: Params) => Effect.Effect<Array<typeof PromptMessage.Type> | string, E, R>
1074
- }
1075
- ): Layer.Layer<never, never, Exclude<ParamsR | R, McpServerClient>> =>
1174
+ >(options: {
1175
+ readonly name: string
1176
+ readonly description?: string | undefined
1177
+ readonly parameters?: Schema.Schema<Params, ParamsI, ParamsR> | undefined
1178
+ readonly completion?:
1179
+ | ValidateCompletions<Completions, Extract<keyof Params, string>>
1180
+ | undefined
1181
+ readonly content: (
1182
+ params: Params
1183
+ ) => Effect.Effect<Array<typeof PromptMessage.Type> | string, E, R>
1184
+ }): Layer.Layer<never, never, Exclude<ParamsR | R, McpServerClient>> =>
1076
1185
  Layer.effectDiscard(registerPrompt(options)).pipe(
1077
1186
  Layer.provide(McpServer.layer)
1078
1187
  )
@@ -1086,32 +1195,37 @@ export const prompt = <
1086
1195
  export const elicit: <A, I extends Record<string, any>, R>(options: {
1087
1196
  readonly message: string
1088
1197
  readonly schema: Schema.Schema<A, I, R>
1089
- }) => Effect.Effect<
1090
- A,
1091
- ElicitationDeclined,
1092
- McpServerClient | R
1093
- > = Effect.fnUntraced(function*<A, I extends Record<string, any>, R>(options: {
1094
- readonly message: string
1095
- readonly schema: Schema.Schema<A, I, R>
1096
- }) {
1097
- const { getClient } = yield* McpServerClient
1098
- const client = yield* getClient
1099
- const request = Elicit.payloadSchema.make({
1100
- message: options.message,
1101
- requestedSchema: makeJsonSchema(options.schema.ast)
1102
- })
1103
- const res = yield* client["elicitation/create"](request).pipe(
1104
- Effect.catchAllCause((cause) => Effect.fail(new ElicitationDeclined({ cause: Cause.squash(cause), request })))
1105
- )
1106
- switch (res.action) {
1107
- case "accept":
1108
- return yield* Effect.orDie(Schema.decodeUnknown(options.schema)(res.content))
1109
- case "cancel":
1110
- return yield* Effect.interrupt
1111
- case "decline":
1112
- return yield* Effect.fail(new ElicitationDeclined({ request }))
1113
- }
1114
- }, Effect.scoped)
1198
+ }) => Effect.Effect<A, ElicitationDeclined, McpServerClient | R> = Effect.fnUntraced(
1199
+ function*<A, I extends Record<string, any>, R>(options: {
1200
+ readonly message: string
1201
+ readonly schema: Schema.Schema<A, I, R>
1202
+ }) {
1203
+ const { getClient } = yield* McpServerClient
1204
+ const client = yield* getClient
1205
+ const request = Elicit.payloadSchema.make({
1206
+ message: options.message,
1207
+ requestedSchema: makeJsonSchema(options.schema.ast)
1208
+ })
1209
+ const res = yield* client["elicitation/create"](request).pipe(
1210
+ Effect.catchAllCause((cause) =>
1211
+ Effect.fail(
1212
+ new ElicitationDeclined({ cause: Cause.squash(cause), request })
1213
+ )
1214
+ )
1215
+ )
1216
+ switch (res.action) {
1217
+ case "accept":
1218
+ return yield* Effect.orDie(
1219
+ Schema.decodeUnknown(options.schema)(res.content)
1220
+ )
1221
+ case "cancel":
1222
+ return yield* Effect.interrupt
1223
+ case "decline":
1224
+ return yield* Effect.fail(new ElicitationDeclined({ request }))
1225
+ }
1226
+ },
1227
+ Effect.scoped
1228
+ )
1115
1229
 
1116
1230
  // -----------------------------------------------------------------------------
1117
1231
  // Internal
@@ -1131,7 +1245,10 @@ const makeUriMatcher = <A>() => {
1131
1245
  return { add, find } as const
1132
1246
  }
1133
1247
 
1134
- const compileUriTemplate = (segments: TemplateStringsArray, ...schemas: ReadonlyArray<Schema.Schema.Any>) => {
1248
+ const compileUriTemplate = (
1249
+ segments: TemplateStringsArray,
1250
+ ...schemas: ReadonlyArray<Schema.Schema.Any>
1251
+ ) => {
1135
1252
  let routerPath = segments[0].replace(":", "::")
1136
1253
  let uriPath = segments[0]
1137
1254
  const params: Record<string, Schema.Schema.Any> = {}
@@ -1173,13 +1290,18 @@ const layerHandlers = (serverInfo: {
1173
1290
  ping: () => Effect.succeed({}),
1174
1291
  initialize(params, { clientId }) {
1175
1292
  const requestedVersion = params.protocolVersion
1176
- const capabilities: Types.DeepMutable<typeof ServerCapabilities.Type> = {
1293
+ const capabilities: Types.DeepMutable<
1294
+ typeof ServerCapabilities.Type
1295
+ > = {
1177
1296
  completions: {}
1178
1297
  }
1179
1298
  if (server.tools.length > 0) {
1180
1299
  capabilities.tools = { listChanged: true }
1181
1300
  }
1182
- if (server.resources.length > 0 || server.resourceTemplates.length > 0) {
1301
+ if (
1302
+ server.resources.length > 0 ||
1303
+ server.resourceTemplates.length > 0
1304
+ ) {
1183
1305
  capabilities.resources = {
1184
1306
  listChanged: true,
1185
1307
  subscribe: false
@@ -1192,7 +1314,9 @@ const layerHandlers = (serverInfo: {
1192
1314
  return Effect.succeed({
1193
1315
  capabilities,
1194
1316
  serverInfo,
1195
- protocolVersion: SUPPORTED_PROTOCOL_VERSIONS.includes(requestedVersion)
1317
+ protocolVersion: SUPPORTED_PROTOCOL_VERSIONS.includes(
1318
+ requestedVersion
1319
+ )
1196
1320
  ? requestedVersion
1197
1321
  : LATEST_PROTOCOL_VERSION
1198
1322
  })
@@ -1201,12 +1325,20 @@ const layerHandlers = (serverInfo: {
1201
1325
  "logging/setLevel": () => InternalError.notImplemented,
1202
1326
  "prompts/get": server.getPromptResult,
1203
1327
  "prompts/list": () => Effect.sync(() => new ListPromptsResult({ prompts: server.prompts })),
1204
- "resources/list": () => Effect.sync(() => new ListResourcesResult({ resources: server.resources })),
1328
+ "resources/list": () =>
1329
+ Effect.sync(
1330
+ () => new ListResourcesResult({ resources: server.resources })
1331
+ ),
1205
1332
  "resources/read": ({ uri }) => server.findResource(uri),
1206
1333
  "resources/subscribe": () => InternalError.notImplemented,
1207
1334
  "resources/unsubscribe": () => InternalError.notImplemented,
1208
1335
  "resources/templates/list": () =>
1209
- Effect.sync(() => new ListResourceTemplatesResult({ resourceTemplates: server.resourceTemplates })),
1336
+ Effect.sync(
1337
+ () =>
1338
+ new ListResourceTemplatesResult({
1339
+ resourceTemplates: server.resourceTemplates
1340
+ })
1341
+ ),
1210
1342
  "tools/call": server.callTool,
1211
1343
  "tools/list": () => Effect.sync(() => new ListToolsResult({ tools: server.tools })),
1212
1344
 
@@ -1245,17 +1377,21 @@ const resolveResourceContent = (
1245
1377
  ): typeof ReadResourceResult.Type => {
1246
1378
  if (typeof content === "string") {
1247
1379
  return {
1248
- contents: [{
1249
- uri,
1250
- text: content
1251
- }]
1380
+ contents: [
1381
+ {
1382
+ uri,
1383
+ text: content
1384
+ }
1385
+ ]
1252
1386
  }
1253
1387
  } else if (content instanceof Uint8Array) {
1254
1388
  return {
1255
- contents: [{
1256
- uri,
1257
- blob: content
1258
- }]
1389
+ contents: [
1390
+ {
1391
+ uri,
1392
+ blob: content
1393
+ }
1394
+ ]
1259
1395
  }
1260
1396
  }
1261
1397
  return content