MCPcopy
hub / github.com/Effect-TS/effect / handler

Function handler

packages/ai/ai/src/McpServer.ts:895–913  ·  view source on GitHub ↗
(input: string)

Source from the content-addressed store, hash-verified

893 for (const [param, handle] of Object.entries(options.completion ?? {})) {
894 const encodeArray = Schema.encodeUnknown(Schema.Array(params[param]))
895 const handler = (input: string) =>
896 handle(input).pipe(
897 Effect.flatMap(encodeArray),
898 Effect.map(
899 (values) =>
900 new CompleteResult({
901 completion: {
902 values: values as Array<string>,
903 total: values.length,
904 hasMore: false
905 }
906 })
907 ),
908 Effect.catchAllCause((cause) => {
909 const prettyError = Cause.prettyErrors(cause)[0]
910 return new InternalError({ message: prettyError.message })
911 }),
912 Effect.provide(context)
913 )
914 completions[param] = handler
915 }
916 yield* registry.addResourceTemplate({

Callers 1

McpServerClass · 0.70

Calls 4

handleFunction · 0.70
pipeMethod · 0.65
mapMethod · 0.65
provideMethod · 0.65

Tested by

no test coverage detected