Get the FREE Ultimate OpenClaw Setup Guide →

envmcp

A lightweight way to use environment variables in your Cursor MCP server definitions.

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
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:

  1. Install envmcp globally using npm:
npm install -g envmcp
  1. Verify installation:
envmcp --version
  1. 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

Sponsor this space

Reach thousands of developers