mcp_Shield
MCP Shield π‘οΈ
A local policy-enforcement runtime for MCP tool calls.
MCP Shield evaluates tool names and arguments against configurable security policies. It returns an ALLOW or BLOCK decision and records the result in an audit log.
MCP Shield is an early-stage project. The current release does not automatically discover MCP servers or transparently intercept tool calls from Codex, Claude Code, Cursor, Proxyman, or other MCP clients and servers.
TL;DR
MCP Shield provides a command-line interface and local REST API for evaluating MCP tool calls against YAML security policies.
It can:
Allow or block tools using configurable allowlists
Recursively inspect tool arguments for dangerous patterns
Detect common SSRF targets, sensitive paths, and unsafe URL schemes
Record allowed and blocked decisions in an audit log
Display audit statistics
Calculate basic risk scores from tool capabilities
Tool calls must currently be submitted through the mcpshield CLI or the /inspect API. The application making the actual MCP call is responsible for enforcing the returned decision.
Related MCP server: protect-mcp
Why MCP Tool Calls Need Security Controls
The Model Context Protocol (MCP) allows AI applications to connect to external tools and data sources through MCP servers.
Depending on the server, those tools may be able to:
Read or write files
Call internal or external APIs
Query databases
Access environment variables
Control browsers
Execute commands
These capabilities are useful, but a malicious, compromised, or overly permissive server can expose credentials, sensitive files, internal services, or the host system.
MCP Shield provides a policy-decision layer that callers can use before allowing a tool call to continue.
How It Works
A caller submits the server name, policy, tool name, and arguments.
MCP Shield checks whether the tool is permitted by the selected policy.
It recursively scans the arguments for blocked hosts, paths, schemes, and patterns.
It returns an
ALLOWorBLOCKdecision with a reason.It records the decision in the audit log.
Tool call
β
βΌ
MCP Shield policy evaluation
β
βββ BLOCK β record decision and reject the call
β
βββ ALLOW β record decision and permit the caller to continueMCP Shield currently evaluates requests; it is not yet a transparent MCP proxy.
Features
YAML-based policies
Per-policy tool allowlists
Recursive argument inspection
SSRF and sensitive-path pattern detection
CLI inspection commands
REST API
SQLite audit logging
Audit statistics
Basic server risk scoring
Docker sandbox management endpoints
Experimental Firecracker backend for Linux/KVM environments
Requirements
Python 3.12 or newer
macOS, Linux, or Windows for the core API and CLI
Docker only when using the Docker sandbox backend
Linux with KVM only when using the experimental Firecracker backend
Installation
Standard installation
Create and activate a virtual environment:
python3.12 -m venv ~/mcpshield-env
source ~/mcpshield-env/bin/activateInstall MCP Shield:
python -m pip install --upgrade pip
python -m pip install mcpshield-runtimeVerify the installation:
python --version
mcpshield --helpmacOS installation
Some macOS installations still provide Python 3.9 through Xcode. Check your version:
python3 --versionIf it is older than Python 3.12, install Python 3.12 with Homebrew:
brew install python@3.12Create the environment using Homebrewβs interpreter:
$(brew --prefix python@3.12)/bin/python3.12 -m venv ~/mcpshield-env
source ~/mcpshield-env/bin/activate
python -m pip install --upgrade pip
python -m pip install mcpshield-runtimeTo reactivate the environment later:
source ~/mcpshield-env/bin/activateTo leave it:
deactivateQuick Start
MCP Shield currently uses two terminal windows:
Terminal 1 runs the local API.
Terminal 2 runs the CLI commands.
1. Get the policies
Release 0.1.2 must be started from the cloned repository so the runtime can locate the policies/ directory:
cd ~
git clone https://github.com/srisowmya2000/mcp-shield.git
cd ~/mcp-shieldIf the repository already exists:
cd ~/mcp-shield
git pull origin main2. Terminal 1: Start the API
cd ~/mcp-shield
source ~/mcpshield-env/bin/activate
export NO_PROXY=localhost,127.0.0.1
export no_proxy=localhost,127.0.0.1
uvicorn runtime.api.main:app \
--host 127.0.0.1 \
--port 8000Keep this terminal open. The API will be available at:
http://127.0.0.1:8000Useful pages:
Health:
http://127.0.0.1:8000/healthAPI documentation:
http://127.0.0.1:8000/docsDashboard:
http://127.0.0.1:8000/dashboard
3. Terminal 2: Run CLI commands
source ~/mcpshield-env/bin/activate
export NO_PROXY=localhost,127.0.0.1
export no_proxy=localhost,127.0.0.1Check API health:
curl --noproxy "*" http://127.0.0.1:8000/healthExpected response:
{"status":"ok","service":"mcp-shield","version":"0.1.0"}Inspect a tool that should be blocked:
mcpshield inspect read_secretsInspect an allowed tool:
mcpshield inspect safe_toolView audit statistics and recent decisions:
mcpshield stats
mcpshield auditExpected results:
read_secrets β BLOCKED
safe_tool β ALLOWEDCLI Usage
Inspect a tool call
mcpshield inspect TOOL_NAMEExample:
mcpshield inspect read_secretsProvide tool arguments as JSON:
mcpshield inspect ssrf_fetch \
--args '{"url":"http://169.254.169.254/latest/meta-data/"}'Select a policy and server label:
mcpshield inspect safe_tool \
--policy default \
--server demo-server \
--args '{"name":"Sri"}'Score tool risk
mcpshield risk "read_secrets,ssrf_fetch,safe_tool"View audit records
mcpshield auditView audit statistics
mcpshield statsREST API
Health check
curl --noproxy "*" http://127.0.0.1:8000/healthInspect a tool call
curl --noproxy "*" \
-X POST http://127.0.0.1:8000/inspect \
-H "Content-Type: application/json" \
-d '{
"server_name": "demo",
"policy": "default",
"tool_call": {
"tool_name": "read_secrets",
"arguments": {}
}
}'Example blocked response:
{
"server": "demo",
"tool": "read_secrets",
"policy": "default",
"decision": "BLOCK",
"reason": "Tool 'read_secrets' is not in the allowed_tools list",
"blocked": true
}Audit endpoints
curl --noproxy "*" http://127.0.0.1:8000/audit
curl --noproxy "*" http://127.0.0.1:8000/audit/statsRisk scoring
curl --noproxy "*" \
-X POST http://127.0.0.1:8000/risk/score \
-H "Content-Type: application/json" \
-d '{"tool_names":["read_secrets","ssrf_fetch","safe_tool"]}'Policies
Policies are stored as YAML files inside policies/.
Example:
allowed_tools:
- safe_tool
- list_files
- get_time
block_network: true
block_env_access: true
blocked_arg_patterns:
- "169.254.169.254"
- "169.254.170.2"
- "localhost"
- "127.0.0.1"
- "/etc/passwd"
- "/etc/shadow"
- "file://"
- "gopher://"
max_memory_mb: 256
execution_timeout_seconds: 30The repository includes:
default.yamlβ general allowlist and argument checksstrict.yamlβ more restrictive policy
Select a policy with:
mcpshield inspect safe_tool --policy strictPolicy matching is a security control, not a complete guarantee of safety. Use operating-system isolation, least privilege, network restrictions, and careful review of MCP servers.
Troubleshooting
No matching distribution found
Example:
ERROR: Could not find a version that satisfies the requirement mcpshield-runtime
ERROR: No matching distribution found for mcpshield-runtimeCheck your Python version:
python3 --versionMCP Shield requires Python 3.12 or newer.
On macOS:
brew install python@3.12
$(brew --prefix python@3.12)/bin/python3.12 \
-m venv ~/mcpshield-env
source ~/mcpshield-env/bin/activate
python -m pip install mcpshield-runtimepip: command not found
Use pip through the active Python interpreter:
python -m pip install mcpshield-runtimeDo not run:
pip3 install --upgrade pip3The package is named pip, not pip3. The correct command is:
python -m pip install --upgrade pipCannot connect to mcp-shield API
The CLI requires the local API server.
Start it in another terminal:
cd ~/mcp-shield
source ~/mcpshield-env/bin/activate
uvicorn runtime.api.main:app \
--host 127.0.0.1 \
--port 8000Then verify:
curl --noproxy "*" http://127.0.0.1:8000/healthRemoteProtocolError: Server disconnected without sending a response
A system proxy or an application such as Proxyman may be intercepting localhost traffic.
Set localhost bypass variables in both terminals:
export NO_PROXY=localhost,127.0.0.1
export no_proxy=localhost,127.0.0.1Also add localhost and 127.0.0.1 to the proxy applicationβs bypass or ignore list.
/inspect returns 404 Not Found
In release 0.1.2, policies are resolved relative to the current working directory.
Start Uvicorn from the cloned repository:
cd ~/mcp-shield
uvicorn runtime.api.main:app \
--host 127.0.0.1 \
--port 8000Confirm that the policy files exist:
ls -la ~/mcp-shield/policiesThis packaging limitation is expected to be corrected in a later release.
KeyError: 'blocked'
This usually means the /inspect endpoint returned an error response instead of a policy decision.
Check the API terminal for a 404 or 500 response.
Confirm that:
The API is running
Uvicorn was started from
~/mcp-shieldpolicies/default.yamlexistsPort
8000is availableLocalhost proxy bypass variables are configured
Missing argument 'tool'
This command is incomplete:
mcpshield inspectProvide a tool name:
mcpshield inspect read_secretsRepository already exists
If cloning returns:
fatal: destination path 'mcp-shield' already exists and is not an empty directoryUse the existing repository:
cd ~/mcp-shield
git pull origin mainCurrent Limitations
The current release does not:
Automatically discover MCP client configurations
Automatically discover or scan configured MCP servers
Transparently intercept MCP protocol traffic
Automatically integrate with Codex, Claude Code, Cursor, or Proxyman MCP
Automatically enforce decisions for an external MCP client
Replace operating-system sandboxing or least-privilege controls
An external caller or future proxy integration must submit the tool call to MCP Shield and honor the returned decision.
Security Model
MCP Shield is intended as a defense-in-depth policy layer. It should not be treated as a complete sandbox or a replacement for:
Reviewing third-party MCP server code
Restricting filesystem permissions
Limiting environment variables and secrets
Applying outbound network controls
Running untrusted code in isolated environments
Monitoring the host and MCP server processes
See docs/threat-model.md for additional details.
Development
Clone the repository and install it in editable mode:
git clone https://github.com/srisowmya2000/mcp-shield.git
cd mcp-shield
python3.12 -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
python -m pip install -e .Run the tests:
python -m pip install pytest
pytest tests/ -vStart the development API:
uvicorn runtime.api.main:app --reloadRoadmap
Package built-in policies correctly for installation from any directory
Add clearer CLI handling for API error responses
Add
mcpshield serveandmcpshield doctorcommandsAdd structured policy validation
Add per-tool argument-schema validation
Add prompt-injection detection
Add webhook alerts for blocked calls
Explore an optional MCP proxy and enforcement integration
Automatic MCP client/server discovery belongs to a separate scanner project and is not part of the current MCP Shield runtime.
Responsible Use
Use MCP Shield only with systems, MCP servers, accounts, and environments you own or are authorized to test.
Review policy decisions and server behavior before relying on the project in a sensitive environment.
License
MCP Shield is released under the MIT License.
Author
Sri Sowmya Nemani β security researcher and engineer working in MCP security, application security, detection engineering, and responsible vulnerability disclosure.
Contributions, bug reports, and documentation improvements are welcome.
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseBqualityCmaintenanceSecurity gateway that wraps any MCP server with per-tool policies, approval gates, and optional Ed25519-signed decision receipts. Shadow mode logs every tool call without blocking; enforce mode applies block, rate-limit, and minimum-tier rules. Receipts are independently verifiable offline with no accounts needed.53789MIT
- Alicense-qualityBmaintenanceSecurity gateway for MCP servers. Wraps any MCP server with per-tool policies (Cedar + JSON), Ed25519-signed decision receipts, human approval gates, and trust tiers. Shadow mode by default β logs everything, blocks nothing.3789MIT
- Alicense-qualityFmaintenanceSecurity middleware for MCP servers. Trust-based access control, rate limiting, and audit logging. Zero dependencies.16MIT
- AlicenseAqualityAmaintenanceSecurity scanning for MCP servers from the inside out. Provides runtime inspection, AST-based static analysis, config audit, dependency analysis, and OWASP MCP Top 10 compliance in a single MCP server.55215MIT
Related MCP Connectors
Security scanner for MCP servers. Detect vulnerabilities, prompt injection, and tool poisoning.
Scans MCP servers for tool poisoning, prompt injection and supply chain risks.
An MCP server for Arcjet - the runtime security platform that ships with your AI code.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/srisowmya2000/mcp-shield'
If you have feedback or need assistance with the MCP directory API, please join our Discord server