jmeter-ai-agent

mcp
Security Audit
Warn
Health Warn
  • License — License: Apache-2.0
  • Description — Repository has a description
  • Active repo — Last push 0 days ago
  • Low visibility — Only 9 GitHub stars
Code Pass
  • Code scan — Scanned 12 files during light audit, no dangerous patterns found
Permissions Pass
  • Permissions — No dangerous permissions requested

No AI report is available for this listing yet.

SUMMARY

Local AI agent for Apache JMeter: turns test documents into requirements, runs the plan and judges every run with evidence (verdicts, baseline diff, Prometheus) - MCP built in.

README.md

JMeter Agent

Turn a performance test document into a pass / fail verdict you can defend.

A local AI agent for Apache JMeter: it reads your requirements, builds the test plan, runs it,

and judges every run against the numbers you actually agreed on — with the evidence attached.

English · 简体中文

License
Python
Vue
JMeter
MCP

Test report: requirement verdicts with the measured value and the source quote for each requirement

Why

Most "AI for load testing" tools stop at "the P95 looks high, consider adding a cache."
That is not something you can sign off on. What you need after a run is:

  • Did we meet the requirements? Each one, with the measured value and how far off it is.
  • Did it get worse? Compared with the baseline and the previous run, overall and per transaction.
  • Why? Server-side metrics for the exact test window, not guesses from client latency.

JMeter Agent produces those answers deterministically, then lets the AI explain them — and the AI must cite
requirement IDs and measured values. Anything it cannot back up is labelled as a hypothesis, with a way to check it.

How it works

flowchart LR
    A["Test document<br/>(spec, test plan, API doc)"] -->|AI extracts,<br/>you review| B["Requirements<br/>P95 ≤ 1 s, errors ≤ 0.1%,<br/>500 users"]
    B -->|load profile prefills| C["JMeter test plan<br/>(form or JMX tree)"]
    C -->|run| D["Evidence<br/>verdicts · baseline diff ·<br/>Prometheus metrics"]
    D -->|cited, not guessed| E["AI analysis"]
    D -. same data .-> F["Claude Code / Cursor<br/>via MCP"]
  1. Document → requirements. Paste a spec or upload a file. AI drafts quantified requirements (P90/P95/P99, average, max, error rate, TPS) plus the load profile. Every item quotes its source sentence, and quotes that cannot be found in the document are flagged for review. Nothing is saved until you confirm.
  2. Requirements → test plan. New plans start from the documented concurrency, ramp-up and duration. Edit them in a form view or the full JMX tree.
  3. Run → evidence. Each run is judged requirement by requirement (transaction-level requirements use the worst matching sampler), compared with the active baseline and the previous run, and enriched with Prometheus metrics for the run window: saturation time and correlation with response time.
  4. Evidence → analysis. The AI analysis receives the same evidence and must ground its conclusions in it.

Features

