Fire in da houseTop Tip:Paying $100+ per month for Perplexity, MidJourney, Runway, ChatGPT and other tools is crazy - get all your AI tools in one site starting at $15 per month with Galaxy AI Fire in da houseCheck it out free

serverless-mcp-servers-cdk

MCP.Pizza Chef: huanshenyi

serverless-mcp-servers-cdk provides sample MCP server implementations deployed on AWS Lambda and API Gateway using AWS CDK. It enables stateless MCP servers that leverage serverless compute resources for scalable, cost-efficient, and easy-to-manage MCP hosting. This project includes setup instructions, local testing, and deployment guidance, making it ideal for developers building cloud-native MCP servers with AWS infrastructure.

Use This MCP server To

Deploy stateless MCP servers on AWS Lambda for scalable hosting Run MCP servers without managing server infrastructure Test MCP servers locally before cloud deployment Integrate MCP servers with AWS API Gateway for secure access Use AWS CDK to automate MCP server infrastructure deployment Build cloud-native MCP servers with minimal operational overhead

README

Stateless MCP Server on AWS Lambda (CDK 版)

このプロジェクトは、AWS CDK を使用して AWS Lambda と API Gateway 上でステートレスな MCP サーバーを構築します。 sample-serverless-mcp-serversの CDK 移植になります。

前提条件

  • AWS CLI (設定済み)
  • Node.js と npm
  • AWS CDK

セットアップ手順

1. 依存関係のインストール

npm install

2. MCP サーバーとクライアントの依存関係をインストール

(cd src/js/mcpclient && npm install)
(cd src/js/mcpserver && npm install)
Hono
(cd src/js/mcpclient && npm install)
(cd src/ts/mcpserver && npm install)

3. ローカルでのテスト

MCP サーバーをローカルで実行:

node src/js/mcpserver/index.js
Hono
(cd src/ts/mcpserver && npm run dev)

別のターミナルウィンドウでクライアントを実行:

node src/js/mcpclient/index.js

Claude & Cursor クライアントでテスト

    "example-local": {
      "command": "/path/to/npx",
      "args": ["mcp-remote", "http://localhost:3000/mcp"]
    }

4. AWS へのデプロイ

cdk deploy --region us-east-1
Hono 製の MCP サーバーのデプロイ

cdk deploy する前にまずは実行ファイルを build

(cd src/ts/mcpserver && npm run build)

lib/serverless-mcp-servers-cdk-stack.ts

      code: lambda.Code.fromAsset(path.join(__dirname, "../src/ts/mcpserver/dist")), // Hono

メインディレクトリに戻って

cdk deploy --region us-east-1

重要な注意点

  • このプロジェクトは必ず us-east-1 リージョンにデプロイされます
  • デプロイ後、API Gateway のエンドポイントが利用可能になるまで約 1 分かかる場合があります

デプロイされた MCP サーバーのテスト

デプロイが完了したら、出力されたエンドポイント URL を使用して MCP クライアントをテストできます:

export MCP_SERVER_ENDPOINT=$(aws cloudformation describe-stacks --stack-name ServerlessMcpServersCdkStack --region us-east-1 --query "Stacks[0].Outputs[?OutputKey=='McpEndpoint'].OutputValue" --output text)
node src/js/mcpclient/index.js

Claude & Cursor クライアントでテスト

    "example-remote": {
      "command": "/path/to/npx",
      "args": [
        "mcp-remote",
        "https://{{OutputValue}}.execute-api.us-east-1.amazonaws.com/dev/mcp"
      ]
    }

認証機能

このサンプルには、API Gateway カスタム認証機能が含まれています。デフォルトでは無効になっていますが、CDK スタックファイル内のコメントを解除することで有効にできます。

コスト考慮事項

このサンプルは AWS アカウントに有料リソースをプロビジョニングします。評価が終わったら、以下のコマンドでリソースを削除することを忘れないでください:

cdk destroy --region us-east-1

MCP について詳しく学ぶ

serverless-mcp-servers-cdk FAQ

How do I deploy the MCP server using this project?
Use AWS CDK commands to deploy the MCP server to AWS Lambda and API Gateway as described in the README.
Can I test the MCP server locally before deploying?
Yes, the project includes instructions to run the MCP server locally using Node.js for development and testing.
What are the prerequisites for using this MCP server?
You need AWS CLI configured, Node.js with npm, and AWS CDK installed to set up and deploy the server.
Does this MCP server support stateless operation?
Yes, it is designed as a stateless MCP server running on AWS Lambda for scalability and simplicity.
Which AWS services are used in this MCP server?
It uses AWS Lambda for compute and API Gateway for HTTP endpoint management.
Is this MCP server compatible with multiple LLM clients?
Yes, it can be tested with clients like Claude and Cursor, supporting various LLM providers including OpenAI and Gemini.
How do I install dependencies for this MCP server?
Run npm install in the root and in the client and server source directories as detailed in the README.