Lint JMeter-specific Groovy anti-patterns, inspect JSR223 bindings, and generate ready-to-paste JMX elements from curated recipes or custom scripts.
Static Analysis
No JMeter-specific anti-patterns detected.
Bindings for Selected Element
Groovy Script (.groovy)
JMX Element Snippet
Paste into a .jmx under the target sampler's<hashTree>, or import via JMeter GUI โ Edit โ Paste.Use Groovy tools through MCP
Call get_jsr223_recipe for curated examples, or lint_groovy_script to review your own code and generate JSR223 element XML.
claude mcp add jmeter-docs https://docs.jmeter.ai/api/mcp --transport httpThis builder does not execute Groovy. Review generated code and run it in a controlled JMeter test before load testing. See JSR223 Sampler Reference and JMeter MCP Reference.
Why Groovy over BeanShell
Section titled โWhy Groovy over BeanShellโJMeter supports Groovy through JSR223 compilation caching, while BeanShell is interpreted and substantially slower in a hot sampling path. Groovy also provides modern Java interoperability, mature JSON support, and access to JMeterโs documented script bindings.
This page is a builder and static analyzer. Groovy cannot execute in the browser. The tool inspects source text for JMeter-specific pitfalls and generates files for you to review and run in JMeter; it does not validate runtime types, external classes, network access, or script behavior.
Binding availability
Section titled โBinding availabilityโEvery JSR223 element exposes the common bindings log, Label, FileName, Parameters, args, ctx, vars, props, and OUT. Element-specific bindings differ:
| Element | Available bindings |
|---|---|
JSR223 Sampler | log, Label, FileName, Parameters, args, ctx, vars, props, OUT, SampleResult, sampler |
JSR223 PreProcessor | log, Label, FileName, Parameters, args, ctx, vars, props, OUT, sampler |
JSR223 PostProcessor | log, Label, FileName, Parameters, args, ctx, vars, props, OUT, sampler, prev |
JSR223 Assertion | log, Label, FileName, Parameters, args, ctx, vars, props, OUT, SampleResult, AssertionResult, prev, sampler |
JSR223 Timer | log, Label, FileName, Parameters, args, ctx, vars, props, OUT, sampler |
JSR223 Listener | log, Label, FileName, Parameters, args, ctx, vars, props, OUT, sampleResult, prev, sampleEvent, sampler |
Binding names are case-sensitive. For example, SampleResult is available in a Sampler or Assertion, while lowercase sampleResult and sampleEvent belong to a Listener. prev is available to PostProcessors, Assertions, and Listeners, but not PreProcessors or Timers; sampler is available to all six element types, including Listeners.
Anti-patterns this linter catches
Section titled โAnti-patterns this linter catchesโ| Rule ID | Severity | What it catches |
|---|---|---|
EMPTY_SCRIPT | Error | Blank code |
THREAD_SLEEP | Error | Thread.sleep(...) or sleep(...) blocking a JMeter worker thread |
JMETER_VAR_INTERPOLATION | Warning | ${name} expansion without a preceding Groovy local declaration |
SYSTEM_OUT | Warning | System.out, System.err, or statement-level println(...) |
NEW_RANDOM_PER_CALL | Info | A new Random instance created on each invocation |
REGEX_COMPILE_IN_SCRIPT | Info | Pattern.compile(...) in the hot script path |
UNAVAILABLE_BINDING | Error | A known binding used by the wrong JSR223 element type |
BEANSHELL_IMPORT | Error | BeanShell imports or API references inside Groovy |
LEGACY_JSONSLURPER_CLASSIC | Info | JsonSlurperClassic instead of JsonSlurper |
PROPS_MUTATION_IN_LOOP_HOT_PATH | Info | Writes to shared JMeter properties with props.put(...) |
SCRIPT_TOO_LONG | Warning | Inline code over 200,000 characters that belongs in a .groovy file |
For dynamic JMeter values, prefer vars.get("name") or props.get("name"). Substitution such as ${token} happens before Groovy compilation, can create a new compiled script for each value, and can break syntax when data contains quotes or other special characters.
How to use the generated JMX snippet
Section titled โHow to use the generated JMX snippetโ- Select the JSR223 element that matches where the script should run.
- Fix error-level binding or scripting findings.
- Copy the generated element and its following
<hashTree/>. - Paste it under the target elementโs
<hashTree>in the.jmx, or use JMeter GUI โ Edit โ Paste. - Open the plan in JMeter, confirm the tree location, and run a one-user smoke test with assertions before applying load.
The generated element uses TestBeanGUI, Groovy, and a non-empty cacheKey so JMeter can cache compiled scripts. Downloading the .groovy variant is useful when scripts are shared across plans or maintained in source control; set that file through the JSR223 FileName field in JMeter.
Use via MCP
Section titled โUse via MCPโConnect an MCP-compatible agent:
claude mcp add jmeter-docs https://docs.jmeter.ai/api/mcp --transport httpAsk the agent to call get_jsr223_recipe by recipe name or category to retrieve the curated JWT, HMAC, dynamic header, JSON extraction, and custom logging examples used by this builder. For your own script, call lint_groovy_script with the code and JSR223 element type to receive the same findings, binding analysis, and optional ready-to-paste JMX element XML.