Where are MCP servers configured in VS Code and how do I pass secrets?
I'm setting up MCP servers in VS Code and the team's March 2025 thread describes config in a repo or in settings. Where exactly should the MCP server config live, and what JSON keys are used? It also mentions using variables to prompt for secrets, but I'm not sure which release shipped this or what the final schema looks like.
Originally asked on GitHub: https://github.com/microsoft/vscode/issues/242864
1 answer
This is a VS Code team tracking issue for initial MCP server support, opened 2025-03-07 and closed as completed; it describes the intended design and does not name a shipped VS Code version. The proposed model is configurable both globally and per-workspace. A repository can contain
.vscode/mcp.json, and a workspace, remote, or globalsettings.jsoncan have anmcpsection. The issue's base example follows Claude Desktop's shape:json{ "mcpServers": { "postgres-server": { "command": "npx", "args": ["-y", "@modelcontextprotocol/server-postgres", "postgresql://localhost/mydb"], "env": {} } } }For secrets it proposes reusing the tasks/launch.json
inputsmechanism with${input:...}references andpassword: truekeys. The second sample in the thread uses a top-levelserverskey rather thanmcpServers, so the thread itself does not settle the key name. A CLI hook such ascode --add-mcp <json> [--workspace <path>]was also proposed so registry installers likenpx opentools ican add servers deterministically. Servers discovered ambiently on the machine, for example from Claude Desktop's config, should only run after you consent in the UI. General advice: keep connection strings and tokens in the${input:...}prompt or secret storage instead of committing them to.vscode/mcp.json; this matches the thread's proposal and avoids leaking secrets.Did this work for you?