🚀 ⚡️ 蝗虫 Mcp 服务器
一个模型上下文协议(MCP)服务器实现,用于运行Locust负载测试。该服务器实现了Locust负载测试功能与人工智能驱动的开发环境的无缝集成。
概览
什么是 Locust MCP 服务器?
Locust MCP 服务器是一个专门的实现,旨在通过 Locust 这一流行的开源负载测试工具来促进负载测试。该服务器允许用户通过将 Locust 的功能与 AI 驱动的开发环境集成,来高效地运行负载测试。它提供了一个强大的框架,用于模拟用户流量并在各种条件下测量系统性能,使其成为开发人员和测试人员确保应用程序能够处理预期负载的必备工具。
Locust MCP 服务器的特点
- 无缝集成:Locust MCP 服务器与现有开发环境无缝集成,便于负载测试的设置和执行。
- AI 驱动的能力:利用 AI 技术增强负载测试策略,提供传统方法可能忽视的见解和优化。
- 可扩展性:该服务器设计用于处理大量并发用户,适合测试各种规模的应用程序。
- 实时监控:用户可以在负载测试期间实时监控应用程序的性能,便于即时反馈和调整。
- 可定制场景:创建量身定制的负载测试场景,模拟真实用户行为,确保测试相关且有效。
如何使用 Locust MCP 服务器
- 安装:首先在您的机器或服务器上安装 Locust MCP 服务器。按照文档中提供的安装说明进行操作。
- 配置:配置服务器设置以匹配您的测试需求。这包括设置用户数量、测试持续时间以及您希望模拟的任何特定场景。
- 运行测试:通过服务器界面启动负载测试。实时监控进度和结果,以获取应用程序性能的见解。
- 分析结果:测试完成后,分析结果以识别瓶颈、性能问题和改进领域。
- 迭代:根据发现,对应用程序进行必要的调整,并重复测试过程以确保最佳性能。
常见问题解答
问:Locust MCP 服务器的主要目的是什么?
答:主要目的是促进应用程序的负载测试,使开发人员能够模拟用户流量并评估在各种条件下的性能。
问:我可以将 Locust MCP 服务器与其他工具集成吗?
答:可以,Locust MCP 服务器设计用于与各种开发和测试工具集成,增强其功能和可用性。
问:使用 Locust MCP 服务器是否需要费用?
答:Locust MCP 服务器是开源的,免费使用,适合各类开发人员和组织。
问:我如何能为 Locust MCP 服务器项目做贡献?
答:欢迎贡献!您可以通过报告问题、建议功能或通过项目的代码库提交代码改进来参与。
问:我在哪里可以找到有关 Locust MCP 服务器的更多信息?
答:有关更详细的信息、文档和支持,请访问官方网站 qainsights.com。
详情
🚀 ⚡️ locust-mcp-server
A Model Context Protocol (MCP) server implementation for running Locust load tests. This server enables seamless integration of Locust load testing capabilities with AI-powered development environments.
✨ Features
- Simple integration with Model Context Protocol framework
- Support for headless and UI modes
- Configurable test parameters (users, spawn rate, runtime)
- Easy-to-use API for running Locust load tests
- Real-time test execution output
- HTTP/HTTPS protocol support out of the box
- Custom task scenarios support
🔧 Prerequisites
Before you begin, ensure you have the following installed:
- Python 3.13 or higher
- uv package manager (Installation guide)
📦 Installation
- Clone the repository:
git clone https://github.com/qainsights/locust-mcp-server.git
- Install the required dependencies:
uv pip install -r requirements.txt
- Set up environment variables (optional):
Create a
.env
file in the project root:
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
🚀 Getting Started
- Create a Locust test script (e.g.,
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"})
- Configure the MCP server using the below specs in your favorite MCP client (Claude Desktop, Cursor, Windsurf and more):
{
"mcpServers": {
"locust": {
"command": "/Users/naveenkumar/.local/bin/uv",
"args": [
"--directory",
"/Users/naveenkumar/Gits/locust-mcp-server",
"run",
"locust_server.py"
]
}
}
}
- Now ask the LLM to run the test e.g.
run locust test for hello.py
. The Locust MCP server will use the following tool to start the test:
run_locust
: Run a test with configurable options for headless mode, host, runtime, users, and spawn rate
📝 API Reference
Run Locust Test
run_locust(
test_file: str,
headless: bool = True,
host: str = "http://localhost:8089",
runtime: str = "10s",
users: int = 3,
spawn_rate: int = 1
)
Parameters:
test_file
: Path to your Locust test scriptheadless
: Run in headless mode (True) or with UI (False)host
: Target host to load testruntime
: Test duration (e.g., "30s", "1m", "5m")users
: Number of concurrent users to simulatespawn_rate
: Rate at which users are spawned
✨ Use Cases
- LLM powered results analysis
- Effective debugging with the help of LLM
🤝 Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
Server配置
{
"mcpServers": {
"locust-mcp-server": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"ghcr.io/metorial/mcp-container--qainsights--locust-mcp-server--locust-mcp-server",
"python main.py"
],
"env": {}
}
}
}