api
from corio import api
api provides a lightweight FastAPI base where endpoints are defined as classes.
Main pieces:
endpoint.Base: base endpoint contract (run)endpoint.API: class-based HTTP endpoint with registration helpersendpoint.MCP: class-based MCP endpoint with tool registration helpersendpoint.Tool: MCP tool endpointendpoint.Prompt: MCP prompt endpointendpoint.Resource: MCP resource endpointBase: app bootstrap, endpoint registration, child API mounting, and uvicorn launch helpers
Install:
pip install "corio[api]" --upgrade
Typical Endpoint Pattern
from __future__ import annotations
from corio import api
class HealthApi(api.Base):
TITLE = "Health API"
@property
def ENDPOINTS(self):
return [Health]
@property
def TRANSFORMS(self):
return []
class Health(api.endpoint.API):
"""Service health."""
PATH = "/health"
TAGS = "status"
async def run(self):
return {"ok": True}
Run with:
HealthApi.launch()
Real-World Usage Pattern (generalized)
Sibling repos commonly:
- subclass
api.Base - keep endpoint class list in
ENDPOINTS(can includeapi.endpoint.APIandapi.endpoint.MCP) - keep MCP transform class list in
TRANSFORMS(each class is initialized withself.mcp) - attach tags per feature area (
cache,blocking,documents, etc.) - mount child APIs using
childrenwhen composing a larger API surface
Notes
Baseinstruments FastAPI viacorio.logs.- In dev mode, exception handling is configured to re-raise for easier debugging.
- Endpoints register as GET routes.
- MCP endpoint classes register tools via
self.mcp.tool(...). - Default endpoint path is
/{endpoint_class_name_lower}unlessPATHis overridden.