- Explore MCP Servers
- middy-mcp
Middy Mcp
What is Middy Mcp
Middy MCP is a middleware designed for integrating Model Context Protocol (MCP) servers with AWS Lambda functions, facilitating the handling of MCP requests and responses within the Lambda environment.
Use cases
Use cases for Middy MCP include building serverless APIs that need to process complex data structures, integrating with existing MCP clients, and creating responsive applications that leverage AWS Lambda’s scalability.
How to use
To use Middy MCP, install it via pnpm with the command ‘pnpm install middy-mcp’. Then, integrate it into your Lambda function by creating an MCP server instance and applying the middleware in your handler function, typically alongside an HTTP error handler.
Key features
Key features of Middy MCP include seamless integration with AWS Lambda, support for both REST API and HTTP API through API Gateway, compatibility with Application Load Balancer (ALB) requests, and the ability to handle HTTP exceptions effectively.
Where to use
Middy MCP can be used in serverless applications that require the processing of Model Context Protocol requests, particularly in environments hosted on AWS Lambda, making it suitable for various cloud-based services.
Clients Supporting MCP
The following are the main client software that supports the Model Context Protocol. Click the link to visit the official website for more information.
Overview
What is Middy Mcp
Middy MCP is a middleware designed for integrating Model Context Protocol (MCP) servers with AWS Lambda functions, facilitating the handling of MCP requests and responses within the Lambda environment.
Use cases
Use cases for Middy MCP include building serverless APIs that need to process complex data structures, integrating with existing MCP clients, and creating responsive applications that leverage AWS Lambda’s scalability.
How to use
To use Middy MCP, install it via pnpm with the command ‘pnpm install middy-mcp’. Then, integrate it into your Lambda function by creating an MCP server instance and applying the middleware in your handler function, typically alongside an HTTP error handler.
Key features
Key features of Middy MCP include seamless integration with AWS Lambda, support for both REST API and HTTP API through API Gateway, compatibility with Application Load Balancer (ALB) requests, and the ability to handle HTTP exceptions effectively.
Where to use
Middy MCP can be used in serverless applications that require the processing of Model Context Protocol requests, particularly in environments hosted on AWS Lambda, making it suitable for various cloud-based services.
Clients Supporting MCP
The following are the main client software that supports the Model Context Protocol. Click the link to visit the official website for more information.
Content
Middy MCP
A Middy middleware for Model Context Protocol (MCP) server integration with AWS Lambda functions.
Description
Middy MCP is a middleware that enables seamless integration between AWS Lambda functions and Model Context Protocol servers. It provides a convenient way to handle MCP requests and responses within your Lambda functions using the Middy middleware framework. It supports requests sent to AWS Lambda from API Gateway (both REST API / v1 and HTTP API / v2) using the Proxy integration, as well as requests sent form an ALB.
Disclaimer: hosting your MCP server this way is only compatible with MCP clients using at least protocol version 2025-03-26.
Install
pnpm install middy-mcp
Requirements
- Node.js >= 18.0.0
- Middy >= 6.0.0
Usage
This middleware can throw HTTP exceptions, so it can be convenient to use it in combination with the @middy/http-error-handler.
Hereafter is an exemple of a minimal Lambda function handler file. Deploy this lambda as a proxy integration on a POST route of your API Gateway and you’re good to go.
import middy from "@middy/core";
import httpErrorHandler from "@middy/http-error-handler";
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { z } from "zod";
import mcpMiddleware from "middy-mcp";
// Create an MCP server
const server = new McpServer({
name: "Lambda hosted MCP Server",
version: "1.0.0",
});
// Add an addition tool
server.tool("add", { a: z.number(), b: z.number() }, async ({ a, b }) => ({
content: [{ type: "text", text: String(a + b) }],
}));
export const handler = middy()
.use(mcpMiddleware({ server }))
.use(httpErrorHandler());
License
This project is licensed under the MIT License - see the LICENSE file for details.
Contributing
Contributions are welcome! Please feel free to open an issue or to submit a pull request 🚀!
Dev Tools Supporting MCP
The following are the main code editors that support the Model Context Protocol. Click the link to visit the official website for more information.










