Skip to main content
Glama
Narasimhakatta

JMeter MCP Server

execute_jmeter_test_non_gui

Run JMeter performance tests in non-GUI mode by specifying a test file path to execute automated load testing without graphical interface.

Instructions

Execute a JMeter test in non-GUI mode.

Args: test_file: Path to the JMeter test file (.jmx)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
test_fileYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • Handler function decorated with @mcp.tool(), registering and implementing the tool by delegating to run_jmeter helper.
    @mcp.tool()
    async def execute_jmeter_test_non_gui(test_file: str) -> str:
        """Execute a JMeter test in non-GUI mode.
    
        Args:
            test_file: Path to the JMeter test file (.jmx)
        """
        return await run_jmeter(test_file, non_gui=True)
  • Core helper function that runs JMeter tests in non-GUI or GUI mode using subprocess, with validation and logging.
    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?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool executes a test but doesn't describe what happens during execution (e.g., runs the test, generates reports, returns results), potential side effects, or any constraints like performance impacts or error handling. This leaves significant gaps for a tool that performs an action.

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 brief and front-loaded with the main purpose, followed by parameter details in a clear 'Args:' section. There's no wasted text, but it could be slightly more informative without losing conciseness.

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 the tool has an output schema (which should cover return values), no annotations, and low complexity (1 parameter), the description is minimally complete. It explains what the tool does and the parameter, but lacks behavioral details and usage context, making it adequate but with clear gaps.

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?

The description adds the parameter 'test_file' and specifies it's a 'Path to the JMeter test file (.jmx)', which provides meaning beyond the schema's basic 'string' type. However, with 0% schema description coverage and only 1 parameter, this is adequate but minimal; it doesn't elaborate on path format or validation, so it meets the baseline for low coverage.

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

Purpose4/5

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

The description clearly states the action ('Execute a JMeter test') and specifies the mode ('in non-GUI mode'), which distinguishes it from the sibling tool 'execute_jmeter_test' that presumably runs in GUI mode. However, it doesn't explicitly contrast with the sibling, so it's not a perfect 5.

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?

The description provides no guidance on when to use this tool versus its sibling 'execute_jmeter_test'. It mentions the non-GUI mode but doesn't explain why or when this mode is preferable, nor does it mention any prerequisites or alternatives.

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'

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