[FEATURE] MCP Servers configuration : add expanding variables support

Status Fixed / completed
Maintainer reply ✓ Yes — ashwin-ant
Activity 7 comments · opened Apr 30, 2025 · closed Jul 10, 2025
💡 Likely answer: A maintainer (ashwin-ant, collaborator) responded on this thread — see the highlighted reply below.

In order for the project scope mcp servers to really be useful, it would be great that the config allowed for expanding environment variables.

For instance in a project .mcp.json :

{
  "mcpServers": {
    "mysql_local": {
      "type": "stdio",
      "command": "uvx",
      "args": [
        "--with",
        "pymysql",
        "mcp-alchemy"
      ],
      "env": {
        "DB_URL": "mysql+pymysql://$USER@localhost:3306/database"
      }
    }
  }
}

The $USER variable isn't expanding, forcing everyone to install this mcp server locally and rendering it useless as a project mcp.

View original on GitHub ↗

7 Comments

ashwin-ant collaborator · 1 year ago

We're currently supporting the same MCP config format that most other clients are. One approach to solving this is to make the command a script inside your repo that invokes the MCP server with variables that it pulls from elsewhere.

moltar · 1 year ago

@ashwin-ant This is however not possible when using HTTP:

{
  "mcpServers": {
	"github": {
      "type": "http",
      "url": "https://api.githubcopilot.com/mcp/",
      "headers": {
        "Authorization": "Bearer ${THIS SHOULD BE A SECRET}"
      }
    }
}

See: https://github.com/github/github-mcp-server

vast00 · 1 year ago

Please support this feature.
Without it, the project mcp json is unusable with many useful mcp servers like figma, github.

ollie-anthropic collaborator · 1 year ago

Hey all - just a heads up, I've picked this up and this feature should hopefully be released very shortly, in the next few releases

ollie-anthropic collaborator · 1 year ago

Hey all - this is now available in the latest release (1.0.48).

Docs are here! https://docs.anthropic.com/en/docs/claude-code/mcp#environment-variable-expansion-in-mcp-json

moltar · 1 year ago

Beautiful! Thanks

github-actions[bot] · 1 year ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.