run_attack
Execute vulnerability scans on language models by specifying model type, model name, and probe. Identify potential risks and generate a list of vulnerabilities for analysis.
Instructions
Run an attack with the given model and probe which is a Garak attack.
Args:
model_type (str): The type of model to use.
model_name (str): The name of the model to use.
probe_name (str): The name of the attack / probe to use.
Returns:
list: A list of vulnerabilities.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| model_name | Yes | ||
| model_type | Yes | ||
| probe_name | Yes |
Implementation Reference
- src/server.py:152-165 (handler)MCP tool handler for 'run_attack': decorated function that executes the tool by delegating to GarakServer.run_attack method.@mcp.tool() def run_attack(model_type: str, model_name: str, probe_name: str): """ Run an attack with the given model and probe which is a Garak attack. Args: model_type (str): The type of model to use. model_name (str): The name of the model to use. probe_name (str): The name of the attack / probe to use. Returns: list: A list of vulnerabilities. """ return GarakServer().run_attack(model_type, model_name, probe_name)
- src/server.py:60-101 (helper)Core helper function in GarakServer class that implements the attack by running 'garak' CLI commands with appropriate model configuration.def run_attack(self, model_type: str, model_name: str, probe_name: str): """ Run an attack with the given model and probe. Args: model_type (str): The type of model to use. model_name (str): The name of the model to use. probe_name (str): The name of the probe to use. Returns: list: A list of vulnerabilities. """ if model_type == "ollama": config_file = self._get_generator_options_file(model_name) try: return get_terminal_commands_output([ 'garak', '--model_type', 'rest', '--generator_option_file', config_file, '--probes', probe_name, '--report_prefix', REPORT_PREFIX, "--generations", "1", "--config", "fast", "--parallel_attempts", str(self.config.parallel_attempts), "-v" ]) finally: # Clean up the temporary file if os.path.exists(config_file): os.unlink(config_file) else: return get_terminal_commands_output([ 'garak', '--model_type', model_type, '--model_name', model_name, '--probes', probe_name, '--report_prefix', REPORT_PREFIX, "--generations", "1", "--config", "fast", "--parallel_attempts", str(self.config.parallel_attempts), "-v" ])
- src/server.py:152-152 (registration)Registration of the 'run_attack' tool using the @mcp.tool() decorator.@mcp.tool()