MCP Transport – SSE (Server Sent Events)
Normal HTTP
- Client Asks -> Server Replies -> Connection Closes
- If client wants updates, it must keep asking (polling)
SSE
- Client Asks once -> Server keeps replying many times
- Connection stays open
- Server Pushes updates like
- Task started
- 50 % progress
- Here is the final output
Why MCP used to use SSE
- MCP needs to stream
- logs
- tool output
- partial AI results
- events
- Client listens on /sse
- MCP Server pushes events as they Happen
- No Polling, no delays.
-
SSE is one way streaming: server -> client only
-
SSE is a standard unidirectional communication from server to client over a single, long lived HTTP connection.
- Protocol: SSE uses standard HTTP with MIME type text/event-stream
- Client API: The browser uses EventSource API to recieve events
- Format: Messages are sent as plain text with fields such as event, data and id each terminated by two endlines
- SSE is split into two parts
- SSE endpoint: way to handshake connection b/w client and server
- Messages endpoint: This is use to route messages to MCP servers and its features
Creating an SSE Server as a web app
- In python we need to use a framework supporting ASGI. For this we will be using
Starlette. -
Starlette is a lightweight ASGI framework, We need uvicorn to run Starlette Application
-
Create a new folder, initialize using uv and execute the following
uv add starlette uvicorn
.venv\Scripts\activate
- Add this code to main.py
from starlette.applications import Starlette
from starlette.responses import JSONResponse
from starlette.routing import Route
async def homepage(request):
return JSONResponse({"hello": "world"})
async def otherpage(request):
return JSONResponse({"other": "page"})
app = Starlette(debug=True, routes=[
Route("/", homepage),
Route("/other", otherpage),
])
- run the application using
uv run main:app -
Now access
http://localhost:8000/andhttp://localhost:8000/other

-
Refer Here for the code written
Starlette and MCP
- Lets create a new folder and initialize and add the necessary dependencies
uv add mcp[cli] httpx uvicorn starlette - Create mcp server as usual
- Refer Here as a sample .
