Observability & Security2026-11-11 · 10 min read

Zero-Secret mcp.json Hardening: Eliminating Plaintext API Key Leaks in AI IDEs

How developers accidentally leak sk-ant, ghp_, and production PostgreSQL URIs inside .cursor/mcp.json—and how to enforce secret-free manifests.

Executive Architecture Summary (TL;DR)

Workspace-level .cursor/mcp.json and .vscode/mcp.json files are frequently committed to Git repositories with hardcoded env credentials. Production teams must replace literal secrets with environment variable interpolation, OS keyring wrappers, and pre-commit schema linting.

Thousands of public repositories accidentally expose live Stripe, GitHub, and database credentials inside committed .cursor/mcp.json manifests. Even when repositories are private, feeding raw credentials into workspace files allows prompt-injected filesystem tools to exfiltrate keys.

1. Enforcing Environment Interpolation & Wrapper Scripts

Instead of embedding sk-live-... inside JSON env blocks, reference host-injected variables (${STRIPE_RESTRICTED_KEY}) or invoke a keychain wrapper such as 1password-cli or HashiCorp Vault leases. Validate every config before committing using the SyndiPath mcp.json Security Auditor.

2. Isolating Prompt Injection Blast Radius

Combine secret-free manifests with read-only database roles and strict domain egress rules, following threat models analyzed in NeuroBulletin's AI safety and cognitive security digests.

Production Benchmark & Trade-off Matrix

Engineering DimensionNaive SetupHardened Production PatternImpact
Secret StoragePlaintext env in .cursor/mcp.jsonOS Keyring / ${ENV_VAR} interpolationEliminates Git leaks
Package Pinningnpx -y unpinned@latestExact semver + SHA-512 lock verificationBlocks supply-chain hijack
Database PrivilegeSuperuser postgres DSNRead-only role + 5s statement_timeoutZero destructive SQL risk

Frequently Asked Technical Questions

Can an LLM read the env block of its own MCP server?

Not via the MCP protocol itself, unless a filesystem MCP tool is simultaneously granted read access to ~/.cursor/mcp.json or the project root without secret-file denylists.

Why is npx @latest risky in MCP configs?

Auto-installing @latest executes arbitrary upstream postinstall scripts on every IDE restart; pinning exact versions prevents sudden typosquatting or compromised minor releases.

Verified External AI Benchmarks & Protocol Standards
Review adversarial prompt-injection security studies on NeuroBulletin