Lambda-MCP-Server

作者 mikegc-aws已验证

Creates a simple MCP tool server with "streaming" HTTP.

235
Stars
49
Forks
Python
语言
2026/8/23
添加时间

⚠️ 第三方软件声明

本 Skill 为第三方开源软件,独立托管于 GitHub。SkillTip 仅为信息目录,不控制或维护底层仓库。所显示的安全检查为自动化且范围有限,安装前请自行审查源码。

阅读服务条款

安装

添加到你的 Claude Code skills 目录:

# Add to your Claude Code skills
git clone https://github.com/mikegc-aws/Lambda-MCP-Server

快速入门

使用 Lambda-MCP-Server 等 Skills 的指南。

安全报告

已验证

上次扫描:—

{
  "status": "PASSED",
  "issues": []
}

README.md

Lambda MCP Server Demo (Streamable HTTP)

⚠️ IMPORTANT: The Lambda MCP Server module code IS maintained, just not in this repository. It is now hosted and maintained at awslabs/mcp-lambda-handler. This repository remains as sample code of how to use the module.

To use the Lambda MCP Server, install the package directly from PyPI:

pip install awslabs.mcp_lambda_handler
# or, if using uv:
uv add awslabs.mcp_lambda_handler

This server requires a client that supports Streamable HTTP (not SSE). There are a few MCP clients that currently support Streamable HTTP including the MCP Inspector. There is also as a Streamable HTTP client included in this repo, built Strands Agents.

This project demonstrates a powerful and developer-friendly way to create serverless MCP (Model Context Protocol) tools using AWS Lambda. It showcases how to build a stateless, serverless MCP server with minimal boilerplate and an excellent developer experience.

the_context()

In an episode of the_context, Tiffany Souterre and Mike discussed streamable HTTP for MCP as well as running (an older version of) this project:

MCP - Can Lambda do it? - Streamable HTTP Model Context Protocol

Example

Here is the minimal code to get an MCP server running in an AWS Lambda function:

from awslabs.mcp_lambda_handler import MCPLambdaHandler

mcp_server = MCPLambdaHandler(name="mcp-lambda-server", version="1.0.0")

@mcp_server.tool()
def get_time() -> str:
    from datetime import datetime, UTC
    return datetime.now(UTC).isoformat()

def lambda_handler(event, context):
    return mcp_server.handle_request(event, context)

Session State Management

The Lambda MCP Server includes built-in session state management that persists across tool invocations within the same conversation. This is particularly useful for tools that need to maintain context or share data between calls.

Session data is stored in a DynamoDB table against a sessionId key. This is all managed for you.

Here's an example of how to use session state:

from lambda_mcp.lambda_mcp import LambdaMCPServer

session_table = os.environ.get('MCP_SESSION_TABLE', 'mcp_sessions')

mcp_server = LambdaMCPServer(name="mcp-lambda-server", version="1.0.0", session_store=session_table)

@mcp_server.tool()
def increment_counter() -> int:
    """Increment a session-based counter."""
    # Get the current counter value from session state, default to 0 if not set
    counter = mcp_server.session.get('counter', 0)
    
    # Increment the counter
    counter += 1
    
    # Store the new value in session state
    mcp_server.session['counter'] = counter
    
    return counter

@mcp_server.tool()
def get_counter() -> int:
    """Get the current counter value."""
    return mcp_server.session.get('counter', 0)

The session state is automatically managed per conversation and persists across multiple tool invocations. This allows you to maintain stateful information without needing additional external storage, while still keeping your Lambda function stateless.

Authentication

The sample server stack uses Bearer token authentication via an Authorization header, which is compliant with the MCP standard. This provides a basic level of security for your MCP server endpoints. Here's what you need to know:

  1. Bearer Token: When you deploy the stack, a bearer token is configured through a custom authorizer in API Gateway

  2. Using the Bearer Token:

    • The client must include the bearer token in requests using the Authorization header with the format: Bearer <your-token>
    • The token value is provided in the stack outputs after deployment
    • The sample client is configured to automatically include this header when provided with the token
  3. Custom Authorizer: The implementation uses a simple custom authorizer that validates a single bearer token. This can be easily extended or replaced with more sophisticated authentication systems like Amazon Cognito for production use.

⚠️ Security Note: While bearer token authentication provides a standard-compliant authentication mechanism, consider implementing additional security measures such as:

  • AWS IAM roles and policies
  • OAuth 2.0 / JWT with proper token management
  • Amazon Cognito User Pools

The current bearer token implementation is primarily intended for demonstration and development purposes. For production systems handling sensitive data, implement appropriate additional security measures based on your specific requirements.

What is this all about?

This is a proof-of-concept implementation of an MCP server running on AWS Lambda, along with a Strands Agents client that demonstrates its functionality. The project consists of two main components:

  1. Lambda MCP Server: A Python-based serverless implementation that makes it incredibly simple to deploy cloud hosted MCP tools.
  2. Strands Agents Client: A demonstration client that shows how to interact with the Lambda MCP server using Strands Agents.

Example Tools

The server comes with three example tools that demonstrate different use cases:

  1. get_weather(city: str): Get the current weather for a city. Returns a simulated temperature for the given city.
  2. count_s3_buckets(): Count the number of S3 buckets in your AWS account.
  3. get_time(): Get the current UTC date and time, and show how long since last time was asked for (if session available).

Getting Started

Prerequisites

Amazon Bedrock Setup

Before running the client, ensure you have:

  1. Enabled Amazon Bedrock access in your AWS account
  2. Enabled the Amazon Nova Models in your Bedrock model access settings
  3. Appropriate IAM permissions to invoke Bedrock APIs

Server Deployment

  1. Clone this repository:

    git clone <repository-url>
    
  2. Navigate to the server directory:

    cd server-http-python-lambda
    
  3. Deploy using SAM:

    sam build && sam deploy --guided
    

    Note: You will be prompted for an McpAuthToken. This is the Authorization Bearer token that will be requitred to call the endpoint. This simple implimentation uses an AWS API Gateway authorizers with the McpAuthToken passed in as an env var. This can be swapped out for a production implimentation as required.

Client Setup

  1. Update the api_gateway_url and auth_token in ./client-strands-agents-mcp/main.py:

    cd client-strands-agents-mcp
    
  2. Navigate to the client directory:

    cd client-strands-agents-mcp
    
  3. Run the helper script:

    uv sync
    uv run main.py
    

Adding New Tools

The Lambda MCP Server is designed to make tool creation as simple as possible. Here's how to add a new tool:

  1. Open server/app.py
  2. Add your new tool using the decorator pattern:
@mcp_server.tool()
def my_new_tool(param1: str, param2: int) -> str:
    """Your tool description.
    
    Args:
        param1: Description of param1
        param2: Description of param2
        
    Returns:
        Description of return value
    """
    # Your tool implementation
    return f"Processed {param1} with value {param2}"

That's it! The decorator handles:

  • Type validation
  • Request parsing
  • Response formatting
  • Error handling
  • MCP Documentation generation

Notes

Security

See CONTRIBUTING for more information.

For AWS security best practices, refer to the AWS Security Documentation and Amazon Bedrock security best practices.

License

This library is licensed under the MIT-0 License. See the LICENSE file.

Changes

Version 2.0.0

  • The Lambda MCP Server module code is no longer included in this repository; it is now maintained at awslabs/mcp-lambda-handler.
  • Updated installation instructions to use the PyPI package: pip install awslabs.mcp_lambda_handler or uv add awslabs.mcp_lambda_handler.
  • README example code now uses the new package import and shows a minimal Lambda MCP server example.
  • Updated the list and descriptions of example tools to match the current implementation in app.py.
  • Updated client instructions to use Strands Agents and removed references to the TypeScript client.
  • Updated prerequisites and deployment instructions for clarity and accuracy.
  • Improved documentation for session state management and authentication.
  • Various documentation and usability improvements throughout the README.

Version 1.1.0

  • Replaced API Key authentication with Bearer token authentication via Authorization header
  • Added custom authorizer to API Gateway for token validation
  • Updated client configuration to use bearer tokens
  • Made authentication system compliant with MCP standard
  • Added this change log section

