MCPcopy Create free account
hub / github.com/bearlyai/OpenADE / invokeHandler

Method invokeHandler

projects/runtime/src/server.ts:313–341  ·  view source on GitHub ↗
(request: RuntimeRequest, connection: RuntimeConnection, entry: RegisteredRuntimeHandler)

Source from the content-addressed store, hash-verified

311 }
312
313 private async invokeHandler(request: RuntimeRequest, connection: RuntimeConnection, entry: RegisteredRuntimeHandler): Promise<RuntimeResponse> {
314 try {
315 let params = request.params
316 if (entry.validateParams) {
317 const validation = entry.validateParams(params)
318 if (!validation.ok) {
319 return {
320 id: request.id,
321 error: runtimeError(validation.error.code, validation.error.message, { path: validation.error.path }),
322 }
323 }
324 params = validation.value
325 }
326 const result = await entry.handler(params, { connection, server: this })
327 if (request.method === "initialize") this.initializedConnections.add(connection.id)
328 return { id: request.id, result: result === undefined ? null : result }
329 } catch (error) {
330 if (error instanceof RuntimeHandlerError) {
331 return {
332 id: request.id,
333 error: runtimeError(error.code, error.message, error.data),
334 }
335 }
336 return {
337 id: request.id,
338 error: runtimeError("handler_error", error instanceof Error ? error.message : "Runtime handler failed"),
339 }
340 }
341 }
342
343 private clientRequestKey(request: RuntimeRequest, connection: RuntimeConnection): string | undefined {
344 if (!this.isRetainableMethod(request.method)) return undefined

Callers 1

handleRequestMethod · 0.95

Calls 1

runtimeErrorFunction · 0.90

Tested by

no test coverage detected