Requirement verdicts Overall and per-transaction requirements, a verdict banner on every report, gap percentages for failures, verified source quotes.
Start from a document One wizard for a requirements/API document or an OpenAPI URL; produces the project, test plans and a requirements draft.
Baselines that stay put One click on a report sets it as the baseline. The baseline keeps a metrics snapshot, so deleting old runs does not break comparisons.
Server-side evidence Prometheus presets for host (node_exporter), JVM + HikariCP and MySQL; collected per run window and cached.
Honest AI analysis Fact sheet and number validation: each number is checked against the request it names, or the whole run, in Chinese and English reports alike. Reports compare with earlier runs of the plan, other loads and the same requests in other plans, check earlier predictions automatically, and cite lessons your team saved. Reports follow the UI language, or REPORT_LANGUAGE.
Most model providers 25 presets: OpenAI, Claude, Gemini, Azure OpenAI, xAI Grok, Mistral, Cohere, Groq, OpenRouter, Together, DeepSeek, Qwen, Kimi, Zhipu GLM, Doubao, ERNIE, Hunyuan, MiniMax, StepFun, SiliconFlow, plus local Ollama, LM Studio, vLLM and any OpenAI- or Anthropic-compatible API. Parameters reasoning models refuse are adapted automatically.
Verification and capacity A hypothesis a program can check gets a Run a check button: the plan reruns at the load its prediction names and the run settles it. Capacity search raises the load step by step and stops at the first step that fails a requirement, errors too much or stops gaining throughput.
Live run view Running tests get a card on the Runs page; opening one shows throughput, response time, errors and threads every 5 seconds, the requests with the most errors, real progress and time left from the planned duration, and a Stop button.
Run guard and CI gate A run whose recent requests nearly all fail is stopped, with the reason recorded. scripts/ci_gate.py runs a plan and exits non-zero when it fails a requirement or regresses against the baseline.
MCP built in Streamable HTTP endpoint with evidence tools (get_execution_evidence, extract_performance_requirements, promote_execution_to_baseline, …). Writes need your confirmation in the UI.
Solid JMeter plumbing Streaming JTL parser with exact percentiles and flat memory use, queued runs when the load generator is busy, live progress over WebSocket, and a one-user trial run that shows each response and offers extractor fixes proven by it.
Private by default No accounts and no login; the server refuses to bind to anything but loopback, and Host/Origin checks block other sites in your browser.

Screenshots

Project overview with loop setup steps and recent runs
Project overview — what is set up, and the latest verdicts
Requirements editor with verified source quotes
Requirements — AI draft, source quotes, load profile
Report trends: response time, throughput and error rate over time
Trends — response time, throughput, errors, percentiles
All runs with verdict, key metrics and AI status
Runs — every run, its verdict and key numbers at a glance

Screenshots come from a sample run against the public JSONPlaceholder API, with four example requirements.

Quick start

Requirements: Python 3.11+, Node.js 20+, Java 11+ and Apache JMeter 5.6.3. Tested on Windows and Linux; macOS should work but is untested.

git clone https://github.com/xiaoyuCR7/jmeter-ai-agent.git
cd jmeter-ai-agent

1. Make JMeter discoverable — pick one:

  • extract the archive's bin/ and lib/ into the project root (zero configuration), or
  • set JMETER_HOME to JMeter's bin directory (or its install root), or
  • put JMeter's bin on your PATH.

JMeter is only needed to execute load tests; editing plans and running the unit tests work without it.

2. Start everything

./start.sh        # Linux / macOS
start.bat         # Windows

The script opens the app through a link carrying your local access token. Only that first visit needs it: the browser
then keeps a cookie. There is no login; see Local access.

On Windows, stop.bat closes the backend and frontend start.bat opened (a port held by another program is left
alone), and create-shortcut.bat puts a "JMeter Agent" shortcut with the app icon on the desktop.

Or by hand:

cd jmeter-agent-backend && pip install -r requirements.txt && python -m app.main   # http://127.0.0.1:8000
cd jmeter-agent-frontend && npm install && npm run dev                             # open the link the backend prints

3. Add a model in Settings → AI models: pick one of 25 providers (China, international and local) and paste an API key.
Local servers such as Ollama and LM Studio need none; Azure OpenAI takes its resource endpoint, an API version and the
deployment name as the model. Leave Context window empty and the app asks the provider for the model's real size,
falling back to the documented size. Then click Start from a document.

API docs are served at http://127.0.0.1:8000/api/docs.

Use it from Claude Code, Cursor and friends

claude mcp add --transport http jmeter-agent http://127.0.0.1:8000/api/v1/mcp --header "Authorization: Bearer <token>"

The token is the one in your access link, also stored in jmeter-agent-backend/.local_access_token. Ready-to-copy
configs that already include it, for Cursor, VS Code and others, are under Settings → Assistants (MCP). Ask the assistant to use the
analyze-execution prompt, or to call get_execution_evidence first — it gets exactly what the report page shows.
Older SSE-only clients can use /api/v1/mcp/sse.

