VS Code MCP Service

MCP (Model Context Protocol) is an open standard that provides a unified interface, allowing AI models (such as Copilot Chat) to discover and call external tools, enabling multiple operations such as reading files, calling APIs, and executing tasks.

In VS Code, the MCP client (Copilot) completes tasks through the tools provided by the MCP server, while the server side can be deployed locally or remotely.

The above figure is the MCP architecture diagram:

  • MCP is the core, connecting to clients (MCP clients) on one side, such as programs written with client.py; on the other side, through the server (MCP server), it connects to remote services (such as the colorful icon Apps in the diagram) and local data sources (such as the blue smiley icon).

  • Clients can also connect to MCP hosts, such as Claude and ChatGPT, allowing MCP to call their capabilities and link all parties together to get work done~ It's like building a "collaboration network" for different tools, enabling MCP to connect remote and local resources while leveraging the power of external large models.

Before using the VS Code MCP service, make sure to install the latest version of Visual Studio Code.

You also need to install the related VS Code AI extension. We can use Microsoft's GitHub Copilot and simply log in with an account (including Free, Business, or Enterprise plans).

Starting from VS Code 1.102, MCP support in VS Code is fully available. You can check whether it is enabled in the settings.


Configure MCP Server

There are multiple ways to add an MCP server in VS Code:

  • Direct installation: visit the curated MCP server listhttps://code.visualstudio.com/mcp, select "Install" on any MCP server, and it will be automatically added to your VS Code instance.
  • Workspace settings: add a.vscode/mcp.jsonfile in the workspace to configure the MCP server for that workspace and share the configuration with team members.
  • User settings: specify the server in the user configuration (via "MCP: Open User Configuration") to enable the MCP server in all workspaces and sync it through "Settings Sync".
  • Auto-discovery: enable the auto-discovery feature (chat.mcp.discovery.enabled) to discover MCP servers defined in other tools (such as Claude Desktop).

In this section, we use the workspace settings method.

Example

The following is a simple "Hello World" example of an MCP application in VS Code. First, we create a Python file test.py with the following code:

test.py File Code

import sys
import json

# Read MCP initialization request
_ = json.load(sys.stdin)

# Output MCP response (standard JSON)
json.dump({
    "type": "text",
    "text": "Hello World from MCP!"
}, sys.stdout)

Next, we create an MCP server configuration that can return "Hello World".

In your workspace folder, create.vscode/mcp.json(if the.vscodedirectory does not exist, create it) file, and fill in the following configuration (simulating a simple local MCP server):

.vscode/mcp.json File Code

{
  "servers": {
    "HelloWorldServer": {
      "type": "stdio",
      "command": "python3",
      "args": ["test.py"]
    }
  }
}

After saving the file, open the VS Code command palette (Ctrl+Shift+P): run the "MCP: Show Installed Servers" command:

You will see the configured "HelloWorldServer":

Start the server, and it will immediately return the message "Hello World from MCP!"

We can enter "execute HelloWorldServer" in the AI chat window and see the output result:

Open.vscode/mcp.jsonThere is an "Add Server..." icon in the bottom right corner, through which we can add more services, including commands to execute or remote HTTP services:

<hr></h2>Using MCP to Control the Browser</h2> <p> We can control the Chrome browser in VS Code, such as automatically opening web pages, scraping content, taking screenshots, and even filling out forms.</p><p> This requires the open-source project mcp-chrome, whose open-source address is <a href="https://github.com/hangwin/mcp-chrome/" target="_blank">https://github.com/hangwin/mcp-chrome/</a>.</p> <p>We can let AI agents or tools operate the browser through the MCP protocol.</p> <p> <strong>Environment Requirements:</strong></p> <ul> <li>Chrome or Chromium browser</li> <li>Node.js ≥ v18.19.0</li> <li>VS Code, Github Copilot</li> </ul><p> <h3>Install mcp-chrome-bridge</h3><p> mcp-chrome-bridge is the bridge between VS Code and the browser.</p> <pre>npm install -g mcp-chrome-bridge</pre> <h3>Install and Configure the Browser Extension</h3> Go to the GitHub Releases page <a href="https://github.com/hangwin/mcp-chrome/releases" target="_blank">https://github.com/hangwin/mcp-chrome/releases</a> to download the mcp-chrome extension source code (not the .crx, but the complete extracted package). <p><img decoding="async" src="../wp-content/uploads/2025/08/1699b3a5-c94f-4513-9bbb-7c6607a0896f.png"></p> <li><p>Open Chrome and enter: <span class="marked">chrome://extensions</span></p></li> <li> <p>Enable "Developer mode" in the top right corner</p></li> <li> <p> Click "Load unpacked extension" and select the extension folder you downloaded</p></li> <li> <p> After successful installation, click the extension icon and click "Connect"</p></li> <p><img decoding="async" src="../wp-content/uploads/2025/08/00cd8cee-3410-4ca0-b449-3b03c9c3958d.png"></p> <p> Click the extension icon to open the extension, and click Connect to see the MCP configuration:</p> <p><img decoding="async" src="../wp-content/uploads/2025/08/01380c12-9611-4185-bef4-3e5eafc17f87.png"></p> <h2>Configure VS Code and MCP Communication</h2><p> Create <span class="marked">.vscode/mcp.json</span> in the project directory and add the following basic configuration:</p> <pre> { "servers": { "chrome-mcp": { "type": "http", "url": "http://127.0.0.1:12306/mcp" } } } </pre><p> http://127.0.0.1:12306/ is the default listening address of the extension bridge service.</p> <p> Start it:</p> <p><img decoding="async" src="../wp-content/uploads/2025/08/c65533f5-8d10-402d-8b7c-7457335482d9.png"></p> Other Extensions