
awslabs/run-model-context-protocol-servers-with-aws-lambda
Developer toolsこのページは AI により自動翻訳されています。技術的な詳細は原文をご確認ください。 原文を見る
既存のモデルコンテキストプロトコル(MCP)標準ベースのサーバーをAWS Lambda関数で実行します
概要
このプロジェクトにより、AWS Lambda関数内でモデルコンテキストプロトコルのスタンディオベースのサーバーを運用できるようになります。 現在、ほとんどのMCPサーバーとクライアントの実装は、単一のマシン上で完全にローカル化されています。IDEやClaude Desktopのようなデスクトップアプリケーションは、MCPサーバーをローカルで子プロセスとして起動し、長期間実行するstdioストリームを通じて各サーバーと通信します。 このライブラリは、既存のstdio MCPサーバーをLambda関数にラップするのに役立ちます。これらの関数ベースのMCPサーバーは、短命なHTTPS接続を介してMCPプロトコルを使ってアプリケーションから呼び出すことができます。アプリケーションはデスクトップベースのアプリ、クラウド上で動作する分散システム、またはその他のアーキテクチャに対応できます。 このライブラリを使えば、Lambda関数はStdio MCPサーバーのライフサイクルを管理します。各Lambda関数呼び出しは以下の通りです: 1. stdio MCPサーバーを子プロセスとして起動する 1.MCPサーバーを初期化する 1.受信リクエストをローカルサーバーに転送する 1.
概要(AI 翻訳)
このプロジェクトにより、AWS Lambda関数内でモデルコンテキストプロトコルのスタンディオベースのサーバーを運用できるようになります。
現在、MCPサーバーとクライアントのほとんどの実装は、単一のマシン上で完全にローカル化されています。 IDEやClaude Desktopのようなデスクトップアプリケーションは、MCPサーバーを子プロセスとしてローカルで起動します そして、それらのサーバーと長期運行のStDiOストリームを通じて通信します。
このライブラリは、既存のstdio MCPサーバーをLambda関数にラップするのに役立ちます。 これらの関数ベースのMCPサーバーは、MCPプロトコルを使ってアプリケーションから呼び出すことができます 短命なHTTPS接続を介して。 あなたのアプリケーションはデスクトップベースのアプリ、クラウド上で動作する分散システムにもなり得ます。 または他の建築のことです。
このライブラリを使えば、Lambda関数がStdio MCPサーバーのライフサイクルを管理します。 各ラムダ関数呼び出しは以下の通りになります:
- stdio MCPサーバーを子プロセスとして起動
- MCPサーバーの初期化
- 受信リクエストをローカルサーバーに転送する
- サーバの応答を関数呼び出し者に返す
- MCPサーバーの子プロセスをシャットダウンする
このライブラリは、4つの方法でラムダベースのMCPサーバーへの接続をサポートしています。
このページは AI により自動翻訳されています。技術的な詳細は原文をご確認ください。
README
以下は原文 README の抜粋です。原文を見る。
Run Model Context Protocol (MCP) servers with AWS Lambda
This project enables you to run Model Context Protocol stdio-based servers in AWS Lambda functions.
Currently, most implementations of MCP servers and clients are entirely local on a single machine. A desktop application such as an IDE or Claude Desktop initiates MCP servers locally as child processes and communicates with each of those servers over a long-running stdio stream.
flowchart LR
subgraph "Your Laptop"
Host["Desktop Applicationwith MCP Clients"]
S1["MCP Server A(child process)"]
S2["MCP Server B(child process)"]
Host |"MCP Protocol(over stdio stream)"| S1
Host |"MCP Protocol(over stdio stream)"| S2
end
This library helps you to wrap existing stdio MCP servers into Lambda functions. You can invoke these function-based MCP servers from your application using the MCP protocol over short-lived HTTPS connections. Your application can then be a desktop-based app, a distributed system running in the cloud, or any other architecture.
flowchart LR
subgraph "Distributed System"
App["Your Applicationwith MCP Clients"]
S3["MCP Server A(Lambda function)"]
S4["MCP Server B(Lambda function)"]
App |"MCP Protocol(over HTTPS connection)"| S3
App |"MCP Protocol(over HTTPS connection)"| S4
end
Using this library, the Lambda function will manage the lifecycle of your stdio MCP server. Each Lambda function invocation will:
- Start the stdio MCP server as a child process
- Initialize the MCP server
- Forward the incoming request to the local server
- Return the server’s response to the function caller
- Shut down the MCP server child process
This library supports connecting to Lambda-based MCP servers in four ways:
- The MCP Streamable HTTP transport, using Amazon API Gateway. Typically authenticated using OAuth.
- The MCP Streamable HTTP transport, using Amazon Bedrock AgentCore Gateway. Authenticated using OAuth.
- A custom Streamable HTTP transport with support for SigV4, using a Lambda function URL. Authenticated with AWS IAM.
- A custom Lambda invocation transport, using the Lambda Invoke API directly. Authenticated with AWS IAM.
Determine your server parameters
インストール
npx --offline my-mcp-server-typescript-module --my-server-command-line-parameter some_value