Classes
JsonRpcError
2
▼
JSON-RPC error object (§5.1).
JsonRpcError
2
▼
JSON-RPC error object (§5.1).
Attributes
| Name | Type | Description |
|---|---|---|
code |
int
|
— |
message |
str
|
— |
JsonRpcErrorResponse
3
▼
JSON-RPC error response envelope.
JsonRpcErrorResponse
3
▼
JSON-RPC error response envelope.
Attributes
| Name | Type | Description |
|---|---|---|
jsonrpc |
str
|
— |
error |
JsonRpcError
|
— |
id |
str | int | float | None
|
— |
JsonRpcSuccessResponse
3
▼
JSON-RPC success response envelope.
JsonRpcSuccessResponse
3
▼
JSON-RPC success response envelope.
Attributes
| Name | Type | Description |
|---|---|---|
jsonrpc |
str
|
— |
result |
Any
|
— |
id |
str | int | float | None
|
— |
McpContentBlock
2
▼
MCP text content block.
McpContentBlock
2
▼
MCP text content block.
Attributes
| Name | Type | Description |
|---|---|---|
type |
str
|
— |
text |
str
|
— |
Functions
handle_mcp_request
2
Response
▼
Handle an MCP JSON-RPC request.
Takes a chirp Request, returns a chirp Respons…
async
handle_mcp_request
2
Response
▼
async def handle_mcp_request(request: Request, registry: ToolRegistry) -> Response
Handle an MCP JSON-RPC request.
Takes a chirp Request, returns a chirp Response. This function is
called from within the middleware pipeline inhandle_request(),
so all middleware (auth, CORS, rate limiting) applies.
Parameters
| Name | Type | Description |
|---|---|---|
request |
Request |
|
registry |
ToolRegistry |
Returns
Response
_handle_notification
1
Response
▼
Handle a JSON-RPC notification (no response expected).
MCP clients send ``noti…
_handle_notification
1
Response
▼
def _handle_notification(method: str) -> Response
Handle a JSON-RPC notification (no response expected).
MCP clients sendnotifications/initializedafter the initialize
handshake completes. Per JSON-RPC spec, notifications have noid
and the server MUST NOT reply. We return 204 No Content.
Parameters
| Name | Type | Description |
|---|---|---|
method |
str |
Returns
Response
_dispatch
3
Any
▼
Route a JSON-RPC method to the appropriate handler.
async
_dispatch
3
Any
▼
async def _dispatch(method: str, params: dict[str, Any], *, registry: ToolRegistry) -> Any
Parameters
| Name | Type | Description |
|---|---|---|
method |
str |
|
params |
dict[str, Any] |
|
registry |
ToolRegistry |
Returns
Any
_handle_initialize
1
dict[str, Any]
▼
Handle MCP ``initialize`` — capability negotiation.
_handle_initialize
1
dict[str, Any]
▼
def _handle_initialize(params: dict[str, Any]) -> dict[str, Any]
Parameters
| Name | Type | Description |
|---|---|---|
params |
dict[str, Any] |
Returns
dict[str, Any]
_handle_tools_list
1
dict[str, Any]
▼
Handle MCP ``tools/list`` — return registered tool schemas.
_handle_tools_list
1
dict[str, Any]
▼
def _handle_tools_list(registry: ToolRegistry) -> dict[str, Any]
Parameters
| Name | Type | Description |
|---|---|---|
registry |
ToolRegistry |
Returns
dict[str, Any]
_handle_tools_call
2
dict[str, Any]
▼
Handle MCP ``tools/call`` — dispatch to tool handler.
async
_handle_tools_call
2
dict[str, Any]
▼
async def _handle_tools_call(params: dict[str, Any], registry: ToolRegistry) -> dict[str, Any]
Parameters
| Name | Type | Description |
|---|---|---|
params |
dict[str, Any] |
|
registry |
ToolRegistry |
Returns
dict[str, Any]
_format_result
1
McpContentBlock
▼
Format a tool result as an MCP content block.
_format_result
1
McpContentBlock
▼
def _format_result(result: Any) -> McpContentBlock
Parameters
| Name | Type | Description |
|---|---|---|
result |
Any |
Returns
McpContentBlock
_json_response
2
Response
▼
Build a chirp Response with JSON content.
_json_response
2
Response
▼
def _json_response(status: int, body: JsonRpcErrorResponse | JsonRpcSuccessResponse) -> Response
Parameters
| Name | Type | Description |
|---|---|---|
status |
int |
|
body |
JsonRpcErrorResponse | JsonRpcSuccessResponse |
Returns
Response