Cursor secrets and env variables, without a .env file in the chat
Cursor can read any file in your project, including .env. With Envshed, Cursor lists which keys exist, asks you for a missing one, and runs the app with the values injected, so the values stay out of the chat. Setup takes about ten minutes.
Cursor works a little differently from Claude Code: there are no hooks, and output masking is not automatic. The steps below cover both. You need an Envshed account, Node.js 20.12 or later and Cursor.
Steps
Step 1: Install the CLI and sign in
Run this in your own terminal, not in the agent:
npm install -g envshed envshed login
The browser shows a code. Check that it matches the one in the terminal, then choose Approve sign-in.
Step 2: Add the MCP server to Cursor
Add the server to ~/.cursor/mcp.json for every project, or to .cursor/mcp.json in one project:
{
"mcpServers": {
"envshed": { "url": "https://app.envshed.com/api/mcp" }
}
}The Cursor editor and the Cursor CLI read the same file. To sign in from the CLI:
cursor-agent mcp login envshed cursor-agent mcp list-tools envshed
The second command lists 10 tools, such as list_secret_keys and request_secret. Use a current Cursor version: an old Cursor CLI asks for a scope Envshed does not issue, and sign-in stops with "This connection can't continue".
Step 3: Write the project rule
From the project folder:
envshed agent rules
It writes AGENTS.md and CLAUDE.md, and .cursor/rules/envshed.mdc when the project has a .cursor folder. Cursor applies that rule to every chat. Pass --all to write the files for every supported tool. Commit the files: they hold no secret.
Step 4: Ask for masked output
In Cursor, output masking is not automatic. Ask the agent to run envshed run --redact -- npm start, or set ENVSHED_AGENT_MODE=1 in the environment of Cursor's terminal.
Step 5: Give Cursor a task
Paste this, with your organization, project and start command:
Run this app with Envshed. Organization: acme. Project: my-app. Environment: development. 1. Use the Envshed MCP server to list the key names and find any that are missing. 2. For each missing key, call request_secret, give me the link and wait until I fill it. 3. Run the app with: envshed run --redact -- npm start Never read .env files, never print secret values and never ask me to paste a value in the chat.
Cursor gets each key name with a status and no values. For a missing key it gives you a link, and you enter the value in the dashboard.
What this does and does not do
Cursor has no hooks in this setup, because envshed agent install supports Claude Code only. Nothing stops Cursor from reading a .env file; the project rule only asks it not to, and an agent can ignore a rule. Limits that must hold, such as who can read production, belong on the server: use roles and scoped service tokens. See what Envshed guarantees and what it does not.
FAQ
Can Cursor read my .env file?
Yes, if the file is in the project: nothing blocks it in Cursor. The rule asks the agent not to, and envshed run removes the need for a .env file, because it injects the secrets as environment variables instead.
Does the MCP server give Cursor my secret values?
No. No tool returns a secret value, and no tool has a field for one. Tools deal in key names and statuses.
Is output masked in Cursor?
Not by itself. Ask for envshed run --redact, or set ENVSHED_AGENT_MODE=1 in the environment of Cursor's terminal.
Where do I put my API key then?
In Envshed, entered by you in the dashboard or with envshed secret set API_KEY -e development in your own terminal, which asks for the value with a masked prompt.
Using another agent? See the Claude Code or Codex guide.