Skip to content

Support {workspaceFolder} Variable in .vscode/mcp.json Configuration #251263

Closed
@icai

Description

@icai

Summary

The .vscode/mcp.json configuration file should support VS Code's built-in {workspaceFolder} variable for path resolution, similar to how it works in tasks.json, launch.json, and other VS Code configuration files.

Problem Description

Currently, when using MCP (Model Context Protocol) servers with configuration files, we must use absolute paths in .vscode/mcp.json, which creates several issues:

  1. Portability: Configurations are not portable across different machines or users
  2. Team Collaboration: Different team members have different absolute paths
  3. Version Control: Absolute paths in committed files cause conflicts
  4. Maintenance: Hard to maintain when project locations change

Current Behavior

In .vscode/mcp.json, this configuration fails:

{
  "servers": {
    "playwright": {
      "command": "npx",
      "args": [
        "@playwright/mcp@latest",
        "--isolated",
        "--config",
        "{workspaceFolder}/playwright-mcp-config.json"
      ]
    }
  }
}

Error Message:

Error: Failed to load config file: {workspaceFolder}/playwright-mcp-config.json, Error: ENOENT: no such file or directory, open '{workspaceFolder}/playwright-mcp-config.json'

Expected Behavior

The {workspaceFolder} variable should be resolved to the absolute path of the workspace root, just like in other VS Code configuration files:

{
  "servers": {
    "playwright": {
      "command": "npx",
      "args": [
        "@playwright/mcp@latest",
        "--isolated",
        "--config",
        "{workspaceFolder}/playwright-mcp-config.json"
      ]
    }
  }
}

Should resolve to:

{
  "servers": {
    "playwright": {
      "command": "npx",
      "args": [
        "@playwright/mcp@latest",
        "--isolated",
        "--config",
        "/absolute/path/to/workspace/playwright-mcp-config.json"
      ]
    }
  }
}

Consistency with Other VS Code Features

VS Code already supports {workspaceFolder} in:

  • .vscode/tasks.json
  • .vscode/launch.json
  • .vscode/settings.json
  • Extension configurations

Example from tasks.json:

{
  "version": "2.0.0",
  "tasks": [
    {
      "label": "build",
      "command": "npm",
      "args": ["run", "build"],
      "options": {
        "cwd": "{workspaceFolder}"
      }
    }
  ]
}

Use Cases

  1. Multi-user Development: Teams can share the same MCP configuration
  2. CI/CD Pipelines: Automated builds with consistent paths
  3. Docker Containers: Mounted volumes with different paths
  4. Cross-platform Development: Windows/macOS/Linux compatibility

Workaround

Currently, we must use absolute paths:

{
  "servers": {
    "playwright": {
      "command": "npx",
      "args": [
        "@playwright/mcp@latest",
        "--isolated",
        "--config",
        "/Users/username/project/playwright-mcp-config.json"
      ]
    }
  }
}

This makes the configuration non-portable and causes issues in team environments.

Proposed Solution

Implement variable substitution for .vscode/mcp.json similar to other VS Code configuration files:

  1. Support {workspaceFolder} variable
  2. Support other common variables like {workspaceFolderBasename}, {file}, etc.
  3. Apply variable resolution before passing arguments to MCP servers

Environment

  • VS Code Version: 1.96.x
  • OS: macOS/Windows/Linux
  • MCP Extension: Latest version
  • Reproduction: Any workspace with MCP configuration using relative paths

Steps to Reproduce

  1. Create a workspace with an MCP server configuration
  2. Use {workspaceFolder} in the config path within .vscode/mcp.json
  3. Try to start the MCP server
  4. Observe the "file not found" error

Additional Context

This feature would greatly improve the developer experience for MCP users and align with VS Code's existing variable substitution patterns used throughout the platform.

Related Issues

  • Similar variable substitution requests for other VS Code features
  • MCP configuration portability issues
  • Team collaboration with MCP servers

Priority: Medium
Labels: enhancement, mcp, configuration, developer-experience
Assignee: VS Code MCP Team

Metadata

Metadata

Assignees

Labels

*questionIssue represents a question, should be posted to StackOverflow (VS Code)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions