AWS Lambda MCP Server: A serverless HTTP handler for the Model Context Protocol (MCP) using AWS Lambda.
Project description
MCP Lambda Handler Module
A Python library for creating serverless HTTP handlers for the Model Context Protocol (MCP) using AWS Lambda. This library provides a minimal, extensible framework for building MCP HTTP endpoints with pluggable session management support.
Features
- 🚀 Easy serverless MCP HTTP handler creation using AWS Lambda
- 🔌 Pluggable session management system (NoOp or DynamoDB, or custom backends)
Quick Start
- Install the package with development dependencies:
pip install -e .[dev]
- Use the handler in your AWS Lambda function:
Basic Usage
from awslabs.mcp_lambda_handler import MCPLambdaHandler
mcp = MCPLambdaHandler(name="mcp-lambda-server", version="1.0.0")
@mcp.tool()
def add_two_numbers(a: int, b: int) -> int:
"""Add two numbers together."""
return a + b
def lambda_handler(event, context):
"""AWS Lambda handler function."""
return mcp.handle_request(event, context)
Session Management
The library provides flexible session management with built-in support for DynamoDB and the ability to create custom session backends. You can use the default stateless (NoOp) session store, or configure a DynamoDB-backed store for persistent sessions.
Example Architecture for Auth & Session Management
A typical serverless deployment using this library might look like:
- API Gateway: Exposes the
/mcpendpoint. - Lambda Authorizer: Validates authentication tokens (e.g., bearer tokens in the
Authorizationheader). - MCP Server Lambda: Implements MCP tools and session logic using this library.
- DynamoDB: Stores session data (if using the DynamoDB session backend).
Development
- Clone the repository:
git clone https://github.com/awslabs/mcp.git
cd mcp/src/mcp-lambda-handler
- Install development dependencies:
pip install -e .[dev]
- Run tests:
pytest
Contributing
Contributions are welcome! Please see the CONTRIBUTING.md in the monorepo root for guidelines.
License
This project is licensed under the Apache-2.0 License - see the LICENSE file for details.
Python Version Support
- Python 3.10+
Dependencies
Core dependencies:
- python-dateutil >= 2.8.2
Optional dependencies:
- boto3 >= 1.38.1 (for AWS/DynamoDB support)
- botocore >= 1.38.1 (for AWS/DynamoDB support)
Development dependencies:
- pytest >= 8.0.0
- black >= 24.2.0
- isort >= 5.13.0
- flake8 >= 7.0.0
- moto >= 5.0.3 (for AWS mocking in tests)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file awslabs_mcp_lambda_handler-0.1.12.tar.gz.
File metadata
- Download URL: awslabs_mcp_lambda_handler-0.1.12.tar.gz
- Upload date:
- Size: 68.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f63c3ce08578dcaf7733c011fb0b08843010dd7c7811734a69428008b30eb7f8
|
|
| MD5 |
7089295683371403af131b81fe9076a0
|
|
| BLAKE2b-256 |
6a0d81c3ee5ed93a2004f47d487a869ffb6723aaf932e628319455e950f7d36e
|
Provenance
The following attestation bundles were made for awslabs_mcp_lambda_handler-0.1.12.tar.gz:
Publisher:
release.yml on awslabs/mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
awslabs_mcp_lambda_handler-0.1.12.tar.gz -
Subject digest:
f63c3ce08578dcaf7733c011fb0b08843010dd7c7811734a69428008b30eb7f8 - Sigstore transparency entry: 842553627
- Sigstore integration time:
-
Permalink:
awslabs/mcp@c816e7fa8729545d65e31043cff9c35892bd5dc7 -
Branch / Tag:
refs/tags/2026.01.20260121110136 - Owner: https://github.com/awslabs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@c816e7fa8729545d65e31043cff9c35892bd5dc7 -
Trigger Event:
push
-
Statement type:
File details
Details for the file awslabs_mcp_lambda_handler-0.1.12-py3-none-any.whl.
File metadata
- Download URL: awslabs_mcp_lambda_handler-0.1.12-py3-none-any.whl
- Upload date:
- Size: 18.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4c45c78b7c38f2576238f1b0830704872a6f0a9344cd7f4e1fe050386e41c299
|
|
| MD5 |
bd67b889e562518ad0ce80fbbe4098e5
|
|
| BLAKE2b-256 |
4068abd6046761b821f3e31dc9ad5e0c1072e690a979b251e37a703ffdc2faf7
|
Provenance
The following attestation bundles were made for awslabs_mcp_lambda_handler-0.1.12-py3-none-any.whl:
Publisher:
release.yml on awslabs/mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
awslabs_mcp_lambda_handler-0.1.12-py3-none-any.whl -
Subject digest:
4c45c78b7c38f2576238f1b0830704872a6f0a9344cd7f4e1fe050386e41c299 - Sigstore transparency entry: 842553651
- Sigstore integration time:
-
Permalink:
awslabs/mcp@c816e7fa8729545d65e31043cff9c35892bd5dc7 -
Branch / Tag:
refs/tags/2026.01.20260121110136 - Owner: https://github.com/awslabs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@c816e7fa8729545d65e31043cff9c35892bd5dc7 -
Trigger Event:
push
-
Statement type: