-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Description
What would you like to be added?
The Gemini CLI should support environment variable substitution within the headers
values of the mcpServers
configuration. This would allow users to store sensitive tokens securely in their environment and reference them in the configuration.
Eg:
{
"mcpServers": {
"myApiServer": {
"httpUrl": "https://api.example.com/",
"headers": {
"Authorization": "Bearer $MY_API_TOKEN"
}
}
}
}
The CLI should replace $MY_API_TOKEN
with the value of the MY_API_TOKEN
environment variable before sending the request. It should support both $VAR
and ${VAR}
syntax.
Why is this needed?
Currently, when configuring an MCP server in settings.json
, any values in the headers
object are treated as literal strings. This means sensitive data, like bearer tokens or API keys, must be hardcoded into the configuration file, which is a security risk.
Additional context
The current alternative is to hardcode the token, which is not secure. Another alternative would be to use a local script as a proxy, but this adds unnecessary complexity for a common use case.