MCP.so
Sign In
Back to blog

VS Code MCP Setup: Add MCP Servers to GitHub Copilot Chat

Oct 15, 2026MCP.so TeamMCP.so Team

VS Code MCP setup: install servers from the @mcp gallery, configure .vscode/mcp.json or .mcp.json, store secrets with inputs, sign in with OAuth and fix errors.

How to Add an MCP Server in VS Code

The fastest way to add an MCP server in VS Code is the built-in gallery: open the Extensions view, search @mcp, and click Install. For anything not in the gallery, run MCP: Add Server from the Command Palette or edit a config file yourself: .vscode/mcp.json (servers under servers) or the portable .mcp.json (servers under mcpServers). The server's tools then show up for the agent in GitHub Copilot Chat.

Everything here is checked against the official VS Code docs: Add and manage MCP servers and the MCP configuration reference. Looking for servers to try? Browse the MCP server directory.

Quick Reference

TaskHow
Install from the galleryExtensions view, search @mcp, Install (or right-click, Install in Workspace)
Guided setupCommand Palette, MCP: Add Server
Workspace config (VS Code format).vscode/mcp.json, top-level servers
Workspace config (portable format).mcp.json at the workspace root, top-level mcpServers
User configMCP: Open User Configuration
Start, stop, view logsMCP: List Servers, pick a server
Toggle individual toolsConfigure Tools in the chat input
Install from the CLIcode --add-mcp '...json...'
Clear stale toolsMCP: Reset Cached Tools

Step 1: Install from the MCP Gallery

VS Code has an MCP server gallery inside the Extensions view:

  1. Open the Extensions view and type @mcp in the search box (for example @mcp playwright).
  2. Click Install to add the server to your user profile, or right-click it and choose Install in Workspace to write it to .vscode/mcp.json.
  3. When prompted, confirm that you trust the server. VS Code starts it and discovers its tools.
  4. Open the Chat view and ask for something the server can do, such as "open code.visualstudio.com and take a screenshot" for the Playwright MCP server.

The same gallery is reachable from MCP: Add Server, then Browse MCP Servers.

Step 2: Configure mcp.json by Hand

For servers outside the gallery, or to share a setup with your team, write the config yourself. VS Code reads four locations:

ScopeFileTop-level keyBest for
Workspace.mcp.json at the rootmcpServersSharing with your team and other Copilot tools
Workspace.vscode/mcp.jsonserversVS Code-only features: input variables, dev mode, sandboxing
User~/.copilot/mcp-config.json (or $COPILOT_HOME/mcp-config.json)mcpServersPersonal servers shared with Copilot CLI
User profilemcp.json in your profile (MCP: Open User Configuration)serversProfile-specific servers

The docs now call the workspace-root .mcp.json the preferred place to share servers, because the same file works in other tools. .vscode/mcp.json remains the format that supports VS Code extras, so this guide uses it for the examples. Commit either file to source control, without secrets.

A local (stdio) server and a remote (HTTP) server

{
  "servers": {
    "github": {
      "type": "http",
      "url": "https://api.githubcopilot.com/mcp"
    },
    "memory": {
      "type": "stdio",
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-memory"]
    }
  }
}

The first entry is the remote GitHub MCP server; the second runs the Memory MCP server locally. In the portable .mcp.json, the same entries go under mcpServers instead of servers.

Fields at a glance:

  • stdio: type ("stdio"), command, args, cwd, env, envFile, plus dev and sandboxEnabled.
  • HTTP/SSE: type ("http" or "sse"), url, headers, oauth. With "http", VS Code tries Streamable HTTP first and falls back to SSE if the server doesn't support it.

command must be on your PATH or be a full path. If you run a server in Docker, don't use the detach flag (-d): stdio servers must stay in the foreground. VS Code gives IntelliSense in these files, so typos in field names show up immediately.

Step 3: Keep Secrets Out with Input Variables

Hardcoded API keys in a committed mcp.json are the classic mistake. In .vscode/mcp.json you can declare inputs: VS Code prompts for the value the first time the server starts, then stores it securely.

{
  "inputs": [
    {
      "type": "promptString",
      "id": "perplexity-key",
      "description": "Perplexity API Key",
      "password": true
    }
  ],
  "servers": {
    "perplexity": {
      "type": "stdio",
      "command": "npx",
      "args": ["-y", "server-perplexity-ask"],
      "env": {
        "PERPLEXITY_API_KEY": "${input:perplexity-key}"
      }
    }
  }
}

Input types are promptString (free text; password: true hides typing), pickString (a list of options) and command (the result of a VS Code command). Inputs also work in headers, for example "Authorization": "Bearer ${input:api-token}".

Alternatives: point a stdio server at a dotenv file with "envFile": "${workspaceFolder}/.env", and use predefined variables such as ${workspaceFolder} in paths. Note the format limits: inputs, envFile and dev mode only work in .vscode/mcp.json and profile mcp.json, not in the portable .mcp.json. Also, servers that need ${input:...} values aren't forwarded to Copilot harness sessions, which read the portable files directly.

