Traffic Generator MCP Server
A Model Context Protocol (MCP) server for running k6 load tests and Kafka performance tests using AWS CodeBuild.
Features
- Load Testing: Run k6 load tests with configurable virtual users, duration, and request parameters
- Test Monitoring: Check status and get results of running tests
- Kafka Performance Testing: Run high-performance Kafka message injection tests using AWS CodeBuild
- JSON Results: Get detailed test results in JSON format
- Flexible Configuration: Support for custom HTTP methods, headers, body, and thresholds
Prerequisites
- Python 3.10 or higher
- k6 installed on your system (Installation Guide)
- AWS credentials configured for CodeBuild and Kafka testing functionality
Usage
Configuration File
{
"mcpServers": {
"traffic-generator-mcp": {
"command": "uvx",
"args": ["traffic-generator-mcp@latest"],
"env": {
"KAFKA_BOOTSTRAP_SERVERS": "broker1:9094,broker2:9094,broker3:9094",
"KAFKA_TOPIC": "your-topic-name",
"S3_BUCKET_NAME": "your-s3-bucket",
"VPC_ID": "vpc-xxxxxxxxx",
"SUBNET_IDS": "subnet-xxxxxxxx,subnet-yyyyyyyy",
"SECURITY_GROUP_IDS": "sg-xxxxxxxxx,sg-yyyyyyyy",
"IAM_ROLE": "YourCodeBuildRole",
"USE_SSL": "true",
"AWS_REGION": "us-west-2"
}
}
}
}
Strands Agent SDK
traffic_generator_mcp_client = MCPClient(
lambda: stdio_client(
StdioServerParameters(
command="uvx",
args=["traffic-generator-mcp@latest"],
env={
**aws_env,
"KAFKA_BOOTSTRAP_SERVERS": "broker1:9094,broker2:9094,broker3:9094",
"KAFKA_TOPIC": "your-topic-name",
"S3_BUCKET_NAME": "your-s3-bucket",
"VPC_ID": "vpc-xxxxxxxxx",
"SUBNET_IDS": "subnet-xxxxxxxx,subnet-yyyyyyyy",
"SECURITY_GROUP_IDS": "sg-xxxxxxxxx,sg-yyyyyyyy"
},
)
)
)
traffic_generator_mcp_client.start()
agent = Agent(
model,
system_prompt,
tools=[traffic_generator_mcp_client.list_tools_sync()],
)
Tools
start_k6_load_test
Start a k6 load test in background and return test ID for monitoring.
Parameters:
url(required): Target URL for the load testvus(optional): Number of virtual users (default: 10)duration(optional): Test duration (default: "30s")rps(optional): Requests per second limitmethod(optional): HTTP method (default: "GET")headers(optional): HTTP headers objectbody(optional): Request body for POST/PUT requeststhresholds(optional): k6 thresholds for pass/fail criteria
Example:
{
"url": "https://httpbin.org/get",
"vus": 20,
"duration": "1m",
"method": "GET",
"headers": {
"User-Agent": "k6-test"
}
}
check_k6_test_status
Check the status of a running k6 test.
Parameters:
test_id(required): Test ID returned by start_k6_load_test
get_k6_test_results
Get detailed results of a completed k6 test.
Parameters:
test_id(required): Test ID returned by start_k6_load_test
run_codebuild_kafka_test
Create a CodeBuild project, trigger a Kafka performance test, and automatically clean up resources.
Parameters:
vus(optional): Number of virtual users (default: 50)msg_per_sec(optional): Messages per second (default: 10000)duration_sec(optional): Test duration in seconds (default: 300)
Example:
{
"vus": 100,
"msg_per_sec": 20000,
"duration_sec": 600
}
Environment Variables Required:
KAFKA_BOOTSTRAP_SERVERS: Kafka broker endpoints (comma-separated)KAFKA_TOPIC: Target Kafka topic nameS3_BUCKET_NAME: S3 bucket containing test data inevents/data.jsonVPC_ID: VPC ID where Kafka cluster is locatedSUBNET_IDS: Subnet IDs for CodeBuild (comma-separated)SECURITY_GROUP_IDS: Security group IDs for CodeBuild (comma-separated)IAM_ROLE(optional): IAM role for CodeBuild (default: "FISExperimentRole")USE_SSL(optional): Enable SSL for Kafka connection (default: "true")AWS_REGION(optional): AWS region (default: "us-west-2")
Test Data Format
The Kafka test expects JSON data in S3 at s3://{bucket}/events/data.json. Example format:
[
{
"url": "https://amazon.com",
"test_number": 20,
"duration": "1m",
"method": "GET"
}
]
License
MIT License
Metadata
Release files for traffic-generator-mcp 2.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| traffic_generator_mcp-2.0.0.tar.gz | 11.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| traffic_generator_mcp-2.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 22.7 kB
Release files / traffic_generator_mcp-2.0.0.tar.gz
| Download URL | traffic_generator_mcp-2.0.0.tar.gz |
|---|---|
| Size | 11.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1ab7ddec1c457781bfa5ebe99f21d52d119b9d4db1e7b86f53d59a405e08ba20
|
|
BLAKE2b-256 checksum How to use checksums |
28bfade9b9bb3349a9f1d7beb0ce8cc1453344f81deae26df33a61fd3d9b6c50
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.4
|
Release files / traffic_generator_mcp-2.0.0-py3-none-any.whl
| Download URL | traffic_generator_mcp-2.0.0-py3-none-any.whl |
|---|---|
| Size | 11.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
02ebb92a43ee8547f32c493b5a2f6ec6cbc4c6446262eb5309197d97aa86ed9e
|
|
BLAKE2b-256 checksum How to use checksums |
cecfeec266a9cdd0d8e5bbdeb264dc042cad842d125a35fe88cfcd8d860b1012
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.4
|