Version 1.0.0

  • Initial release
  • Basic MCP server implementation with AWS Lambda
  • Session state management with DynamoDB
  • Example tools implementation
  • TypeScript HTTP client with Amazon Bedrock integration

常见问题

What is Lambda-MCP-Server?

Lambda-MCP-Server is an open-source mcp servers skill for AI coding assistants such as Claude Code, Codex CLI, and ChatGPT, built by mikegc-aws. Creates a simple MCP tool server with "streaming" HTTP. It has 235 GitHub stars.

Is Lambda-MCP-Server safe to use?

Yes. Lambda-MCP-Server passed SkillsLLM's automated security scan — a dependency vulnerability audit plus prompt-injection heuristics — with no high-severity issues. You can read the full report in the Security Report section on this page.

How do I install Lambda-MCP-Server?

Clone the repository with "git clone https://github.com/mikegc-aws/Lambda-MCP-Server" and add it to your Claude Code skills directory (see the Installation section above).

What programming language is Lambda-MCP-Server written in?

Lambda-MCP-Server is primarily written in Python. It is open-source under mikegc-aws on GitHub, so you can review or fork the full source.

Are there alternatives to Lambda-MCP-Server?

Yes. SkillsLLM lists many other MCP Servers skills you can browse and compare side by side. Open the MCP Servers category from the badge at the top of this page, or use the Related Skills and comparison links further down to weigh Lambda-MCP-Server against similar tools.

评论 (0)

暂无评论,成为第一个分享想法的人!

n8n

by n8n-io

12

Fair-code workflow automation platform with native AI capabilities. Combine visual building with custom code, self-host or cloud, 400+ integrations.

201,88160,308TypeScript
MCP 服务器apisai-tools
查看详情

Scrapling

by D4Vinci

🕷️ An adaptive Web Scraping framework that handles everything from a single request to a full-scale crawl!

75,9137,581Python
MCP 服务器
查看详情

TrendRadar

by sansan0

⭐AI-driven public opinion & trend monitor with multi-platform aggregation, RSS, and smart alerts.🎯 告别信息过载,你的 AI 舆情监控助手与热点筛选工具!聚合多平台热点 + RSS 订阅,支持关键词精准筛选。AI 智能筛选新闻 + AI 翻译 + AI 分析简报直推手机,也支持接入 MCP 架构,赋能 AI 自然语言对话分析、情感洞察与趋势预测等。支持 Docker ,数据本地/云端自持。集成微信/飞书/钉钉/Telegram/邮件/ntfy/bark/slack 等渠道智能推送。

61,65224,883Python
MCP 服务器
查看详情

context7

by upstash

Context7 Platform -- Up-to-date code documentation for LLMs and AI code editors

61,0602,938TypeScript
MCP 服务器
查看详情

High-performance code intelligence MCP server. Indexes codebases into a persistent knowledge graph — average repo in milliseconds. 158 languages, sub-ms queries, 99% fewer tokens. Single static binary, zero dependencies.

39,9393,219C
MCP 服务器
查看详情

开发者还喜欢

基于喜欢此 Skill 的开发者投票和收藏

ECC

by affaan-m

10

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.

242,21936,702JavaScript
AI 智能体ai-agentsanthropicclaude-code
查看详情
15

An agentic skills framework & software development methodology that works.

234,96620,863Shell
AI 智能体ai-agentsbrainstorming
查看详情

hermes-agent

by NousResearch

10

The agent that grows with you

234,43747,175Python
AI 智能体ai-agentsagent-orchestration
查看详情

n8n

by n8n-io

12

Fair-code workflow automation platform with native AI capabilities. Combine visual building with custom code, self-host or cloud, 400+ integrations.

201,88160,308TypeScript
MCP 服务器apisai-tools
查看详情

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.

185,94028,768JavaScript
AI 智能体ai-agentsanthropicclaude-code
查看详情

cc-switch

by farion1231

3

A cross-platform desktop All-in-One assistant for Claude Code, Codex, OpenCode, OpenClaw, Grok Build & Hermes Agent. Only official website: ccswitch.io

128,8688,826Rust
AI 智能体claude-codeai-tools
查看详情