MCP secrets · Cursor

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 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 travels
    A project config with a key in it goes wherever the repository goes.
  • envFile is still a file
    Moving the key to a .env file keeps it out of mcp.json, not off the disk.
  • One key per server
    Every 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 entry
    Add MoltenRock Connect once and Cursor reads 30 platforms through it, with no key in mcp.json.
  • Keychain for the rest
    A wrapper reads other servers’ keys from the macOS Keychain when they start.
  • Answers, not keys
    Connect returns data, with customer names and addresses as tokens.
  • Changes wait for you
    On 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

OptionWhat’s in the config fileGood for
The key in env or headersThe key itself, in plain textA quick test, then remove it
${env:NAME} or envFileA variable name; the key sits in your environment or a .env fileShared project config
Keychain and a wrapper scriptA path to the wrapper; no secretAny MCP server you trust
MoltenRock ConnectOne entry, no key at allIts 30 business platforms

How it works

Clean up Cursor’s mcp.json

  1. 01
    Find the keys
    Check ~/.cursor/mcp.json and every .cursor/mcp.json in your projects for env values and headers.
  2. 02
    Add Connect once
    Copy the entry from MoltenRock Connect → Settings → Agent Setup → Claude Desktop, Cursor into ~/.cursor/mcp.json.
  3. 03
    Keychain for the rest
    Store 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.
  4. 04
    Rotate what was in the file
    Any 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.