Topic 2: The production app
12 min read·22 Sept 2026
What stays the same, and what gets added
notes_assistant/server.py already knows everything about MCP: tools, resources, the prompt, auth. None of that changes. Production concerns are about the process around it: how requests arrive, how many copies run, what happens under load, and how you see inside it. Keeping those in a separate file means Module 11's capstone can import the same build_server and choose how much of this to switch on.
A few terms first:
- ASGI app: a Python callable
app(scope, receive, send)that a web server such as uvicorn drives.mcp.streamable_http_app()returns one; so does Starlette. - ASGI middleware: an ASGI app that wraps another and can look at, change, or answer each HTTP request before the inner app sees it. It works on raw HTTP.
- MCP middleware: the SDK's own
async (ctx, call_next)hook that wraps each decoded MCP message. It works on JSON-RPC methods. The two compose: ASGI middleware sees HTTP, MCP middleware sees MCP. - Lifespan: startup and shutdown code for an ASGI app. The SDK's session manager must run inside it.
- Replica: one running copy of the server. A fleet is several replicas that serve the same URL through a load balancer.