MCP Hub
Back to servers

ZugaShield

A 7-layer security system for AI agents that detects and blocks prompt injection, data exfiltration, and malicious tool calls. It enables real-time scanning of inputs, outputs, and tool definitions to protect agentic workflows from emerging AI-specific threats.

Updated
Feb 17, 2026

ZugaShield

7-layer security system for AI agents

Stop prompt injection, data exfiltration, and AI-specific attacks — in under 15ms.

CI PyPI Python License: MIT


65% of organizations deploying AI agents have no security defense layer. ZugaShield is a production-tested, open-source library that protects your AI agents with:

  • Zero dependencies — works out of the box, no C extensions
  • < 15ms overhead — compiled regex fast path, async throughout
  • 150+ signatures — curated threat catalog, updated regularly
  • MCP-aware — scans tool definitions for hidden injection payloads
  • 7 defense layers — defense in depth, not a single point of failure

Quick Start

pip install zugashield
import asyncio
from zugashield import ZugaShield

async def main():
    shield = ZugaShield()

    # Check user input for prompt injection
    decision = await shield.check_prompt("Ignore all previous instructions")
    print(decision.is_blocked)  # True
    print(decision.verdict)     # ShieldVerdict.BLOCK

    # Check LLM output for data leakage
    decision = await shield.check_output("Your API key: sk-live-abc123...")
    print(decision.is_blocked)  # True

    # Check a tool call before execution
    decision = await shield.check_tool_call(
        "web_request", {"url": "http://169.254.169.254/metadata"}
    )
    print(decision.is_blocked)  # True (SSRF blocked)

asyncio.run(main())

Try It Yourself

Run the built-in attack test suite to see ZugaShield in action:

pip install zugashield
python -c "import urllib.request; exec(urllib.request.urlopen('https://raw.githubusercontent.com/Zuga-luga/ZugaShield/master/examples/test_it_yourself.py').read())"

Or clone and run locally:

git clone https://github.com/Zuga-luga/ZugaShield.git
cd ZugaShield && pip install -e . && python examples/test_it_yourself.py

Expected output: 10/10 attacks blocked, 0 false positives, <1ms average scan time.

Architecture

ZugaShield uses layered defense — every input and output passes through multiple independent detection engines. If one layer misses an attack, the next one catches it.

┌─────────────────────────────────────────────────────────────┐
│                       ZugaShield                            │
├─────────────────────────────────────────────────────────────┤
│  Layer 1: Perimeter         HTTP validation, size limits    │
│  Layer 2: Prompt Armor      10 injection detection methods  │
│  Layer 3: Tool Guard        SSRF, command injection, paths  │
│  Layer 4: Memory Sentinel   Memory poisoning, RAG scanning  │
│  Layer 5: Exfiltration Guard  DLP, secrets, PII, canaries   │
│  Layer 6: Anomaly Detector  Behavioral baselines, chains    │
│  Layer 7: Wallet Fortress   Transaction limits, mixers      │
├─────────────────────────────────────────────────────────────┤
│  Cross-layer: MCP tool scanning, LLM judge, multimodal     │
└─────────────────────────────────────────────────────────────┘

What It Detects

AttackHowLayer
Direct prompt injectionCompiled regex + 150+ catalog signatures2
Indirect injectionSpotlighting + content analysis2
Unicode smugglingHomoglyph + invisible character detection2
Encoding evasionNested base64 / hex / ROT13 decoding2
Context window floodingRepetition + token count analysis2
Few-shot poisoningRole label density analysis2
GlitchMiner tokensShannon entropy per word2
Document embeddingCSS hiding patterns (font-size:0, display:none)2
ASCII art bypassEntropy analysis + special char density2
Multi-turn crescendoSession escalation tracking2
SSRF / command injectionURL + command pattern matching3
Path traversalSensitive path + symlink detection3
Memory poisoningWrite + read path validation4
RAG document injectionPre-ingestion imperative detection4
Secret / PII leakage70+ secret patterns + PII regex5
Canary token leaksSession-specific honeypot tokens5
DNS exfiltrationSubdomain depth / entropy analysis5
Image-based injectionEXIF + alt-text + OCR scanningMulti
MCP tool poisoningTool definition injection scanCross
Behavioral anomalyCross-layer event correlation6
Crypto wallet attacksAddress + amount + function validation7

MCP Server

ZugaShield ships with an MCP server so Claude, GPT, and other AI platforms can call it as a tool:

pip install zugashield[mcp]

Add to your MCP config (claude_desktop_config.json or similar):

{
  "mcpServers": {
    "zugashield": {
      "command": "zugashield-mcp"
    }
  }
}

9 tools available:

ToolDescription
scan_inputCheck user messages for prompt injection
scan_outputCheck LLM responses for data leakage
scan_tool_callValidate tool parameters before execution
scan_tool_definitionsScan tool schemas for hidden payloads
scan_memoryCheck memory writes for poisoning
scan_documentPre-ingestion RAG document scanning
get_threat_reportGet current threat statistics
get_configView active configuration
update_configToggle layers and settings at runtime

FastAPI Integration

pip install zugashield[fastapi]
from fastapi import FastAPI
from zugashield import ZugaShield
from zugashield.integrations.fastapi import create_shield_router

shield = ZugaShield()
app = FastAPI()
app.include_router(create_shield_router(lambda: shield), prefix="/api/shield")

This gives you a live dashboard with these endpoints:

EndpointDescription
GET /api/shield/statusShield health + layer statistics
GET /api/shield/auditRecent security events
GET /api/shield/configActive configuration
GET /api/shield/catalog/statsThreat signature statistics

Human-in-the-Loop

Plug in your own approval flow (Slack, email, custom UI) for high-risk decisions:

from zugashield.integrations.approval import ApprovalProvider
from zugashield import set_approval_provider

class SlackApproval(ApprovalProvider):
    async def request_approval(self, decision, context=None):
        # Post to Slack channel, wait for thumbs-up
        return True  # or False to deny

    async def notify(self, decision, context=None):
        # Send alert for blocked actions
        pass

set_approval_provider(SlackApproval())

Configuration

All settings via environment variables — no config files needed:

VariableDefaultDescription
ZUGASHIELD_ENABLEDtrueMaster on/off toggle
ZUGASHIELD_STRICT_MODEfalseBlock on medium-confidence threats
ZUGASHIELD_PROMPT_ARMOR_ENABLEDtruePrompt injection defense
ZUGASHIELD_TOOL_GUARD_ENABLEDtrueTool call validation
ZUGASHIELD_MEMORY_SENTINEL_ENABLEDtrueMemory write/read scanning
ZUGASHIELD_EXFILTRATION_GUARD_ENABLEDtrueOutput DLP
ZUGASHIELD_WALLET_FORTRESS_ENABLEDtrueCrypto transaction checks
ZUGASHIELD_LLM_JUDGE_ENABLEDfalseLLM deep analysis (requires anthropic)
ZUGASHIELD_SENSITIVE_PATHS.ssh,.env,...Comma-separated sensitive paths

Optional Extras

pip install zugashield[fastapi]     # Dashboard + API endpoints
pip install zugashield[multimodal]  # Image scanning (Pillow)
pip install zugashield[llm-judge]   # LLM deep analysis (Anthropic)
pip install zugashield[mcp]         # MCP server
pip install zugashield[all]         # Everything above
pip install zugashield[dev]         # Development (pytest, ruff)

Contributing

See CONTRIBUTING.md for development setup and guidelines.

Security

Found a vulnerability? See SECURITY.md for responsible disclosure.

License

MIT — see LICENSE for details.

Reviews

No reviews yet

Sign in to write a review