🛡️ MCP-Shield
Zero-Trust Runtime Security for AI Agents
Protect your AI coding agents from indirect prompt injection, unauthorized tool execution, sensitive data exposure, and malicious MCP servers.
MCP-Shield is a local-first runtime security gateway for the Model Context Protocol (MCP). It acts as a security layer between AI agents and the MCP servers they use, inspecting tool interactions and applying security policies before actions reach downstream tools.
Don't stop AI agents from working. Stop compromised instructions from turning into dangerous actions.
Why MCP-Shield • Architecture • Features • Installation • Integrations • Testing
📸 Screenshots & Demo
Add the actual screenshots to
docs/assets/before publishing this README. The filenames below are the intended project asset paths, not existing screenshots.
Security Dashboard
Live security events, tool activity, session state, and policy decisions.
Agent Arena
Observe AI-agent tool interactions and simulated security scenarios.
Shadow Workspace & Diff Review
Review modifications made inside an isolated shadow workspace.
Security Event Demonstration
🚨 Why MCP-Shield?
AI coding agents are becoming increasingly capable.
They can:
- Read source code and project files.
- Access GitHub repositories and issues.
- Execute terminal commands.
- Interact with APIs and external services.
- Send emails and publish comments.
- Use multiple MCP servers within a single workflow.
However, connecting an AI agent to powerful tools introduces a serious security problem.
An agent may read an untrusted document containing malicious instructions. Those instructions can influence its subsequent actions, potentially causing it to access private information, execute unintended commands, or transmit sensitive data.
This is known as Indirect Prompt Injection.
The Lethal Trifecta
MCP-Shield focuses on the dangerous combination of three capabilities:
UNTRUSTED INPUT
External instructions
|
|
v
PRIVATE DATA
Files / Secrets
|
|
v
EXTERNAL EGRESS / EXECUTION
APIs / Terminal / Git
When these three capabilities are available to the same agent, malicious instructions may lead to unauthorized data access or exfiltration.
MCP-Shield introduces a runtime security layer to monitor and control these interactions.
The problem
| Without runtime protection | With MCP-Shield |
|---|---|
| Untrusted instructions can influence tool usage | Configurable taint tracking |
| Sensitive file access may go unnoticed | Sensitive-path inspection |
| Fake credentials may be transmitted | Honey-token detection |
| Tool definitions may change unexpectedly | SHA-256 tool fingerprinting |
| Dangerous external actions may execute immediately | Human approval workflow |
| Agent modifications may affect the original workspace | Shadow-copy workflow |
These controls protect supported MCP execution paths; they do not automatically protect every native tool an agent may use outside MCP.
🏗️ Architecture
MCP-Shield follows a local-first security architecture.
The AI agent communicates with MCP-Shield through the MCP stdio transport. MCP-Shield launches the original downstream MCP server and inspects supported requests before forwarding them.
High-Level Architecture
flowchart TB
A["AI Coding Agent<br/>Antigravity / VS Code"]
B["MCP-Shield<br/>Stdio Reverse Proxy"]
C["Security Decision Engine"]
D["Taint Tracking"]
E["Honey-Token Detection"]
F["Tool Fingerprinting"]
G["Policy Enforcement"]
H["Approval Workflow"]
I["Shadow Workspace / Sandbox"]
J["Original MCP Server"]
K["Protected Resources<br/>Files / GitHub / APIs"]
L["SQLite Audit Storage"]
M["FastAPI Control Server"]
N["Web Security Dashboard"]
A <-->|"JSON-RPC / stdio"| B
B <--> C
C --> D
C --> E
C --> F
C --> G
C --> H
C --> I
C --> L
C <--> M
M <--> N
B -->|"Authorized requests"| J
J --> K
Request Lifecycle
sequenceDiagram
participant Agent as AI Agent
participant Proxy as MCP-Shield Proxy
participant Engine as Security Engine
participant DB as SQLite
participant Server as MCP Server
participant User as Human User
Agent->>Proxy: tools/call
Proxy->>Engine: Inspect tool and arguments
Engine->>DB: Read session and policy state
Engine->>Engine: Evaluate security rules
alt Request allowed
Engine-->>Proxy: ALLOW
Proxy->>Server: Forward request
Server-->>Proxy: Tool result
Proxy-->>Agent: Return result
else Request blocked
Engine->>DB: Record blocked event
Engine-->>Proxy: BLOCK
Proxy-->>Agent: Security error
else Approval required
Engine->>DB: Store pending approval
Engine-->>Proxy: Freeze request
Proxy->>User: Request approval
User-->>Proxy: Approve or reject
Note over Proxy,Server: Execute only after approval
end
The approval workflow is designed around the original request lifecycle. It must not forward an approval-required operation before authorization.
Main Components
| Component | Responsibility |
|---|---|
| MCP Proxy | Intercepts supported MCP stdio messages |
| Security Engine | Evaluates tool requests and security policies |
| Taint Tracker | Tracks sessions that consume configured untrusted input |
| Deception Engine | Generates and detects honey-tokens |
| Fingerprint Engine | Detects changes in MCP tool definitions |
| Shadow Workspace | Provides an isolated working copy |
| Approval Manager | Controls configured sensitive external actions |
| SQLite Database | Stores sessions, approvals, tokens and events |
| FastAPI Backend | Coordinates inspection and dashboard events |
| Web Dashboard | Displays runtime activity and security decisions |
🔐 Security Features
1. Smart Taint Tracking
Not all input is trustworthy.
MCP-Shield can mark a session as TAINTED after configured untrusted sources are read.
Examples include:
- GitHub issues.
- External documents.
- Web content.
- User-provided external data.
A tainted session is not necessarily compromised. It means the agent has consumed content that may contain adversarial instructions and should be subject to stricter policies.
CLEAN SESSION
|
| Read untrusted content
v
TAINTED SESSION
|
| Apply stricter policies
v
Protected tool execution
2. Shadow Workspace Isolation
MCP-Shield uses a shadow workspace to separate supported agent modifications from the original project workspace.
flowchart TD
A["Original Project"]
B["Create Shadow Copy"]
C["Agent Works in Shadow"]
D["Inspect File Changes"]
E{"User Decision"}
F["Merge Changes"]
G["Discard Shadow"]
A --> B
B --> C
C --> D
D --> E
E -->|"Accept"| F
E -->|"Reject"| G
The user can inspect the generated diff before accepting or discarding changes.
For arbitrary command execution, a separate operating-system or container isolation boundary is required. A copied directory alone is not a complete security sandbox.
3. Honey-Token Deception
MCP-Shield generates unique fake credentials for a session.
These tokens are planted in a decoy environment file within the shadow workspace.
If an agent attempts to transmit a planted token through a configured outbound action, the deception engine can detect the match and block that action.
Supported detection transformations in the implementation include:
- Raw token.
- Reversed token.
- URL encoding.
- Base64 encoding.
Honey-tokens are detection signals, not real credentials. They do not guarantee detection of every possible transformation, encryption method, or exfiltration channel.
4. Exit-Door Protection
Certain actions have consequences outside the local workspace.
Examples:
- Publishing a GitHub comment.
- Sending an email.
- Pushing code.
- Triggering external integrations.
MCP-Shield can require explicit human approval for configured exit-door operations.
Agent requests external action
|
v
Security inspection
|
v
Approval required
|
User review
/ \
/ \
APPROVE REJECT
| |
v v
Execute Block
5. Rug-Pull Detection
MCP servers expose tool definitions describing their names, descriptions and input schemas.
A malicious or compromised server may unexpectedly change a tool definition.
MCP-Shield calculates SHA-256 fingerprints of canonicalized tool definitions and compares subsequent versions with stored baselines.
An unexpected change can generate a security event and block the affected tool listing according to the configured enforcement behavior.
6. Lethal Trifecta Configuration Audit
MCP-Shield includes a configuration auditor that examines MCP server names, commands, arguments and environment-variable names for indicators of:
- Untrusted input.
- Private data access.
- External egress or execution.
It generates a risk classification:
| Risk level | Meaning |
|---|---|
| LOW | Fewer than two categories detected |
| MEDIUM | Two categories detected |
| CRITICAL | All three categories detected |
This is a heuristic configuration audit, not a proof that a configuration is safe or unsafe.
7. Live Security Monitoring
The FastAPI backend and WebSocket event system support live security monitoring.
The dashboard is designed to expose events such as:
TOOL_EVENTTAINT_TRIGGEREDHONEYPOT_SERVEDTRAP_TRIGGEREDRUG_PULL_DETECTEDAPPROVAL_REQUIREDAPPROVAL_RESOLVEDSHADOW_UPDATED
⚙️ Installation
MCP-Shield targets Python 3.11 and newer.
Install from source
Clone the repository:
git clone https://github.com/The-Blue-Pheonix/MCP-Shield.git
cd MCP-Shield
Create a virtual environment:
python -m venv .venv
Activate it:
Windows PowerShell
.venv\Scripts\Activate.ps1
Linux / macOS
source .venv/bin/activate
Install the project and its dashboard dependencies:
python -m pip install --upgrade pip
pip install -e ".[dashboard,agent,dev]"
The extras must be kept aligned with the dependencies and entry points in
pyproject.toml.
PyPI installation
Once the official distribution is published and verified, installation will be:
pip install mcp-shield
The package name and release availability should be verified before announcing this command as a working public installation route.
🚀 Quick Start
Step 1 — Start the MCP-Shield Control Server
From the repository root:
mcp-start --project-dir .
By default, the local control server listens on:
http://127.0.0.1:8000
The dashboard can be opened in the browser automatically.
Step 2 — Check the control server
curl http://127.0.0.1:8000/api/health
Expected response:
{
"status": "ok"
}
Step 3 — Run the proxy
Example using a GitHub MCP server:
mcp-shield proxy \
--server-name github \
--session-id demo-session \
-- npx -y @modelcontextprotocol/server-github
On Windows PowerShell, the same command can be entered on one line:
mcp-shield proxy --server-name github --session-id demo-session -- npx -y @modelcontextprotocol/server-github
Make sure the required environment variables for the downstream server are available in the process environment.
Step 4 — Inspect configuration
MCP-Shield can audit an MCP JSON configuration and generate a wrapped configuration snippet:
mcp-shield init --config path/to/mcp_config.json
Specify a custom output path:
mcp-shield init --config path/to/mcp_config.json --output shielded_config.json
Step 5 — Inspect runtime paths
mcp-shield status
The CLI reports the resolved project directory, data directory, SQLite database path and policy path.
🔌 Integrations
MCP-Shield is designed to sit between existing MCP clients and their downstream MCP servers.
The initial integration targets are Google Antigravity and Visual Studio Code with supported MCP clients.
Google Antigravity
Antigravity uses an mcpServers configuration object for local MCP servers.
A protected server entry can use the MCP-Shield proxy as its launch command:
{
"mcpServers": {
"github-shield": {
"command": "mcp-shield",
"args": [
"proxy",
"--server-name",
"github",
"--session-id",
"antigravity-session",
"--",
"npx",
"-y",
"@modelcontextprotocol/server-github"
]
}
}
}
Add the original server's required environment variables to the entry.
Visual Studio Code
VS Code uses a servers configuration object for MCP servers.
Example:
{
"servers": {
"github-shield": {
"type": "stdio",
"command": "mcp-shield",
"args": [
"proxy",
"--server-name",
"github",
"--session-id",
"vscode-session",
"--",
"npx",
"-y",
"@modelcontextprotocol/server-github"
]
}
}
}
Reload the MCP connection after updating the configuration.
Integration scope: these examples route the configured MCP server through MCP-Shield. They do not intercept native agent tools that bypass MCP. Automatic configuration discovery, safe backups, restoration and end-to-end client verification should be treated as separate integration acceptance criteria.
🧪 Testing
MCP-Shield uses pytest for automated testing.
Install development dependencies:
pip install -e ".[dev]"
Run the test suite:
pytest -v
Run a specific test module:
pytest tests/test_proxy.py -v
The exact test filenames should be checked against the current repository.
Security Test Scenarios
| Scenario | Expected security behavior |
|---|---|
| Normal file listing | Allowed |
| Configured untrusted source read | Taint event |
| Sensitive file access | Policy evaluation |
| Honey-token in outbound payload | Block and record detection |
| Changed MCP tool definition | Rug-pull event |
| Configured exit-door action | Approval workflow |
| Rejected approval | Operation not forwarded |
| Shadow workspace modification | Diff available for review |
| Invalid MCP configuration | Report error without overwriting original |
Benchmarking
The project includes a benchmark suite intended to compare:
- No Shield.
- Basic blocker.
- MCP-Shield.
Metrics of interest:
- Attack prevention rate.
- Legitimate task completion rate.
- False positive rate.
- Approval frequency.
- Proxy latency.
- Runtime stability.
Only measured benchmark results should be presented as actual performance claims. Preview data and target metrics must be labelled separately.
🗂️ Project Structure
The repository is organized around the following major areas:
MCP-Shield/
│
├── src/
│ └── mcp_shield/
│ ├── cli.py
│ ├── proxy.py
│ ├── server.py
│ ├── engine.py
│ ├── auditor.py
│ ├── config.py
│ ├── db.py
│ ├── deception.py
│ ├── shadow.py
│ ├── sandbox.py
│ ├── routes_b.py
│ ├── policy.json
│ └── static/
│
├── agent/
├── backend/
├── benchmark/
├── demo_servers/
├── docker/
├── frontend/
├── proxy/
├── sample_repo/
├── sample_repo_clean/
├── tests/
│
├── docs/
│ └── assets/
│
├── pyproject.toml
├── requirements.txt
├── CHANGELOG.md
└── LICENSE
The exact contents may evolve as the package is consolidated around src/mcp_shield/.
⚠️ Security Model & Limitations
MCP-Shield is a defense-in-depth project. It is not a guarantee against every form of prompt injection or agent compromise.
Important limitations:
- MCP coverage: only MCP connections routed through the proxy are inspected. Native agent tools and other unwrapped execution paths may bypass it.
- Local process security: a stdio proxy does not automatically isolate arbitrary operating-system processes.
- Shadow isolation: a shadow copy protects the original workspace from supported file modifications, but is not equivalent to a hardened container or VM.
- Honey-token detection: detection depends on known token representations and inspected outbound tool arguments.
- Configuration audit: keyword-based classification is heuristic.
- Tool fingerprinting: a definition change is a signal requiring investigation, not proof of malicious behavior.
- Policy correctness: weak or incomplete rules can allow unsafe actions or block legitimate work.
- Control-server availability: enforcement behavior during control-server failures must be tested and configured safely.
Do not expose the local control server to an untrusted network without adding authentication, authorization, and appropriate network protections.
🛣️ Roadmap
- Python package foundation
- MCP stdio proxy foundation
- FastAPI control server
- SQLite event and session storage
- Policy engine foundation
- Tool fingerprinting foundation
- Shadow workspace and deception components
- Configuration auditor
- Complete end-to-end security enforcement validation
- Production-ready Antigravity adapter and recovery workflow
- Production-ready VS Code / Copilot adapter and recovery workflow
- Cross-platform integration testing
- Dashboard and approval lifecycle hardening
- Reproducible benchmark results
- TestPyPI validation
- Official PyPI release
- Remote Streamable HTTP proxy support
- Additional coding-agent integrations
Check the actual test and integration status before changing roadmap items to completed.
🤝 Contributing
Contributions, security feedback, bug reports and feature suggestions are welcome.
Development Setup
git clone https://github.com/The-Blue-Pheonix/MCP-Shield.git
cd MCP-Shield
python -m venv .venv
pip install -e ".[dashboard,agent,dev]"
Run tests:
pytest -v
Contribution Guidelines
- Keep security decisions deterministic and auditable.
- Never log real secrets or credentials.
- Preserve valid MCP protocol behavior.
- Keep protocol messages on stdout and diagnostic logs on stderr.
- Include tests for new security controls.
- Document known limitations.
- Do not claim unmeasured security or benchmark results.
For significant changes, open an issue before submitting a pull request.
📚 References
- Model Context Protocol
- MCP Specification — stdio transport
- MCP Specification — Tools
- Google Antigravity
- Visual Studio Code MCP documentation
- Python Packaging Guide
- PyPI
📄 License
MCP-Shield is released under the MIT License.
Built by Team BLUE_PHEONIX
Work Freely. Guard the Exit Doors.
⭐ If you find MCP-Shield useful, consider giving the repository a star.
Metadata
Release files for mcp-shield-proxy 0.2.3
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 |
|---|---|---|---|---|
| mcp_shield_proxy-0.2.3.tar.gz | 151.0 kB | Without provenance | Details for mcp_shield_proxy-0.2.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mcp_shield_proxy-0.2.3-py3-none-any.whl | Python 3 | none | any | Details for mcp_shield_proxy-0.2.3-py3-none-any.whl |
Total release size: 304.8 kB
Release files / mcp_shield_proxy-0.2.3.tar.gz
| Download URL | mcp_shield_proxy-0.2.3.tar.gz |
|---|---|
| Size | 151.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
634851334e899e15dfcbdbd2f755cd8d09c385f688a280d307661e86662750b0
|
|
BLAKE2b-256 checksum How to use checksums |
745cfa890fe33b96b6a4291dd9039cc4c742ec52bc5a618663b904588b9862fe
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.2
|
Release files / mcp_shield_proxy-0.2.3-py3-none-any.whl
| Download URL | mcp_shield_proxy-0.2.3-py3-none-any.whl |
|---|---|
| Size | 153.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ffae9923c29e9e714f46dbd42a601aad252082125b2b514a13ec883e21d18132
|
|
BLAKE2b-256 checksum How to use checksums |
bdadc71a51c00c30c7bc014139472de68d0f2b6f6e972f7260152c0babf1a540
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.2
|
Security for mcp-shield-proxy 0.2.3
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A 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.