API keys out of Cursor’s mcp.json
Cursor’s own docs say it: use environment variables for secrets, never hardcode them. Here’s how, and how to need no key at all.
The problem
Keys in the project, one commit away
The solution
MoltenRock Connect
Keys that are never in a file
The short answer
Cursor reads MCP servers from ~/.cursor/mcp.json (all projects) or .cursor/mcp.json (one project). It resolves ${env:NAME} in command, args, env, url and headers, and STDIO servers can load an envFile, so the file can name a variable instead of holding the key. For business platforms, add MoltenRock Connect as one MCP server: it holds the keys and Cursor gets answers. For other servers, read the key from the macOS Keychain at launch.
The problem
Where it goes wrong
- .cursor/mcp.json travelsA project config with a key in it goes wherever the repository goes.
- envFile is still a fileMoving the key to a .env file keeps it out of mcp.json, not off the disk.
- One key per serverEvery server you add is another secret to rotate and another package to trust.
The solution
MoltenRock Connect: Keys that are never in a file
- One Connect entryAdd MoltenRock Connect once and Cursor reads 30 platforms through it, with no key in mcp.json.
- Keychain for the restA wrapper reads other servers’ keys from the macOS Keychain when they start.
- Answers, not keysConnect returns data, with customer names and addresses as tokens.
- Changes wait for youOn Stripe, Cloudflare and GitHub, Cursor’s agent can only propose; you approve with Touch ID.
Side by side
Where a Cursor MCP key can live
| Option | What’s in the config file | Good for |
|---|---|---|
| The key in env or headers | The key itself, in plain text | A quick test, then remove it |
| ${env:NAME} or envFile | A variable name; the key sits in your environment or a .env file | Shared project config |
| Keychain and a wrapper script | A path to the wrapper; no secret | Any MCP server you trust |
| MoltenRock Connect | One entry, no key at all | Its 30 business platforms |
How it works
Clean up Cursor’s mcp.json
- 01Find the keysCheck ~/.cursor/mcp.json and every .cursor/mcp.json in your projects for env values and headers.
- 02Add Connect onceCopy the entry from MoltenRock Connect → Settings → Agent Setup → Claude Desktop, Cursor into ~/.cursor/mcp.json.
- 03Keychain for the restStore the key once with security add-generic-password -a "$USER" -s my-mcp-key -w (it asks for the value, so it never lands in your shell history), then point the server’s command at a two-line wrapper script that reads it with security find-generic-password -s my-mcp-key -w, exports it and starts the server. The config then holds a path, not a secret.
- 04Rotate what was in the fileAny key that sat in a config file may have been copied, synced or shared. Make a new one and revoke the old.
Straight answer
What this fixes, and what it doesn’t
Stays on your Mac
- Platform keys, in Connect or MoltenRock’s vault
- Keys for other servers, in the Keychain
- An mcp.json with nothing secret in it
Leaves your Mac
- Connect’s calls from your Mac to each platform
- Tool results, to Cursor and its model
- MoltenRock Connect covers its 30 business platforms (Stripe, Shopify, WooCommerce, GitHub, Cloudflare and more). An MCP server for anything else still needs its own key: keep that one in the Keychain.
Questions
What people ask first
Where is Cursor’s mcp.json?
~/.cursor/mcp.json for every project, or .cursor/mcp.json inside one project.
Does Cursor support environment variables in mcp.json?
Yes: ${env:NAME}, plus ${userHome} and ${workspaceFolder}, in command, args, env, url and headers. STDIO servers can also load an envFile.
Does Cursor need a key to use MoltenRock Connect?
No. Connect holds the platform keys on your Mac; Cursor talks to it over MCP.
What does it cost?
Connect is free for two platforms; one $9.99 unlock opens all 30, and MoltenRock Pro includes it.
An mcp.json you could publish.
MoltenRock Connect is free for Mac.