The keys to your connected ecosystem
Environment variables are how Claude Code authenticates with external services. When you connect an MCP server to GitHub, Notion, Stripe, or any other service, the API key or token lives in an environment variable. These values get passed to MCP server processes at startup, enabling Claude to read your repositories, query your databases, manage your tasks, and interact with every connected service in your ecosystem.
There are three common places to set environment variables for Claude Code. Shell profiles (
~/.zshrc or ~/.bashrc) make variables available globally. Project .env files scope variables to a specific project. MCP server configurations in ~/.claude.json or ~/.claude/settings.json pass variables directly to specific server processes through the env field.