Catalog PyPI
PACKAGE EXPLORERView in registry

agentic-shield

PyPI

Security scanner and runtime firewall for AI agents and MCP servers

ai-agentsfirewallguardrailsllmmcpscannersecuritytool-poisoning
Versions collected1
Direct dependencies10From release 1.0.0b1
Last observed20 Oct, 22:21 UTC

README

Version 1.0.0b1 documentation

AgentShield

Security scanner and runtime firewall for AI agents and MCP servers.

License: MIT Python 3.10+ CI

AgentShield protects your AI coding tools (Claude Code, Cursor, Windsurf, VS Code, Cline, Continue) from malicious MCP servers, tool poisoning, supply chain attacks, and configuration vulnerabilities.

The Problem

MCP servers are the plugins of AI coding tools. Developers install them from npm, give them access to their codebase, API keys, and databases — and nobody checks if they're safe.

  • A plugin's tool description can contain hidden instructions that trick the AI into exfiltrating your data
  • A typosquatted package like mcp-sevrer-semgrep silently installs malware
  • Hardcoded API keys in config files get committed to git
  • A trusted plugin gets silently updated with a malicious payload

AgentShield catches all of this.

Quick Start

pip install agentshield

Scan your MCP config:

# Auto-detect and scan .mcp.json in current directory
agentshield scan

# Scan a specific config file
agentshield scan mcp-config -f .mcp.json

# Scan all AI tool configs in a project
agentshield scan project --dir .

Output:

+-------------------------------- AgentShield --------------------------------+
| Scan Results                                                                |
| Target: .mcp.json                                                           |
| Servers: 4 scanned                                                          |
| Findings: 3 high, 1 medium                                                  |
+-----------------------------------------------------------------------------+

! CFG-NPX-server  Unverified npx install: server
  Uses 'npx -y' which auto-installs packages without verification.
  Fix: Pin the package version explicitly.

! CFG-SECRET-api-KEY  Hardcoded secret in config: API_KEY
  Has env var 'API_KEY' with a hardcoded value.
  Fix: Use environment variable references (${VAR}).

Features

Scanner (14 Security Checks)

CheckWhat it DetectsOWASP Ref
Tool PoisoningHidden instructions, invisible unicode, exfiltration URLs, prompt injectionASI04
Config Auditnpx -y, hardcoded secrets, missing binaries, no version pinningASI04
Auth GapsDestructive tools without auth, unauthenticated HTTP endpointsASI03
TransportPlaintext HTTP, secrets in CLI args—
Tool ExposureAdmin/debug tools, overly broad permissions (shell, file access)ASI07
Rug PullSilent tool definition changes (baseline tracking)ASI04
Code ExecutionTools enabling arbitrary code executionASI05
Data LeakagePII fields in schemas, bulk data exposureASI08
Permission ScopeDangerous tool combinations (read_file + exec = RCE)ASI03+07
Cross-OriginCross-server escalation, external service interactionASI01+09
Schema ValidationMissing schemas, injection-prone fields, unbounded stringsASI04
Resource ExposureSensitive URIs (database://, file://), internal pathsASI08
Tool ShadowingName impersonation via Levenshtein distance, leet-speakASI04
npm VerifyTyposquat detection, npm 404 check, deprecated packagesASI04

Runtime Proxy (Firewall for AI Tool Calls)

AgentShield can sit between your AI client and MCP servers, intercepting every tool call:

# Generate a protected config
agentshield shield --config .mcp.json

# Wraps every server with the proxy:
#   "command": "agentshield"
#   "args": ["proxy", "--server", "name", "--config", ".mcp.json"]

Define guardrails in .agentshield.yml:

guardrails:
  default_action: allow
  rules:
    - name: block-destructive
      action: deny
      tools: ["delete_*", "rm_*", "drop_*"]
      message: "Destructive operations blocked"

    - name: audit-file-writes
      action: audit
      tools: ["write_*", "create_*", "edit_*"]

    - name: block-ssrf
      action: deny
      args_pattern: "169\\.254\\.169\\.254"
      message: "SSRF attempt blocked"

    - name: rate-limit
      action: rate_limit
      tools: ["*"]
      rate: "100/minute"

View the audit log:

agentshield audit

Policy Engine

# .agentshield.yml
version: 1
profile: standard  # strict | standard | minimal

checks:
  disabled:
    - transport-security

severity_overrides:
  "CFG-BINARY-*": low

ignore:
  - check_id: config-audit
    server: local-dev-server

custom_rules:
  - name: no-localhost
    pattern: "localhost"
    target: args
    severity: high
    message: "No localhost in production configs"

fail_on: medium

More Commands

# Auto-fix security issues
agentshield fix -f .mcp.json
agentshield fix -f .mcp.json --no-dry-run  # Apply fixes

# Compare scan results over time
agentshield scan mcp-config -f .mcp.json --format json -o baseline.json
# ... make changes ...
agentshield scan mcp-config -f .mcp.json --format json -o current.json
agentshield diff baseline.json current.json

# Watch for config changes in real-time
agentshield watch -f .mcp.json

# Machine-wide inventory of all MCP servers
agentshield inventory

# Convert configs between AI tools
agentshield convert -f .mcp.json --from claude --to cursor

# List compliance profiles
agentshield profiles

# Generate a secure config template
agentshield init --format claude

Output Formats

FormatFlagUse Case
Text--format textTerminal (default)
JSON--format jsonProgrammatic consumption
SARIF--format sarifGitHub Security tab
HTML--format htmlShareable reports
Markdown--format markdownPR comments, docs

CI/CD Integration

GitHub Action

- uses: ewibrahim/agentshield@v1
  with:
    file: .mcp.json
    fail-on: high
    sarif-output: agentshield.sarif

- uses: github/codeql-action/upload-sarif@v3
  with:
    sarif_file: agentshield.sarif

Pre-commit Hook

# .pre-commit-config.yaml
repos:
  - repo: https://github.com/ewibrahim/agentshield
    rev: v1.0.0
    hooks:
      - id: agentshield

CI Pipeline

pip install agentshield
agentshield scan mcp-config -f .mcp.json --ci --fail-on high

Supported AI Tools

ToolConfig PathAuto-detected
Claude Code.mcp.jsonYes
Cursor.cursor/mcp.jsonYes
Windsurf.windsurf/mcp.jsonYes
VS Code.vscode/mcp.jsonYes
Cline.cline/mcp_settings.jsonYes
Continue.continue/config.jsonYes

Plugin System

Create custom checks and distribute them as pip packages:

# my_plugin/checks.py
from agentshield.checks.base import BaseCheck, CheckContext
from agentshield.core.models import Finding

class MyCustomCheck(BaseCheck):
    id = "my-custom-check"
    name = "My Custom Check"
    requires_connection = True

    async def run(self, context: CheckContext) -> list[Finding]:
        # Your check logic here
        return []
# pyproject.toml
[project.entry-points."agentshield.checks"]
my_check = "my_plugin.checks:MyCustomCheck"

Testing

pip install -e ".[dev]"
pytest tests/ -v

Full test suite covering all 14 security checks, policy engine, guardrails, proxy, converter, and diff engine.

Architecture

agentshield/
  cli.py               # Typer CLI (13 commands)
  core/
    scanner.py          # Orchestrator
    models.py           # Pydantic data models
    mcp_client.py       # MCP connection (read-only, never calls tools)
    guardrails.py       # Runtime rule engine
    proxy.py            # MCP stdio proxy
    policy.py           # .agentshield.yml loading
    scoring.py          # Risk scoring (0-100)
    report.py           # Text/JSON/SARIF formatters
    ...
  checks/
    base.py             # BaseCheck ABC
    mcp/                # 14 security checks
  db/
    known_tools.json    # Known MCP tool definitions
    known_mcp_packages.json  # Known npm packages

Safety constraint: AgentShield never calls call_tool() on MCP servers. It only reads metadata via list_tools(), list_resources(), and list_prompts().

Contributing

Contributions welcome! Please open an issue first to discuss what you'd like to change.

License

MIT

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Versions 1

Collected releases
VersionPublishedDirect dependenciesOpen version
1.0.0b112 Mar 202610

Package advisories

0
No matching advisories collected

This describes our collected data; it is not a security assessment.

Repository

PENDING
ewibrahim/agentshield

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 22:21 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package:d2e673226b1737948cfc44564979326dae88750cd24de6253f5d2da4f261c287