Discover MCPs & agents
Loading MCPs and agents…
Loading MCPs and agents…
Default-deny MCP/JSON-RPC security gateway for agent tool-call authorization, prompt-injection detection, exfiltration controls, and audit telemetry.
Fetched from the repository for this visit.
READ THIS LICENSE BEFORE USING THIS REPOSITORY. Owner-controlled new releases are subject to the proprietary All Rights Reserved LICENSE: copying, modification, and redistribution require written authorization except where law or GitHub's Terms allow. Previously granted MIT rights remain valid for versions covered by that license; see the historical license. Third-party rights remain unaffected.
Inspect and enforce AI-agent MCP/JSON-RPC tool calls at the agent-to-tool boundary before they execute.
Maintainer: Pooja Kiran (@poojakira).
Portfolio: Pooja Kiran Security Engineering Portfolio.
mcp-agent-security-gateway sits between an AI agent (MCP client) and downstream MCP servers and inspects each tools/call request over JSON-RPC before it executes, returning an allow/block decision. It applies prompt-injection, PII/exfiltration, capability/shadow-server, and process/egress-policy checks, and records tamper-evident audit and telemetry. It exists because an agent that can call tools, assume roles, and load artifacts is making privileged decisions on infrastructure, and nothing in the base MCP protocol inspects those calls. Enforcement applies only to traffic routed through a supported integration path. This is an engineering research prototype with tested enforcement paths, not a network firewall, customer deployment, or deployed SOC.
Data-protection scope: PII and exfiltration checks apply to supported, routed tool-call paths. They are signals and scoped policy controls, not complete data-loss prevention.
October 13, 2026 hosted Linux Python 3.12 CI at commit c75c52db passed 782 tests at 81.93% Python statement coverage (5,657 statements; 1,022 missed). See current verified metrics. The 69 named detector signatures are a code-inventory count, not a held-out measure of effectiveness or production traffic prevention.
The October 4, 2026 snapshot (723 passed, 81.91% statement coverage, 55 named signatures) is preserved, with its original commit and CI run, in Historical Verification Evidence. The linked research poster also presents dated evidence rather than verification of the current main commit.
MCP gives agents a standardized way to invoke external tools that can read data, send messages, reach networks, or execute operations. That creates a trust boundary between model-generated requests and systems that can act. The gateway addresses whether a caller can apply explicit validation, authorization, detection, audit, and policy controls before selected tool calls reach a downstream server — covering prompt-injection content in arguments, unexpected server/capability use, sensitive-data leakage, process-execution intent, and disallowed egress destinations.
Adversaries modeled: malicious prompt authors, compromised MCP servers, rogue agents, and insiders with log access. See THREAT_MODEL.md for the full model and residual risks.
In scope: JSON-RPC traffic routed through the gateway (stdio proxy or the HTTP control plane); heuristic detection; tamper-evident audit.
Out of scope / not claimed: It is not an OS firewall, endpoint agent, or complete DLP system. Its egress control is application-layer policy, not packet-level enforcement. Detectors are heuristic (false positives and negatives possible). Enforcement depends on the integration path; only routed traffic can be inspected or blocked.
Agent / MCP client
|
v
Inline stdio proxy OR HTTP control plane (/v1/inspect_call)
|
+--> parse / normalize (JSON-RPC 2.0)
+--> capability + shadow-server checks
+--> content / policy signals (injection, PII, exfiltration, egress)
+--> audit (hash-chained) + WAL + telemetry
|
v
allow / block decision (fail-closed on detector/circuit-breaker error)
|
v
downstream MCP server or integrating application
Enforcement depends on the integration path: the Python wrapper raises ToolBlocked when the control plane returns allowed=false; the stdio proxy rejects malformed/duplicate-key JSON and blocks disallowed batched calls.
tools/call requestsMCP_API_KEYS) with legacy single-key compatibilityX-Forwarded-For accepted only from configured trusted proxy CIDRssrc/mcp_monitor/production/identity_telemetry.py adds a locally computed telemetry surface for external behavioral-validation workflows without exporting raw API credentials or raw source addresses. The gateway supports multiple stable credentials, canonicalizes IPv4/IPv6 source addresses (including IPv4-mapped IPv6), derives exact/network/block inputs, and fingerprints them with HMAC-SHA256(key=tenant_salt, message=UTF-8(value)).hexdigest()[:32]. Forwarded source headers are only trusted when the socket peer belongs to an explicitly configured trusted proxy CIDR; otherwise the socket peer is authoritative. Current event objects set tokens_in = 0 and tokens_out = 0 where token accounting is unavailable. Live transport records use an integer schema version of 1, client identifier mcp-gateway/1.0.0, backfill: false, an events array, and a positional event_fps array. Each event fingerprint is computed locally as HMAC-SHA256 over "evt:" + event_id, truncated to 32 lowercase hexadecimal characters. The internal event ID is not transmitted. Queued envelopes are immutable and retries resend the same stored envelope/fingerprint.
Current full-suite verification reports 782 passed, 81.93% hosted Linux coverage (October 13, 2026 CI run 38462601803). See current metrics; prior evidence is archived.
These follow the same discipline as the rest of the repo: separate detection from enforcement, attach scope to every metric, and label anything synthetic or unverified. Subsection-specific measurements are scoped to those modules; the repository-wide test/coverage snapshot above applies to the Python suite at the cited commit.
src/mcp_monitor/policy/policy_engine.py is a fail-closed, default-deny Python Policy Decision Point: deny-wins evaluation, structured reason codes, and anti-SSRF egress checks. Enforcement is proven, not asserted — tests/test_policy_enforcement.py is 15 passed (verified locally with .venv, Ruff clean), including tests that a denied tool call never reaches the downstream transport (send/receive not called) and that allowed calls do. Rego policies under policy/rego/ exist for OPA parity but are UNVERIFIED here — requires the opa binary. See docs/policy/POLICY_AS_CODE.md.
src/mcp_monitor/siem/lifecycle.py generates a coverage matrix (6 correlation rules + 9 Elastic rules mapped to 7 ATT&CK techniques, with ATLAS cross-references) plus per-rule precision/recall. The precision/recall numbers are computed on synthetic fixtures only: micro-averaged P/R/F1 = 1.000 over 9 fixture sequences — this measures fixture coverage, not real-world efficacy. A local latency microbench over 2000 synthetic events records p50 0.47ms, p95 1.19ms, p99 1.75ms (~1863 events/s single-process) — a local microbench, not a production SLA. Artifacts in docs/detection/; tuning log in docs/detection/TUNING_LOG.md; tests in tests/test_detection_lifecycle.py.
The rust/ crate ports the fail-closed JSON-RPC inspection decision (parse, duplicate-key rejection, batch atomicity, allow/block/indeterminate) to Rust. Verified via a rust:1-slim Docker build: cargo build 0 warnings, cargo test 9 passed / 0 failed. See rust/README.md.
The cpp/ directory ports the same fail-closed inspection core to C++17, with a small self-contained JSON parser that explicitly rejects duplicate keys. Verified via a gcc:13 Docker build: compiled with -Wall -Wextra -Wpedantic (no warnings), make test 11/11 checks passed, and the CMake path reports ctest 100% passed (1/1). Both native cores hold the same parity table as the Python implementation. See cpp/README.md.
git clone https://github.com/poojakira/mcp-agent-security-gateway.git
cd mcp-agent-security-gateway
python -m venv .venv
source .venv/bin/activate # Windows: .\.venv\Scripts\Activate.ps1
python -m pip install --upgrade pip
python -m pip install -e ".[dev,server]"
python -m pytest tests -q
Run a downstream stdio MCP server through the proxy:
Security requirement: Select and review each trusted tool explicitly with repeatable
--allow-tool NAMEflags; CLI startup without an allowlist fails closed. This guards traffic routed through the proxy only. The default-branch stdio proxy is not an OS sandbox and cannot prevent independently privileged clients or browsers from accessing a server directly. The Phase 1–16 offline Docker review stack remains unmerged and production NO-GO.
python -m mcp_monitor.proxy.stdio_proxy --allow-tool read_file -- <server-command> [args...]
Run the local FastAPI control plane (default 127.0.0.1:8000):
python run_realtime.py
Production API (port 8080) requires X-API-Key on inspection/metrics endpoints; one legacy key (MCP_API_KEY) or multiple stable credentials (MCP_API_KEYS) may be configured. /v1/health and /v1/ready are open for orchestration. See RUNBOOK.md.
python -m pytest tests -q --cov=mcp_monitor
ruff check src tests
ruff format --check src tests
bandit -r src -ll
pip-audit
Current full-suite metrics are 782 passing tests and 81.93% statement coverage on hosted Linux CI (October 13, 2026, run 38462601803, commit c75c52db). See current, environment-scoped evidence. The October 4, 2026 historical snapshot remains dated.
GitHub Actions runs Ruff, Pyright, Bandit, pip-audit, CodeQL, Trivy, SBOM generation, Docker build validation, and the Python 3.10/3.11/3.12 test matrix plus a Windows control-plane job. Historical successful runs do not establish that the current head passes every job. The October 9 ordinary Docker failures occurred before application build execution: Docker Hub returned HTTP 429 for the Python base image, and the PR build timed out pulling BuildKit. See Docker build validation for the mitigation and validation boundary.
Heuristic detectors can be evaded; the fixed red-team catalog is a regression suite, not a population-level detection rate. No production latency/throughput/uptime guarantee is made. Enforcement is only as strong as the integration path routing traffic through the gateway.
Engineering research prototype. Functional, tested, and CI-validated, with fail-closed auth and tamper-evident audit. It has not been proven at production scale or in a live SOC deployment.
Proprietary / All Rights Reserved. See LICENSE; previous MIT terms are archived.
Security Systems / 01 — Runtime Policy Enforcement at the AI Agent-to-Tool Boundary
Technical research poster (36 x 48 in). Click the image for the print-resolution PDF. Poster measurements are dated snapshots at their printed commits. Use the repository evidence files for newer results; do not read the poster as a verification of the latest
main. Every metric on it is evidence-backed; historical/projected numbers are labeled and separated from current results.
poojakira repository pass covering source/configuration, CI/release workflows, security-hygiene gates, dependency/SAST controls, and documentation consistency.2801e7b80735e5d7392ad82b9ad867c060f2e013main commits may be newer; consult GitHub Actions for the latest run state. It does not claim zero vulnerabilities or universal production readiness.Keep runtime credentials outside Git. If this repository provides an .env.example or .env.sample, copy it to a local .env or .env.local and fill in values locally; the real environment file must remain untracked.
Do not commit AWS access keys or session credentials, API tokens, service-account JSON, private keys, package-manager credentials, Terraform state, or secret-bearing tfvars. CI/deployment credentials belong in GitHub Actions secrets or the deployment provider's secret manager. AWS account IDs are identifiers; AWS access-key IDs, secret access keys, and session tokens are credentials.
If a real credential is ever exposed, revoke or rotate it at the provider first, then remove it from the working tree and reachable Git history. The Security Hygiene workflow checks the current tree and reachable history for common credential formats without printing matched secret values.
.env file..env and .env.* files are ignored by Git. Only safe templates such as .env.example or .env.sample may be committed, and they must contain placeholder or empty values only..env file (or use your shell/secret manager) and supply your own API key. In GitHub Actions, use repository/environment secrets rather than hard-coding values in workflow YAML.See the bounded recruiting evidence audit for current dated verification, test-scope limitations and unsupported impact claims.
See evidence and limitations. Passing CI at a dated commit or a preview deployment does not certify all source, security controls or operational claims.
Commit c30075da1dc1d3fa7b843bb76be8e842fbfa6ae3 merged the detector-only changes from PR #123. The named runtime prompt-injection signature list now has 69 entries (55 historical plus 14 added). The focused local regression run passed 77 tests. The small development-only text probe is not an independent detector-effectiveness measurement: the committed assertions do not establish the reported benign-positive count for the cited CI snapshot. No numerical detection/false-positive rate from that probe is therefore claimed here; the current 69-signature inventory is a source count, not a measured recall or precision percentage.
A separate five-case synthetic policy-enforcement check denied 5/5 disallowed calls against a deliberately pass-through comparator, not a measured reduction in incidents or unauthorized execution attempts in the field. A comparison of the earlier 12-signature and 55-signature detectors on 15 familiar positive fixtures found 0 percentage-point recall difference, because both detected all 15. The 14 additional signatures have not been independently validated against unseen data. The IAM Guard's five-case synthetic check detected 5/5 deliberately vulnerable cases, but also produced a finding on one nominally benign read policy (AIG007); it is not evidence of general IAM recall or precision.
The Cerberus pilot, persistent identities, baseline, deployment and transport configuration are not involved in these measurements. Do not combine the 69-entry runtime detector with the older 55-entry verified snapshot, and do not combine the original 81.91% code coverage figure with the later 752-test Docker run.
GitHub checked 16h ago - refresh overdue. Recently viewed repositories target hourly refresh.