- Explore MCP Servers
- mcp_on_ecs_sample
Mcp On Ecs Sample
What is Mcp On Ecs Sample
mcp_on_ecs_sample is a sample code repository for setting up an MCP server on ECS (Elastic Container Service). It provides a practical implementation guide and code examples to help users deploy and manage an MCP server using Infrastructure as Code (IaC) principles.
Use cases
Use cases for mcp_on_ecs_sample include deploying machine learning models in production, testing and validating MCP server functionalities, and integrating with other cloud services for scalable applications. It can also be used for educational purposes to learn about MCP and ECS deployment.
How to use
To use mcp_on_ecs_sample, first ensure that you have the required prerequisites, including Python 3.10+, Terraform 1.9+, and the AWS CLI configured. Set up a virtual environment, install necessary packages using ‘uv sync’, and follow the README instructions in the mcp_client and mcp_server directories for running the client and server applications.
Key features
Key features of mcp_on_ecs_sample include a structured directory for client and server code, a Dockerfile for server deployment, and Terraform scripts for managing infrastructure resources on ECS. It also provides a GUI built with Streamlit for easier interaction with the MCP server.
Where to use
mcp_on_ecs_sample can be used in cloud computing environments, specifically for deploying and managing machine learning models and services that require a Model Context Protocol (MCP) server. It is suitable for developers and data scientists working with AWS and containerized applications.
Overview
What is Mcp On Ecs Sample
mcp_on_ecs_sample is a sample code repository for setting up an MCP server on ECS (Elastic Container Service). It provides a practical implementation guide and code examples to help users deploy and manage an MCP server using Infrastructure as Code (IaC) principles.
Use cases
Use cases for mcp_on_ecs_sample include deploying machine learning models in production, testing and validating MCP server functionalities, and integrating with other cloud services for scalable applications. It can also be used for educational purposes to learn about MCP and ECS deployment.
How to use
To use mcp_on_ecs_sample, first ensure that you have the required prerequisites, including Python 3.10+, Terraform 1.9+, and the AWS CLI configured. Set up a virtual environment, install necessary packages using ‘uv sync’, and follow the README instructions in the mcp_client and mcp_server directories for running the client and server applications.
Key features
Key features of mcp_on_ecs_sample include a structured directory for client and server code, a Dockerfile for server deployment, and Terraform scripts for managing infrastructure resources on ECS. It also provides a GUI built with Streamlit for easier interaction with the MCP server.
Where to use
mcp_on_ecs_sample can be used in cloud computing environments, specifically for deploying and managing machine learning models and services that require a Model Context Protocol (MCP) server. It is suitable for developers and data scientists working with AWS and containerized applications.
Content
リモートMCPサーバーサンプルコード
Qiitaの記事:「リモートMCPサーバーをECSでたててみよう 〜IaCを添えて〜」のサンプルコードになります。記事を読み進める際に参考にしていただければと思います。
ディレクトリ構成
mcp_client
- MCPサーバー構築後にプログラムから利用できることを確認するためのコード群です
- cliから動作確認するためのmain.pyと、streamlitを利用して実装したGUIのコードであるmain_gui.pyがあります
- それぞれの実行方法に関してはmcp_clientディレクトリ下のREADMEに詳しく記載しています
mcp_server
- サンプルのMCPサーバーのコード群になります。以下のMCPのドキュメントのQuickStartを愚直に行なったものになります
- dockerで起動するためのDockerfileも配置しています。イメージの作成や実行方法等はmcp_server下のREADMEに詳しく記載しています
terraform
- MCPサーバーをECSで起動するためのインフラリソースを管理するサンプルコードになります
- デプロイ方法についてはterraformディレクトリ下のREADMEに詳しく記載しています
セットアップ
前提条件
- Python 3.10以上
- terraform 1.9以上
- tfenvでのバージョン管理がおすすめです
- プロジェクト管理にuvを利用しているので、事前にインストールしておいてください
- こちらも上記のQuickStartを参考にしてください
- AWS CLIの認証設定
- mcp_client のプログラムからの実行を試す場合は、東京リージョン(ap-northeast-1)だけではなく、バージニア北部(us-east-1)のプロファイルも用意して切り替えるか、環境変数のAWS_REGIONをus-east-1に変更してください
mcp_server / mcp_client ディレクトリ共通のセットアップ
- 仮想環境を作成して有効化します:
uv venv
source .venv/bin/activate # Linuxの場合
# または
.venv\Scripts\activate # Windowsの場合
- uv syncを実行して必要なパッケージをインストールします:
uv sync