envmcp
A lightweight way to use environment variables in your Cursor MCP server definitions.
claude mcp add --transport stdio griffithsbs-envmcp npx envmcp your-mcp-server $DATABASE_URL
How to use
envmcp allows you to load environment variables from a file and substitute them into your MCP server definitions. By prefixing your server command with envmcp, secrets can be kept out of your MCP configuration files and injected at runtime from a centralized environment file. The quick start shows using npx envmcp your-mcp-server $DATABASE_URL to substitute variables like DATABASE_URL into the command arguments. You can also point envmcp at a custom environment file with --env-file (or -e) to load specific secrets, and you can pass the resulting values to your MCP server commands. This enables safer handling of credentials and other sensitive data in your deployment workflows.
In practice, you would transform an ordinary MCP client configuration such as a database connection string into one that references environment variables managed by envmcp. For example, instead of exposing secrets directly in the MCP definition, you wrap the server invocation with envmcp so that $VARIABLE references are resolved from the environment file found by envmcp (and, if specified, the custom --env-file). The tool searches for .env.mcp starting from the current directory, then parent directories, and finally ~/.env.mcp, falling back to a user-provided --env-file if supplied. After loading the variables, envmcp substitutes the placeholders in your server command arguments and executes the final command.
How to install
Prerequisites:
- Node.js and npm installed on your system
Installation steps:
- Install envmcp globally using npm:
npm install -g envmcp
- Verify installation:
envmcp --version
- Use npx as shown in the Quick Start to run MCP servers with environment variable support:
npx envmcp your-mcp-server $DATABASE_URL
If you prefer a local setup or CI integration, you can also install envmcp locally in your project and reference the binary from node_modules/.bin.
Additional notes
Tips and considerations:
- The environment file format supports comments and quoted values. Example: DATABASE_URL=postgresql://user:password@localhost/db and QUOTED_VALUE="value with spaces".
- If you need to override the default search path for the environment file, use --env-file <path> (or -e <path>).
- Environment variables loaded by envmcp are substituted in your MCP server arguments where you place the $VARIABLE_NAME placeholders.
- See sample.env.mcp in the project for more examples.
- This tool is compatible with MCP setups that require secrets to be kept out of source-controlled configurations. For broader functionality, you may explore mcpipe for additional debugging tools and features.
Related MCP Servers
ls
List MCP Server configurations in your system used by AI applications like Cursor, Claude Desktop, VS Code and others
cursor10x
The Cursor10x MCP is a persistent multi-dimensional memory system for Cursor that enhances AI assistants with conversation context, project history, and code relationships across sessions.
adb
An MCP (Model Context Protocol) server for interacting with Android devices through ADB in TypeScript.
fast -telegram
Telegram MCP Server and HTTP-MTProto bridge | Multi-user auth, intelligent search, file sending, web setup | Docker & PyPI ready
mcpipe
Decorate stdio MCP servers with debugging and other capabilities
memory
A MCP (Model Context Protocol) server providing long-term memory for LLMs