Recipes¶
Short, opinionated cookbook entries. Each one is a complete, runnable snippet that solves a single concrete problem. Browse the list:
- Expose a service — the smallest possible end-to-end.
- Swap the session store — when the default cache isn't what you want.
- Add a custom permission — a kernel
PermissionCheckon a spec, a prompt or a view. - Write an async-native auth backend —
httpxintrospection against a remote IDP without blocking the event loop. - Add rate limiting — per-binding
MCPRateLimitwith the shippedFixedWindowRateLimit/SlidingWindowRateLimitor your own. - Multi-worker SSE with Redis — swap the in-memory
broker for
RedisSSEBrokerso any ASGI worker can fan out push messages. - Resume SSE with Last-Event-ID — opt-in per-session replay buffer so reconnecting clients catch up on missed events.
- Selector tool with FilterSet —
expose a list-shaped read tool with
django-filter, ordering, and pagination, generatedinputSchemaand all. - Render a list as an interactive table — MCP Apps:
declare a
ui://view, link a selector tool to it, and a host draws the results inline in the chat instead of reading JSON aloud. - Register tools from a shared spec registry
— when the same specs are exposed over MCP and another transport, declare
them once in a kernel
SpecRegistryand bulk-register withregister_tools. - Connect a Pydantic-AI agent over MCP — drive this
server from a
pydantic_ai.AgentwithMCPToolset, and when to reach for the in-processSpecToolsetinstead. - Migrate from
fastapi-mcp/ hand-rolled MCP — step by step from a custom Django MCP view or afastapi-mcpapp. - Hide plumbing from the model — mark presented fields as handles, labels or plumbing so a tool result stops naming records by primary key and reading ETags out loud.