Over MCP, execute_test and execute_distributed return as soon as the run has started, so a client's request timeout
never stops a load test; poll get_execution_status for the result. Tools that change or run something wait up to two
minutes for your approval in the JMeter Agent window, so keep it open. If the client cancels or disconnects first, the
request and its pending approval are dropped.

CI

On the machine that runs JMeter Agent (a self-hosted runner):

python jmeter-agent-backend/scripts/ci_gate.py --plan <test-plan-id>

It starts the plan, polls GET /api/v1/executions/{id}/gate and exits 0 when requirements and the baseline pass,
1 when a requirement fails or cannot be evaluated, or the run regressed against the baseline, and 2 when the run did
not complete or timed out. It is also 2 when the machine running JMeter was saturated (the numbers are then its own),
and when the project has neither requirements nor a baseline, because nothing was checked; --lenient accepts that last
case, and a requirement that could not be evaluated, with a warning.
The token comes from --token, JMETER_AGENT_TOKEN or .local_access_token. A plan with scripts is refused once with the
sha256 to approve; pass it with --approved-sha256 once you trust the plan.

Evaluating AI reports

tests/golden/report_claims.json holds report sentences labelled by hand: does each state a number the run did not
measure? The test suite requires the number checker to catch every wrong one and flag none of the right ones. To score
the reports a model writes:

cd jmeter-agent-backend
python scripts/eval_reports.py --list-models
python scripts/eval_reports.py --model <model-id> [--lang en] [--repeat 3]

The model writes a report for each labelled run; the script counts the numbers checked, the wrong ones before and after
the rewrite, empty sections and the language. Results go to eval_results/ and are compared with that model's previous
result, so a prompt or model change shows up as numbers. This calls the model and costs tokens.

Configuration

Common settings in jmeter-agent-backend/.env:

Variable Purpose Default
PORT Backend port 8000
JMETER_HOME JMeter bin directory or install root <project>/bin
JMETER_TIMEOUT Stops a run that never ends (seconds). A plan with a longer fixed duration gets its duration plus time to write the report 3600
AUTO_ANALYSIS_ENABLED Write an AI report after every finished run, whatever started it; measured history is kept either way true
JMETER_HEAP_MIN / JMETER_HEAP_MAX JMeter's JVM heap in local mode; a HEAP variable in the backend's environment wins 256m / 2g
JMETER_GC_OPTS / JMETER_EXTRA_OPTS GC options and further JVM options (local mode) G1 / empty
JMETER_EXECUTION_MODE local or container; see Execution isolation below local
JMETER_MAX_OUTPUT_MB Stop a run whose report directory grows past this; 0 = no limit 10240
RESOURCE_CPU_THRESHOLD / RESOURCE_MEMORY_THRESHOLD Above this load-generator usage (%), unattended runs (started by an assistant, verification runs, each capacity step) wait; a run you start by hand is recorded, not held 80 / 85
RESOURCE_COOLDOWN_SECONDS Seconds to let the load generator settle between unattended runs 10
REPORTS_RETENTION_DAYS / REPORTS_RETENTION_INCLUDE_JTL Daily, remove the HTML dashboard (about 3 MB each) of runs older than this many days, optionally with the raw results; 0 keeps everything. Summaries, AI reports and history stay, and the run an active baseline came from is never pruned. Settings → System info can also prune by hand 0 / false
EXECUTION_CACHE_SIZE Runs kept whole in memory (summary detail and AI report); the rest are held in outline and read from the database when opened 256
LOG_LEVEL / LOG_FILE Backend log level and file (default logs/jmeter-agent.log, 5 MB x 3 rotated; off for console only) INFO / empty
I18N_DEFAULT_LANG Language of backend messages when no request names one (an MCP client, for example) zh-CN
DEFAULT_AI_MODEL Model ID used when a request names none first enabled model
AGENT_CONTEXT_TOKEN_BUDGET Token budget for a model whose context window is unknown 16384
AGENT_MAX_CONCURRENT AI tasks at once; reports written after runs use at most N-1, leaving one for questions 3
REPORT_LANGUAGE Language of reports written after a run, zh-CN or en; empty follows I18N_DEFAULT_LANG. Rewrites and questions follow the page empty
RUN_GUARD_ENABLED Stop a run whose recent requests nearly all fail true
RUN_GUARD_ERROR_RATE / RUN_GUARD_WINDOW_SECONDS Error rate (%) and window (s) that stop a run; two checks in a row must exceed it 90 / 30
RUN_GUARD_MIN_SAMPLES / RUN_GUARD_GRACE_SECONDS Fewer requests than this in the window decide nothing; nor does the start of the run 50 / 30
RUN_GUARD_MEMORY_PERCENT Stop a run when this machine's memory is this full (0 = off) 97
RUN_GUARD_LATENCY_FACTOR Stop a run whose average response time is this many times its starting value (0 = off; stress tests are meant to slow the target, so it is off by default) 0

