Lesson 07.06 · Phase 07 · Model Context Protocol
Streamable HTTP transport
A remote MCP server is one URL that accepts POST. Each request is its own HTTP exchange, answered with JSON or with a short SSE stream of progress then the result. Key fields are copied into headers so load balancers can route without reading the body, and the server checks they match.
Learning objectives
- Implement an MCP endpoint that accepts POST and answers each request with application/json or a text/event-stream carrying progress notifications then the final response.
- Mirror MCP-Protocol-Version, Mcp-Method, Mcp-Name and x-mcp-header parameters into headers, with the Base64 sentinel for unsafe values, and reject mismatches with -32020.
- Return the right HTTP status for each case: 202, 400, 403, 404, 405.
- Cancel a request by closing its stream, and run the same server as several stateless instances behind round-robin.
stdio works when the server runs on the user's machine. A company's ticket system, a SaaS product or a shared database server can't be spawned as a child process of every user's IDE. It needs to be a network service: one URL, many clients, deployed like any other web service, behind load balancers, gateways and proxies.
Loading the full lesson…