Middy
Middy middleware for Model Context Protocol server hosting on AWS Lambda
What is Middy?
Middy is a Model Context Protocol (MCP) server that allows AI assistants like Claude, Cursor, and VS Code to middy middleware for model context protocol server hosting on aws lambda
Middy middleware for Model Context Protocol server hosting on AWS Lambda
This server falls under the Cloud Services category on MCPgee, the world's largest MCP server directory with 33,000+ servers.
Features
- Middy middleware for Model Context Protocol server hosting o
Use Cases
Maintainer
Works with
Installation
NPM
npx -y middy-mcpManual Installation
npx -y middy-mcpConfiguration
Configuration Details
claude_desktop_config.json
Performance
Response Metrics
Resource Usage
How to Set Up and Use Middy
middy-mcp is a Middy middleware package that enables hosting Model Context Protocol servers as AWS Lambda functions, turning any MCP server into a serverless endpoint accessible via API Gateway. It handles the HTTP request/response translation between MCP clients and the Lambda runtime so you can define tools with the standard MCP SDK and deploy them without a persistent server. Teams use it to expose internal tools, data sources, or AI capabilities to MCP clients at scale without managing infrastructure.
Prerequisites
- Node.js 18 or later
- Middy 6.0 or later (npm package @middy/core)
- An AWS account with Lambda and API Gateway configured
- An MCP client supporting protocol version 2025-03-26 or later
- npm or pnpm for package management
Install middy-mcp and its peer dependencies
Add middy-mcp along with the MCP SDK and Middy core to your Lambda project.
pnpm install middy-mcp @middy/core @middy/http-error-handler @modelcontextprotocol/sdkCreate your MCP server and register tools
Define an MCP server instance and register the tools you want to expose. Each tool specifies its input schema and a handler function that returns content.
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
import { z } from 'zod';
const server = new McpServer({ name: 'my-lambda-mcp', version: '1.0.0' });
server.tool('add', { a: z.number(), b: z.number() }, async ({ a, b }) => ({
content: [{ type: 'text', text: String(a + b) }]
}));Wrap your Lambda handler with mcpMiddleware
Import the middleware and wrap your handler. Combine it with @middy/http-error-handler so HTTP exceptions are returned as proper error responses.
import middy from '@middy/core';
import httpErrorHandler from '@middy/http-error-handler';
import { mcpMiddleware } from 'middy-mcp';
export const handler = middy()
.use(mcpMiddleware({ server }))
.use(httpErrorHandler());Deploy to AWS Lambda with an API Gateway POST integration
Deploy your function with a POST proxy integration on API Gateway. The middleware expects POST requests following the MCP HTTP transport specification.
Connect your MCP client to the Lambda endpoint
Point your MCP client at the API Gateway URL. The endpoint accepts MCP protocol messages over HTTP POST.
Middy Examples
Client configuration
Configure an MCP client (e.g., Claude Desktop) to use a Lambda-hosted MCP server via its API Gateway URL.
{
"mcpServers": {
"lambda-mcp": {
"command": "npx",
"args": ["-y", "middy-mcp"],
"env": {
"MCP_SERVER_URL": "https://your-api-gateway-id.execute-api.us-east-1.amazonaws.com/prod"
}
}
}
}Prompts to try
After deploying a Lambda-hosted MCP server with custom tools, you can invoke those tools through your MCP client.
- "Use the add tool to compute 42 plus 58."
- "List all available tools on the Lambda MCP server."
- "Call the data-lookup tool with id=12345 and return the result."
- "What tools does this server expose?"Troubleshooting Middy
MCP client reports protocol version mismatch
middy-mcp requires MCP clients that support protocol version 2025-03-26 or later. Update your MCP client to the latest version.
Lambda returns 500 errors for all MCP requests
Add @middy/http-error-handler after mcpMiddleware in the chain. Check CloudWatch logs for the actual error — common causes are missing tool handlers or malformed input schemas.
Tool calls time out on Lambda
Increase the Lambda function timeout (default is 3 seconds). For tools that call external APIs or run ML inference, set the timeout to 30 seconds or more in your Lambda configuration.
Frequently Asked Questions about Middy
What is Middy?
Middy is a Model Context Protocol (MCP) server that middy middleware for model context protocol server hosting on aws lambda It connects AI assistants to external tools and data sources through a standardized interface.
How do I install Middy?
Install via npm with the command: npx -y middy-mcp. Then add the server configuration to your AI client's JSON config file (e.g., claude_desktop_config.json or .cursor/mcp.json).
Which AI clients work with Middy?
Middy works with all major MCP-compatible AI clients including Claude Desktop, Claude Code, Cursor, VS Code (GitHub Copilot), Windsurf, and Cline.
Is Middy free to use?
Yes, Middy is open source and available under the MIT license. You can use it freely in both personal and commercial projects.
Middy Alternatives — Similar Cloud Services Servers
Looking for alternatives to Middy? Here are other popular cloud services servers you can use with Claude, Cursor, and VS Code.
Open WebUI
★ 138.2kUser-friendly AI Interface (Supports Ollama, OpenAI API, ...)
Anything LLM
★ 60.4kThe all-in-one AI productivity accelerator. On device and privacy first with no annoying setup or configuration.
LocalAI
★ 46.4kLocalAI is the open-source AI engine. Run any model - LLMs, vision, voice, image, video - on any hardware. No GPU required.
Nacos
★ 33.0kan easy-to-use dynamic service discovery, configuration and service management platform for building AI cloud native applications.
Xiaozhi ESP32
★ 26.7k本项目为xiaozhi-esp32提供后端服务,帮助您快速搭建ESP32设备控制服务器。Backend service for xiaozhi-esp32, helps you quickly build an ESP32 device control server.
Gateway
★ 11.8kA blazing fast AI Gateway with integrated guardrails. Route to 1,600+ LLMs, 50+ AI Guardrails with 1 fast & friendly API.
Browse More Cloud Services MCP Servers
Explore all cloud services servers available in the MCPgee directory. Each server includes setup guides for Claude, Cursor, and VS Code.
Set Up Middy in Your Editor
Choose your AI client for step-by-step setup instructions.
Quick Config Preview
Add this to your claude_desktop_config.json or .cursor/mcp.json
Ready to use Middy?
Browse our complete directory of 33,000+ MCP servers, read setup guides for your editor, and start building with the Model Context Protocol.