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 invoke external tools, enabling operations such as reading files, calling APIs, and executing tasks.
In VS Code, the MCP client (Copilot) completes tasks through tools provided by MCP servers, which can be deployed locally or remotely.

The figure above is the MCP architecture diagram:
-
MCP is the core. On one side it connects to clients (MCP clients), such as programs written with client.py; on the other side, through a server (MCP server), it connects to remote services (such as the colorful icon Apps in the figure) and local data sources (such as the blue smiley face icons).
-
Clients can also connect to MCP hosts, such as Claude and ChatGPT, allowing MCP to invoke their capabilities and link all parties together. It is like building a "collaboration network" for different tools, enabling MCP to connect remote and local resources and leverage external large models.
Before using the VS Code MCP service, make sure the latest version of Visual Studio Code is installed.
Then install the relevant VS Code AI extension. We can use Microsoft's GitHub Copilot; simply log in with an account (including Free, Business, or Enterprise plans).
Starting from VS Code version 1.102, MCP support in VS Code is fully available and can be enabled or checked in the settings.

Configure MCP servers
There are several ways to add MCP servers in VS Code:
- Direct installation: Visit the curated list of MCP servers https://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.json file in the workspace to configure MCP servers for that workspace and share the configuration with team members.
- User settings: Specify servers in the user configuration (via "MCP: Open User Configuration") so that the MCP server is enabled in all workspaces and synchronized via "Settings Sync".
- Automatic discovery: Enable automatic discovery (chat.mcp.discovery.enabled) to discover MCP servers defined in other tools (such as the Claude desktop app).
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:
Code of the test.py file
import
sys
import
json
Read the MCP initialization request
_
=
json.
load
(
sys
.
stdin
)
Output the 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".
Create a .vscode/mcp.json file in your workspace folder (create the .vscode directory if it does not exist) 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) and 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 type "execute HelloWorldServer" in the AI chat window to see the output:

In the lower right corner of .vscode/mcp.json there is an "Add Server..." icon, through which we can add more services, including commands to execute or remote http services:
