Skip to main content

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 test
  • vus (optional): Number of virtual users (default: 10)
  • duration (optional): Test duration (default: "30s")
  • rps (optional): Requests per second limit
  • method (optional): HTTP method (default: "GET")
  • headers (optional): HTTP headers object
  • body (optional): Request body for POST/PUT requests
  • thresholds (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 name
  • S3_BUCKET_NAME: S3 bucket containing test data in events/data.json
  • VPC_ID: VPC ID where Kafka cluster is located
  • SUBNET_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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

traffic_generator_mcp-2.0.0.tar.gz (11.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

traffic_generator_mcp-2.0.0-py3-none-any.whl (11.0 kB view details)

Uploaded Python 3

File details

Details for the file traffic_generator_mcp-2.0.0.tar.gz.

File metadata

File hashes

Hashes for traffic_generator_mcp-2.0.0.tar.gz
Algorithm Hash digest
SHA256 1ab7ddec1c457781bfa5ebe99f21d52d119b9d4db1e7b86f53d59a405e08ba20
MD5 e384211bfa104c9c2111201d36803dad
BLAKE2b-256 28bfade9b9bb3349a9f1d7beb0ce8cc1453344f81deae26df33a61fd3d9b6c50

See more details on using hashes here.

File details

Details for the file traffic_generator_mcp-2.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for traffic_generator_mcp-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 02ebb92a43ee8547f32c493b5a2f6ec6cbc4c6446262eb5309197d97aa86ed9e
MD5 30c7791edb9e1faf3bb758a597924d30
BLAKE2b-256 cecfeec266a9cdd0d8e5bbdeb264dc042cad842d125a35fe88cfcd8d860b1012

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

2.0.0 This release

2 files

1.0.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page