MCPcopy Index your code
hub / github.com/github/copilot-sdk / _dispatch_request

Method _dispatch_request

python/copilot/_jsonrpc.py:430–456  ·  view source on GitHub ↗
(self, message: dict, handler: RequestHandler)

Source from the content-addressed store, hash-verified

428 )
429
430 async def _dispatch_request(self, message: dict, handler: RequestHandler):
431 try:
432 params = message.get("params", {})
433 outcome = handler(params)
434 if inspect.isawaitable(outcome):
435 outcome = await outcome
436 if outcome is not None and not isinstance(
437 outcome, dict | list | str | int | float | bool
438 ):
439 raise ValueError(
440 "Request handler must return a JSON-serializable value, "
441 f"got {type(outcome).__name__}"
442 )
443 await self._send_response(message["id"], outcome)
444 except JsonRpcError as exc:
445 logger.debug(
446 "Error handling JSON-RPC method %s: %s", message.get("method", ""), exc.message
447 )
448 await self._send_error_response(message["id"], exc.code, exc.message, exc.data)
449 except Exception as exc: # pylint: disable=broad-except
450 logger.debug(
451 "Error handling JSON-RPC method %s: %s",
452 message.get("method", ""),
453 str(exc),
454 exc_info=True,
455 )
456 await self._send_error_response(message["id"], -32603, str(exc), None)
457
458 async def _send_response(self, request_id: str, result: Any):
459 response = {

Callers 1

_handle_requestMethod · 0.95

Calls 4

_send_responseMethod · 0.95
_send_error_responseMethod · 0.95
handlerFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected