injection_scan
Scan text for prompt injection patterns to detect security risks. Returns risk assessment without blocking content.
Instructions
Scan text for prompt injection patterns. Returns risk assessment without blocking.
Args: text: The text to scan for injection attempts. threshold: Sensitivity level — "LOW", "MEDIUM", "HIGH", or "CRITICAL".
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| text | Yes | ||
| threshold | No | MEDIUM |
Implementation Reference
- src/agent_safety_mcp/server.py:206-222 (handler)The injection_scan tool handler which uses PromptScanner to evaluate text for prompt injection patterns.
@mcp.tool() def injection_scan(text: str, threshold: str = "MEDIUM") -> dict: """Scan text for prompt injection patterns. Returns risk assessment without blocking. Args: text: The text to scan for injection attempts. threshold: Sensitivity level — "LOW", "MEDIUM", "HIGH", or "CRITICAL". """ scanner = PromptScanner(threshold=threshold) result = scanner.scan(text) return { "severity": result.severity, "risk_score": result.risk_score, "is_safe": result.is_safe, "matches": result.matches, "text_preview": result.text[:200], }