Middy

v0.1.6Cloud Servicesstable

Middy middleware for Model Context Protocol server hosting on AWS Lambda

mcpmodel context protocolmiddymiddlewareaws
Share:
39
Stars
0
Downloads
0
Weekly
0/5

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

Host MCP servers on AWS Lambda using Middy middleware for serverless deployment.
LicenseMIT
Languagetypescript
Versionv0.1.6
UpdatedApr 26, 2026
Statushealthy
Maintenanceactive

Works with

ClaudeOpenAIwindowsmacoslinux

Installation

NPM

npx -y middy-mcp

Manual Installation

npx -y middy-mcp

Configuration

Configuration Details

Config File

claude_desktop_config.json

Performance

Response Metrics

Response Time< 200ms
ThroughputMedium

Resource Usage

Memory UsageLow
CPU UsageLow

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
1

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/sdk
2

Create 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) }]
}));
3

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());
4

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.

5

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.

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.

Quick Config Preview

{ "mcpServers": { "middy": { "command": "npx", "args": ["-y", "middy-mcp"] } } }

Add this to your claude_desktop_config.json or .cursor/mcp.json

Read the full setup guide →

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.

33,000+ ServersFree & Open SourceStep-by-Step Guides