run-model-context-protocol-servers-with-aws-lambda  by awslabs

Run Model Context Protocol (MCP) servers in AWS Lambda

Created 6 months ago
302 stars

Top 88.4% on SourcePulse

GitHubView on GitHub
Project Summary

This project provides a library for running existing Model Context Protocol (MCP) stdio-based servers within AWS Lambda functions, enabling their use in distributed systems or cloud-based applications. It targets developers who need to leverage MCP servers, typically used locally by desktop applications, in a serverless, scalable manner.

How It Works

The library wraps stdio MCP servers into Lambda functions, managing their lifecycle. Each Lambda invocation starts the server as a child process, initializes it, forwards the incoming request, returns the server's response, and then shuts down the child process. This approach allows MCP servers to be invoked via HTTPS or the Lambda Invoke API, abstracting away the underlying stdio communication.

Quick Start & Requirements

  • Installation: Install the @aws/run-mcp-servers-with-aws-lambda package for TypeScript or mcp-lambda for Python.
  • Prerequisites: AWS account, Node.js/Python environment, and an existing MCP stdio server.
  • Examples: Detailed examples for Python and TypeScript servers and clients are available in the repository.

Highlighted Details

  • Supports three invocation methods: API Gateway (with OAuth or SigV4), Lambda Function URLs (with AWS IAM), and direct Lambda Invoke API calls (with AWS IAM).
  • Compatible with off-the-shelf MCP clients like Cursor and Claude Desktop when using API Gateway with OAuth.
  • Provides examples for both server-side Lambda functions and client-side integrations in Python and TypeScript.

Maintenance & Community

  • This is an AWS Labs project. Contribution guidelines are available in CONTRIBUTING.

Licensing & Compatibility

  • Licensed under the Apache-2.0 License.
  • Compatible with commercial use and closed-source linking.

Limitations & Caveats

This library only supports MCP servers written for stdio and is not compatible with other protocols like SSE. It is designed for stateless MCP servers; stateful servers will lose their state across invocations. The library does not manage secrets for wrapped MCP servers, requiring manual configuration via environment variables, which may expose API keys to all Lambda function invokers.

Health Check
Last Commit

3 days ago

Responsiveness

1 day

Pull Requests (30d)
138
Issues (30d)
2
Star History
44 stars in the last 30 days

Explore Similar Projects

Feedback? Help us improve.