Skip to content

[Feature] Support environment variable references in MCP server definitions #7

@kiwamizamurai

Description

@kiwamizamurai

Is your feature request related to a problem?

Currently, MCP server definitions don't support environment variable references, making it difficult to handle sensitive data like API keys and secrets in project-level configurations. This forces developers to hardcode sensitive information in mcp.json files.

Describe the solution you'd like

Implement an injectEnv utility that supports environment variable references in MCP configurations using VSCode's env ref syntax (${env:VAR_NAME}). This would allow:

  • Secure handling of sensitive data
  • Dynamic configuration based on environment
  • Consistent with VSCode's environment variable reference syntax

~/.cursor/mcp.json:

{
    "mcpServers": {
        "kibela": {
            "command": "npx",
            "args": ["-y", "@kiwamizamurai/mcp-kibela-server"],
            "env": {
                "KIBELA_TEAM": "${env:KIBELA_TEAM}",
                "KIBELA_TOKEN": "${env:KIBELA_TOKEN}"
            }
        }
    }
}

Describe alternatives you've considered

  1. Hardcoding values in mcp.json (current approach, not secure)
  2. Using external configuration management tools (see forum post)

Additional context

  • Similar functionality has been implemented in Roo-Code (see PR #2679)
  • Community discussion on Cursor forum shows demand for this feature (see forum post)
  • VSCode already supports environment variable references (see issue 243709_1)
  • reddit

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions