Skip to content

How to add an MCP server to VS Code

Level 3: Connect AI to your tools. About 7 min. Checked on 19 November 2026.
Stage 3 of 4: Connect AI to your tools

In this lesson you'll add MCP servers to VS Code for your user or one workspace, keep API keys out of the file, and check that Copilot uses them.

Copilot in VS Code is good with the code in front of it. Ask it about your team's documentation, a browser test or a ticket, and it has to guess. MCP servers give Copilot's agent new tools, and VS Code offers two ways to add them: a short guided form, or a JSON file you can share.

Pick a servera publisher you trustAdd it in VS CodeMCP: Add ServerSign in or restartso tools loadTry, approveone small task
Adding a server, step by step. Pick a server you trust, add it to your app (a URL or a command), sign in or restart, then try a small task and approve the first tool call.

The quick way: the form

As of 19 November 2026, VS Code's docs describe these steps:

  1. Make sure AI features are on and a folder is open.
  2. Run Chat: Open Customizations from the Command Palette and select MCP Servers.
  3. Select Add Server (+) in the User group.
  4. Choose HTTP (HTTP or Server-Sent Events) and paste a URL for a remote server, or Command (stdio) and enter the command for a local one.

MCP: Add Server in the Command Palette walks you through the same thing.

The shareable way: mcp.json

VS Code reads two files with the same format:

  • .vscode/mcp.json in a workspace, for that workspace (and your team, if you commit it).
  • Your user mcp.json, for every workspace. Open it with MCP: Open User Configuration.

The exact entries for a remote server (Context7, library documentation) and a local one (Microsoft's Playwright browser server):

Context7 in VS Code. Add to .vscode/mcp.json:

Install in VS Code
{
  "servers": {
    "context7": {
      "type": "http",
      "url": "https://mcp.context7.com/mcp"
    }
  }
}

Built from the server's registry entry, the same config as on its listing page.

Playwright MCP in VS Code. Add to .vscode/mcp.json:

Install in VS Code
{
  "servers": {
    "playwright-mcp": {
      "type": "stdio",
      "command": "npx",
      "args": [
        "-y",
        "@playwright/mcp"
      ]
    }
  }
}

Built from the server's registry entry, the same config as on its listing page.

Keep API keys out of the file

Don't paste keys into mcp.json, least of all one you commit. Declare an input instead. VS Code asks 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}"
      }
    }
  }
}

Remote servers can sign in with OAuth instead; the reference documents an oauth object with a clientId.

Check that it worked

Copilot picks relevant tools by itself, so you don't have to name the server every time.

To switch a server off, open Chat: Open Customizations → MCP Servers and use the … menu to Disable or Uninstall it. Stopping a server only ends its current run; the next request can start it again.

Servers worth a look

MCP servers for developer tools from the directory, most popular first.

More for developer tools
  1. Official MCP server connecting AI assistants to GitHub repos, issues and workflows

    • Remote
    • Open source
    • 34.6K GitHub stars
    • Developer tools
  2. Python framework for building MCP servers, clients and interactive apps

    Not checked yet
    • Open source
    • 28.7K GitHub stars
    • Developer tools
  3. Local MCP server that builds a code knowledge graph for AI coding agents

    Runs locally
    • Open source
    • 48.8K GitHub stars
    • Knowledge and memory
  4. Local search engine for AI agents with cited answers over your code and docs

    Runs locally
    • Open source
    • 19.2K GitHub stars
    • Knowledge and memory
  5. CLI and MCP server that lets coding agents reverse engineer apps and binaries

    Runs locally
    • Open source
    • 468K GitHub stars
    • Developer tools

Stay safe

VS Code's docs warn that local servers can run code on your machine and that tools can use services with your permissions. Before you install or start a server, check who publishes it, its command or URL and the access it asks for, and read trust prompts before you accept them.

In short

  • Quick: Chat: Open Customizations → MCP Servers → Add Server.
  • Shareable: .vscode/mcp.json with servers and a type on each entry.
  • Keys go in inputs, never in the file.

What to try next

Share this lesson
  • Connect a hosted server to ChatGPT, where only URLs work.
  • See why one server works in all these apps: MCP server vs API.

Lesson 4 of 13 in this path

Words used in this lesson

Sources

Official documentation, checked on 19 November 2026. Products change: if a step differs, the source has the current version.

Get the next lesson

New Academy lessons are announced in the weekly AI-Powered email.