Middy middleware for integrating Model Context Protocol (MCP) servers with AWS Lambda functions. Current version 0.1.6, requires Node.js >= 18.0.0 and Middy >= 6.0.0. Supports API Gateway (REST, HTTP API v2) and ALB proxy integrations, but only compatible with MCP clients using protocol version 2025-03-26 or later. Provides seamless request/response handling within the Middy middleware framework, with TypeScript type definitions included.
npm install middy-mcpVerified import paths — ran on the pinned version, not inferred.
Create a Lambda handler with MCP server and Middy middleware.
Ensure MCP client supports version 2025-03-26+
Update to v0.1.0+ for header compatibility with other middlewares.
Use @middy/http-error-handler after mcpMiddleware.
Upgrade @middy/core to v6 or later.
Convert project to ESM or use dynamic import().
Install @modelcontextprotocol/sdk and import from '@modelcontextprotocol/sdk/server/mcp.js'.
Use import middy from '@middy/core' (default import).
Update MCP client to support protocol version 2025-03-26 or later.