Model Context Protocol – Advanced Patterns for Production By the end of this lesson, students should be able to: Transport selection criteria. Default choice: stdio for personal tools and development. HTTP/SSE for production servers, shared organizational tools, and remote deployments. HTTP/SSE server implementation (Python pattern). from mcp.server.sse import SseServerTransport sse = SseServerTransport("/messages/") async def handle_sse(request): starlette_app = Starlette(routes=[ Run with an ASGI server (uvicorn). Verify current HTTP/SSE implementation patterns at modelcontextprotocol.io/sdk. Authentication for remote servers. Remote MCP servers should require authentication. Common patterns: For Claude Code connecting to a remote server, configure the bearer token in the MCP server configuration entry. The client includes it on every connection. Health checks and load balancing. HTTP/SSE servers integrate with standard infrastructure: stdio servers have no HTTP surface – health checking must be via process monitoring. Enroll to continue this lesson. The preview above shows the lesson objectives and opening lesson content. Enroll to view the full lesson, complete the practice work, and take the lesson quiz.
Lesson 4: Transport Mechanisms for Production
Lesson Objectives
Lesson Content
from starlette.applications import Starlette
from starlette.routing import Route, Mount
async with sse.connect_sse(request.scope, request.receive, request._send) as streams:
await app.run(streams[0], streams[1], app.create_initialization_options())
Route("/sse", endpoint=handle_sse),
Mount("/messages/", app=sse.handle_post_message),
])/health endpoint that returns 200 when the server is ready/health
