k6-mcp-server

by QAInsights
Verified

Integrations

  • Enables running load tests through k6, supporting customizable test durations and virtual user counts with real-time execution output

🚀⚡️k6-mcp-服务器

用于运行 k6 负载测试的模型上下文协议 (MCP) 服务器实现。

✨ 特点

  • 与模型上下文协议框架的简单集成
  • 支持自定义测试时长和虚拟用户(VU)
  • 用于运行 k6 负载测试的易于使用的 API
  • 可通过环境变量配置
  • 实时测试执行输出

🔧 先决条件

开始之前,请确保已安装以下软件:

📦安装

  1. 克隆存储库:
git clone https://github.com/yourusername/k6-mcp-server.git
  1. 安装所需的依赖项:
uv pip install -r requirements.txt
  1. 设置环境变量(可选):在项目根目录中创建一个.env文件:
K6_BIN=/path/to/k6 # Optional: defaults to 'k6' in system PATH

🚀 入门

  1. 创建k6测试脚本(例如, test.js ):
import http from "k6/http"; import { sleep } from "k6"; export default function () { http.get("http://test.k6.io"); sleep(1); }
  1. 在您最喜欢的 MCP 客户端(Claude Desktop、Cursor、Windsurf 等)中使用以下规格配置 MCP 服务器:
{ "mcpServers": { "k6": { "command": "/Users/naveenkumar/.local/bin/uv", "args": [ "--directory", "/Users/naveenkumar/Gits/k6-mcp-server", "run", "k6_server.py" ] } } }
  1. 现在让 LLM 运行测试,例如run k6 test for hello.js 。k6 mcp 服务器将利用以下任一工具来启动测试。
  • execute_k6_test :使用默认选项运行测试(持续时间 30 秒,10 VU)
  • execute_k6_test_with_options :使用自定义持续时间和 VU 运行测试

📝 API 参考

执行K6测试

execute_k6_test( script_file: str, duration: str = "30s", # Optional vus: int = 10 # Optional )

使用自定义选项执行 K6 测试

execute_k6_test_with_options( script_file: str, duration: str, vus: int )

🤝 贡献

欢迎贡献代码!欢迎提交 Pull 请求。

📄 许可证

该项目根据 MIT 许可证获得许可 - 有关详细信息,请参阅 LICENSE 文件。

-
security - not tested
A
license - permissive license
-
quality - not tested

模型上下文协议 (MCP) 服务器实现允许 AI 助手通过自然语言命令运行 k6 负载测试,支持自定义测试持续时间和虚拟用户。

  1. ✨ Features
    1. 🔧 Prerequisites
      1. 📦 Installation
        1. 🚀 Getting Started
          1. 📝 API Reference
            1. Execute K6 Test
            2. Execute K6 Test with Custom Options
          2. 🤝 Contributing
            1. 📄 License
              ID: bq2z9vqvbx