From stdio to the Web: Streamable HTTP and Mounting MCP in FastAPI
Move your MCP server from stdio to the web: how Streamable HTTP sessions and SSE streams work, flipping the transport in FastMCP, and mounting the server inside a FastAPI app.
Tag
Move your MCP server from stdio to the web: how Streamable HTTP sessions and SSE streams work, flipping the transport in FastMCP, and mounting the server inside a FastAPI app.
Build real FastAPI endpoints: typed routing, Pydantic request and response models, dependency injection, and automatic docs.
Harden a FastAPI app for production: typed settings with pydantic-settings, bearer auth, logging and CORS middleware, and a scalable project structure.
Stream responses from FastAPI with server sent events, run side effects with BackgroundTasks, and know when to move to a real task queue.
Test FastAPI with pytest and the test client: assert on validation, override dependencies to isolate from real services, and cover async and streaming code.
Build a RAG service end to end: chunk documents, embed and search by similarity, and answer grounded in retrieved context from a FastAPI endpoint.
Stream a real model response to the browser: consume the model stream in Python, forward it through a FastAPI SSE endpoint, and render it live.
Build a small AI agent API: the tool calling loop, conversation memory, and the guardrails that keep an action taking agent safe and bounded.