Module

server.handler

ASGI handler — translates ASGI scope/messages to chirp types.

The only component that touches raw ASGI directly. Converts scope dicts to typed Request objects, dispatches through middleware and routing, and sends Response back through ASGI send().

Functions

handle_request 14 None
Process a single HTTP request through the full pipeline.
async
async def handle_request(scope: Scope, receive: Receive, send: Send, *, router: Router, middleware: tuple[Callable[..., Any], ...], error_handlers: dict[int | type, Callable[..., Any]], kida_env: Environment | None = None, debug: bool, providers: dict[type, Callable[..., Any]] | None = None, tool_registry: ToolRegistry | None = None, mcp_path: str = '/mcp', sse_heartbeat_interval: float = 15.0, sse_retry_ms: int | None = None, sse_close_event: str | None = None) -> None
Parameters
Name Type Description
scope Scope
receive Receive
send Send
router Router
middleware tuple[Callable[..., Any], ...]
error_handlers dict[int | type, Callable[..., Any]]
kida_env Environment | None Default:None
debug bool
providers dict[type, Callable[..., Any]] | None Default:None
tool_registry ToolRegistry | None Default:None
mcp_path str Default:'/mcp'
sse_heartbeat_interval float Default:15.0
sse_retry_ms int | None Default:None
sse_close_event str | None Default:None
_invoke_handler 4 AnyResponse
Call the matched route handler, converting path params and return value.
async
async def _invoke_handler(match: RouteMatch, request: Request, *, kida_env: Environment | None = None, providers: dict[type, Callable[..., Any]] | None = None) -> AnyResponse
Parameters
Name Type Description
match RouteMatch
request Request
kida_env Environment | None Default:None
providers dict[type, Callable[..., Any]] | None Default:None
Returns
AnyResponse
_build_handler_kwargs 5 dict[str, Any]
Inspect handler signature and build kwargs from request + path params. Resolut…
def _build_handler_kwargs(handler: Callable[..., Any], request: Request, path_params: dict[str, str], providers: dict[type, Callable[..., Any]] | None = None, *, body_data: dict[str, Any] | None = None) -> dict[str, Any]

Inspect handler signature and build kwargs from request + path params.

Resolution order:

  1. request parameter (by name or Requestannotation)
  2. Path parameters (by name, with type conversion)
  3. Context cascade values (page routes only — handled in page_wrapper)
  4. Service providers (by type annotation viaapp.provide())
  5. Typed extraction (dataclass annotation → query string or body)
Parameters
Name Type Description
handler Callable[..., Any]
request Request
path_params dict[str, str]
providers dict[type, Callable[..., Any]] | None Default:None
body_data dict[str, Any] | None Default:None
Returns
dict[str, Any]
_read_body_if_needed 2 dict[str, Any] | None
Pre-read form/JSON body if the handler has extractable dataclass params. Only …
async
async def _read_body_if_needed(handler: Callable[..., Any], request: Request) -> dict[str, Any] | None

Pre-read form/JSON body if the handler has extractable dataclass params.

Only reads the body for non-GET methods. ReturnsNoneif no extraction is needed or the method is GET/HEAD.

Parameters
Name Type Description
handler Callable[..., Any]
request Request
Returns
dict[str, Any] | None