Welcome! Type "help" for available commands.
$
Loading terminal interface...
Back to Blog

How to Secure Environment Variables for LLMs, MCPs, and AI Tools Using 1Password or Doppler

September 25, 2025
William Callahan

Software engineer, founder, and leadership background in finance/tech. Based in San Francisco.

security1passworddopplermcpaillmapi-keysdevops
How to Secure Environment Variables for LLMs, MCPs, and AI Tools Using 1Password or Doppler

If you're using AI coding tools like Claude Desktop, Cursor, or Continue, you've probably configured MCP servers or API keys somewhere. And if you're like most developers, those secrets are sitting in plain text in JSON config files.

That's a security nightmare waiting to happen—especially with the rise of prompt injection attacks and untrusted MCP servers potentially accessing your environment.

The Security Problem

AI tools increasingly need access to various API keys:

  • MCP Servers: Supabase, GitHub, Linear, etc. all need authentication tokens
  • LLM Providers: OpenAI, Anthropic, Google AI keys for model access
  • External Services: Database credentials, cloud provider tokens, OAuth secrets

Storing these in plain text config files means they're exposed to any process that can read your filesystem—including potentially malicious MCP servers or compromised dependencies.

After testing various approaches, I've found two rock-solid solutions: 1Password CLI for those already in the 1Password ecosystem, and Doppler for teams needing centralized secret management. Here's exactly how to implement each one.

Part 1: Understanding the MCP Security Model

When an AI assistant uses an MCP tool, your secrets are injected by the host app as process environment variables only when the MCP server starts. The LLM never sees the values; the MCP server process does. This just-in-time injection is the core security boundary we’ll leverage.

┌─────────────┐ ┌──────────────┐ ┌─────────────┐ │ Claude/ │ JSON │ MCP Host │ ENV │ MCP Server │ │ LLM │ RPC │ (Claude │ VARS │ Process │ │ │ ──────> │ App) │ ──────> │ │ │ NEVER sees │ │ Injects │ │ SEES the │ │ secrets │ │ secrets │ │ secrets │ └─────────────┘ └──────────────┘ └─────────────┘

Part 2: The 1Password CLI Approach (Personal Use)

If you're already using 1Password, their CLI provides excellent integration for personal secret management.

Toggle dropdown1Password Setup
  1. Install 1Password CLI
# macOS
brew install --cask 1password-cli

# Windows (winget)
winget install 1Password/CLI

# Linux (apt)
curl -sS https://downloads.1password.com/linux/keys/1password.asc | \
  sudo gpg --dearmor --output /usr/share/keyrings/1password-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/1password-archive-keyring.gpg] https://downloads.1password.com/linux/debian/$(dpkg --print-architecture) stable main" | \
  sudo tee /etc/apt/sources.list.d/1password.list
sudo apt update && sudo apt install 1password-cli
  1. Sign In and Configure
# Sign in (will prompt for account details)
op signin

# Create a vault for AI tools
op vault create "AI Tools"

# Store secrets
op item create \
  --category "API Credential" \
  --title "Anthropic API Key" \
  --vault "AI Tools" \
  'api_key[password]=sk-ant-...'

op item create \
  --category "API Credential" \
  --title "OpenAI API Key" \
  --vault "AI Tools" \
  'api_key[password]=sk-...'

1Password env template (.env.op)

ANTHROPIC_API_KEY="op://AI Tools/Anthropic API Key/api_key"
OPENAI_API_KEY="op://AI Tools/OpenAI API Key/api_key"
SUPABASE_ACCESS_TOKEN="op://AI Tools/Supabase Token/api_key"
GITHUB_TOKEN="op://AI Tools/GitHub Token/token"

Wrapper and IDE config

1Password needs a wrapper to refresh auth periodically. Create ~/.config/1password/op-mcp-wrapper:

#!/bin/bash
# ~/.config/1password/op-mcp-wrapper
if ! op account get &>/dev/null 2>&1; then
    eval $(op signin)
fi
op run --env-file="$HOME/.env.op" -- "$@"

Make it executable:

chmod +x ~/.config/1password/op-mcp-wrapper

Claude Desktop config (~/Library/Application Support/Claude/claude_desktop_config.json):

{
  "mcpServers": {
    "github": {
      "command": "/Users/YOUR_USERNAME/.config/1password/op-mcp-wrapper",
      "args": ["npx", "-y", "@modelcontextprotocol/server-github"]
    },
    "filesystem": {
      "command": "/Users/YOUR_USERNAME/.config/1password/op-mcp-wrapper",
      "args": ["npx", "-y", "@modelcontextprotocol/server-filesystem", "/Users/YOUR_USERNAME/projects"]
    }
  }
}
1Password Access Requested system prompt with Touch ID
1Password access prompt when authorizing secure actions (e.g., CLI/SSH).

