Skip to content

${env:VAR} is not substituted in mcp.json server headers #336232

Closed as not planned

Description

VS Code version: 1.137.0 (645f29c), x64

Repro:

  1. In mcp.json, configure an http server with:
    "headers": { "Authorization": "Bearer ${env:MY_VAR}" }
  2. Set MY_VAR as a persisted Windows user-level env var. Confirm it resolves correctly in a fresh terminal ($env:MY_VAR).
  3. Fully quit and relaunch VS Code (not just "Reload Window") so the process inherits the env var.
  4. Server fails to connect / registers no tools - consistent with the literal unsubstituted string ${env:MY_VAR} being sent as the header value (401 from the remote endpoint).

Workaround: hardcoding the literal secret value directly in headers works immediately - confirms substitution is the issue, not auth/connectivity/env-var scoping.

Expected: ${env:VAR} should resolve in headers the same way it does in other MCP config contexts, or docs should explicitly state headers only supports ${input:...} (current docs are ambiguous/silent on this).

Activity

  1. oburlaca commented on Oct 7, 2026

    @oburlaca

    I confirm the issue. Nothing is interpolated, i.e. ${env:} or even ${input:paddle-sandbox-api-key}
    VS Code version: 1.140
    I've used mitmproxy to see what vscode does:

    Image

    Here is my workspace .mcp.json config:

    {
    	"inputs": [
    		{
    			"id": "paddle-sandbox-api-key",
    			"type": "promptString",
    			"description": "Paddle sandbox API key",
    			"password": true
    		}
    	],
    	"mcpServers": {
    		"sandbox-paddle": {
    			"url": "https://sandbox-mcp.paddle.com/mcp",
    			"type": "http",
    			"headers": {
    				"Authorization": "Bearer ${input:paddle-sandbox-api-key}"
                }
    	}
    }
  2. oburlaca commented on Oct 7, 2026

    @oburlaca

    In my example above I'm using the new .mcp.json format. It doesn't support interpolation. Use the old /.vscode/mcp.json.

    see this issue

  3. dmitrivMS commented on Oct 27, 2026

    @dmitrivMS
    Collaborator

    Portable config the syntax is ${MY_VAR}, not ${env:MY_VAR} or ${input:...} - those not supported there.
    So for example "Authorization": "Bearer ${MY_VAR}"

    Could you please try the correct syntax and let me know if it still does not work for you?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions