MCP Environment Variables
Documentation and guides for OutcomeDev.
Last updated: April 2026
What Are MCP Environment Variables?
When you connect an MCP server (like Browserbase, Stripe, or Notion), you often need to provide credentials — API keys, OAuth secrets, or other tokens. These are called environment variables.
Normally, those credentials only work inside the MCP server itself. We fixed that.
How It Works
Step 1: You Configure an MCP Server
When you click the Cable/Plug icon in the task form and add an MCP server, you can attach environment variables:
Browserbase API Key: bbk_live_xxxxxxxxxxxx
Stripe API Key: sk_live_xxxxxxxxxxxx
Step 2: When the Sandbox Starts
Your environment variables are automatically available to:
| Where | How it's available |
|---|---|
| AI Agent | The agent can read env and use your credentials in commands |
| Terminal | echo $BROWSERBASE_API_KEY prints your key |
| CLI Tools | stripe subscriptions list works because STRIPE_API_KEY is set |
| All Commands | Any sh -c "..." command gets your vars prepended automatically |
What This Means for Your Tasks
You can now write prompts like:
Use Stripe to check the status of subscription
sub_123, then use Browserbase to take a screenshot of example.com
The agent will have access to both STRIPE_API_KEY and BROWSERBASE_API_KEY — not just for the MCP tools themselves, but for any CLI command or script that needs those credentials.
Setting Up MCP Servers
1. Open the Task Form
Navigate to the task creation form. Click the Cable/Plug icon next to the prompt input.
2. Add an MCP Server
Click Add MCP Server or select a preset like Browserbase.
For presets, the expected environment variables are pre-populated for you:
For custom servers, click Add Variable to add your own key-value pairs.
Click Add MCP Server to save.
3. Start Your Task
When the sandbox starts, your environment variables are automatically injected. No extra configuration needed.
Verifying Your Variables
Once your task is running, open the Terminal tab and run:
# Check if a specific variable is set
echo $BROWSERBASE_API_KEY
# List all MCP-related variables
env | grep -E '(BROWSERBASE|STRIPE|NOTION|LINEAR)'
If you don't see your variables, try opening a new terminal tab. The .bashrc is sourced on shell startup, so existing sessions may not pick up changes.
Using Credentials in Tasks
In Prompts
The agent automatically has access to your MCP credentials. You can reference them directly:
Use the Stripe CLI to list all active subscriptions, then create a summary report
Use Browserbase to browse to example.com and take a screenshot of the hero section
In Terminal
Any CLI tool that needs your credentials will work:
# Stripe CLI
stripe subscriptions list
# Browserbase
npx @browserbasehq/mcp list-projects
# GitHub CLI (if configured)
gh repo list
Security
- Environment variables are scoped to your sandbox session only
- They are not persisted beyond the sandbox lifetime
- Variables are redacted in logs (replaced with
[REDACTED]) - The
~/.env.mcpfile is stored in your sandbox's ephemeral filesystem - All MCP credentials are encrypted at rest in our database
Troubleshooting
"No API keys detected" appears
- Verify the variable name matches exactly what the MCP server expects
- Check the Logs tab to see if the MCP server connection succeeded
- Try restarting the task with the MCP server re-connected
Terminal doesn't see variables
Open a new terminal tab. If that doesn't work:
source ~/.env.mcp
echo $YOUR_VARIABLE
Variables work for the agent but not in terminal
The agent and terminal run in the same sandbox but potentially different shell sessions. Running source ~/.env.mcp will load the variables manually.
Resume and Restart Behavior
Your environment variables persist across follow-up messages in the same task. If the sandbox is resumed:
- The
~/.env.mcpfile is read and variables are restored to memory - The agent can still access your credentials
- Terminal sessions will have access after running
source ~/.env.mcpor opening a new tab
Example: Complete Workflow
- Configure MCP: Add Browserbase with
BROWSERBASE_API_KEY=bbk_live_xxx - Start task: Prompt "Use Browserbase to screenshot github.com and save the image"
- Agent runs: Browserbase MCP tools work, and the agent can also run
curlcommands that reference$BROWSERBASE_API_KEY - Send follow-up: "Now do the same for example.com" — credentials still work
- Open terminal:
echo $BROWSERBASE_API_KEYshows your key