Serverless Streamable HTTP MCP Servers on AWS
— terraform, aws, mcp, llm — 2 min read
Introduction
Model Context Protocol (MCP) servers are all the rage these days, for better or worse. If you're not familiar with MCP or MCP servers Anthropic, the proprietor of the protocol, has published an introduction that may be worth a look.
Typically MCP servers live and die on the same machine as their invoking MCP client. They are installed via uvx
or npx
, spawned as a child process of a client such as Claude Code, and communication occurs via stdio pipes. Standard Input/Output (stdio) is one of the protocol's built-in transport types. The other two are Server-Sent Events (SSE) and Streamable HTTP both of which facilitate communication between an MCP client and server which are not running on the same machine, i.e., remotely. The former, now deprecated, never really saw widespread use, the latter, Streamable HTTP, is the scheme with which we will concern ourselves in this post. It's worth noting that the protocol supports custom transport schemes as well, but that is beyond the scope of this article.
Why?
You may find yourself wondering why anyone would want to remotely host an MCP server when you could avoid unnecessary network calls and communicate over fast and reliable pipes. To answer that question I will defer to the related debates concerning libraries versus services and SaaS versus on-prem distribution models for software, because many of the same costs and benefits apply:
- You decide when the users of your service receive upgrades
- Centralized observability and monitoring
- Abilty to provision specialized hardware to run your MCP server and lessen the hardware requirements of the consumers of your MCP server.
- etc
We will assume that if you're here you have a reason or requirement to remotely host your MCP server.
Architecture
Our architecture will consist of the following components:
- Lambda
- API Gateway
- Optionally: WAF
...
TODO: Rest of article