MCPSentinel
Active Zero-Trust Runtime Security Firewall & Interceptor Gateway for AI Agent Tools & MCP Servers.
MCPSentinel provides real-time security gating for Agentic tools and MCP servers across 4 critical lifecycle phases:
- Pre-Registration Intent & Threat Inspection: Static and semantic analysis detecting covert exfiltration, indirect prompt injection, privilege escalation, and schema manipulation.
- Pre-Execution Argument Gating: Sandboxing and runtime inspection blocking unauthorized path traversal, command injection, and sensitive parameter overrides.
- Execution & Latency Profiling: Tamper-proof telemetry profiling execution latency and outputs.
- Post-Execution Behavioral Drift Verification: Intercepts outputs and quarantines tools exhibiting sudden behavioral shifts, capability creep, or mimicry attacks.
⚡ 1-Click Auto-Protect for Claude Desktop, Cursor & Codex
Instead of manually editing JSON configs, MCPSentinel can automatically detect, backup, and wrap all configured MCP servers with one command:
# Automatically scan & protect Claude Desktop, Cursor, and Codex / Claude Code configs
mcpsentinel protect
# Or target a specific application / config file
mcpsentinel protect --claude
mcpsentinel protect --cursor
mcpsentinel protect --codex
mcpsentinel protect --config /path/to/custom_mcp_config.json
# Restore / unwrap servers at any time
mcpsentinel unwrap
🔒 Transparent MCP Proxy (mcpsentinel wrap)
MCPSentinel can transparently wrap any standard MCP server over stdio without any code modifications.
MCP Client Configuration (claude_desktop_config.json, Cursor, etc.)
{
"mcpServers": {
"filesystem": {
"command": "mcpsentinel",
"args": ["wrap", "npx", "@modelcontextprotocol/server-filesystem", "/workspace"]
},
"custom_server": {
"command": "mcpsentinel",
"args": ["wrap", "python3", "my_mcp_server.py"]
}
}
}
When wrapped, MCPSentinel automatically:
- Intercepts
tools/listwith zero startup handshake latency by caching tool definitions without eager evaluation. - Intercepts
tools/callrequests with JIT Intent & Security Analysis upon first call, blocking malicious schemas, sensitive parameter overrides (e.g./etc/shadow), and quarantined tools fail-fast before execution. - Intercepts
tools/callresponses, detecting prompt injections and behavioral drift to suppress malicious payloads before they reach the LLM.
📊 Structured Logging & Telemetry (Loguru & Loki)
MCPSentinel provides dual real-time and persistent telemetry:
- Stdio Safe: Real-time console logs are streamed exclusively to
sys.stderr, ensuring MCP JSON-RPC protocol messages overstdoutare never corrupted. - Persistent Local Logs:
- Formatted text log:
~/.mcpsentinel/logs/mcpsentinel.log(automatic 10MB rotation, 14-day retention). - Structured JSONL log:
~/.mcpsentinel/logs/mcpsentinel.jsonl(machine-readable SIEM format).
- Formatted text log:
- Grafana Loki Streaming: Set
MCPSENTINEL_LOKI_URL="http://localhost:3100"to stream telemetry asynchronously in background daemon threads.
# Stream live logs with the built-in CLI monitor
mcpsentinel logs
# Follow only ERROR / WARNING logs
mcpsentinel logs --level ERROR
# View last 50 lines without following
mcpsentinel logs --no-follow -n 50
# Stream raw structured JSONL SIEM events
mcpsentinel logs --json
# Clear stored logs
mcpsentinel logs --clear
🛠️ Python SDK Usage
You can also protect native Python tools and functions directly using the @firewall.protect decorator:
from mcpsentinel import RuntimeFirewall
firewall = RuntimeFirewall()
@firewall.protect()
def query_database(query: str) -> dict:
"""Executes a database query."""
return {"status": "success", "rows": []}
# Calls are gated through pre-call checks and post-call drift verification
result = query_database(query="SELECT * FROM users")
💻 CLI Usage
MCPSentinel includes a full CLI powered by Typer and Rich.
Installation
# Global installation via pipx / pip
pip install mcpsentinel
# or
pipx install mcpsentinel
# Or for local development:
pip install -e .
Commands Overview
1. Transparent MCP Server Wrap (mcpsentinel wrap)
mcpsentinel wrap npx @modelcontextprotocol/server-filesystem /tmp
2. Auto-Protect MCP Client Configurations (mcpsentinel protect)
mcpsentinel protect --claude
mcpsentinel protect --cursor
mcpsentinel protect --codex
3. Inspect / Analyze Tool Security (mcpsentinel inspect)
# Inspect via JSON string
mcpsentinel inspect --tool-json '{"name": "search_docs", "description": "Search public docs", "parameters": {"query": "string"}}'
# Inspect via JSON file
mcpsentinel inspect --file tool_definition.json
4. Execute / Call Tools Through Firewall (mcpsentinel call)
# Call a safe tool
mcpsentinel call search_docs --tool-json '{"name": "search_docs"}' --arguments '{"query": "firewall"}'
# Malicious arguments will be blocked fail-fast
mcpsentinel call read_file --tool-json '{"name": "read_file"}' --arguments '{"path": "/etc/shadow"}'
5. Manually Approve Blocked Tools (mcpsentinel approve)
mcpsentinel approve fetch_notes --operator alice --reviewer-note "Approved for restricted debug environment"
6. Quarantine Management (mcpsentinel quarantine)
# List all quarantined tools
mcpsentinel quarantine list
# Check status of a specific tool
mcpsentinel quarantine status fetch_notes
# Release a tool from quarantine
mcpsentinel quarantine release fetch_notes --operator admin --reviewer-note "Audit resolved"
7. Audit Trail (mcpsentinel audit)
mcpsentinel audit logs --limit 20
8. Live Log Monitoring (mcpsentinel logs / mcpsentinel monitor)
# Follow formatted live logs
mcpsentinel logs
# Filter by log level
mcpsentinel logs --level WARNING
# Output in JSON format
mcpsentinel logs --json
📁 Project Structure
mcpsentinel/
├── cli.py # Unified CLI entrypoint (Typer & Rich)
├── config_patcher.py # Automatic client config scanner & patcher
├── firewall_cli.py # Standalone firewall CLI interface
├── main.py # Top-level executable entry
├── mcp_firewall_client.py # MCP Firewall client wrapper
├── mcp_proxy.py # Transparent stdio MCP JSON-RPC proxy gateway
├── runtime_firewall.py # Core 4-phase runtime security firewall engine
├── sentinel_logger.py # Dual console/file & Grafana Loki logger
├── pyproject.toml # Package metadata & build configuration
├── README.md # Project documentation
│
├── intent_analyser/ # Phase 1: Static & LLM semantic intent analysis
│ ├── static_analyser.py # AST & regex threat pattern matching
│ ├── semantic_analyser.py # Zero-dependency LLM caller (Ollama/OpenAI/Claude/Gemini/Groq)
│ └── schemas.py # Security intent schemas & data models
│
├── quarantine_engine/ # Quarantine persistence & manual review workflow
│ ├── quarantine_engine/
│ │ ├── core.py # Quarantine manager core logic
│ │ ├── models.py # Quarantine & audit state models
│ │ ├── audit_log.py # Immutable audit logging engine
│ │ ├── version_store.py # Schema & tool version store
│ │ └── analyzer_integration.py# Firewall integration hook
│ └── tests/ # Quarantine unit test suite
│
├── trust_betray/ # Phase 4: Post-execution drift & mimicry detection
│ ├── classifier.py # Threat classification engine
│ ├── drift.py # Statistical & semantic drift analyzer
│ ├── fingerprint.py # Behavioral fingerprinting
│ ├── store.py # Behavioral state storage
│ ├── timeline.py # Event timeline generator
│ └── attacks/ # Attack simulation modules (drift, mimicry, pivot)
│
└── tests/ # Comprehensive pytest test suite
├── test_cli.py
├── test_config_patcher.py
├── test_firewall_cli.py
├── test_intent_analyser.py
├── test_intent_quarantine_integration.py
├── test_mcp_firewall_client.py
├── test_mcp_proxy.py
├── test_runtime_firewall.py
├── test_sentinel_logger.py
└── test_trust_betray.py
🧪 Running Tests
Run the full pytest suite from the mcpsentinel/ directory:
# Using pytest directly
python3 -m pytest
# Or using uv
uv run --with pytest pytest
Metadata
Release files for mcpknight 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mcpknight-0.1.0.tar.gz | 74.8 kB | With provenance | Details for mcpknight-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mcpknight-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for mcpknight-0.1.0-py3-none-any.whl |
Total release size: 147.4 kB
Release files / mcpknight-0.1.0.tar.gz
| Download URL | mcpknight-0.1.0.tar.gz |
|---|---|
| Size | 74.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
932d5c041506343e859cdea37bc3abcacbd03eda0a645f9eef14ab0eddd59ce9
|
|
BLAKE2b-256 checksum How to use checksums |
7004709bac97018c96acd6cfc399d23e0ff1bee0ee8bf19b40882daed8205e1b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 12, 2026.
Transparency logRelease files / mcpknight-0.1.0-py3-none-any.whl
| Download URL | mcpknight-0.1.0-py3-none-any.whl |
|---|---|
| Size | 72.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
637fd518ec49d05a140c564f4cb32e4611d35451a7b0b3a1f18f06a29f82b00f
|
|
BLAKE2b-256 checksum How to use checksums |
e1c036df49892b46a55ebc7ec7a70864e8e3d809a1e28bf69dc8401e5433f8b5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 12, 2026.
Transparency logSecurity for mcpknight 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for mcpknight-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 12, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.