Generate load testing with k6 and Amazon Relay
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file traffic_generator_mcp-2.0.0.tar.gz.
File metadata
- Download URL: traffic_generator_mcp-2.0.0.tar.gz
- Upload date:
- Size: 11.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1ab7ddec1c457781bfa5ebe99f21d52d119b9d4db1e7b86f53d59a405e08ba20
|
|
| MD5 |
e384211bfa104c9c2111201d36803dad
|
|
| BLAKE2b-256 |
28bfade9b9bb3349a9f1d7beb0ce8cc1453344f81deae26df33a61fd3d9b6c50
|
File details
Details for the file traffic_generator_mcp-2.0.0-py3-none-any.whl.
File metadata
- Download URL: traffic_generator_mcp-2.0.0-py3-none-any.whl
- Upload date:
- Size: 11.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
02ebb92a43ee8547f32c493b5a2f6ec6cbc4c6446262eb5309197d97aa86ed9e
|
|
| MD5 |
30c7791edb9e1faf3bb758a597924d30
|
|
| BLAKE2b-256 |
cecfeec266a9cdd0d8e5bbdeb264dc042cad842d125a35fe88cfcd8d860b1012
|