Environment Variables
Configure your MCP servers using environment variables.
Overview
Environment variables are the recommended way to configure your MCP servers. They allow you to change configuration without modifying code.
Setting Environment Variables
During Deployment
- In the deployment configuration form
- Click "Add Environment Variable"
- Enter the variable name (e.g.,
NOTION_API_KEY) - Enter the value
- Mark as secret if it's sensitive
- Add more variables as needed
After Deployment
- Go to your server dashboard
- Click "Settings" → "Environment Variables"
- Click "Add Variable"
- Enter name and value
- Save changes
- Redeploy if needed
Common Environment Variables
API Keys
NOTION_API_KEY=secret_xxx
OPENAI_API_KEY=sk-xxx
DATABASE_URL=postgresql://...
Configuration
LOG_LEVEL=info
DEBUG=false
PORT=8080
Service URLs
EXTERNAL_API_URL=https://api.example.com
WEBHOOK_URL=https://your-app.com/webhook
Secret Variables
Mark sensitive variables as secrets:
- They're encrypted at rest
- Hidden in the UI (shown as
****) - Never logged or exposed
- Secure storage
Best Practices
- Use descriptive names: Clear variable names help understanding
- Document required variables: List them in README
- Never commit secrets: Use
.env.examplefor documentation - Rotate regularly: Update secrets periodically
- Use defaults: Provide sensible defaults where possible
Accessing in Code
Python
import os
api_key = os.getenv('NOTION_API_KEY')
database_url = os.getenv('DATABASE_URL', 'default_value')
Node.js
const apiKey = process.env.NOTION_API_KEY;
const databaseUrl = process.env.DATABASE_URL || 'default_value';
Environment-Specific Configuration
You can use different variables for different environments:
- Development: Local
.envfile - Production: Set in agnexus dashboard