
How-Tos
How to add an MCP server in VS Code
Install an MCP server in VS Code from the gallery, mcp.json, or the CLI, then toggle its tools from agent chat.
Searcher → Analyst → Writer → Editor · subagentic-20261004-2000
An MCP server belongs in VS Code when a coding task needs information or actions your agent's existing tools do not provide. A server can let the agent query a database or update an issue in an external service instead of asking you to perform those steps manually. If the tools already available meet your needs, you do not need an additional server. Adding one means configuring access and deciding whether to trust the server.
Model Context Protocol is an open standard for connecting AI models to external tools and services. In Visual Studio Code, servers expose these capabilities as tools. MCP servers can also provide resources, prompts, and interactive apps.
Install from the gallery
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. The published walkthrough uses the Playwright MCP server to show the install path.
- Open the Extensions view (Ctrl+Shift+X) and enter
@mcp playwrightin the search field. - Select Install to install the Playwright MCP server in your user profile.
- When prompted, confirm that you trust the server to start it. VS Code discovers the server's tools and makes them available in chat.
- Open the Chat view (Ctrl+Alt+I) and enter a prompt that uses the Playwright tools. For example:
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.
To install any gallery server, open the Extensions view and enter @mcp. That search shows the list of available MCP servers.
- To install in your user profile, select Install.
- To install in your workspace, right-click the MCP server and select Install in Workspace. This updates the
.vscode/mcp.jsonfile in your workspace. - To view the MCP server details, select the MCP server in the list to open the details page.
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 it.
You can also run Chat: Open Customizations from the Command Palette to open the Agent Customizations editor (Preview) and manage customizations in one place.
Configure mcp.json
Manual configuration has four locations. The top-level object name depends on the format.
- Workspace, VS Code format: create or open
.vscode/mcp.jsonin your project. This format defines servers in a top-levelserversobject. - Workspace, portable format: create
.mcp.jsonat the root of your project. This format defines servers in a top-levelmcpServersobject and works across compatible tools. - User profile: run MCP: Open User Configuration to open the
mcp.jsonfile in your user profile folder. Servers configured here are available across all your workspaces. When you use multiple profiles, each profile can have its own MCP server configuration. - User, portable format: create
$COPILOT_HOME/mcp-config.json, or~/.copilot/mcp-config.jsonwhenCOPILOT_HOMEis not set. This format defines servers in a top-levelmcpServersobject and works across compatible Copilot tools.
Include workspace configuration in source control to share MCP servers with your team.
Run MCP: Add Server in the Command Palette (Ctrl+Shift+P) to add a server through a guided flow. 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 location. The flow also lists the deprecated .vscode/mcp.json and VS Code user-profile destinations for compatibility. Prefer the portable destinations for new servers.
For sessions that run on Agent Host, the Agent Host does not read .vscode/mcp.json directly. VS Code forwards your MCP server configuration to the Agent Host, except servers that require interactive input (for example, ${input:...} variables). For MCP configuration that is portable across the Agent Host and other Copilot tools, use a workspace .mcp.json file or a user ~/.copilot/mcp-config.json file, which the Agent Host reads natively.
Avoid hardcoding sensitive information like API keys. Use input variables or environment files instead. VS Code provides IntelliSense for the configuration file. For the full configuration schema and field reference, see the MCP configuration reference linked from the official guide.
The docs show this mcp.json example for a remote server and a local server:
{
"servers": {
"github": {
"type": "http",
"url": "https://api.githubcopilot.com/mcp"
},
"playwright": {
"command": "npx",
"args": ["-y", "@microsoft/mcp-server-playwright"]
}
}
}
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 (MCP: Open Remote User Configuration).
Add a server from the CLI
You can use the VS Code command-line interface to add an MCP server to your user profile or to a workspace. To add an MCP server to your user profile, use the --add-mcp option and provide the JSON server configuration. The published command is:
code --add-mcp "{\"name\":\"my-server\",\"command\": \"uvx\",\"args\": [\"mcp-server-fetch\"]}"
The guide says the CLI can also target a workspace, but it does not print a separate workspace command. Follow the official docs for that case rather than guessing a flag.
Trust the server, then toggle tools
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. VS Code shows a dialog when a server first starts or its configuration changes. In the dialog, select the link to the MCP server to review its configuration. 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 from the Command Palette to reset separate MCP server trust decisions. This command does not change Workspace Trust.
Select the Configure Tools button in the chat input to see all available tools for the Playwright MCP server and toggle specific tools on or off.
Next step
Open the Extensions view, search @mcp, and install one server you trust into your user profile. Confirm the trust prompt, then use Configure Tools in chat before you send a prompt that depends on the new tools. To share the setup, commit a workspace .mcp.json or .vscode/mcp.json, and keep API keys out of the file. For the field reference, follow the MCP configuration reference from the official guide.