|
|
MCP over HTTP with SSE Transport
Author: Venkata Sudhakar
Stdio transport works well for single-agent setups where the MCP server runs as a subprocess. But when multiple ADK agents across different machines need the same tools, you need a persistent MCP server accessible over the network. MCP supports HTTP with Server-Sent Events (SSE) as a transport, turning the server into a long-running service that any agent can connect to over HTTP.
FastMCP runs as an HTTP server when you set transport to 'sse'. The agent connects using SseServerParameters with the server URL instead of StdioServerParameters. The SSE connection stays open for the duration of the session, allowing the server to stream tool results back to the agent in real time. This is the recommended transport for production deployments where the MCP server is shared infrastructure.
The below example shows a ShopMax India MCP server running as an HTTP service, with an ADK agent connecting to it over the network.
Start the server in a terminal, then connect an ADK agent using SSE transport,
It gives the following output,
Q: Do you have any laptops available?
A: Yes! We have the Lenovo IdeaPad laptop in stock.
Price: Rs 45,000 | Stock: 42 units available. Ready to ship!
Q: What is the price of the LG TV?
A: The LG 43-inch 4K TV is priced at Rs 35,000.
We currently have 15 units in stock. Would you like to order one?
SSE transport makes the MCP server network-accessible, so deploy it behind a reverse proxy like nginx or Cloud Run with HTTPS enabled. Add authentication headers to SseServerParameters using the headers parameter to pass Bearer tokens or API keys with each HTTP request. For high-availability deployments at ShopMax India, run multiple MCP server replicas behind a load balancer - the stateless tool design means any replica can handle any request without session affinity.
|
|