Security Architecture

Codebase access, strictly bounded.

Never give an AI model unfettered machine access. CodeMCP was designed from the ground up as a defensive boundary for developer workstations.

Path Traversal & Jailbreak Confinement

Every path requested by an AI model is resolved against the absolute canonical root using `fs.realpathSync`. Traversal attempts (such as `../../etc/passwd` or null-byte injections) are intercepted before touching the filesystem.

Zero Secret Ingestion (.mcpignore)

CodeMCP respects `.mcpignore` files similarly to `.gitignore`. Environment files (`.env*`), private keys (`id_rsa`), AWS credentials, and database dumps are completely invisible to AI model inspection tools.

Ephemeral Vault Credentials

Sessions generate high-entropy randomized passwords saved to a local encrypted vault. Remote AI endpoints verify tokens on every HTTP SSE handshake. Sessions terminate instantly when you exit (`q`).

Shell Command Restriction

When terminal execution is enabled, commands run in a constrained subshell with timeouts and environment variable sanitization. Destructive system calls (like recursive deletes outside root) are denied by policy.

Human Approval Diff Previews

By default, CodeMCP pauses and renders colorized unified diffs in your terminal whenever an AI initiates file edits or creation. You review, approve, or reject changes with a single keystroke.

Local-First & Zero Telemetry

Your source code never routes through third-party proxy servers or analytics engines. CodeMCP runs directly on your machine. AI models only see the specific files they query via your direct API setup.

Recommended Configuration

Standard `.mcpignore` Shield

Place an `.mcpignore` file in your project root to permanently cloak private files. CodeMCP drops matching files from directory listings, search indexes, and read APIs.

.mcpignoreProtected Patterns
# Environment and secrets
.env
.env.*
*.pem
*.key
id_rsa*

# Cloud and API credentials
.aws/
.gcp/
credentials.json
token.json

# Sensitive databases
*.sqlite
*.db
dumps/