When using Remote-SSH with MCP, ${env:NAME} in mcp.json resolves to the local environment variables instead of the remote

Where does the bug appear (feature/product)?

Cursor IDE

Describe the Bug

When using MCP over Remote-SSH, environment variables referenced in mcp.json (e.g., ${env:API_KEY}) fail to resolve because ${env:...} appears to use my local macOS environment (I found this by passing PATH into MCP tool and print it) instead of the remote Linux server environment, causing variables that exist only on the remote host to be “empty”. I was using Python fastmcp script as MCP tool.

Steps to Reproduce

  1. Use remote-ssh development enviorment
  2. Create a simple MCP tool as following:
# debug.py
import os
from fastmcp import FastMCP

mcp = FastMCP("debug")

@mcp.tool()
def get_env_var(name: str) -> str:
    """Get a specific environment variable."""
    return os.environ.get(name, f"{name} not found")

if __name__ == "__main__":
    mcp.run()

  1. Update your MCP setting file mcp.json to the following:
{
  "mcpServers": {
    "debug": {
      "command": "<Python path>",
      "args": ["<path to debug.py>"],
      "env": {
        "PATH": "${env:PATH}"
      }
    }
  }
}
  1. Ask the AI to run the MCP tool, the PATH of the local machine instead of the remote-ssh machine will be print out instead

Expected Behavior

When using remote-ssh with ${env:NAME} in mcp.json, it should reference to environment variables in remote-ssh machine instead of local

Operating System

MacOS

Current Cursor Version (Menu → About Cursor → Copy)

Version: 2.2.20
VSCode Version: 1.105.1
Commit: b3573281c4775bfc6bba466bf6563d3d498d1070
Date: 2025-12-12T06:29:26.017Z (4 days ago)
Electron: 37.7.0
Chromium: 138.0.7204.251
Node.js: 22.20.0
V8: 13.8.258.32-electron.0
OS: Darwin arm64 24.5.0

For AI issues: which model did you use?

Not related.

For AI issues: add Request ID with privacy disabled

Not related.

Additional Information

Nope.

Does this stop you from using Cursor

Sometimes - I can sometimes use Cursor

Thanks for the detailed bug report. I’ve raised this with the extensions team!

This topic was automatically closed 22 days after the last reply. New replies are no longer allowed.