Add MCP Servers to VS Code for AI Agent Tools

Install MCP servers via VS Code extensions or mcp.json to give AI agents access to tools like browsers, databases, and APIs, with built-in trust prompts and sandboxing for security.

Install MCP Servers via Extensions for Instant AI Tool Access

Search @mcp or @mcp playwright in the Extensions view (⇧⌘X) to find and install servers like Playwright MCP from the gallery. User installs go to your profile; right-click for workspace installs, updating .vscode/mcp.json. Confirm trust in the dialog to start—VS Code auto-discovers tools for chat. Prompt example: "Go to code.visualstudio.com, decline cookie banner, screenshot homepage" invokes browser tools, with optional confirmation per call. Toggle tools via Configure Tools button.

Manually edit mcp.json (user or .vscode/mcp.json) for custom setups:

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

Use MCP: Add Server command for guided addition. Avoid hardcoding API keys—use input variables. For remotes/Dev Containers, configure in devcontainer.json under customizations.vscode.mcp. CLI add: code --add-mcp '{"name":"my-server","command":"uvx","args":["mcp-server-fetch"]}'. Enable chat.mcp.discovery.enabled to reuse from apps like Claude Desktop.

Secure Servers with Sandboxing and Centralized Management

On macOS/Linux, set "sandboxEnabled": true in mcp.json for stdio servers, restricting filesystem/network:

{
  "servers": {
    "myServer": {
      "type": "stdio",
      "command": "npx",
      "args": ["-y", "@example/mcp-server"],
      "sandboxEnabled": true,
      "sandbox": {
        "filesystem": { "allowWrite": ["${workspaceFolder}"] },
        "network": { "allowedDomains": ["api.example.com"] }
      }
    }
  }
}

Auto-approves tool calls in sandbox. Organizations control via GitHub policies. Trust resets with MCP: Reset Trust. Sync configs across devices via Settings Sync by enabling MCP Servers in Settings Sync: Configure.

Manage, Debug, and Extend with Resources, Prompts, Apps

Manage via Extensions view (right-click/gear), mcp.json lenses (MCP: Open User/Workspace Config), or MCP: List Servers commands: start/stop, logs, uninstall, cache clear. Enable/disable per server/workspace without altering mcp.json. Auto-restart on config changes with chat.mcp.autoStart (Experimental).

Beyond tools, access:

  • Resources: Add read-only context (files/DBs/APIs) via Add Context > MCP Resources or MCP: Browse Resources.
  • Prompts: /<server>.<prompt> for templates.
  • Apps: Inline UIs (forms/visuals) auto-render if supported.

Debug: Click Chat error > Show Output, or MCP: List Servers > Show Output. Check detached containers avoid -d flag.

Summarized by x-ai/grok-4.1-fast via openrouter

6569 input / 1646 output tokens in 7615ms

© 2026 Edge