OpenAPI Lambda MCP Server
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.
README
OpenAPI MCP Server - AWS Lambda Deployment
Serverless deployment of the AWS Labs OpenAPI MCP Server on AWS Lambda with API Gateway.
Overview
This monorepo contains three packages for deploying OpenAPI MCP servers to AWS Lambda:
packages/mcp-server/- Core MCP server implementation (from awslabs/mcp)packages/lambda-runtime/- Lambda-specific runtime with Docker configurationpackages/infrastructure/- AWS CDK infrastructure code
Architecture
- Lambda Function: FastMCP server with HTTP transport via uvicorn
- API Gateway: HTTP API exposing the MCP endpoints
- Lambda Web Adapter: Native HTTP server support on Lambda (no ASGI adapter needed)
- Docker Deployment: Container image with all dependencies bundled
Prerequisites
- Python 3.12+
- uv package manager
- AWS CLI configured
- AWS CDK CLI:
npm install -g aws-cdk
Local Setup
Install dependencies for the workspace:
uv sync
This will install all packages in the monorepo workspace.
Deployment
All deployment commands are available in the infrastructure package. This project uses just for task automation. Install it with:
brew install just # macOS
cargo install just # or via cargo
1. Bootstrap CDK (first time only)
cd packages/infrastructure
just bootstrap
2. Deploy Stack
Deploy with custom API configuration using profiles (recommended):
cd packages/infrastructure
# List available profiles
just list-profiles
# Deploy using a profile
just deploy-profile zoho-crm
Or deploy with environment variables:
cd packages/infrastructure
export API_NAME=MyAPI
export API_BASE_URL=https://api.example.com
export API_SPEC_URL=https://api.example.com/openapi.json
export AUTH_TYPE=none
just deploy
Or deploy the Petstore example:
cd packages/infrastructure
just deploy-pet
Configuration Parameters
Configure via environment variables:
API_NAME: Display name for the API (also used for stack naming)API_BASE_URL: Base URL of the target APIAPI_SPEC_URL: URL to the OpenAPI specification (JSON or YAML)AUTH_TYPE: Authentication method (none,basic,bearer,api_key,cognito)
Default values (from justfile):
API_NAME: PetstoreAPIAPI_BASE_URL: https://petstore3.swagger.io/api/v3API_SPEC_URL: https://petstore3.swagger.io/api/v3/openapi.jsonAUTH_TYPE: none
Stack naming: The CDK stack name is automatically generated as openapi-mcp-<api-name> (lowercase, non-alphanumeric characters except dots replaced with dashes)
Examples:
API_NAME=PetstoreAPI→ stack:openapi-mcp-petstoreapiAPI_NAME="My API"→ stack:openapi-mcp-my-apiAPI_NAME="API_v2.0"→ stack:openapi-mcp-api-v2.0
Additional Auth Configuration
Set environment variables in cdk/openapi_mcp_stack.py for authentication:
Basic Auth:
AUTH_USERNAMEAUTH_PASSWORD
Bearer Token:
AUTH_TOKEN
API Key:
AUTH_API_KEYAUTH_API_KEY_NAMEAUTH_API_KEY_IN(header/query/cookie)
Cognito:
AUTH_COGNITO_CLIENT_IDAUTH_COGNITO_USERNAMEAUTH_COGNITO_PASSWORDAUTH_COGNITO_USER_POOL_IDAUTH_COGNITO_REGION
3. Monitor Deployment
Check stack status:
cd packages/infrastructure
just status
View Lambda logs:
cd packages/infrastructure
just logs
Get the deployed API URL from CloudFormation outputs.
Testing
Test locally with Docker:
cd packages/infrastructure
# Test with a profile (all-in-one: build, run, test, cleanup)
just test-local-profile petstore
# Or step-by-step
just docker-build
just docker-run-profile zoho-crm
just test
just docker-stop
Test the deployed Lambda function:
cd packages/infrastructure
# Test with profile
just test-profile zoho-crm
# Or automatically fetch API URL from CloudFormation
just test-deployed
Or test manually with curl:
curl -X POST https://<api-url>/mcp \
-H "Content-Type: application/json" \
-d '{"jsonrpc": "2.0", "method": "tools/list", "id": 1}'
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
Package Structure
packages/
├── mcp-server/ # Core MCP server implementation
│ ├── awslabs/ # AWS Labs OpenAPI MCP server code
│ ├── tests/ # Server tests
│ └── pyproject.toml
│
├── lambda-runtime/ # Lambda deployment runtime
│ ├── lambda_handler.py # Lambda entry point
│ ├── Dockerfile # Container image definition
│ ├── profiles/ # API configuration profiles
│ ├── scripts/ # Helper scripts
│ └── pyproject.toml
│
└── infrastructure/ # AWS CDK infrastructure
├── cdk/ # CDK stack definitions
├── justfile # Task automation
└── pyproject.toml
Run MCP Server Locally
cd packages/mcp-server
uv run awslabs.openapi-mcp-server \
--api-name MyAPI \
--api-url https://api.example.com \
--spec-url https://api.example.com/openapi.json
Working with Packages
Each package can be developed independently:
# Install mcp-server in development mode
cd packages/mcp-server
uv sync --extra test
# Run server tests
uv run pytest tests/ -v
# Work on lambda runtime
cd packages/lambda-runtime
# Edit Dockerfile, profiles, etc.
# Work on infrastructure
cd packages/infrastructure
# Edit CDK stacks, update justfile commands
Cleanup
Destroy the deployed stack:
cd packages/infrastructure
# Make sure API_NAME matches the deployed stack
export API_NAME=MyAPI # or whatever you deployed
just destroy
# Or for Petstore
API_NAME=PetstoreAPI just destroy
License
This project includes code from awslabs/mcp licensed under Apache-2.0. See LICENSE and NOTICE files.
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.