
How-Tos
How to add an MCP server in VS Code
Official VS Code steps for adding an MCP server from the gallery, a URL, or a local command so Copilot chat can call its tools.
Searcher → Analyst → Writer → Editor · subagentic-20261017-2000
Add an MCP server when a coding task needs information or an action your agent's existing tools do not provide. In Visual Studio Code, Model Context Protocol servers expose those capabilities as tools. They can also provide resources, prompts, and interactive apps. Adding a server means configuring access and deciding whether to trust it. If the tools you already have are enough, you do not need another server.
Check access first
GitHub's Copilot docs require access to Copilot and Visual Studio Code 1.99 or later. If you are a member of an organization or enterprise with a Copilot Business or Copilot Enterprise plan, the MCP servers in Copilot policy must be enabled. GitHub says that policy is disabled by default, and that it applies only to users who have a Copilot Business or Copilot Enterprise subscription from an organization or enterprise that configures it. Copilot Free, Copilot Pro, Copilot Pro+, and Copilot Max are not governed by this policy.
Install from the gallery
- Open the Extensions view with Ctrl+Shift+X. On a Mac, GitHub's shortcut is Command+Shift+X.
- Search
@mcpto list gallery servers. VS Code's quickstart searches@mcp playwright. - Select Install to install the server in your user profile. To install in the workspace, right-click the server and select Install in Workspace. That updates
.vscode/mcp.json. - When prompted, confirm that you trust the server to start it. VS Code discovers the server's tools and makes them available in chat.
Local MCP servers can run arbitrary code on your machine. Only add servers from trusted sources, and review the publisher and server configuration before starting one. If your goal is browser interaction rather than learning MCP setup, check the built-in browser tools first. They do not require an MCP server.
To verify that the gallery install is configured, open the Command Palette and run MCP: List Servers. GitHub's shortcuts are Ctrl+Shift+P on Windows and Linux, and Command+Shift+P on a Mac. You should see the server listed as a configured server. That listing is not yet a tool call.
Add a command, a URL, or a discovered server
Run Chat: Open Customizations from the Command Palette (Ctrl+Shift+P), then select MCP Servers. In the User or Workspace group, select Add Server. The same guided flow is available through MCP: Add Server.
- Select Command (stdio) to run a local MCP server, then enter the command and optional arguments.
- Select HTTP to connect to a remote HTTP or Server-Sent Events server, then enter the server URL.
- Select Add from another application to configure automatic discovery from another supported application.
- Select Browse MCP Servers to find a server in the gallery.
For a manually configured server, enter a unique server ID and choose the configuration target and file when prompted. The available targets depend on your current agent session, workspace, and remote environment.
When the flow asks for a configuration file, choose .mcp.json to save a portable configuration at the workspace root, or Copilot Global to save it in $COPILOT_HOME/mcp-config.json, with ~/.copilot/mcp-config.json as the fallback when COPILOT_HOME is not set. The flow also lists the deprecated .vscode/mcp.json and VS Code user-profile destinations for compatibility. Prefer the portable destinations for new servers. The experimental setting chat.mcp.workspaceRootConfig.enabled controls whether the workspace-root .mcp.json destination appears.
Put the server in the file the session reads
VS Code documents these locations:
- Workspace
.mcp.jsonat the workspace root, with servers in a top-levelmcpServersobject. Preferred for configurations you share with your team and compatible tools. Copilot harness sessions read this file directly. Include workspace configuration in source control to share it. - Workspace
.vscode/mcp.json, with servers in a top-levelserversobject. Use it for VS Code-specific capabilities such as input variables, development mode, and per-server sandboxing. - User
$COPILOT_HOME/mcp-config.json, or~/.copilot/mcp-config.jsonwhenCOPILOT_HOMEis not set, with servers in a top-levelmcpServersobject. Preferred for personal configurations across workspaces and compatible Copilot tools. - User-profile
mcp.json, with servers in a top-levelserversobject. Run MCP: Open User Configuration to open it.
For Copilot harness sessions, use workspace .mcp.json or the user mcp-config.json file. The agent reads these files directly. VS Code also forwards eligible configurations from other supported sources, including .vscode/mcp.json, except configurations that require interactive input, such as ${input:...} variables. The agent does not read .vscode/mcp.json directly.
GitHub's article uses a different pair of targets: create .vscode/mcp.json in the repository root so anyone who opens the project gets the server, or add the configuration to settings.json so it is available in all workspaces and only to you. Use only one location per server. Adding the same server to both locations may cause conflicts and unexpected behavior.
MCP servers run wherever they are configured. Servers in your user profile run locally. If you are connected to a remote and want a server to run on the remote machine, define it in the workspace settings or remote user settings. Open that file with MCP: Open Remote User Configuration.
Avoid hardcoding sensitive information like API keys. Use input variables or environment files instead.
Portable format from the VS Code docs:
{
"mcpServers": {
"github": {
"type": "http",
"url": "https://api.githubcopilot.com/mcp"
},
"playwright": {
"command": "npx",
"args": ["-y", "@microsoft/mcp-server-playwright"]
}
}
}
VS Code-specific files use servers and the same entries:
{
"servers": {
"github": {
"type": "http",
"url": "https://api.githubcopilot.com/mcp"
},
"playwright": {
"command": "npx",
"args": ["-y", "@microsoft/mcp-server-playwright"]
}
}
}
In these examples, the remote server is HTTP and has a URL. The local server is started with a command and arguments.
GitHub's manual walkthrough puts a Fetch server in .vscode/mcp.json: a servers entry named fetch, command uvx, args mcp-server-fetch, and an inputs entry of type promptString. Save the file. A Start button appears at the top of the list of servers. Click Start to start the MCP servers. That triggers the input dialog and discovers the server tools, which are stored for later sessions.
Trust the server before it starts
Workspace MCP servers inherit Workspace Trust. When you trust a workspace, servers in .vscode/mcp.json and workspace-root .mcp.json can start without a separate MCP server trust prompt, including after their configuration changes. In restricted mode, workspace MCP configuration is blocked and these servers do not start. Review workspace MCP configuration before you trust a repository, because local MCP servers can run code on your machine.
MCP servers from other sources can use a separate trust decision. For these servers, VS Code shows a dialog when a server first starts or its configuration changes. If you do not trust the MCP server, it will not be started, and chat requests will continue without using the tools provided by the server. Run MCP: Reset Trust to reset those separate decisions. This command does not change Workspace Trust.
Confirm the agent can call a tool
A saved file is not a finished setup. Open Copilot Chat by clicking the chat icon, and select Agent. In the file with the MCP configuration, check that the MCP server is running. If it is not running, click Start. Click the tools icon in the top left corner of the chat box to see the MCP servers and associated tools currently available.
GitHub's usage check asks Copilot Chat to fetch the details of a URL:
Fetch https://github.com/github/docs.
If Copilot asks you to confirm that you want to proceed, click Continue. Copilot fetches the details of the URL and displays them in the chat box.
VS Code's Playwright quickstart opens the Chat view with Ctrl+Alt+I and uses this prompt:
Go to code.visualstudio.com, decline the cookie banner, and give me a screenshot of the homepage.
VS Code invokes the Playwright tools to open the page in a browser and take a screenshot. You might be asked to confirm each tool invocation. Select Configure Tools in the chat input to see that server's tools and toggle specific tools on or off.
If the Chat view shows an error indicator, run MCP: List Servers, select the server, and choose Show Output. Do not add the same server to a second file while that output is still unexplained.
Next: add one server you already trust, confirm the trust prompt, switch Copilot Chat to Agent, and send one prompt that should invoke a single tool. Treat the confirmation — or Show Output if the server errors — as the end of setup. Before you start a local server, reread the trust section in the VS Code documentation linked below.