Part 3: The Doppler Approach (Team-Friendly)

Doppler is purpose-built for developers environment variables across teams and environments. It's my top recommendation if you need centralized control and audit logging, and is equally great for CI/CD and general development environment focused secrets/automatic injection. They have a lot of deployment options, including normal shell and API access and a CLI tool like 1Password's, but also custom packages for many different languages/frameworks.

Toggle dropdownDoppler Setup
  1. Install Doppler CLI
# macOS/Linux
curl -Ls https://cli.doppler.com/install.sh | sh

# macOS (Homebrew)
brew install dopplerhq/cli/doppler

# Windows (Scoop)
scoop install doppler
  1. Authenticate and Create Project
# Login to Doppler
doppler login

# Create a project for your AI tools
doppler projects create ai-tools

# Set up a config for local development
doppler setup --project ai-tools --config dev

# Add your secrets
doppler secrets set ANTHROPIC_API_KEY "sk-ant-..."
doppler secrets set OPENAI_API_KEY "sk-..."
doppler secrets set SUPABASE_ACCESS_TOKEN "sbp_..."
doppler secrets set GITHUB_TOKEN "ghp-..."
  1. Generate and store a Service Token for non-interactive use
# Create a service token for your local machine
# (copy the token printed, it starts with dp.st.)
doppler configs tokens create --project ai-tools --config dev --name "desktop-mcp"

# Store the token in Doppler CLI config (no env var export)
doppler configure set token dp.st.dev.xxxxx

Doppler MCP configuration

Here's how to configure popular MCP servers to use Doppler for secret injection:

Claude Desktop Configuration

Edit ~/Library/Application Support/Claude/claude_desktop_config.json:

{
  "mcpServers": {
    "github": {
      "command": "doppler",
      "args": [
        "run",
        "--project", "ai-tools",
        "--config", "dev",
        "--",
        "npx",
        "-y",
        "@modelcontextprotocol/server-github"
      ]
    },
    "supabase": {
      "command": "doppler",
      "args": [
        "run",
        "--project", "ai-tools",
        "--config", "dev",
        "--",
        "npx",
        "-y",
        "@supabase/mcp-server-supabase",
        "serve",
        "--project-id", "your-project-id"
      ]
    },
    "postgres": {
      "command": "doppler",
      "args": [
        "run",
        "--",
        "npx",
        "-y",
        "@cloudflare/mcp-server-postgres"
      ]
    }
  }
}

How This Works

When the MCP server starts, Doppler:

  1. Authenticates using your service token
  2. Fetches the latest secrets from your project
  3. Injects them as environment variables into the MCP server process
  4. The server runs with access to the secrets, but they're never written to disk

Part 4: Comparison & Recommendations

Here's how Doppler and 1Password stack up for AI tool secret management:

FeatureDoppler1Password CLI
Setup ComplexitySimple (service token)Moderate (wrapper script needed)
AuthenticationPersistent tokenPeriodic (Touch ID/password)
Team Sharing✅ Excellent⚠️ Requires family/business plan
Audit Logging✅ Full audit trail✅ Activity log
PerformanceFast (cached locally)Slower (auth overhead)
Offline Access✅ With cached secrets❌ Requires connection
PriceFree tier available$3–8/month per user
MCP IntegrationNative (no wrapper)Requires wrapper script
IDE SupportDirect env injectionLimited (via wrapper)
Secret Rotation✅ AutomaticManual

When to Use 1Password

  • Personal projects where you're the only developer
  • Already using 1Password for other passwords
  • Highest security requirements (biometric auth on every access)
  • Mixed secret types (not just env vars but also passwords, SSH keys)

When to Use Doppler

  • Team environments where multiple developers need the same secrets
  • CI/CD pipelines that need programmatic access
  • Rapid iteration where you're frequently updating secrets
  • Multiple environments (dev, staging, prod) with different values
  • Audit requirements for compliance

Part 5: Security Best Practices

Critical Security Tips

  1. Never commit tokens: Add *.env, *config.json with secrets to .gitignore
  2. Use read-only tokens where possible for MCP servers
  3. Rotate secrets regularly: Both tools support secret rotation
  4. Enable 2FA on Doppler and 1Password accounts
  5. Scope permissions tightly: Give MCP servers minimum required access
Toggle dropdownAdditional Security Hardening Options

Rate Limiting and Monitoring

For Doppler, enable activity webhooks:

doppler settings webhook create \
  --project ai-tools \
  --url "https://your-monitoring.com/doppler-webhook" \
  --event "secret.fetch"

For 1Password, use their Events API to monitor access:

# Check recent secret access
op events-api list --limit 10 | jq '.[] | select(.action == "reveal")'

Emergency Revocation

If you suspect a token is compromised:


