pub struct McpMonitor { /* private fields */ }Expand description
MCP Protocol Security Monitor.
Tracks registered MCP servers and their tools, validates server trust, detects injection in tool schemas and responses, and flags exfiltration attempts.
Implementations§
Source§impl McpMonitor
impl McpMonitor
Sourcepub fn new(config: McpMonitorConfig) -> Self
pub fn new(config: McpMonitorConfig) -> Self
Create a new monitor from the given configuration.
Sourcepub fn with_defaults() -> Self
pub fn with_defaults() -> Self
Create a monitor with sensible defaults.
Sourcepub fn register_server(
&mut self,
uri: &str,
name: &str,
tools: HashMap<String, String>,
) -> Result<(), Vec<McpSecurityViolation>>
pub fn register_server( &mut self, uri: &str, name: &str, tools: HashMap<String, String>, ) -> Result<(), Vec<McpSecurityViolation>>
Register an MCP server and its tools.
Returns an error if the server is not on the allowlist, or if any tool triggers a security violation (shadowing, schema injection, etc.).
Sourcepub fn validate_server(&self, uri: &str) -> ServerValidation
pub fn validate_server(&self, uri: &str) -> ServerValidation
Validate whether a server URI is on the allowlist.
Sourcepub fn validate_tool_schema(
&self,
_tool_name: &str,
description: &str,
param_descriptions: &[&str],
) -> SchemaValidation
pub fn validate_tool_schema( &self, _tool_name: &str, description: &str, param_descriptions: &[&str], ) -> SchemaValidation
Scan a tool’s description and parameter descriptions for injection patterns.
Sourcepub fn detect_tool_shadowing(
&self,
tool_name: &str,
server_uri: &str,
) -> Option<ShadowingAlert>
pub fn detect_tool_shadowing( &self, tool_name: &str, server_uri: &str, ) -> Option<ShadowingAlert>
Detect if a tool name is already registered by a different server.
Sourcepub fn validate_tool_response(
&self,
_tool_name: &str,
response_content: &str,
) -> ResponseValidation
pub fn validate_tool_response( &self, _tool_name: &str, response_content: &str, ) -> ResponseValidation
Validate a tool’s response content for injection and exfiltration.
Sourcepub fn scan_for_injection(&self, text: &str) -> Vec<InjectionIndicator>
pub fn scan_for_injection(&self, text: &str) -> Vec<InjectionIndicator>
Scan arbitrary text for instruction-like injection patterns.
Sourcepub fn check_exfiltration_indicators(
&self,
content: &str,
) -> Vec<ExfiltrationIndicator>
pub fn check_exfiltration_indicators( &self, content: &str, ) -> Vec<ExfiltrationIndicator>
Check text for data-exfiltration indicators (URLs, base64 blocks, etc.).
Sourcepub fn to_security_findings(
&self,
violations: &[McpSecurityViolation],
) -> Vec<SecurityFinding>
pub fn to_security_findings( &self, violations: &[McpSecurityViolation], ) -> Vec<SecurityFinding>
Convert a list of MCP violations into SecurityFinding values for the
LLMTrace pipeline.
Sourcepub fn server_count(&self) -> usize
pub fn server_count(&self) -> usize
Number of registered servers.
Sourcepub fn tool_count(&self) -> usize
pub fn tool_count(&self) -> usize
Number of tracked tool-to-server ownership entries.