Enables serverless deployment of OpenAPI MCP servers on AWS Lambda with API Gateway, allowing MCP clients to interact with OpenAPI-defined APIs through AWS infrastructure
OpenAPI MCP Server - AWS Lambda Deployment
Serverless deployment of the AWS Labs OpenAPI MCP Server on AWS Lambda with API Gateway.
Overview
This project wraps the awslabs openapi-mcp-server to run as a serverless Lambda function, enabling MCP (Model Context Protocol) clients to interact with OpenAPI-defined APIs through AWS infrastructure.
Architecture
Lambda Function: FastMCP server with HTTP transport (Starlette ASGI)
API Gateway: HTTP API exposing the MCP endpoints
Transport: Mangum ASGI adapter (no child process overhead)
Prerequisites
Python 3.12+
uv package manager
AWS CLI configured
AWS CDK CLI:
npm install -g aws-cdk
Local Setup
Install dependencies:
Deployment
1. Bootstrap CDK (first time only)
2. Deploy Stack
Configuration Parameters
ApiName
: Display name for the APIApiBaseUrl
: Base URL of the target APIApiSpecUrl
: URL to the OpenAPI specification (JSON or YAML)AuthType
: Authentication method (none
,basic
,bearer
,api_key
,cognito
)
Additional Auth Configuration
Set environment variables in cdk/openapi_mcp_stack.py for authentication:
Basic Auth:
AUTH_USERNAME
AUTH_PASSWORD
Bearer Token:
AUTH_TOKEN
API Key:
AUTH_API_KEY
AUTH_API_KEY_NAME
AUTH_API_KEY_IN
(header/query/cookie)
Cognito:
AUTH_COGNITO_CLIENT_ID
AUTH_COGNITO_USERNAME
AUTH_COGNITO_PASSWORD
AUTH_COGNITO_USER_POOL_ID
AUTH_COGNITO_REGION
3. Get API URL
After deployment, CDK outputs the API Gateway URL:
Testing
Test the deployed Lambda function:
Performance Considerations
Cold Start: ~1-2 seconds (initializes MCP server + loads OpenAPI spec)
Warm Start: ~100-300ms (reuses server instance)
Timeout: 30 seconds (configurable in stack)
Memory: 512 MB (configurable in stack)
Cost Optimization
Requests: Pay per invocation
Memory/Duration: 512 MB x execution time
API Gateway: HTTP API (cheaper than REST API)
Development
Run MCP server locally:
Cleanup
License
This project includes code from awslabs/mcp licensed under Apache-2.0. See LICENSE and NOTICE files.
This server cannot be installed
remote-capable server
The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.
Enables MCP clients to interact with any OpenAPI-defined REST API through a serverless AWS Lambda deployment. Supports multiple authentication methods and provides cost-effective, scalable access to third-party APIs through natural language.