Doppler:

# Revoke all service tokens
doppler configs tokens revoke --all --project ai-tools --config dev

# Generate new token
doppler configs tokens create --project ai-tools --config dev --name "new-desktop"

1Password:

# Sign out all sessions
op signout --all

# Rotate the specific secret
op item edit "Anthropic API Key" api_key="sk-ant-new-key..."

Part 6: Troubleshooting Common Issues

Toggle dropdownDoppler Issues
  • "DOPPLER_TOKEN not set": Ensure your token is exported in your shell profile
  • "Project not found": Verify project name matches exactly (case-sensitive)
  • Rate limited: Free tier has limits; upgrade or reduce polling frequency
Toggle dropdown1Password Issues
  • "Authentication required": Your session expired; run op signin manually
  • "Item not found": Check vault and item names match exactly
  • Biometric prompt not appearing: Enable Touch ID in 1Password settings
Toggle dropdownGeneral MCP Issues
  • Environment variables not visible: MCP server might be caching; restart the AI tool
  • Wrong values loaded: Check you're not overriding with local .env files
  • Permission denied: Ensure wrapper scripts are executable (chmod +x)

TL;DR

Securing your environment variables/secrets/credentials doesn't have to be complicated. With 1Password CLI or Doppler, you can:

  • Keep all secrets encrypted and centralized
  • Inject them just-in-time without exposing them in config files
  • Maintain a full audit trail of what accessed which secret when
  • Rotate credentials easily when needed

For most individual developers, 1Password is the most convenient choice. For teams and CI/CD, I prefer Doppler.

Similar Content

HomeExperienceEducationCVProjectsBookmarksInvestmentsContactBlog
Welcome! Type "help" for available commands.
$
Loading terminal interface...

Similar Content

Related Investments

INV
December 31, 2021
WeLoveNoCode

WeLoveNoCode

Platform connecting businesses with no-code developers and tools.

enterpriseseedrealized+7 more
INV
December 31, 2021
Safe

Safe

Browser and email tech for secure verification of senders.

securitypre-seedrealized+7 more
INV
December 31, 2021
SailPlan

SailPlan

Maritime navigation and vessel optimization platform using AI for route planning.

logisticsseries aactive+8 more

Related Bookmarks

LINK
July 30, 2025
Claude Code Agents

Claude Code Agents

Directory of Claude Code agents and tools

developer toolsai agentsworkflow automation+4 more
claudecodeagents.com
LINK
June 3, 2025
MCP: Build Rich-Context AI Apps with Anthropic

MCP: Build Rich-Context AI Apps with Anthropic

Build AI apps that access tools, data, and prompts using the Model Context Protocol.

model context protocolanthropicai application development+10 more
deeplearning.ai
LINK
June 12, 2025
SDK for Claude Code (CLI) - Anthropic

SDK for Claude Code (CLI) - Anthropic

Programmatically integrate Claude Code into your applications using the SDK.

sdkssoftware development toolsai coding assistants+10 more
docs.anthropic.com

Related Projects

PRJ
repo-tokens-calculator

repo-tokens-calculator

CLI token counter (Python + tiktoken + uv) with pretty summary

clipythontiktoken+11 more
PRJ
Filey - Flag Deprecated Files Extension

Filey - Flag Deprecated Files Extension

VS Code extension for flagging deprecated files

vs codevisual studio codecursor+17 more
PRJ
ComposerAI

ComposerAI

AI email client / mailbox for agentic search and tasks

aiemail clientllm+13 more

Related Articles

BLOG
August 22, 2025
Claude Code Output Styles: Explanatory, Learning, and Custom Options

Claude Code Output Styles: Explanatory, Learning, and Custom Options

An implementation guide to Claude Code's /output-style, the built‑in Explanatory and Learning modes (with to-do prompts), and creating reusable custom...

aiclaude codeoutput styles+10 more
William CallahanWilliam Callahan
BLOG
July 20, 2025
How I Finally Got a DigitalOcean Spaces Bucket to Default Public (Spoiler: Ditch Per-Bucket Keys)

How I Finally Got a DigitalOcean Spaces Bucket to Default Public (Spoiler: Ditch Per-Bucket Keys)

Still hitting 403 errors trying to make a DigitalOcean Spaces bucket public? Turn off Per-Bucket Access Keys, lean on simple ACLs, and skip the old su...

digitaloceans3object storage+16 more
William CallahanWilliam Callahan
BLOG
June 16, 2025
Claude Code: Automatic Linting, Error Analysis, & Custom Commands

Claude Code: Automatic Linting, Error Analysis, & Custom Commands

How to leverage Claude Code's error analysis slash-commands and create your own linting commands to automate repetitive CLI tasks.

aiclaude codelinting+12 more
William CallahanWilliam Callahan