MCPcopy Create free account
hub / github.com/Effect-TS/effect / handler

Function handler

packages/effect/src/unstable/ai/McpServer.ts:1750–1768  ·  view source on GitHub ↗
(
        input: string,
        context: CompletionContext
      )

Source from the content-addressed store, hash-verified

1748 for (const [param, handle] of Object.entries(options.completion ?? {})) {
1749 const encodeArray = Schema.encodeUnknownEffect(Schema.Array(params[param]))
1750 const handler = (
1751 input: string,
1752 context: CompletionContext
1753 ) =>
1754 handle(input, context).pipe(
1755 Effect.flatMap(encodeArray),
1756 Effect.map((values) => ({
1757 completion: {
1758 values: values as Array<string>,
1759 total: values.length,
1760 hasMore: false
1761 }
1762 })),
1763 Effect.catchCause((cause) => {
1764 const prettyError = Cause.prettyErrors(cause)[0]
1765 return Effect.fail(new InternalError({ message: prettyError.message }))
1766 }),
1767 Effect.provideContext(services)
1768 )
1769 completions[param] = handler
1770 }
1771 yield* registry.addResourceTemplate({

Callers 11

Stream.tsFile · 0.50
matchFunction · 0.50
makeWriteFunction · 0.50
handleRemoteFunction · 0.50
runFunction · 0.50
emitFunction · 0.50
accessHandlerFunction · 0.50
makeFunction · 0.50
onMessageFunction · 0.50
runRawFunction · 0.50

Calls 5

handleFunction · 0.70
pipeMethod · 0.65
mapMethod · 0.45
failMethod · 0.45
provideMethod · 0.45

Tested by

no test coverage detected