run_mutmut
Execute mutation testing on Python code to identify untested sections by running mutmut on specified modules or packages with optional virtual environment support.
Instructions
Run a full mutation testing session with mutmut on the specified target.
This tool initiates mutation testing on the given module or package. You can provide additional mutmut options as needed. The output includes a summary of mutations tested, including counts of killed, survived, and timed-out mutations. If a virtual environment path is provided, mutmut will be run using the binaries from that environment to ensure compatibility with project-specific dependencies.
Args: target (str): The module or package to run mutation testing on. options (str): Additional command-line options for mutmut (e.g., '--use-coverage'). Defaults to empty. venv_path (Optional[str]): Path to the project's virtual environment to use for running mutmut. Defaults to None.
Returns: str: Summary of the mutation testing run, or error message if the run fails.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| target | Yes | ||
| options | No | ||
| venv_path | No |
Implementation Reference
- mutmut_mcp.py:65-90 (handler)The handler function 'run_mutmut' which executes the mutation testing command.
def run_mutmut(target: str, options: str = "", venv_path: Optional[str] = None) -> str: """ Run a full mutation testing session with mutmut on the specified target. This tool initiates mutation testing on the given module or package. You can provide additional mutmut options as needed. The output includes a summary of mutations tested, including counts of killed, survived, and timed-out mutations. If a virtual environment path is provided, mutmut will be run using the binaries from that environment to ensure compatibility with project-specific dependencies. Args: target (str): The module or package to run mutation testing on. options (str): Additional command-line options for mutmut (e.g., '--use-coverage'). Defaults to empty. venv_path (Optional[str]): Path to the project's virtual environment to use for running mutmut. Defaults to None. Returns: str: Summary of the mutation testing run, or error message if the run fails. """ if venv_path: mutmut_path = _get_mutmut_path(venv_path) if not os.path.exists(mutmut_path): return f"Error: mutmut not found in the specified venv at {mutmut_path}. Please ensure mutmut is installed in the venv." command = [mutmut_path, "run", target] + options.split() else: command = ["mutmut", "run", target] + options.split() return _run_command(command) - mutmut_mcp.py:182-182 (registration)Registration of the 'run_mutmut' tool with the MCP server.
mcp.tool()(run_mutmut)