Home/Docs/MCP Environment Variables

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:

WhereHow it's available
AI AgentThe agent can read env and use your credentials in commands
Terminalecho $BROWSERBASE_API_KEY prints your key
CLI Toolsstripe subscriptions list works because STRIPE_API_KEY is set
All CommandsAny 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.

MCP Servers Dialog

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:

Preset with Env Vars

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.mcp file is stored in your sandbox's ephemeral filesystem
  • All MCP credentials are encrypted at rest in our database

Troubleshooting

"No API keys detected" appears

  1. Verify the variable name matches exactly what the MCP server expects
  2. Check the Logs tab to see if the MCP server connection succeeded
  3. 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.mcp file is read and variables are restored to memory
  • The agent can still access your credentials
  • Terminal sessions will have access after running source ~/.env.mcp or opening a new tab

Example: Complete Workflow

  1. Configure MCP: Add Browserbase with BROWSERBASE_API_KEY=bbk_live_xxx
  2. Start task: Prompt "Use Browserbase to screenshot github.com and save the image"
  3. Agent runs: Browserbase MCP tools work, and the agent can also run curl commands that reference $BROWSERBASE_API_KEY
  4. Send follow-up: "Now do the same for example.com" — credentials still work
  5. Open terminal: echo $BROWSERBASE_API_KEY shows your key