Catalog PyPI
PACKAGE EXPLORERView in registry

agentsec-gateway

PyPI

Security gateway for MCP (Model Context Protocol) server connections

Versions collected1
Direct dependencies6From release 0.1.1
Last observed20 Oct, 23:19 UTC

README

Version 0.1.1 documentation

MCP Security Gateway

Security gateway that proxies MCP (Model Context Protocol) server connections with real-time scanning, audit logging, and policy enforcement.

Part of the AgentSec suite -- open-source security primitives for AI agents.

Install

pip install agentsec-gateway

Premium: Get IP reputation database, advanced data flow analytics, and multi-server policy orchestration at zazmatt.gumroad.com/l/hjpwk

Quick Start

# Patch .mcp.json to route all MCP servers through the gateway
mcp-gateway install

# That's it. All MCP traffic is now scanned and logged.

How It Works

Claude Code                MCP Gateway              MCP Server
    |                          |                         |
    |--- JSON-RPC request ---->|                         |
    |                          |-- scan for secrets ---->|
    |                          |-- scan for injections ->|
    |                          |-- log to audit trail -->|
    |                          |--- forward request ---->|
    |                          |                         |
    |                          |<--- response -----------|
    |                          |-- scan for leakage ---->|
    |                          |-- log to audit trail -->|
    |<--- forward response ----|                         |

The gateway wraps each MCP server command in .mcp.json so all stdio traffic passes through a transparent proxy. It scans for:

  • Secret leakage -- API keys, tokens, passwords, PII in tool parameters
  • Prompt injection -- attempts to override system instructions via tool arguments
  • Path traversal -- ../etc/passwd, ~/.ssh/ style attacks
  • Command injection -- shell metacharacters, subshell execution
  • Data exfiltration -- secrets in server responses flowing back to Claude

CLI Reference

CommandDescription
mcp-gateway installPatch .mcp.json to route through gateway
mcp-gateway uninstallRestore original .mcp.json
mcp-gateway proxy --server NAME -- CMDRun as proxy (internal, called by patched config)
mcp-gateway scanList configured servers and their status
mcp-gateway audit [-n 20] [--server NAME]View audit log
mcp-gateway reportGenerate security report (reputation + data flow)
mcp-gateway statusShow install status and server list

Configuration

Create .mcp-gateway/policy.yaml to define per-server policies:

servers:
  filesystem:
    allowed_tools: ["read_*", "list_*", "search_*"]
    blocked_tools: ["write_*", "delete_*"]
    max_calls_per_minute: 30
    data_classification: internal

  gmail:
    allowed_tools: ["gmail_search*", "gmail_read*"]
    blocked_tools: ["gmail_create_draft", "gmail_send*"]
    max_calls_per_minute: 10
    data_classification: confidential

Policy Fields

FieldTypeDefaultDescription
allowed_toolslist[str][] (all)Glob patterns for allowed tools
blocked_toolslist[str][]Glob patterns for blocked tools
max_calls_per_minuteint60Rate limit per server
data_classificationstrinternalpublic, internal, confidential

Security Features

  • Secret scanning -- 23 pattern rules covering API keys, tokens, passwords, PII (SSN, credit cards)
  • High-entropy detection -- Shannon entropy analysis catches unknown secret formats
  • Prompt injection detection -- catches "ignore previous instructions", developer mode, system tag injection
  • Path traversal detection -- blocks ../, /etc/passwd, ~/.ssh/ access attempts
  • Command injection detection -- catches shell metacharacters, subshells, pipe-to-bash
  • Tamper-proof audit log -- SHA-256 hash chain on every log entry
  • Server reputation tracking -- trust scores degrade on violations
  • Data flow monitoring -- per-server byte counting with anomaly detection

Architecture

Built on agentsec-core for scanning, policy, and audit primitives. Uses synchronous threading for the stdio proxy (no asyncio complexity).

Free vs Premium

FeatureFree (OSS)Premium
Transparent MCP proxyYesYes
Secret scanning (23 patterns)YesYes
Prompt injection detectionYesYes
Tamper-proof audit logYesYes
IP reputation database--Yes
Data flow analytics dashboard--Yes
Multi-server policy orchestration--Yes
Rate limiting with burst control--Yes
Priority support--Yes

Get Premium -- $10

Development

pip install -e ".[dev]"
pytest
ruff check .

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
0.1.16 Apr 20266

Package advisories

0
No matching advisories collected

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

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 23:19 UTC

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

Record identity

package:5c95e39e42cb70077e56d35749e36acfb3f187a578c3bd882ce87f268b8e39a5