The Model Context Protocol (MCP) is an open standard developed by Anthropic to simplify and standardize how large language models (LLMs) integrate with external tools, databases, and APIs. Think of MCP as the “USB-C port” for AI models: just as USB-C unified device connectivity, MCP aims to create a universal interface for AI-to-tool interaction.
Originally built to enhance Claude’s ability to interact with external systems, MCP was open-sourced in early 2024 to promote industry-wide adoption. By making the protocol public, Anthropic’s goal was to establish a shared infrastructure for tool communication that minimizes the need for custom integrations while boosting modularity, interoperability, and developer productivity in AI applications.
Through MCP, language models can:
In short, MCP is reshaping how AI models plug into the real world, shifting from isolated, monolithic systems to flexible, tool-aware agents that can reason, retrieve, and act using standardized methods.
Before you begin, ensure you have the following:
Visual Studio Code (VS Code): Updated to the latest version.
GitHub Account: With access to GitHub Copilot(Free, Pro, Business, or Enterprise plan).
GitHub Copilot Extensions: Both GitHub Copilot and GitHub Copilot Chat extensions installed and enabled in VS Code.
Node.js: Latest LTS version installed (check with node -v
in your terminal). Download from the official Node.js website if needed.
Python: Installed for PIP packages (optional, depending on the MCP server). Download from the official Python website if needed.
Git: Installed for version control and repository management.
Open VS Code and check for updates via the Help > Check for Updates menu.
Ensure you’re running the latest stable or Insiders version to support MCP integration.
In VS Code, go to the Accounts menu in the Activity Bar.
Select “Sign in with GitHub to use GitHub Copilot” and follow the prompts to authenticate using your GitHub account. If you don’t have a Copilot subscription, you’ll be signed up for the Copilot Free plan with limited completions and chat interactions.
Verify Node.js installation by running node -v
in your terminal. Install the latest LTS version if not present.
Verify Python installation by running python --version
or python3 --version
. Install Python if needed for PIP-based MCP servers.
MCP supports multiple languages and packages (e.g., TypeScript, Docker, C#), but this guide focuses on Node.js for NPX packages and Python for PIP packages.
In VS Code, go to the Extensions view (Ctrl+Shift+X
or Cmd+Shift+X
on macOS).
Search for “GitHub Copilot” and install both the GitHub Copilot and GitHub Copilot Chat extensions.
Restart VS Code after installation.
MCP servers enhance GitHub Copilot’s Agent Mode by providing tools for tasks like repository management, file operations, or API calls. Here’s how to configure an MCP server in VS Code:
Visit the MCP documentation or GitHub’s MCP server repository for a list of supported servers (e.g., GitHub MCP server, Microsoft Playwright MCP server).
For this guide, we’ll use the GitHub MCP Server for repository-related actions like creating issues or comparing files.
Open a terminal in VS Code (Ctrl+`(next 1) or
Cmd+` on macOS).
For the GitHub MCP server, follow the setup instructions from the official repository (e.g., npm install @github/copilot-language-server
for Node.js-based servers).
Alternatively, use the VS Code interface:
Open the GitHub Copilot Chat view (Ctrl+Alt+I
or Cmd+Alt+I
).
Select Agent Mode from the chat mode dropdown.
Click the “Install MCP Server” button if prompted (e.g., for Azure MCP Server or GitHub MCP Server).
Create a .vscode/mcp.json
file in your workspace folder to define MCP server settings. Example:
{
"servers": [
{
"name": "GitHub MCP Server",
"transport": "stdio",
"command": ["node", "./node_modules/@github/copilot-language-server/dist/language-server.js", "--stdio", "true"]
}
]
}
Alternatively, add MCP server settings to your user settings(Ctrl+,
or Cmd+,
> Search for “MCP”):
{
"mcp.servers": [
{
"name": "GitHub MCP Server",
"transport": "stdio",
"command": ["node", "./node_modules/@github/copilot-language-server/dist/language-server.js", "--stdio", "true"]
}
]
}
Ensure the command
points to the correct path for your MCP server executable.
In the Copilot Chat view, switch to Agent Mode.
Click the Tools button and refresh the tools list. The installed MCP server (e.g., “GitHub MCP Server”) should appear. Toggle it on if needed.
MCP enables Copilot to perform actions like creating GitHub issues or comparing files. Here’s how to write and test MCP-related interactions:
In the Copilot Chat view, ensure Agent Mode is selected.
ServerConfig.json
with similar public GitHub repository configurations and suggest
improvements. #file:ServerConfig.json”Add context using the Add Context button or variables like #file
or #codebase
.
Enter the prompt in the Copilot Chat input field and press Enter.
Copilot will invoke the MCP server’s tools (e.g., GitHub API for creating issues) and display results in the Chat view.
Review the output (e.g., a new issue created in your repository or a diff of file comparisons).
Accept changes by selecting Keep or Accept in the Chat view, or reject them if they’re incorrect.
If developing a custom MCP server, use the MCP SDK. Below is a basic Node.js example to create a tool for listing repository files:
const { MCPServer } = require('@anthropic/mcp-sdk');
const server = new MCPServer({
transport: 'stdio',
tools: [
{
name: 'list_repository_files',
description: 'Lists files in a GitHub repository',
execute: async (params) => {
const { repo } = params;
// Simulated GitHub API call
return ['index.js', 'package.json', 'README.md'];
},
},
],
});
server.start();
Save this as mcp-server.js
and run it with node mcp-server.js
.Configure VS Code to use this server as shown in Step 2.
For Python-based MCP servers, use the Python MCP SDK:
from mcp_sdk import MCPServer
server = MCPServer(
transport="stdio",
tools=[
{
"name": "create_github_issue",
"description": "Creates a GitHub issue in a repository",
"execute": lambda params: f"Issue created in {params['repo']} with title: {params['title']}",
}
],
)
server.start()span>Use async/await for asynchronous code.
Save as mcp_server.py
and run with python mcp_server.py
. Update the .vscode/mcp.json
file to point to this script.
Create a .github/copilot-instructions.md
file to provide project-specific context (e.g., coding standards, preferred libraries). Example:
# Copilot Instructions
This project is a web application built with Node.js and Express.
- Use camelCase for variable names.
- Prefer async/await over callbacks.
- Use the GitHub MCP server for repository actions.
Copilot automatically applies these instructions in Agent Mode.
MCP servers can dynamically update tools using list-changed events. Modify your MCP server code to emit updates when new tools are added.
Host MCP servers on platforms like Azure Container Apps for remote access. Configure VS Code to connect via server-sent events (SSE) instead of stdio.
Use specific prompts for better results. Example: “Generate a Node.js function to fetch data from an API using the GitHub MCP server.
.vscode/mcp.json
file for correct command paths. Run
MCP: List Servers
from the Command Palette to verify.
.github/copilot-instructions.md
in your repository to share
with your team.
Integrating the Model Context Protocol (MCP) with GitHub Copilot in VS Code unlocks powerful AI-driven capabilities, enabling seamless interaction with GitHub repositories, APIs, and external tools. By following this guide, you’ve learned how to set up your environment, configure MCP servers, write and test MCP interactions, and leverage advanced features like custom instructions. With MCP’s standardized interface, you can extend Copilot’s Agent Mode to suit your project’s needs, boosting productivity and modularity.
Experiment with different MCP servers and prompts to tailor Copilot to your workflow, and share your feedback with the community to help shape the future of AI-driven development!