6 Ways to Add an MCP Server in Visual Studio Code

Each method caters to different use cases (e.g., solo projects, team collaboration, containerized environments, or automation).

Before starting, remember: Only add MCP servers from trusted sources—local servers can run arbitrary code on your machine.

1. From the GitHub MCP Server Registry (Extensions View)

Use Case

Quick, one-click installation of pre-listed MCP servers (best for common, trusted servers).

Step-by-Step

  1. Enable the MCP gallery: Open VS Code settings (Ctrl,,/⌘,,), search for chat.mcp.gallery.enabled, and check the box.
  2. Open the Extensions view (⇧⌘X/Ctrl+Shift+X).
  3. Search for @mcp to filter MCP servers from the GitHub registry (or run MCP: Browse Servers via the Command Palette ⇧⌘P/Ctrl+Shift+P).
  4. Install:
    • User-wide: Click Install (available across all workspaces).
    • Workspace-only: Right-click the server → Install in Workspace.

2. Manual Configuration in Workspace mcp.json

Use Case

Share custom MCP server configs with your team (project-specific setup).

Step-by-Step

  1. In your project root, create a .vscode folder (if missing), then add a mcp.json file inside it.
  2. Open mcp.json—click the Add Server button for a template (VS Code provides IntelliSense for validation).
  3. Add your server config (e.g., GitHub remote MCP server): { "servers": { "github-mcp": { "type": "http", "url": "<https://api.githubcopilot.com/mcp>" } } }
  4. Critical: Never hardcode API keys/credentials—use environment variables or input variables instead.

3. Add to User Global Configuration

Use Case

Reuse the same MCP server across all your VS Code workspaces (global setup).

Step-by-Step

Method A (Command Palette)

  1. Open the Command Palette (⇧⌘P/Ctrl+Shift+P) → run MCP: Add Server.
  2. Enter the server details (type, URL/command, args) → select Global to save to your user profile.

Method B (Manual Edit)

  1. Run MCP: Open User Configuration via the Command Palette (opens your user-level mcp.json).
  2. Manually add the server config (same format as the workspace mcp.json example above).

Key Tip

Use VS Code profiles to assign different MCP servers to different workflows (e.g., Playwright MCP for web dev, Python MCP for data science).

4. Configure in Dev Containers

Use Case

Integrate MCP servers into containerized development environments (shared team dev setups).

Step-by-Step

  1. Open your project’s devcontainer.json file (create one if missing in .devcontainer/).
  2. Add the MCP server config under customizations.vscode.mcp: { "image": "mcr.microsoft.com/devcontainers/typescript-node:latest", "customizations": { "vscode": { "mcp": { "servers": { "playwright": { "command": "npx", "args": ["-y", "@microsoft/mcp-server-playwright"] } } } } } }
  3. Rebuild the Dev Container—VS Code auto-writes the config to the remote mcp.json in the container.

5. Auto-Discover from Other Applications

Use Case

Reuse MCP server configs from external tools (e.g., Claude Desktop) without manual setup.

Step-by-Step

  1. Open VS Code settings (Ctrl+,/⌘+,), search for chat.mcp.discovery.enabled, and enable the toggle.
  2. Select the tools you want to auto-discover MCP servers from (VS Code lists supported apps like Claude Desktop).
  3. VS Code will automatically detect and import valid MCP server configs from the selected tools.

6. Install via VS Code Command Line (CLI)

Use Case

Automate MCP server installation (e.g., in scripts, CI/CD, or batch setups).

Step-by-Step

  1. Open your terminal (Command Prompt, Terminal, Bash).
  2. Run the code --add-mcp command with your server config (JSON string)
# Add to user profile (global)
code --add-mcp "{\"name\":\"my-custom-server\",\"command\":\"uvx\",\"args\":[\"mcp-server-fetch\"]}"

# Add to a specific workspace (replace ./my-project with your project path)
code --folder-uri ./my-project --add-mcp "{\"name\":\"workspace-server\",\"type\":\"http\",\"url\":\"https://custom-mcp-server.com\"}"

Note

Ensure the JSON string is properly escaped (e.g., \\\\" instead of ") for terminal compatibility.

See also: Mastering the Linux Command Line — Your Complete Free Training Guide


Summary

  1. Security first: Only trust MCP servers from verified sources—local servers can execute arbitrary code on your machine.
  2. Match method to use case: Use the GitHub registry for quick installs, workspace mcp.json for team projects, Dev Containers for containerized setups, and CLI for automation.
  3. Execution context: User-configured MCP servers run locally; remote/workspace-configured servers run on the target machine (remote/container).
David Cao
David Cao

David is a Cloud & DevOps Enthusiast. He has years of experience as a Linux engineer. He had working experience in AMD, EMC. He likes Linux, Python, bash, and more. He is a technical blogger and a Software Engineer. He enjoys sharing his learning and contributing to open-source.

Articles: 583

Leave a Reply

Your email address will not be published. Required fields are marked *