{"id":18558,"library":"middy-mcp","title":"middy-mcp","description":"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.","status":"active","version":"0.1.6","language":"javascript","source_language":"en","source_url":"https://github.com/fredericbarthelet/middy-mcp","tags":["javascript","mcp","model context protocol","middy","middleware","aws","lambda","typescript"],"install":[{"cmd":"npm install middy-mcp","lang":"bash","label":"npm"},{"cmd":"yarn add middy-mcp","lang":"bash","label":"yarn"},{"cmd":"pnpm add middy-mcp","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency for Middy middleware framework","package":"@middy/core","optional":false},{"reason":"Required for McpServer creation","package":"@modelcontextprotocol/sdk","optional":false}],"imports":[{"note":"ESM-only package; default export is the middleware function.","wrong":"const mcpMiddleware = require('middy-mcp');","symbol":"default","correct":"import mcpMiddleware from 'middy-mcp'"},{"note":"Must import from the specific subpath /server/mcp.js for correct ESM resolution.","wrong":"import { McpServer } from '@modelcontextprotocol/sdk'","symbol":"McpServer","correct":"import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'"},{"note":"Default export from @middy/core; named export 'middy' does not exist.","wrong":"import { middy } from '@middy/core'","symbol":"middy","correct":"import middy from '@middy/core'"}],"quickstart":{"code":"import middy from '@middy/core';\nimport mcpMiddleware from 'middy-mcp';\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { z } from 'zod';\n\nconst server = new McpServer({ name: 'MyMCP', version: '1.0.0' });\nserver.tool('add', { a: z.number(), b: z.number() }, async ({ a, b }) => ({\n  content: [{ type: 'text', text: String(a + b) }],\n}));\n\nexport const handler = middy()\n  .use(mcpMiddleware({ server }));","lang":"typescript","description":"Create a Lambda handler with MCP server and Middy middleware."},"warnings":[{"fix":"Ensure MCP client supports version 2025-03-26+","message":"Only compatible with MCP clients using protocol version 2025-03-26 or later.","severity":"breaking","affected_versions":">=0.0.0"},{"fix":"Update to v0.1.0+ for header compatibility with other middlewares.","message":"Cannot be used in a bundle with other middlewares that modify headers due to order issues.","severity":"gotcha","affected_versions":"<0.1.0"},{"fix":"Use @middy/http-error-handler after mcpMiddleware.","message":"Requires HTTP error handler middleware to handle thrown HTTP exceptions.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Upgrade @middy/core to v6 or later.","message":"Requires Middy >= 6.0.0, which introduced breaking changes from earlier versions.","severity":"breaking","affected_versions":">=0.0.0"},{"fix":"Convert project to ESM or use dynamic import().","message":"The package uses ESM-only exports – CommonJS require() will not work.","severity":"deprecated","affected_versions":">=0.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Install @modelcontextprotocol/sdk and import from '@modelcontextprotocol/sdk/server/mcp.js'.","cause":"Missing or incorrect import path for the SDK.","error":"Cannot find module '@modelcontextprotocol/sdk'"},{"fix":"Use import middy from '@middy/core' (default import).","cause":"Incorrect import of Middy (named instead of default).","error":"TypeError: middy is not a function"},{"fix":"Update MCP client to support protocol version 2025-03-26 or later.","cause":"MCP client uses an older protocol version.","error":"Error: MCP protocol version not supported. Must be at least 2025-03-26."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}