Skip to content

[BUG] .env variable substitution in .mcp.json works in Cursor but not VS Code #14032

Description

@apelosi

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • I am using the latest version of Claude Code

What's Wrong?

Cursor: using Claude Code for VS Code extension 2.0.62 - 6 days ago (current)
VS Code: using Claude Code for VS Code extension 2.0.65 - 4 days ago (current)

Both IDEs are pointed to the same local project folder. I started with the following in .mcp.json:
{
"mcpServers": {
"supabase": {
"type": "http",
"url": "https://mcp.supabase.com/mcp?project_ref=${SUPABASE_PROJECT_REF}",
"headers": {
"Authorization": "Bearer ${SUPABASE_ACCESS_TOKEN}"
}
}
}
}

Claude Code extension for VS Code in Cursor is able to connect to Supabase and read the tables, but Claude Code extension for VS Code in VS Code is not. Tells me I need to auth. Even when it says it can now see the env variables and I need to do a developr refresh or restart, and subsequently do both, it still says not connected to supabase. IT suggested I hardcode the variable values in .msp.json and then it connected to Supabase right away. This is not ideal because it means specifying the value of these variables in multiple places and not having a single source of truth for their values. Not a hypothetical issue because we did in fact just change our Supabase instance.

Image

What Should Happen?

Not sure if this is simply a limitation of VS Code, or something extra Claude Code needs to do in VS Code to get this to work, but Claude Code extension in VS Code should hopefully work the same way as Claude Code extension in Cursor when it comes to being able to specify env variables in .mcp.json instead of having to hardcode them.

Error Messages/Logs

Steps to Reproduce

  1. Use variable references in your .mcp.json file for and mcp server (for example, supabase, using the following, or any other mcp config)

{
"mcpServers": {
"supabase": {
"type": "http",
"url": "https://mcp.supabase.com/mcp?project_ref=${SUPABASE_PROJECT_REF}",
"headers": {
"Authorization": "Bearer ${SUPABASE_ACCESS_TOKEN}"
}
}
}
}

  1. attempt to access the mcp server using Claude Code extensions in both Cursor and VS Code

  2. Verify it successfully connects in Cursor but not in VS Code

  3. Attempt to get VS Code to read the .env file and know that it should replace the referenced variables with their values from the .env file when acessing the mcp server defined, and do a developer refresh, and then restart VS code. Try again and see if you can connect to the mcp server (you probably won't).

  4. Hardcode the values in .mcp.json now and test mcp connection. It should work. This proves that Claude Code extension in Cursor can successfully deal with env variable references in .mcp.json but Claude Code extension in VS Code can not.

Claude Model

Sonnet (default)

Is this a regression?

I don't know

Last Working Version

No response

Claude Code Version

2.0.65

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

VS Code integrated terminal

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:idearea:mcpbugSomething isn't workinghas reproHas detailed reproduction stepsplatform:macosIssue specifically occurs on macOSstaleIssue is inactive

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions