
Setting up MCP on VS Code
3 min read
An MCP (Model Context Protocol) server is a backend system that acts as an intermediary between an AI agent (like GitHub Copilot) and various tools, APIs, or data sources. It provides a structured way for the AI to access and interact with external systems, enhancing its capabilities beyond basic code or text generation.
What Is an MCP Server?
An MCP server:
Hosts a collection of tools or plugins (e.g., GitHub API, file system access).
Receives queries from the AI based on user prompts.
Matches queries to appropriate tools, executes actions, and returns results.
Ensures secure, controlled interactions with external resources.
It enables the AI to perform complex tasks, like fetching GitHub data or modifying files, by serving as a bridge between the AI’s reasoning and the practical execution of commands.
Prerequisites
Before starting, ensure you have:
VS Code version 1.99 or later installed.
An active GitHub Copilot subscription (free or paid plan) with the Copilot extension enabled in VS Code.
Awareness that MCP support in agent mode is in preview, so features may evolve.
Configuring the MCP Server in VS Code
Step 1: Create the .vscode/mcp.json File
Open your project in VS Code.
If your workspace lacks a .vscode folder:
- Right-click in the Explorer view, select New Folder, and name it .vscode.
Inside .vscode, create the mcp.json file:
- Right-click, select New File, and name it mcp.json.
Step 2: Define the MCP Configuration
The .vscode/mcp.json file uses JSON format to define MCP servers. It usually includes two main sections:
inputs: Defines any user inputs (e.g., API keys) required by the server, prompted on first start and stored securely by VS Code.
servers: Specifies the MCP servers, including their names, types, commands, and arguments.
Example: Setting Up a GitHub MCP Server
Step 1: Configure and Start the Server
Add the above configuration to your mcp.json file, following the official MCP documentation.
Save the file and restart VS Code.
On startup, VS Code prompts for your GitHub token. Enter it securely.
The server launches (e.g., via Docker, as specified in the config).
That’s it, couldn’t be easier. Let’s check it out!
Step 2: Interact with Copilot
With the MCP server running, Copilot can now:
Access your GitHub account details.
Query public and private repositories, including those in your organization.
Perform tasks like fetching commits or updating profiles.
For example, ask Copilot: “Show my latest GitHub commit.” It will query the MCP server, retrieve the data, and display it in the chat view.
Even to private repositories under my organization
Summary
Setting up an MCP server in VS Code unlocks powerful features for GitHub Copilot, enabling it to interact with your GitHub account and beyond. By configuring mcp.json and providing secure inputs, you can automate tasks, access private data, and streamline your workflow—all while keeping control over the process. Try it out and explore the possibilities!