Runtime Guard
Policy enforcement before every tool call. ALLOW, DENY, or ESCALATE in real time.
Three Decisions
ALLOW
Tool call passes policy checks. Execution proceeds normally.
DENY
Tool call violates a policy rule. Execution is blocked and the reason is returned to the agent.
ESCALATE
Tool call needs human approval. Execution pauses until a human approves or rejects.
Python SDK
Import SpiderGuard and wrap your tool execution flow.
python
from spidershield import SpiderGuard, Decision guard = SpiderGuard(policy="balanced", dlp="redact", audit=True) # Before tool execution — policy check result = guard.check("execute_sql", {"query": "DROP TABLE users"}) if result.decision == Decision.DENY: print(f"Blocked: {result.reason}") elif result.decision == Decision.ESCALATE: print(f"Needs approval: {result.reason}") else: output = run_tool("execute_sql", {"query": "DROP TABLE users"}) # After tool execution — DLP scan clean = guard.after_check("execute_sql", output)
Policy Rules
Policies are YAML files with pattern-matching rules. SpiderShield ships with three presets: permissive, balanced, and strict.
yaml
# balanced.yaml — ships with SpiderShield rules: - name: block-destructive-sql tool: "execute_sql" pattern: "DROP|DELETE|TRUNCATE|ALTER" match_on: "arguments.query" decision: DENY reason: "Destructive SQL operations are blocked" - name: block-shell-danger tool: "run_command" pattern: "rm -rf|mkfs|dd if=|:(){ :|:& };:" match_on: "arguments.command" decision: DENY - name: escalate-file-write tool: "write_file" pattern: ".*" match_on: "arguments.path" decision: ESCALATE reason: "File writes require human approval"
Guard Mode (CLI)
Wrap any stdio-based MCP server with zero code changes.
bash
# Wrap any MCP stdio server — zero code changes "code-keyword">$ "code-function">spidershield guard \ "code-keyword">--preset balanced \ -- "code-function">npx @modelcontextprotocol/server-filesystem /tmp # With custom policy file "code-keyword">$ "code-function">spidershield guard \ "code-keyword">--policy ./my-policy.yaml \ -- python my_mcp_server.py # With DLP and audit enabled "code-keyword">$ "code-function">spidershield guard \ "code-keyword">--preset strict \ "code-keyword">--dlp redact \ "code-keyword">--audit \ -- "code-function">npx @modelcontextprotocol/server-everything
Proxy Mode (CLI)
Transparent HTTP proxy for network-based MCP servers.
bash
# HTTP proxy mode for network-based MCP servers "code-keyword">$ "code-function">spidershield proxy \ "code-keyword">--policy strict \ "code-keyword">--port 8080 \ -- python my_http_mcp_server.py # All tool calls intercepted transparently: # read_file("/etc/passwd") → DENIED # exec("rm -rf /") → DENIED # fetch("https://c2.evil") → DENIED # read_file("./data.csv") → ALLOWED
Policy Presets
| Preset | Shell Commands | File Writes | Network | SQL |
|---|---|---|---|---|
| Permissive | Allow (log only) | Allow | Allow | Allow |
| Balanced | Escalate | Escalate | Allow | Block destructive |
| Strict | Deny | Deny | Escalate | Block all mutations |