.env files, mcp.json files, and config files can be committed to source control or accidentally shared, allowing anyone who finds them to access your accounts.
1Password gives you secure ways to provide secrets to AI tools and agents. Store your credentials in 1Password, then load them into your AI workflows without exposing them in plaintext or allowing agents to directly handle your secrets.
The security principles guiding 1Password's approach to AI
How 1Password applies ideas like secrets staying secret, deterministic authorization, auditability, and least privilege when building and integrating AI.
Secure AI API keys
If you use AI services like OpenAI, Anthropic, or Google in your applications or scripts, you may have plaintext API keys stored in environment variables,.env files, or shell profiles.
1Password Environments allow you to manage your API keys and other project secrets together in 1Password, then securely load them into your code when you need them.
To get started:
- Create an Environment in 1Password and add the API keys and other secrets your AI workflow needs as variables. If you have an existing
.envfile for your project, you can import it. - Create a locally mounted
.envfile for the Environment. The contents of this file aren’t tracked by Git or stored on disk, and are only available at the moment you access it. - Verify you can access your variables and make sure they work with your tools.
.env files or shell profiles (~/.zshrc, ~/.bashrc).
Add validation for AI-assisted coding
If you use AI coding agents in tools like Cursor, GitHub Copilot, Claude Code, or Windsurf, you can use 1Password hooks to validate that your locally mounted.env files are properly configured before the agent executes shell commands.
If any required .env files are missing or invalid, the hook prevents the agent from executing and the agent provides instructions for how to fix the issue.
In Claude Code and Cursor, the hook is bundled in a plugin that installs the validation hook, an Environments agent skill, and MCP server configuration together.
Create and manage Environments
Store your AI API keys in an Environment.
Access secrets through local .env files
Sync an Environment to a local
.env file.Install the validation hook
Validate locally mounted
.env files before your agent runs shell commands.Secure MCP server config files
MCP server configurations (likemcp.json) often include API tokens and other credentials as environment variables. Yours might look something like this:
- In 1Password, create an Environment and add the secrets your MCP server needs as variables.
- Open the Environment you just created and select Manage environment > Copy environment ID.
-
Update your MCP config file to use
opas the command, withrun --environmentinargswrapping your original MCP server command. Remove any hardcoded secrets from theenvblock:
npx. The MCP server receives the real secret values without your secrets ever being stored in your config file.
With this approach, there’s no need to re-declare your secrets in the env block. Because op run injects the variables directly into the process environment, they’re already available to the MCP server. If you need to pass additional non-secret configuration values alongside your command, you can still use the env block for those.
Some MCP hosts (like Claude Desktop on Mac) launch as GUI apps and may not inherit your shell’s
$PATH. If op can’t be found, use its full path as the command value instead. For example, /usr/local/bin/op or /opt/homebrew/bin/op. You can find the path by running which op in your terminal.op run and secret references.
Use the 1Password Environments MCP Server
The 1Password Environments MCP Server lets MCP clients like Codex, Cursor, and Kiro create and manage your 1Password Environments directly, with a secure 1Password authorization prompt required for every action. The MCP server doesn’t read or return secrets to the AI agent. Your secrets stay in 1Password and are only accessed by authorized processes, so your MCP client can act on your secrets without ever seeing them. You can use the MCP server from your client to create Environments, list environment variable names, handle local.env files within authenticated workflows, and manage secrets within your Environments.
Set up the 1Password Environments MCP Server
Connect your MCP client to 1Password to securely create and manage Environments.
Install the 1Password plugin for Claude Code
Add MCP configuration,
.env file validation, and the Environments agent skill to Claude Code.Install the 1Password plugin for Cursor
Add MCP configuration,
.env file validation, and the Environments agent skill to Cursor.Keep secrets out of agent context with 1Password and NVIDIA OpenShell (beta)
1Password for NVIDIA OpenShell (beta) lets a coding agent use the credentials it needs without those credentials entering the agent’s context. You connect a 1Password Environment to an OpenShell gateway, then attach it to the sandbox where the agent runs. Inside the sandbox, the agent only ever works with placeholders. When it sends a request to a host you’ve approved, the gateway replaces the placeholders with the real secrets outside the sandbox and forwards the request. Requests to any other host don’t receive the credential. You choose how long OpenShell keeps custody of the secrets. After that window expires, the sandbox keeps running but the agent no longer gets access.Set up 1Password for NVIDIA OpenShell
Connect an Environment to an OpenShell gateway and give sandboxed agents scoped, time-limited access to your secrets.
Authenticate AI command-line tools with biometrics
You can set up 1Password Shell Plugins to authenticate AI command-line tools like OpenAI CLI or Claude Code CLI using the 1Password desktop app, eliminating the need to store plaintext API keys in your shell profile or environment. When you use a shell plugin, you authenticate the underlying CLI in the same way you unlock the 1Password desktop app, like with Touch ID, Apple Watch, or a Linux system authentication option, which enables convenient human-in-the-loop approval.Next steps
Choose what you want to do next:Secure local development
Access credentials in your terminal, IDE, and local projects without exposing your secrets in plaintext.
Secure your deployments
Securely load secrets into CI/CD, containers, and production apps at runtime with least-privilege access.