mcp server
mcp-env
A zero-dependency module that loads MCP environment variables
Set up
Runs on your computer. Pick your agent and operating system.
Before you start
- Node.js 20 or newer
{
"mcpServers": {
"mcp-env": {
"command": "npx",
"args": [
"-y",
"mcp-env"
]
}
}
}same format Cursor, GitHub Copilot CLI, Junie, JetBrains AI Assistant, Augment (Auggie CLI), Factory Droid, Kiro, Devin CLI +12
Values in angle brackets are placeholders. Restart Claude Desktop after editing its config.Claude Desktop docs
README
synced Oct 23, 2026mcp-env
A zero-dependency Node.js module that loads MCP (Model Context Protocol) environment variables and executes commands with those variables set. This tool creates temporary scripts to run commands with specific environment variables, making it easy to manage different configurations for your MCP applications.
Features
- Zero Dependencies: Only uses Node.js built-in modules (except for
dotenv) - Cross-Platform Support: Works on Windows, macOS, and Linux
- Environment Variable Management: Loads variables from
.env.mcp(in your user directory) file or custom env file - Script Caching: Reuses generated scripts for identical commands to improve performance
- Secure: Uses MD5 hashing for script naming to avoid conflicts
Installation
npm install mcp-env
Or use it directly with npx:
npx mcp-env
Usage
Environment File Support
The tool automatically loads environment variables from .env.mcp file in your user directory. You can specify a custom environment file using the MCP_ENV_FILE environment variable:
MCP_ENV_FILE=.env.custom npx mcp-env VAR1=VALUE1 -- command
Basic Syntax
npx mcp-env VAR1=VALUE1 VAR2=VALUE2 -- COMMAND_TO_RUN
Examples
Running a Node.js script with custom environment variables:
npx mcp-env NODE_ENV=production API_KEY=your-api-key -- node app.js
Running a Python script with multiple environment variables:
npx mcp-env PYTHONPATH=/usr/local/lib/python3.9 DATABASE_URL=postgresql://localhost:5432/mydb DEBUG=true -- python script.py
Running a shell command with environment variables:
npx mcp-env AWS_REGION=us-west-2 AWS_PROFILE=production -- aws s3 ls
Using with Docker:
npx mcp-env DOCKER_IMAGE=myapp:latest PORT=3000 -- docker run -p $PORT:3000 $DOCKER_IMAGE
How It Works
- Parsing: The tool parses environment variables and the command from the command line arguments
- Script Generation: Creates a temporary script file with the environment variables and command
- Caching: Uses MD5 hash of variables and command to create unique script names
- Execution: Runs the generated script with the specified environment variables
Generated Scripts
The tool creates platform-specific scripts:
- Windows:
.batfiles usingsetcommands - Unix-like systems:
.shfiles usingexportcommands
Scripts are stored in the same directory as the executable and are reused for identical commands.
License
MIT License - see LICENSE file for details.