Model Context Protocol (MCP) is an open standard that enables AI models to interact with external tools and services via a unified interface. In Visual Studio Code (VS Code), MCP servers unlock capabilities like file operations, database interactions, and external API integrations for AI-powered chat and development workflows.
As one of three ways to extend VS Code Chat with tooling (alongside built-in tools and extension-contributed tools), MCP servers expand your AI assistant’s functionality to fit custom development needs.
This article provides a step-by-step guide to finding, configuring, using, and managing MCP servers in VS Code.
Important Note Your organization may restrict or disable MCP server usage in VS Code. If you encounter access issues, contact your system administrator for further guidance.
Compatibility Note MCP support in VS Code is generally available starting from version 1.102. Ensure you are running a compatible version before proceeding.
Table of Contents
1. Prerequisites
Before you start working with MCP servers, ensure you meet these requirements:
- Install the latest version of Visual Studio Code (update via
Help > Check for Updatesif needed). - Have active access to GitHub Copilot (MCP server functionality is tightly integrated with Copilot Chat).
- Familiarize yourself with basic VS Code navigation (Command Palette, Extensions view, Settings).
2. How Does MCP Work?
MCP acts as a bridge between VS Code’s AI chat interface and external tools. When you invoke an MCP-enabled tool in chat, VS Code sends requests to the configured MCP server.
The server executes the requested task (e.g., listing GitHub issues, querying a database) and returns structured responses to the AI model, which then formats the output for you.
This workflow ensures secure, standardized communication between VS Code, AI models, and third-party tools—without requiring custom extension development for every new integration.
3. Find and Add MCP Servers in VS Code
Finding MCP servers primarily involves exploring official or community-hosted registries, or configuring custom servers. Below are the most common methods to locate and add MCP servers to your VS Code environment.
See also: Mastering the Linux Command Line — Your Complete Free Training Guide
3.1 Find MCP Servers from the GitHub MCP Server Registry
The GitHub MCP Server Registry is the official repository for curated MCP servers, and it is the easiest way to discover pre-built servers for common tasks (e.g., GitHub integration, file system management).
Follow these steps to browse and install MCP servers from the registry:
- Enable the MCP Server Gallery: Open VS Code Settings (Ctrl+, / Cmd+,), search for
chat.mcp.gallery.enabled, and check the box to enable the setting. - Access the Extensions View: Open the Extensions panel (⇧⌘X / Ctrl+Shift+X) or use the Command Palette (⇧⌘P / Ctrl+Shift+P) to run the
MCP: Browse Serverscommand. - Search for MCP Servers: In the Extensions view search bar, type
@mcp—VS Code will filter results to show only MCP servers from the GitHub registry. - Install the Server:
- To install the server for your user profile (available across all VS Code workspaces): Click the
Installbutton next to the server name. - To install the server for the current workspace only: Right-click the server and select
Install in Workspace.
- To install the server for your user profile (available across all VS Code workspaces): Click the
- View Server Details: Click on any MCP server in the list to see its description, publisher information, supported tools, and configuration requirements.
3.2 Other Ways to Find and Add MCP Servers
If you need a custom or workspace-specific MCP server, use these alternative methods to locate and configure it:
- Add via
mcp.jsonWorkspace File: Define custom MCP servers in a workspace-levelmcp.jsonfile (see Section 8 for configuration format details). - User Configuration: Add MCP servers to your global VS Code settings for access across all projects.
- Dev Container Integration: Embed MCP server configurations in dev container setups to standardize tooling for team environments.
- Automatic Discovery: VS Code can detect locally running MCP servers (e.g., self-hosted models or tools) and prompt you to connect.
- Command Line Installation: Use VS Code’s command-line interface (CLI) to install MCP servers for automated setup workflows.
3.3 Explore Additional MCP Server Sources
MCP is a growing standard, and you can find more servers beyond the GitHub registry:
- Official MCP Server Repository: Visit the official MCP GitHub repository to explore core and community-contributed servers for use cases like database queries, web service integrations, and file system management.
- VS Code Marketplace: Search the marketplace for extensions that bundle MCP servers—many extensions automatically configure MCP servers during installation.
4. Use MCP Servers in VS Code Chat
Once you’ve added an MCP server, you can leverage its tools and resources in VS Code Chat to streamline development tasks.
4.1 Access MCP Tools in Chat
- Open the VS Code Chat view (⌃⌘I / Ctrl+Alt+I).
- Click the Tools icon in the chat input bar to open the tool picker. MCP tools are grouped by their respective servers.
- Select the tools you want the AI agent to use (you can toggle tools on/off as needed).
- Invoke tools in two ways:
- Automatic Invocation: Ask a natural language question (e.g., “List my open GitHub issues”), and the agent will automatically use the relevant MCP tool.
- Explicit Invocation: Type
#followed by the tool name (e.g.,#listGitHubIssues) to directly call a specific MCP tool.
- Review and approve tool invocations when prompted—VS Code will display a confirmation dialog before executing any action.
4.2 Use MCP Resources as Chat Context
MCP servers can provide direct access to resources (e.g., files, database tables, API endpoints) that you can include in chat prompts for context-aware responses:
- In the Chat view, select
Add Context > MCP Resources. - Choose a resource type from the list (e.g., “GitHub Repository Issues”) and enter any required parameters (e.g., repository name).
- The selected resource will be added to your chat prompt, enabling the AI to generate responses based on real-time data from the MCP server.
To browse all available resources for an MCP server, run the MCP: Browse Resources command via the Command Palette, or use MCP: List Servers > Browse Resources to filter by a specific server.
4.3 Use Preconfigured MCP Prompts
Many MCP servers include prebuilt prompts for common tasks, which you can invoke using slash commands in chat:
- In the chat input field, type
/to see a list of available commands. - Select an MCP prompt formatted as
mcp.<servername>.<promptname>(e.g.,mcp.github.listPullRequests). - Enter any additional input parameters when prompted (e.g., branch name) to refine the prompt’s output.
5. Manage Installed MCP Servers
VS Code provides multiple ways to manage your MCP servers, including starting/stopping, viewing logs, and uninstalling.
5.1 Basic Server Management Actions
You can perform core management tasks using one of these methods:
- Extensions View: Navigate to the
MCP SERVERS - INSTALLEDsection. Right-click a server or click its gear icon to access actions likeStart,Stop,Restart,Uninstall, andShow Output. - Configuration File: Open the
mcp.jsonfile (workspace or user-level). Use inline code lenses to trigger server actions directly in the editor. - Command Palette: Run
MCP: List Servers, select a server from the list, and choose an action (e.g.,Show Logs,Reset Trust).
5.2 Automatically Start MCP Servers
VS Code can restart MCP servers automatically when their configuration changes (e.g., updating an API key). To enable this feature:
- Open VS Code Settings (Ctrl+, / Cmd+,).
- Search for
chat.mcp.autostartand check the box (note: this is an experimental setting).
For manual restarts, use the Refresh button in the Chat view or the Restart action in the server management menu.
5.3 Clear Cached MCP Tools
VS Code caches the list of tools provided by an MCP server after its first startup. If you update the server’s tooling and need to refresh the cache: Run the MCP: Reset Cached Tools command via the Command Palette.
6. MCP Server Trust and Security
MCP servers can execute arbitrary code on your local machine, so security is a critical consideration. Follow these best practices to stay protected:
- Only Trust Reputable Sources: Install MCP servers from verified publishers (e.g., GitHub official repositories, well-known developers). Avoid unvetted servers from unknown sources.
- Confirm Trust on First Startup: When you start an MCP server for the first time, VS Code will display a trust prompt. Review the server’s configuration details (click the link in the dialog) before confirming trust. If you do not trust the server, it will not start, and chat workflows will proceed without its tools.
- Reset Trust if Needed: If you need to revoke trust for a server, run the
MCP: Reset Trustcommand via the Command Palette.
Caution If you start an MCP server directly from the mcp.json file (e.g., via code lenses), VS Code will not prompt you to confirm trust. Always verify server configurations before manual startup.
7. Synchronize MCP Servers Across Devices
You can sync your MCP server configurations across multiple devices using VS Code’s Settings Sync feature:
- Run the
Settings Sync: Configurecommand via the Command Palette. - Ensure
MCP Serversis included in the list of synchronized configuration categories. - Enable Settings Sync on your other devices—your MCP server setup will be automatically replicated.
8. MCP Server Configuration Format
MCP servers are configured using a JSON file (mcp.json) with two core sections: servers (defines server connections) and inputs (stores sensitive data placeholders). You can create workspace-specific (./.vscode/mcp.json) or user-level (~/.config/Code/User/mcp.json) configurations.
8.1 Core Configuration Structure
{
"servers": {
"server-unique-name": {
// Server connection details go here
}
},
"inputs": [
// Sensitive data placeholders go here
]
}
8.2 Standard I/O (stdio) Server Configuration
Use this format for locally-run MCP servers that communicate via standard input/output streams (the most common type):
{
"servers": {
"localFileSystemServer": {
"type": "stdio",
"command": "python",
"args": ["${workspaceFolder}/mcp-file-server.py", "--port", "3000"],
"env": {
"API_KEY": "${input:file-server-api-key}"
},
"envFile": "${workspaceFolder}/.env"
}
},
"inputs": [
{
"type": "promptString",
"id": "file-server-api-key",
"description": "API key for the local file system MCP server",
"password": true
}
]
}
| Field | Required | Description |
|---|---|---|
type | Yes | Set to stdio for standard I/O servers |
command | Yes | Executable to start the server (e.g., python, node, docker) |
args | No | Array of arguments passed to the command |
env | No | Environment variables for the server (use ${input:variable-id} for sensitive data) |
envFile | No | Path to a .env file for additional environment variables |
Note for Docker Users Do not use the -d (detach) option when running MCP servers via Docker— the server must run in the foreground to communicate with VS Code.
8.3 HTTP/Server-Sent Events (SSE) Server Configuration
Use this format for remote MCP servers that communicate over HTTP/SSE:
{
"servers": {
"remoteDatabaseServer": {
"type": "http",
"url": "<https://api.example.com/mcp/database>",
"headers": {
"Authorization": "Bearer ${input:db-server-token}"
}
}
},
"inputs": [
{
"type": "promptString",
"id": "db-server-token",
"description": "Bearer token for the remote database MCP server",
"password": true
}
]
}
| Field | Required | Description |
|---|---|---|
type | Yes | Set to http or sse |
url | Yes | Server URL (supports Unix sockets: unix:///path/to/sock or Windows named pipes: pipe:///pipe/name) |
headers | No | HTTP headers for authentication or configuration |
8.4 Server Naming Conventions
Follow these rules when naming MCP servers to avoid conflicts:
- Use camelCase (e.g.,
githubIntegration,uiTestingServer). - Avoid whitespace and special characters.
- Use descriptive names that reflect the server’s purpose (e.g.,
postgresqlDatabaseinstead ofserver1).
9. Troubleshoot and Debug MCP Servers
If you encounter issues with MCP servers, use these troubleshooting steps to diagnose and resolve problems.
9.1 View MCP Server Logs
Logs are the primary tool for identifying errors. To access logs:
- Run
MCP: List Serversvia the Command Palette. - Select the problematic server and choose
Show Output. - Review the log entries for error messages (e.g., connection timeouts, invalid API keys).
You can also access logs via the Show Output action in the Extensions view or the mcp.json code lenses.
9.2 Enable Debug Mode for MCP Servers
For advanced troubleshooting, enable development mode for an MCP server to watch for file changes and attach a debugger. Add a dev object to the server configuration:
{
"servers": {
"localFileSystemServer": {
"type": "stdio",
"command": "node",
"args": ["server.js"],
"dev": {
"watch": "${workspaceFolder}/server/**/*.js",
"debug": true
}
}
}
}
VS Code supports debugging for Node.js and Python-based MCP servers. For more details, refer to the official MCP Dev Guide.
9.3 Resolve Common Issues
| Issue | Solution |
|---|---|
| MCP server fails to start with Docker | Ensure the Docker command does not use the -d (detach) option. Check logs for container startup errors. |
| “Cannot have more than 128 tools per request” error | Reduce the number of enabled tools in the chat tool picker. Enable virtual tools via github.copilot.chat.virtualTools.threshold in Settings. |
| Server not detected by VS Code | Verify the server is running locally. Check firewall settings to ensure VS Code can access the server port. |
10. Frequently Asked Questions (FAQs)
Q: Can I control which MCP tools the AI agent uses?
A: Yes. Use the tool picker in the Chat view to toggle tools on/off. You can also explicitly reference tools in prompts with the # syntax, or use a .github/copilot-instructions.md file for advanced tooling rules.
Q: Do I need Copilot to use MCP servers?
A: Yes—MCP server functionality is integrated with VS Code Chat, which requires an active Copilot subscription.
Q: How do I contribute my own MCP server to the GitHub registry?
A: Refer to the MCP registry contribution guidelines for instructions on submitting your server for inclusion.