Step 4: Authenticate Remote Servers

Most hosted servers use OAuth. When a server requires it, VS Code opens a browser window on the first connection and handles the flow for you. If the provider needs a pre-registered client, add an oauth object:

{
  "servers": {
    "slack": {
      "type": "http",
      "url": "https://mcp.slack.com/mcp",
      "oauth": {
        "clientId": "example-client-id"
      }
    }
  }
}

For API-key servers, send the key in headers with an input variable. Enterprises can also set "enterpriseManaged": true (preview) to sign in through their SSO issuer. For how MCP OAuth works under the hood, read our MCP authentication guide.

Step 5: Use the Tools in Copilot Chat

Once a server is running, its tools are available to the agent in the Chat view. You can:

  • Let the agent choose. It calls tools as needed and shows an approval prompt; expand the tool details to check the inputs, then click Allow.
  • Reference a tool directly by typing # in the chat input and picking the tool.
  • Toggle tools with Configure Tools in the chat input, so the agent only sees what the task needs.

The 128-tool limit. A chat request can have at most 128 tools enabled. If you see "Cannot have more than 128 tools per request", deselect tools or whole servers in the tool picker, or turn on virtual tools with the github.copilot.chat.virtualTools.threshold setting, which groups large tool sets automatically. Fewer, more relevant tools also make the agent's choices better; see MCP tool discovery.

MCP servers in VS Code can also provide resources, prompts and interactive MCP Apps, not just tools.

Other Ways to Add Servers

Command line:

code --add-mcp "{\"name\":\"my-server\",\"command\": \"uvx\",\"args\": [\"mcp-server-fetch\"]}"

Install links. Server authors can publish a vscode:mcp/install?... link: URL-encode the JSON config (name, command, args and so on) and append it. Clicking the link opens VS Code's install flow.

Reuse other apps' configs. The chat.mcp.discovery.enabled setting lets VS Code pick up servers already configured in Claude Desktop, Cursor, Windsurf or Copilot CLI. Copilot CLI discovery is on by default; the others are off.

Dev containers. Put servers under customizations.vscode.mcp.servers in devcontainer.json and VS Code writes them into the container's config.

Settings Sync. Run Settings Sync: Configure and enable MCP Servers to carry your setup across machines.

Trust and Sandboxing

Local MCP servers can run arbitrary code with your permissions. VS Code adds two guards:

  • Trust prompts. Workspace servers inherit Workspace Trust and don't start in restricted mode; servers from other sources ask for trust on first start or when their config changes. MCP: Reset Trust clears those decisions.
  • Sandboxing (macOS and Linux). Set "sandboxEnabled": true on a stdio server and use the sandbox object to allow writes only to certain folders or network access only to certain domains.

For a broader checklist, see MCP security best practices.

Troubleshooting VS Code MCP

When a server fails, the Chat view shows an error indicator. Click it and choose Show Output, or run MCP: List Servers, select the server and choose Show Output to read its log.

SymptomFix
Server never startsWorkspace is in restricted mode, or you declined the trust prompt. Trust the workspace or run MCP: Reset Trust.
command not found or ENOENTThe command isn't on VS Code's PATH. Use a full path to npx, uvx or python.
Docker-based server hangsRemove -d from the docker run args; stdio needs the container in the foreground.
Tools are missing or outdatedRestart the server from MCP: List Servers, then run MCP: Reset Cached Tools.
"Cannot have more than 128 tools per request"Deselect tools in Configure Tools or enable virtual tools.
Server works in chat but not in Copilot harness sessionsIt uses ${input:...}. Move it to .mcp.json with another way to pass the secret.
Remote server returns 401Missing sign-in or a wrong header value. Check the server's output log, complete the OAuth prompt, or fix the token you passed in headers.

If the log isn't conclusive, test the server alone with the MCP Inspector.

Next Steps

Frequently asked questions

Where is the MCP config file in VS Code?

Workspace servers go in .vscode/mcp.json (under 'servers') or in a portable .mcp.json at the workspace root (under 'mcpServers'). User-level servers live in your profile's mcp.json, which you open with 'MCP: Open User Configuration'.

Can VS Code use MCP servers I already set up in Claude Desktop or Cursor?

Yes. Turn on the chat.mcp.discovery.enabled setting and pick the sources, such as Claude Desktop, Cursor, Windsurf or Copilot CLI. Copilot CLI discovery is on by default and the others are off.

How do I pass an API key to an MCP server in VS Code without hardcoding it?

Declare an input in .vscode/mcp.json with type promptString and password set to true, then reference it from env or headers with the input variable syntax (input: followed by the input id). VS Code prompts once and stores the value securely.

How many MCP tools can VS Code use at once?

A chat request can have at most 128 tools enabled. Deselect tools in 'Configure Tools' or enable virtual tools with the github.copilot.chat.virtualTools.threshold setting if you hit the limit.