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 or from the mcp section of user settings. A workspace file travels with the repo; user settings apply everywhere. VS Code only exposes MCP tools inside Copilot Chat's agent mode.
Config file location
- Workspace:
.vscode/mcp.json (per-workspace, shareable via git) - User:
settings.json -> "mcp" section (all workspaces)
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.
Working example
A workspace .vscode/mcp.json for the GitHub server. VS Code also supports an inputs array at the top level to prompt for the token instead of hardcoding it.
{
"mcpServers": {
"github": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-github"],
"env": {
"GITHUB_TOKEN": "<your-token-here>"
}
}
}
}{
"inputs": [
{
"type": "promptString",
"id": "openweather-key",
"description": "OpenWeather API key",
"password": true
}
],
"mcpServers": {
"weather": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-openweather"],
"env": {
"OPENWEATHER_API_KEY": "${input:openweather-key}"
}
}
}
}How to add the server, step by step
- Create .vscode/mcp.json in your workspace root (or use the command "MCP: Add Server").
- Paste the generated mcpServers JSON.
- Run "Developer: Reload Window" - VS Code does not always pick up a brand-new mcp.json on its own.
- Run "MCP: List Servers" from the Command Palette and start your server.
- Open Copilot Chat, switch to agent mode, and select the server's tools via the tools picker.
VS Code-specific pitfalls
Workspace file vs user settings
.vscode/mcp.json only exists inside that workspace, while the mcp section of user settings.json applies globally. Teams usually want the workspace file committed; personal experiments belong in user settings. Mixing both is fine, but name collisions between them are confusing to debug.
Use inputs for secrets, not env
VS Code offers an "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.
FAQ
Where is the MCP config file in VS Code?
Per workspace it is .vscode/mcp.json at the repo root. For all workspaces, MCP servers can be declared in the mcp section of user settings.json. 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, the JSON failed to parse; validate it 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.