Skip to content

toFetchHandler

function toFetchHandler(server: ToolkitDefinition): FetchHandler;

Wrap a server definition as a runtime fetch handler.

  • GET *{ tools } (the tools/list corpus)
  • POST * → run the body as a tool call, returns ToolCallResult

Malformed JSON or a non-tool body yields a normalized BAD_REQUEST error (HTTP 200 with { ok: false }), so the caller always parses a result rather than a transport error.

ParameterTypeDescription
serverToolkitDefinitionThe compiled server definition.

FetchHandler

A fetch handler the bundle can export as default.