Developer tests Claude Code MCP env variable expansion, finds key gaps in docs

A developer ran controlled experiments on Claude Code version 2.1.278 to test how environment variables are expanded in .mcp.json configuration files. The official documentation states that two syntaxes — ${VAR} and ${VAR:-default} — are supported across five fields: command, args, env, url, and headers. Testing revealed that ${VAR} and ${VAR:-default} expanded correctly in all supported fields, while bare $VAR syntax never expanded anywhere. An unset variable without a default arrived as literal text, and nested defaults like ${A:-${B}} only expanded in the headers field, which processes expansion twice. The findings highlight several undocumented edge cases that developers relying on MCP configuration may encounter in practice.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.


Discussion (0)
Log in to join the discussion and vote.
Log in