Registry / aws / middy-mcp

middy-mcp

JSON →
library0.1.6jsnpmunverified

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-mcp
INSTALL
IMPORT
SIG · MIDDY-MCP
M
middy-mcp
awsjavascriptv0.1.6
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import mcpMiddleware from 'middy-mcp'
const mcpMiddleware = require('middy-mcp');
ESM-only package; default export is the middleware function.
McpServer
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'
import { McpServer } from '@modelcontextprotocol/sdk'
Must import from the specific subpath /server/mcp.js for correct ESM resolution.
middy
import middy from '@middy/core'
import { middy } from '@middy/core'
Default export from @middy/core; named export 'middy' does not exist.

Create a Lambda handler with MCP server and Middy middleware.

import middy from '@middy/core'; import mcpMiddleware from 'middy-mcp'; import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'; import { z } from 'zod'; const server = new McpServer({ name: 'MyMCP', version: '1.0.0' }); 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 }));
Debug
Known issues
breakingOnly compatible with MCP clients using protocol version 2025-03-26 or later.
fix
Ensure MCP client supports version 2025-03-26+
affects: >=0.0.0
gotchaCannot be used in a bundle with other middlewares that modify headers due to order issues.
fix
Update to v0.1.0+ for header compatibility with other middlewares.
affects: <0.1.0
gotchaRequires HTTP error handler middleware to handle thrown HTTP exceptions.
fix
Use @middy/http-error-handler after mcpMiddleware.
affects: >=0.0.0
breakingRequires Middy >= 6.0.0, which introduced breaking changes from earlier versions.
fix
Upgrade @middy/core to v6 or later.
affects: >=0.0.0
deprecatedThe package uses ESM-only exports – CommonJS require() will not work.
fix
Convert project to ESM or use dynamic import().
affects: >=0.0.0
Errors
Common errors & fixes
Cannot find module '@modelcontextprotocol/sdk'
Missing or incorrect import path for the SDK.
fix
Install @modelcontextprotocol/sdk and import from '@modelcontextprotocol/sdk/server/mcp.js'.
TypeError: middy is not a function
Incorrect import of Middy (named instead of default).
fix
Use import middy from '@middy/core' (default import).
Error: MCP protocol version not supported. Must be at least 2025-03-26.
MCP client uses an older protocol version.
fix
Update MCP client to support protocol version 2025-03-26 or later.
Upgrade
Version history
0.1.6latest on npm
Audit
Dependencies
@middy/corerequiredPeer dependency for Middy middleware framework
@modelcontextprotocol/sdkrequiredRequired for McpServer creation
Agent activity
12 hits · last 30 days
node
11
OpenAI (training)
1
Resources
middy-mcp — npm install middy-mcp · libregistry