[FEATURE] MCP Servers configuration : add expanding variables support
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.
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.
@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
Please support this feature. Without it, the project mcp json is unusable with many useful mcp servers like figma, github.
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
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
Beautiful! Thanks
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.