Skip to main content

Extension de Copilot Chat avec le protocole MCP (Model Context Protocol)

Apprenez à utiliser le protocole MCP (Model Context Protocol) pour étendre Copilot Chat.

Remarque

  • MCP support is generally available (GA) in Copilot for Visual Studio Code, JetBrains, Eclipse, and Xcode.
  • MCP support for Copilot in Visual Studio is in public preview and is subject to change.
  • The GitHub Pre-release License Terms apply only to Copilot in IDEs where MCP support is still in preview. GA terms apply when using MCP for Copilot in Visual Studio Code, JetBrains, Eclipse, and Xcode.

Introduction

The Model Context Protocol (MCP) is an open standard that defines how applications share context with large language models (LLMs). For an overview of MCP, see About Model Context Protocol (MCP).

For information on currently available MCP servers, see the MCP servers repository.

Enterprises and organizations can choose to enable or disable use of MCP for members of their organization or enterprise. The policy is disabled by default. See Managing policies and features for GitHub Copilot in your enterprise and Managing policies and features for GitHub Copilot in your organization. The MCP policy only applies to users who have a Copilot Business or Copilot Enterprise subscription from an organization or enterprise that configures the policy. Copilot Free, Copilot Pro, or Copilot Pro+ do not have their MCP access governed by this policy.

Remarque

The MCP servers in Copilot policy controls use where MCP server support is generally available (GA). In features where MCP support is in preview, for example Copilot editors, availability is controlled by the Editor preview features policy.

Prerequisites

Configuring MCP servers in Xcode

  1. Open the GitHub Copilot for Xcode extension and go to "Settings".
    • Alternatively, in an active Xcode workspace, you can find the settings by clicking Editor in the menu bar, selecting GitHub Copilot, then clicking Open GitHub Copilot for Xcode Settings.
  2. Select the MCP tab, then click Edit Config.
  3. Define your MCP servers, editing mcp.json. Xcode supports both remote and local servers. Remote servers are hosted externally for easier setup and sharing, while local servers run on your local machine and can access local resources.

You can use the following configurations as examples:

Remote server configuration example with PAT

JSON
{
    "servers": {
        "github": {
            "url": "https://api.githubcopilot.com/mcp/",
            "requestInit": {
                "headers": {
                    "Authorization": "Bearer YOUR_PAT_HERE"
                }
            }
        }
    }
  }

Local server configuration example

JSON
{
  "servers": {
    "memory": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-memory"
      ]
    }
  }
}

Creating a new MCP server

You can create a new MCP server to fulfill your specific needs, and then integrate it with Copilot Chat. For example, you can create an MCP server that connects to a database or a web service, and then use that server in Copilot Chat to perform tasks on that database or web service.

For more information on creating and configuring your own MCP servers, see the official MCP documentation.

Further reading