
markvp/mcp-lambda-sam
Developer toolsこのページは AI により自動翻訳されています。技術的な詳細は原文をご確認ください。 原文を見る
An AWS Serverless Application Model that operates as an MCP server via serverless AWS resources
概要
Model Context Protocol (MCP) implementation using AWS Lambda and SAM. This project provides a serverless implementation of the Model Context Protocol, with two distinct interfaces: 1. (Administrative): - Registration of MCP tools, resources, and prompts - IAM permission management - Infrastructure setup and configuration 2. (Client): - Establishing SSE connections - Sending commands - Receiving streaming responses You can visualize the system using this Mermaid syntax: - The reads registrations from the Registration Table on startup and when handling requests. - It uses the Session Table to persist session state. - It dynamically using the ARNs stored in the Registration Table. This section is for system administrators who need to configure and manage the MCP server. The command will interactively prompt for administrative configuration: - Stack name (for multiple instances) - AWS Region - VPC configuration (optional)
README
以下は原文 README の抜粋です。原文を見る。
MCP Lambda SAM
Model Context Protocol (MCP) implementation using AWS Lambda and SAM.
Overview
This project provides a serverless implementation of the Model Context Protocol, with two distinct interfaces:
-
System Configuration (Administrative):
- Registration of MCP tools, resources, and prompts
- IAM permission management
- Infrastructure setup and configuration
-
System Usage (Client):
- Establishing SSE connections
- Sending commands
- Receiving streaming responses
Architecture
Mermaid Diagram
You can visualize the system using this Mermaid syntax:
graph TD
Client --> MCP[/"MCP Lambda\n(/sse & /message)"/]
MCP -->|read/write| SessionTable[(Session Table)]
MCP -->|query| RegistrationTable[(Registration Table)]
MCP -->|invoke| RegisteredLambda["Registered Lambda Tool"]
Admin[Administrator] --> RegistrationLambda[/"Registration Lambda\n(/register)"/]
RegistrationLambda -->|write| RegistrationTable
- The MCP Lambda reads registrations from the Registration Table on startup and when handling requests.
- It uses the Session Table to persist session state.
- It invokes registered Lambda tools dynamically using the ARNs stored in the Registration Table.
System Configuration Guide (Administrators)
This section is for system administrators who need to configure and manage the MCP server.
Deployment
npx @markvp/mcp-lambda-sam deploy
The command will interactively prompt for administrative configuration:
- Stack name (for multiple instances)
- AWS Region
- VPC configuration (optional)
Permissions Overview
To access MCP endpoints, users and clients must have IAM permission to invoke the relevant Function URLs.
- Administrators: must be allowed to invoke the
mcp-registrationfunction URL - Clients: must be allowed to invoke the
mcpfunction URL
You can grant access using either an IAM policy or aws lambda add-permission (see below).
Assigning Permissions via AWS CLI
To grant permission to invoke the registration function URL:
aws lambda add-permission \
--function-name \
--statement-id allow-registration \
--action lambda:InvokeFunctionUrl \
--principal "*" \
--function-url-auth-type IAM
To grant permission to invoke the MCP function URL (SSE and message):
aws lambda add-permission \
--function-name \
--statement-id allow-mcp \
--action lambda:InvokeFunctionUrl \
--principal "*" \
--function-url-auth-type IAM
Replace and with the actual Lambda function names.
Registration API
Use these endpoints to manage MCP tools, resources, and prompts:
Register a New Tool
awscurl -X POST ${REGISTRATION_URL}/register \
--region ap-southeast-2 \
--service lambda \
-H "Content-Type: application/json" \
-d '{
"type": "tool",
"name": "example",
インストール
npx @markvp/mcp-lambda-sam deploy