Power Up VS Code Copilot with MCP Servers in Under 10 Minutes

This article explains how to enhance your Visual Studio Code Copilot extension by connecting it to Model Context Protocol (MCP) servers. This allows your AI assistant to interact with external services, transforming it into a much more powerful agent.

Understanding Copilot and MCP

GitHub Copilot, when running in agent mode, requires an underlying Large Language Model (LLM). By default, the free tier provides access to models from OpenAI and Anthropic. You can also configure it to use local models via Ollama or connect to services like Gemini or Groq with an API key.

Model Context Protocol (MCP) servers act as a bridge, allowing GitHub Copilot to connect with various other services. In this guide, we will demonstrate this process with two examples: 1. GitHub's own MCP server, a streaming HTTP service that requires authentication. 2. A local Neo4j database, using the Cipher MCP server managed by a local subprocess.

Note: To follow the local database example, you will need to have uv installed on your system.

Step 1: Initial Setup in VS Code

First, you need to install the necessary Copilot extensions.

  1. Open Visual Studio Code and navigate to the Extensions view from the activity bar.
  2. Search for "Copilot".
  3. Install both the GitHub Copilot and GitHub Copilot Chat extensions.

After installation, the Copilot icon will appear in the activity bar. Click it to open the chat panel. Ensure you are in agent mode by selecting "Agent" from the dropdown at the bottom of the chat panel. You can manage models and add API keys by clicking the "Manage Models" button.

Step 2: Adding MCP Servers from the VS Code Marketplace

One of the simplest ways to add an MCP server is through the official marketplace.

  1. In the Extensions view, search for "MCP Servers".
  2. Click the Browse MCP Servers button. This will open a new browser tab with a vetted list of available servers.
  3. Find the GitHub Copilot server and click "Install".
  4. Allow the extension to open in VS Code and click the "Install" button again within the editor.
  5. This will initiate an OAuth authentication process. Follow the prompts to authorize access to your GitHub account.

Once complete, the MCP server will be running.

Verifying the Connection

You can verify the installation by clicking the "tools" icon (a small wrench and screwdriver) in the chat window. Scroll down, and you should see MCP Server: GitHub listed as enabled. You can test the connection by asking the agent a question related to the service.

For example: @github How many repositories do I have?

The agent should respond with the correct count of your public and private repositories, confirming the connection is active. When you add a server this way, it is added to your global user settings and will be available across all your VS Code projects.

Step 3: Manually Configuring MCP Servers

For more advanced or project-specific setups, you can configure servers manually. This is useful for servers not on the vetted marketplace list or for configurations tied to a specific project.

You can add a configuration to your global settings.json file, or for a project-level setup, create a .vscode directory in your project root and add an mcp.json file.

Here, we will configure a connection to a local Neo4j database.

  1. Create the file .vscode/mcp.json.
  2. Add the server configuration. Note that in a project-level mcp.json file, the top-level key is server, not mcpServer as it is in the global settings.json.

A key feature is the ability to handle sensitive information, like passwords, securely. Instead of hardcoding a password, you can use a placeholder that prompts for input.

Here is an example configuration for the Neo4j Cipher MCP server:

{
  "server": {
    "neo4j-project-db": {
      "command": [
        "uv",
        "run",
        "cipher-mcp",
        "--uri",
        "neo4j+s://localhost:7687",
        "--username",
        "neo4j",
        "--password",
        "${input:neo4jPassword}"
      ],
      "probes": {
        "startup": {
          "command": ["exit", "0"],
          "period": "5s"
        }
      }
    }
  },
  "inputs": [
    {
      "id": "neo4jPassword",
      "type": "promptString",
      "description": "Enter Neo4j Password",
      "password": true
    }
  ]
}

Note: It's good practice to namespace your server configurations (e.g., neo4j-project-db). This helps distinguish between multiple servers, especially if you have both project-level and user-level connections to similar services.

After saving the file, you may need to restart the server. VS Code will prompt you to enter the password in the command palette area at the top of the screen. Once connected, you can test it by opening a new chat window and asking a question about your database, such as:

@neo4j-project-db How many nodes are in my database?

Verifying and Managing Your Servers

You can manage and inspect your active MCP servers in several locations:

  • Tools Icon: The "tools" icon in the chat window lists all active servers and allows you to enable or disable specific tools they provide.
  • Command Palette: Open the command palette (Ctrl+Shift+P or Cmd+Shift+P) and type >MCP to see commands like MCP: List Servers, which lets you start, stop, and reconfigure servers.
  • World Icon: In the activity bar, the "world" icon lets you browse the vetted marketplace list and manage existing servers.

A Note on Auto-Discovery

VS Code has an auto-discovery feature (mcp.discovery.enabled) that is on by default. This feature can automatically pull in MCP configurations from other development tools like Cursor.

Be aware that if you use these other tools, their configurations might override your local settings. If you encounter unexpected behavior with your MCP servers, consider disabling this auto-discovery feature in your settings to avoid conflicts.

With MCP servers configured, your VS Code Copilot is now a powerful agent capable of interacting with multiple external services, from GitHub repositories to local databases. This allows you to combine these resources to build more complex and interesting workflows directly within your editor. We hope this guide was useful.