🚀 ⚡️ locust-mcp-server
Locust 負荷テストを実行するための Model Context Protocol (MCP) サーバー実装。このサーバーにより、Locust 負荷テスト機能と AI を活用した開発環境をシームレスに統合できます。
✨ 特徴
- モデルコンテキストプロトコルフレームワークとのシンプルな統合
- ヘッドレスモードとUIモードのサポート
- 設定可能なテストパラメータ(ユーザー、生成率、実行時間)
- Locust 負荷テストを実行するための使いやすい API
- リアルタイムテスト実行出力
- HTTP/HTTPSプロトコルのサポート
- カスタムタスクシナリオのサポート

🔧 前提条件
始める前に、以下がインストールされていることを確認してください。
📦 インストール
- リポジトリをクローンします。
git clone https://github.com/qainsights/locust-mcp-server.git
- 必要な依存関係をインストールします。
uv pip install -r requirements.txt
- 環境変数を設定する (オプション): プロジェクト ルートに
.env
ファイルを作成します。
LOCUST_HOST=http://localhost:8089 # Default host for your tests
LOCUST_USERS=3 # Default number of users
LOCUST_SPAWN_RATE=1 # Default user spawn rate
LOCUST_RUN_TIME=10s # Default test duration
🚀 はじめに
- Locust テスト スクリプト (例:
hello.py
) を作成します。
from locust import HttpUser, task, between
class QuickstartUser(HttpUser):
wait_time = between(1, 5)
@task
def hello_world(self):
self.client.get("/hello")
self.client.get("/world")
@task(3)
def view_items(self):
for item_id in range(10):
self.client.get(f"/item?id={item_id}", name="/item")
time.sleep(1)
def on_start(self):
self.client.post("/login", json={"username":"foo", "password":"bar"})
- お気に入りの MCP クライアント (Claude Desktop、Cursor、Windsurf など) で以下の仕様を使用して MCP サーバーを構成します。
{
"mcpServers": {
"locust": {
"command": "/Users/naveenkumar/.local/bin/uv",
"args": [
"--directory",
"/Users/naveenkumar/Gits/locust-mcp-server",
"run",
"locust_server.py"
]
}
}
}
- LLMにテストの実行を指示します(例
run locust test for hello.py
。Locust MCPサーバーは以下のツールを使用してテストを開始します。
run_locust
: ヘッドレスモード、ホスト、ランタイム、ユーザー、およびスポーンレートの設定可能なオプションを使用してテストを実行します。
📝 APIリファレンス
Locustテストを実行する
run_locust(
test_file: str,
headless: bool = True,
host: str = "http://localhost:8089",
runtime: str = "10s",
users: int = 3,
spawn_rate: int = 1
)
パラメータ:
test_file
: Locust テスト スクリプトへのパスheadless
: ヘッドレスモード(True)またはUI付き(False)で実行host
: 負荷テストの対象ホストruntime
: テスト期間(例:「30秒」、「1分」、「5分」)users
: シミュレートする同時ユーザー数spawn_rate
: ユーザーが生成されるレート
✨ ユースケース
- LLMを活用した結果分析
- LLMを活用した効果的なデバッグ
🤝 貢献する
貢献を歓迎します!お気軽にプルリクエストを送信してください。
📄 ライセンス
このプロジェクトは MIT ライセンスに基づいてライセンスされています - 詳細については LICENSE ファイルを参照してください。