k6 MCP for Claude
This is a Model Capabilities Provider (MCP) for Anthropic Claude that enables running k6 load tests directly from the Claude chat interface.
Features
- Run HTTP load tests against any website with a simple prompt
- Configure the number of virtual users and iterations
- Get test results directly in your Claude chat
Requirements
- Go (1.18+)
- k6 installed on your system
- Anthropic Claude desktop app
Installation
-
Clone this repository:
git clone https://github.com/grafana/k6-mcp.git cd k6-mcp -
Build and install:
go install
Setting Up Claude to Use k6 MCP
-
Create or update your Claude developer configuration file at the following location:
- macOS:
/Users/<username>/Library/Application Support/Claude/claude-dev-config.json - Windows:
%APPDATA%\Claude\claude-dev-config.json - Linux:
~/.config/Claude/claude-dev-config.json
- macOS:
-
Add the k6 MCP configuration:
{ "mcpServers": { "k6": { "command": "/usr/local/go/bin/go", "args": [ "run", "-C", "/path/to/your/k6-mcp", "github.com/grafana/k6-mcp" ] } } }Note: Replace
/path/to/your/k6-mcpwith the actual path to your cloned repository.Example for macOS:
{ "mcpServers": { "k6": { "command": "/usr/local/go/bin/go", "args": [ "run", "-C", "/Users/username/Dev/grafana/k6-mcp", "github.com/grafana/k6-mcp" ] } } } -
Restart the Claude desktop app to apply changes.
Running Locally for Development
To run the MCP server locally for development:
go run .
The server will start and listen for input on stdin and write to stdout.
Using k6 MCP with Claude
Once your MCP is set up, you can ask Claude to run load tests with commands like:
Run a load test against https://example.com with 5 users and 20 iterations
Claude will use the k6 MCP to generate and run the test, then display the results in the chat.
Troubleshooting
If you encounter issues:
-
Check the logs at:
- macOS:
/Users/<username>/Library/Logs/Claude/mcp-server-k6.log - Windows:
%APPDATA%\Claude\Logs\mcp-server-k6.log - Linux:
~/.local/share/Claude/logs/mcp-server-k6.log
- macOS:
-
Ensure k6 is properly installed and available in your PATH
-
Verify that your Claude developer configuration is correct
Extending the MCP
This MCP uses interfaces for script generation and execution, making it easy to add new functionality:
- Implement custom
ScriptGeneratorinterfaces for different types of tests - Create a new
K6Executorimplementation to use the k6 Go library directly instead of the CLI
