How to Add an MCP Server to VS Code

Visual Studio Code is Microsoft's extensible editor, and its MCP support reads server definitions from .vscode/mcp.json in a workspace, under a top-level servers key - not mcpServers. A workspace file travels with the repo; a user-level file is managed through the MCP: Open User Configuration command, and its on-disk location varies by version. VS Code only exposes MCP tools inside Copilot Chat's agent mode.

Config file location

Generate a VS Code config

The tool below is pre-set to VS Code. Fill in the server and copy the JSON — it never leaves your browser.

Files are read locally; nothing is uploaded.

Working example

A workspace .vscode/mcp.json for the GitHub server, generated by this site's own VS Code generator: top-level servers and an explicit type:stdio. VS Code also supports a top-level inputs array to prompt for the token instead of hardcoding it.

{
  "servers": {
    "github": {
      "type": "stdio",
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-github"
      ],
      "env": {
        "GITHUB_TOKEN": "<your-token-here>"
      }
    }
  }
}
.vscode/mcp.json
{
  "inputs": [
    {
      "type": "promptString",
      "id": "openweather-key",
      "description": "OpenWeather API key",
      "password": true
    }
  ],
  "servers": {
    "weather": {
      "type": "stdio",
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-openweather"],
      "env": {
        "OPENWEATHER_API_KEY": "${input:openweather-key}"
      }
    }
  }
}
Workspace .vscode/mcp.json with a weather server and a top-level inputs placeholder so the API key is not hardcoded in the file.

How to add the server, step by step

  1. Create .vscode/mcp.json in your workspace root (or use the command "MCP: Add Server").
  2. Paste the generated servers JSON - the top-level key must be servers, not mcpServers.
  3. Run "Developer: Reload Window" - VS Code does not always pick up a brand-new mcp.json on its own.
  4. Run "MCP: List Servers" from the Command Palette and start your server.
  5. Open Copilot Chat, switch to agent mode, and select the server's tools via the tools picker.

VS Code-specific pitfalls

The wrapper key is servers, not mcpServers

Configs copied from Claude Desktop, Cursor, or Zed use mcpServers or context_servers - valid JSON that VS Code silently ignores. Rename the top-level key to servers and the same entries load. The generator above already emits the VS Code shape, and the diagnose tab flags the wrong wrapper as a blocking error.

Workspace file vs user-level config

.vscode/mcp.json only exists inside that workspace. A user-level file is created through the "MCP: Open User Configuration" command; its on-disk location has changed between versions, so the workspace file is the authoritative, shareable option. Name collisions between the two are confusing to debug.

Use inputs for secrets, not env

VS Code offers a top-level "inputs" array that prompts you for a value (like a token) the first time a server starts, storing it outside the file. That keeps .vscode/mcp.json safe to commit - a plain env block with a real token is the most common secret-leak in shared repos.

Tools only exist in agent mode

MCP servers start fine but appear to do nothing in ask or edit mode. The tools picker only shows MCP tools when Copilot Chat is in agent mode - check the mode dropdown before assuming the config is broken.

Silent spawn failures

A server that fails to launch does not produce a popup. Check the MCP output channel (View > Output, then pick your server) for ENOENT or exit-code messages - that is where "command not found" and npx prompts actually surface.

Related troubleshooting

FAQ

Where is the MCP config file in VS Code?

Per workspace it is .vscode/mcp.json at the repo root. For all workspaces, run "MCP: Open User Configuration" from the Command Palette - VS Code creates or edits the user-level file for you, and its on-disk location varies by version. The Command Palette command "MCP: Add Server" creates the right file for you.

Why is my MCP server not showing up in VS Code?

Reload the window first ("Developer: Reload Window"). Then run "MCP: List Servers" - if the server is listed but stopped, start it there. If it is missing entirely, check the top-level key is "servers" (not "mcpServers") and validate the JSON for trailing commas or unescaped backslashes.

How do I avoid putting tokens in .vscode/mcp.json?

Declare an entry in the top-level "inputs" array with a password-type prompt, then reference it as ${input:your-id} in the env block. VS Code asks for the value once and stores it outside the file, so the config stays safe to commit.

Configuring other clients too? See the guides forClaude Desktop,Cursor,VS Code,Windsurf,Zed andCline, or readhow MCP transports differ.