Model API keys are not read from .env; add models in the UI. They are stored in jmeter-agent-backend/ai_models_config.json,
which git ignores.

HOST must stay a loopback address: there is no login, so the server refuses to start on anything else, and it
refuses any connection that does not come from this machine.

Local access

The API, live updates and stored reports need the local access token, because anything on this machine that speaks HTTP
could otherwise call them, including a test plan's own HTTP samplers. The backend creates the token on first start in
jmeter-agent-backend/.local_access_token (git ignores it) and prints the access link. Lost the cookie, or using another
browser? Open that link again, or paste it when the app asks. MCP clients and scripts send Authorization: Bearer <token>.
Delete the file and restart to replace the token; every browser and MCP client then needs the new one.

Stored reports are served in a browser sandbox, since they contain data from the systems under test. Agent tools are
graded read, draft, write or execute: the last two wait for your confirmation, whoever called them (this app's
agents or an MCP client), and the analysis agent only gets read tools.

Execution isolation

JMeter plans can do far more than send load: run code through JSR223 / BeanShell elements, the OS Process Sampler and
functions such as ${__groovy()}, and read or write any file with no script at all, through ${__FileToString()},
${__StringToFile()}, CSV Data Set, HTTP file uploads or listener output paths. JMETER_EXECUTION_MODE decides where
all of that happens.

Mode How JMeter runs Use it for
local (default) A child process with your privileges. Before running a plan with scripts, commands, Java samplers, an Include Controller, file functions, or file paths outside the plan's folder and the app's data folders, the app lists them and asks you (the agent asks a second time, separately). The approval covers those exact bytes: a plan edited afterwards is asked about again. Plans the app generates contain none. Plans you wrote or generated here
container Docker: read-only root filesystem, all capabilities dropped, no privilege escalation, non-root user, memory / CPU / process limits, no shared IPC, only the plan's project folder mounted (read-only) Plans from anywhere else

Container mode needs Docker and JMETER_CONTAINER_IMAGE, a locally available image pinned by @sha256: digest (it is
never pulled automatically). Containers can reach the network so they can generate load; to stop them reaching your
LAN or cloud metadata endpoints, create a Docker network with restricted egress and set JMETER_CONTAINER_NETWORK.
Every run container is labelled jmeter-agent, and the backend removes any left running when it starts.

In both modes a run stops when its report directory exceeds JMETER_MAX_OUTPUT_MB (default 10240), and JMeter
never sees the backend's environment variables (model keys, database settings).

Webhook

Set WEBHOOK_URL to receive a POST for every run, however it was started (UI, agent, scheduler, MCP):

Event When Switch
test.started JMeter is launching WEBHOOK_ON_START
test.completed / test.failed / test.cancelled The run ended; sent before AI analysis WEBHOOK_ON_COMPLETE / WEBHOOK_ON_FAILURE (both failure kinds)
analysis.completed Post-run AI analysis finished or failed WEBHOOK_ON_ANALYSIS

The JSON body carries the execution, project and plan IDs, plan name, status, duration, key metrics, the requirements
verdict and any error. Errors are cut to their first line with local paths reduced to file names. analysis.completed
sends the analysis status and conclusion; set WEBHOOK_INCLUDE_ANALYSIS=true to also send the full assessment, which
may quote your endpoints.

Use an https URL and set WEBHOOK_SECRET; the server logs a warning at startup otherwise. A receiver should:

  1. Compute HMAC-SHA256 with the secret over <X-JMeter-Agent-Timestamp>.<raw body> and compare sha256=<hex>
    with X-JMeter-Agent-Signature in constant time (e.g. Python hmac.compare_digest).
  2. Reject requests whose X-JMeter-Agent-Timestamp (Unix seconds) is more than 5 minutes old.
  3. Drop X-JMeter-Agent-Delivery IDs it has already seen; the ID stays the same across retries.

Only 2xx counts as delivered. Network errors, 408, 429 and 5xx are retried 3 times (after 1 s, 5 s, 15 s); redirects
and other 4xx are not, so point WEBHOOK_URL at the final address. Logs name only the receiver's host, never the URL,
because webhook URLs often contain a token.

Key API endpoints
Method Path Description
GET / PUT /api/v1/projects/{id}/requirements Read / save performance requirements
POST /api/v1/projects/{id}/requirements/extract AI requirements draft from document text
GET / PUT /api/v1/projects/{id}/monitoring Prometheus configuration
POST /api/v1/test-plans/{id}/execute Run a test plan
GET /api/v1/executions Runs with verdicts and key metrics
GET /api/v1/executions/{id}/report Full report
GET /api/v1/executions/{id}/evidence Verdicts, history comparison, server metrics
POST /api/v1/executions/{id}/promote-baseline Set a run as the baseline
POST /api/v1/mcp MCP Streamable HTTP endpoint
Project layout
jmeter-ai-agent/
├── jmeter-agent-backend/     FastAPI service
│   └── app/
│       ├── api/              REST + MCP routes
│       ├── services/
│       │   ├── requirements.py, evidence.py, baseline_compare.py, server_metrics.py
│       │   ├── ai/           model adapters, agents, memory
│       │   └── jmeter/       executor, JMX builder/parser, streaming JTL parser
│       └── middleware/       loopback Host / Origin guard
├── jmeter-agent-frontend/    Vue 3 + TypeScript + Element Plus
└── start.sh / start.bat / stop.bat / create-shortcut.bat

bin/, lib/ (the JMeter runtime), test plans, reports and local databases are git-ignored.

Troubleshooting
  • JMeter executable not found — check java -version, then one of: bin/jmeter(.bat) in the project root, JMETER_HOME, or JMeter on PATH (jmeter --version).
  • AI analysis fails — test the model in Settings → AI models; check the key and network access.
  • "exceeds the context budget" — the model's context window is unknown, so the conservative AGENT_CONTEXT_TOKEN_BUDGET
    applies. Edit the model and enter its context window (in tokens).
  • Port in use — PORT=8001 ./start.sh (Windows: set PORT=8001 then start.bat).
  • Runs stay queued — the load generator is above RESOURCE_*_THRESHOLD; the top bar shows its CPU / memory.
  • Logs — jmeter-agent-backend/server_stdout.log, server_stderr.log, and reports/{execution_id}/jmeter.log per run.

Development

How the code is divided and where AI is and is not used: docs/ARCHITECTURE.md (Chinese).

cd jmeter-agent-backend && pip install -r requirements-dev.txt && pytest tests
cd jmeter-agent-frontend && npm install && npm run test:run && npx vue-tsc --noEmit
cd jmeter-agent-frontend && npx playwright install chromium && npm run test:e2e   # browser smoke test (mocked API); add PW_CHANNEL=chrome to reuse a local Chrome

Issues and pull requests are welcome. Please keep PRs focused and include tests for behaviour changes.

License

Apache License 2.0. Apache JMeter is a trademark of the Apache Software Foundation; this project is not affiliated with or endorsed by it.

Reviews (0)

No results found