Model Context Protocol (MCP) is quickly becoming the standard for enabling LLMs to call external tools. It’s built around clean, declarative tool definitions—but most current implementations fall short of being production-ready. Every official MCP server in the Anthropic repo, for instance, runs locally and communicates over stdio. Even the few that support HTTP rely on Server-Sent Events (SSE) for streaming. This introduces stateful behavior, requiring persistent TCP connections, complicating retries, and ultimately making it incompatible with stateless environments like AWS Lambda. We’ve written more about these limitations, and how we’ve addressed them with MCPEngine.AWS Lambda offers instant scalability, no server management, and efficient, event-driven execution. We built native support for it in MCPEngine, so that MCP tools can run cleanly and reliably in serverless environments.MCPEngine is an open-source implementation of MCP that supports streamable HTTP alongside SSE, making it compatible with Lambda. It also includes first-class support for authentication, packaging, and other capabilities to build and deploy production-grade MCP servers.This post walks through building three progressively more realistic examples:A stateless MCP server with a single toolA stateful version using RDS and a context handlerAn authenticated version using OIDC (Google or Cognito)All three run entirely in Lambda, don't require a custom agent, and are MCP-spec compliant.1. Build and Deploy a Stateless Weather MCP APIYou can follow along on GitHub here for the full project.1.1 Defining the MCP ServerWe'll start with a single tool called get_weather. It takes a city name and returns a canned string response. There's no state or external API call — just enough to validate end-to-end behavior with a live LLM.Install the Python SDK:pip install mcpengine[cli,lambda]Create a file called app.py:from mcpengine import MCPEngine engine = MCPEngine() @engine.tool() def get_weather(city: str)...
First seen: 2025-04-23 21:47
Last seen: 2025-04-24 11:50