Skip to main content
Glama

execute_jmeter_test

Run JMeter performance tests from .jmx files to analyze application load and behavior under stress.

Instructions

Execute a JMeter test.

Args: test_file: Path to the JMeter test file (.jmx) gui_mode: Whether to run in GUI mode (default: False)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
test_fileYes
gui_modeNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The primary handler function for the 'execute_jmeter_test' tool. It is decorated with @mcp.tool() for registration and delegates the execution logic to the run_jmeter helper function, handling GUI/non-GUI mode.
    @mcp.tool()
    async def execute_jmeter_test(test_file: str, gui_mode: bool = False) -> str:
        """Execute a JMeter test.
    
        Args:
            test_file: Path to the JMeter test file (.jmx)
            gui_mode: Whether to run in GUI mode (default: False)
        """
        return await run_jmeter(test_file, non_gui=not gui_mode)  # Run in non-GUI mode by default
  • Supporting helper function that contains the core logic for running JMeter tests via subprocess, including validation, command building, execution, and error handling for both GUI and non-GUI modes.
    async def run_jmeter(test_file: str, non_gui: bool = True) -> str:
        """Run a JMeter test.
    
        Args:
            test_file: Path to the JMeter test file (.jmx)
            non_gui: Run in non-GUI mode (default: True)
    
        Returns:
            str: JMeter execution output
        """
        try:
            # Convert to absolute path
            test_file_path = Path(test_file).resolve()
            
            # Validate file exists and is a .jmx file
            if not test_file_path.exists():
                return f"Error: Test file not found: {test_file}"
            if not test_file_path.suffix == '.jmx':
                return f"Error: Invalid file type. Expected .jmx file: {test_file}"
    
            # Get JMeter binary path from environment
            jmeter_bin = os.getenv('JMETER_BIN', 'jmeter')
            java_opts = os.getenv('JMETER_JAVA_OPTS', '')
    
            # Log the JMeter binary path and Java options
            logger.info(f"JMeter binary path: {jmeter_bin}")
            logger.debug(f"Java options: {java_opts}")
    
            # Build command
            cmd = [str(Path(jmeter_bin).resolve())]
            
            if non_gui:
                cmd.extend(['-n'])
            cmd.extend(['-t', str(test_file_path)])
    
            # Log the full command for debugging
            logger.debug(f"Executing command: {' '.join(cmd)}")
            
            if non_gui:
                # For non-GUI mode, capture output
                result = subprocess.run(cmd, capture_output=True, text=True)
                
                # Log output for debugging
                logger.debug("Command output:")
                logger.debug(f"Return code: {result.returncode}")
                logger.debug(f"Stdout: {result.stdout}")
                logger.debug(f"Stderr: {result.stderr}")
    
                if result.returncode != 0:
                    return f"Error executing JMeter test:\n{result.stderr}"
                
                return result.stdout
            else:
                # For GUI mode, start process without capturing output
                subprocess.Popen(cmd)
                return "JMeter GUI launched successfully"
    
        except Exception as e:
            return f"Unexpected error: {str(e)}"
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. It mentions GUI mode but doesn't disclose behavioral traits like whether execution is blocking/non-blocking, what outputs are generated, error handling, or system requirements. The description is minimal and lacks critical operational context.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized with two sentences and an Args section. It's front-loaded with the core purpose, though the parameter documentation could be more integrated. No wasted words, but structure is basic.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given 2 parameters with 0% schema coverage, no annotations, but an output schema exists, the description is minimally complete. It covers the basic action and parameters but lacks context about execution behavior, sibling differentiation, and error cases that would help an agent use it correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate. It adds basic meaning for both parameters (test_file path and GUI mode default), but doesn't provide format details (e.g., absolute/relative paths), constraints, or implications of GUI mode. This partially compensates but leaves gaps.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states 'Execute a JMeter test' which provides a basic verb+resource combination, but it's vague about what execution entails (e.g., running performance tests, generating reports). It doesn't distinguish from sibling 'execute_jmeter_test_non_gui' beyond mentioning GUI mode in parameters.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No explicit guidance on when to use this tool versus alternatives. The presence of sibling 'execute_jmeter_test_non_gui' suggests alternatives exist, but the description doesn't explain when to choose GUI vs non-GUI modes or other considerations.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Narasimhakatta/MCP-Server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server