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

> **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.

- **Canonical URL:** https://syndipath.com/en/blog/zero-secret-mcp-json-hardening-preventing-api-key-leaks
- **Category:** Observability & Security | **Reading Time:** 10 min

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 &amp; Wrapper ScriptsInstead 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 RadiusCombine 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 Matrix

| Metric | Baseline | Hardened | Verdict |
|---|---|---|---|
| Secret Storage | Plaintext env in .cursor/mcp.json | OS Keyring / ${ENV_VAR} interpolation | Eliminates Git leaks |
| Package Pinning | npx -y unpinned@latest | Exact semver + SHA-512 lock verification | Blocks supply-chain hijack |
| Database Privilege | Superuser postgres DSN | Read-only role + 5s statement_timeout | Zero destructive SQL risk |

## FAQ

### 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.

- External Research Reference: [Review adversarial prompt-injection security studies on NeuroBulletin](https://neurobulletin.com/en)
