一个用于运行k6负载测试的Model Context Protocol(MCP)服务器实现,可助力用户轻松开展负载测试工作。
若想使用k6-mcp-server开展负载测试,可按以下步骤操作:
test.js文件,内容如下:import http from "k6/http";
import { sleep } from "k6";
export default function () {
http.get("http://test.k6.io");
sleep(1);
}
{
"mcpServers": {
"k6": {
"command": "/path/to/bin/uv",
"args": [
"--directory",
"/path/to/k6-mcp-server",
"run",
"k6_server.py"
]
}
}
}
运行hello.js的k6测试。k6 MCP服务器将使用以下工具之一启动测试:
execute_k6_test:使用默认选项运行测试(持续时间:30秒,VU数:10)execute_k6_test_with_options:使用自定义持续时间和VU数运行测试在开始安装前,请确保已安装以下内容:
git clone https://github.com/qainsights/k6-mcp-server.git
uv pip install -r requirements.txt
.env文件:K6_BIN=/path/to/k6 # 可选:默认使用系统PATH中的'k6'
execute_k6_test(
script_file: str,
duration: str = "30s", # 可选:持续时间,默认为30秒
vus: int = 10 # 可选:虚拟用户数,默认为10
)
execute_k6_test_with_options(
script_file: str,
duration: str,
vus: int
)
欢迎各位贡献代码!请随意提交Pull Request。
该项目在MIT License下许可,详细信息请参阅LICENSE文件。