Guides · 26 November 2026

How to give an API key to Claude Code, Cursor or Codex without pasting it in the chat

Coding agents need your keys to deploy, test and call APIs. Pasting them in the conversation leaves them in history and logs. Here is a cleaner way with MCP.

The problem

Sooner or later your coding agent says “I need your Stripe key” or “add your database URL”. The fastest reflex is to paste it in the chat. The key then lives in the conversation history, possibly in the provider's logs, in exported transcripts, and in the model context for the rest of the session, where it can be echoed back into a file, a commit or a log line.

Option 1: put it in the env file yourself

The simplest rule: you open .env or .env.local and paste the key there, and you tell the agent the variable name. It works, but it breaks the flow when the agent runs on a remote machine, in a container, or when you are on your phone.

Option 2: let the agent request it through Shredkey

Shredkey ships an MCP server, the standard way to give tools to Claude, ChatGPT, Cursor, Windsurf or Codex. Once connected, the agent can:

  1. call request_secret with a label such as “Stripe live key”;
  2. send you a one-time link; you paste the key in an end-to-end encrypted page;
  3. call save_secret_to_env, which writes STRIPE_SECRET_KEY=… to your env file with permissions 600 and returns only its length and a short fingerprint.

With the local MCP server, the value is never returned to the model: it goes from your page to the file, encrypted end to end.

Set it up in one minute

mkdir -p ~/.shredkey && curl -fsSL https://shredkey.com/sk.mjs -o ~/.shredkey/sk.mjs
claude mcp add shredkey -- node ~/.shredkey/sk.mjs mcp

For Cursor, Claude Desktop or Windsurf, add the same command to the MCP config file. For ChatGPT or Claude.ai connectors, use the remote URL https://shredkey.com/mcp (encryption then happens in our server memory, then the key is forgotten). All options are on the agents page.

Make it a rule for every agent

Add this to your AGENTS.md or CLAUDE.md:

Never ask me to paste a secret in the chat. Use shredkey request_secret,
send me the fill_url, then save_secret_to_env.

Agents read these files at the start of each session, so the habit sticks.

Giving a key back to a human

The reverse works too: share_secret can read a variable from your env file and hand it to a teammate as a self-destructing link, without the agent ever displaying it.

Share a secret now: encrypted in your browser, destroyed after reading.

Create a secret link Connect an AI agent