| title | Configure MCP servers for your repository | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| shortTitle | Configure MCP servers | ||||||||||
| intro | Configure Model Context Protocol (MCP) servers for your repository to give {% data variables.copilot.copilot_cloud_agent %} and {% data variables.copilot.copilot_code-review_short %} access to external tools and data sources. | ||||||||||
| versions |
|
||||||||||
| redirect_from |
|
||||||||||
| contentType | how-tos | ||||||||||
| category |
|
Before setting up MCP servers for your repository, read AUTOTITLE and AUTOTITLE.
As a repository administrator, you can configure MCP servers for use within your repository. You do this using a JSON-formatted configuration that specifies the details of the MCP servers you want to use. You enter the JSON configuration directly into the settings for the repository on {% data variables.product.prodname_dotcom_the_website %}.
This repository-level MCP configuration is shared by {% data variables.copilot.copilot_cloud_agent %} and {% data variables.copilot.copilot_code-review_short %}. For information on disabling use of MCP servers by {% data variables.copilot.copilot_code-review_short %}, see Disabling MCP tools for {% data variables.copilot.copilot_code-review_short %}.
Note
- Support for agent skills and MCP servers with {% data variables.copilot.copilot_code-review_short %} is in {% data variables.release-phases.public_preview %} and subject to change.
- Existing repository MCP configurations that were previously managed under {% data variables.copilot.copilot_cloud_agent %} settings were automatically moved to the new shared MCP settings page. No migration action is required.
The {% data variables.product.github %} MCP server and Playwright MCP server are enabled by default. You can add your own MCP servers alongside these defaults.
Organization and enterprise administrators can also configure MCP servers as part of {% data variables.copilot.custom_agents_short %} using the YAML frontmatter. For more information, see AUTOTITLE.
Warning
Once you've configured an MCP server, {% data variables.product.prodname_copilot_short %} will be able to use the tools provided by the server autonomously, and will not ask for your approval before using them.
{% data reusables.copilot.mcp.repo-mcp-limitations %}
Repository administrators can configure MCP servers by following these steps:
{% data reusables.repositories.navigate-to-repo %} {% data reusables.repositories.sidebar-settings %}
-
In the "Code & automation" section of the sidebar, click {% data variables.product.prodname_copilot_short %} then MCP servers.
-
On the "Model Context Protocol (MCP)" page, add your configuration in the "MCP configuration" section.
The following sections in this article explain how to write the JSON configuration that you need to enter here.
-
Click Save MCP configuration.
Your configuration will be validated to ensure proper syntax.
-
If your MCP server requires a variable, key, or secret, add an Agents secret or variable with a name prefixed with
COPILOT_MCP_. Only Agents secrets and variables with names prefixed withCOPILOT_MCP_will be available to your MCP configuration. See AUTOTITLE.
You configure MCP servers using a special JSON format. The JSON must contain an mcpServers object, where the key is the name of the MCP server (for example, sentry), and the value is an object with the configuration for that MCP server.
{
"mcpServers": {
"MCP SERVER 1": {
"command": "VALUE",
"args": [ VALUES ],
...
},
"MCP SERVER 2": {
"command": "VALUE",
"args": [ VALUES ],
...
},
...
}
}The configuration object can contain the following keys:
Required keys for local and remote MCP servers
tools(string[]): The tools from the MCP server to enable. You may be able to find a list of tools in the server's documentation, or in its code. We strongly recommend that you allowlist specific read-only tools, since the agent will be able to use these tools autonomously and will not ask you for approval first. You can also enable all tools by including*in the array.type(string): {% data variables.copilot.copilot_cloud_agent %} accepts"local","stdio","http", or"sse".
Local MCP specific keys
command(string): Required. The command to run to start the MCP server.args(string[]): Required. The arguments to pass to thecommand.env(object): Optional. The environment variables to pass to the server. This object should map the name of the environment variable that should be exposed to your MCP server to one of the following:- A substitution reference to a secret or variable in your {% data variables.product.prodname_copilot_short %} environment, such as
$COPILOT_MCP_API_KEYor${COPILOT_MCP_API_KEY}. Referenced names must start withCOPILOT_MCP_. - A literal string value.
- A substitution reference to a secret or variable in your {% data variables.product.prodname_copilot_short %} environment, such as
Remote MCP specific keys
url(string): Required. The MCP server's URL.headers(object): Optional. The headers to attach to requests to the server. This object should map the name of header keys to one of the following:- A substitution reference to a secret or variable in your {% data variables.product.prodname_copilot_short %} environment, such as
$COPILOT_MCP_API_KEYor${COPILOT_MCP_API_KEY}. Referenced names must start withCOPILOT_MCP_. - A literal string value.
- A substitution reference to a secret or variable in your {% data variables.product.prodname_copilot_short %} environment, such as
Note that all string and string[] fields besides tools and type support substitution with a variable or secret you have configured in your {% data variables.product.prodname_copilot_short %} environment.
The following syntax patterns are supported for referencing environment variables configured in your {% data variables.product.prodname_copilot_short %} environment:
| Syntax | Example |
|---|---|
$VAR |
$COPILOT_MCP_API_KEY |
${VAR} |
${COPILOT_MCP_API_KEY} |
${VAR:-default} |
${COPILOT_MCP_API_KEY:-fallback_value} |
The examples below show MCP server configurations for different providers.
The Sentry MCP server gives {% data variables.product.prodname_copilot_short %} authenticated access to exceptions recorded in Sentry.
// If you copy and paste this example, you will need to remove the comments prefixed with `//`, which are not valid JSON.
{
"mcpServers": {
"sentry": {
"type": "local",
"command": "npx",
// We can use the $SENTRY_HOST environment variable which is passed to
// the server because of the `env` value below.
"args": ["@sentry/mcp-server@latest", "--host=$SENTRY_HOST"],
"env": {
// We can specify an environment variable value as a string...
"SENTRY_HOST": "https://contoso.sentry.io",
// or refer to a variable or secret in your {% data variables.product.prodname_copilot_short %} environment
// with a name starting with `COPILOT_MCP_`
"SENTRY_ACCESS_TOKEN": "$COPILOT_MCP_SENTRY_ACCESS_TOKEN"
}
}
}
}The Notion MCP server gives {% data variables.product.prodname_copilot_short %} authenticated access to notes and other content from Notion.
// If you copy and paste this example, you will need to remove the comments prefixed with `//`, which are not valid JSON.
{
"mcpServers": {
"notionApi": {
"type": "local",
"command": "docker",
"args": [
"run",
"--rm",
"-i",
"-e",
// We can use the $NOTION_API_KEY environment variable which is passed to
// the server because of the `env` value below.
"OPENAPI_MCP_HEADERS={\"Authorization\": \"Bearer $NOTION_API_KEY\", \"Notion-Version\": \"2022-06-28\"}",
"mcp/notion"
],
"env": {
// The value of the `COPILOT_MCP_NOTION_API_KEY` secret will be passed to the
// server command as an environment variable called `NOTION_API_KEY`
"NOTION_API_KEY": "$COPILOT_MCP_NOTION_API_KEY"
},
"tools": ["*"]
}
}
}The Microsoft MCP repository includes the Azure MCP server, which allows {% data variables.product.prodname_copilot_short %} to understand your Azure-specific files and Azure resources within your subscription when making code changes.
To automatically configure your repository with a copilot-setup-steps.yml file to authenticate with Azure, plus secrets for authentication, clone the repository locally then run the Azure Developer CLI's azd cloud-agent config command in the root of the repository.
Once you've run the command and merged the created pull request, you can add the MCP configuration to your repository.
{
"mcpServers": {
"Azure": {
"type": "local",
"command": "npx",
"args": [
"-y",
"@azure/mcp@latest",
"server",
"start"
],
"tools": ["*"]
}
}
}The Cloudflare MCP server creates connections between your Cloudflare services, including processing documentation and data analysis.
{
"mcpServers": {
"cloudflare": {
"type": "sse",
"url": "https://docs.mcp.cloudflare.com/sse",
"tools": ["*"]
}
}
}The Azure DevOps MCP server creates a seamless connection between {% data variables.product.prodname_copilot_short %} and your Azure DevOps services, including work items, pipelines or documentation.
To use the Azure DevOps MCP server with {% data variables.copilot.copilot_cloud_agent %}, you must update the repository's copilot-setup-steps.yml file to include an Azure login workflow step.
-
Configure OIDC in a Microsoft Entra application, trusting {% data variables.product.github %}. See Use the Azure Login action with OpenID Connect.
-
Setup access to Azure DevOps organization and projects for the application identity. See Add organization users and manage access.
-
Add a
.github/workflows/copilot-setup-steps.ymlActions workflow file in your repository if you do not already have one. -
Add an Azure login step to the
copilot-setup-stepsworkflow job.{% data reusables.actions.actions-not-certified-by-github-comment %} on: workflow_dispatch: permissions: id-token: write contents: read jobs: copilot-setup-steps: runs-on: ubuntu-latest permissions: id-token: write contents: read environment: copilot steps: - name: Azure login uses: azure/login@a457da9ea143d694b1b9c7c869ebb04ebe844ef5 with: client-id: {% raw %}${{ secrets.AZURE_CLIENT_ID }}{% endraw %} tenant-id: {% raw %}${{ secrets.AZURE_TENANT_ID }}{% endraw %} allow-no-subscriptions: true
This configuration ensures the
azure/loginaction is executed when {% data variables.copilot.copilot_cloud_agent %} runs. -
Configure secrets for your
AZURE_CLIENT_IDandAZURE_TENANT_IDas Agents secrets at either the organization or repository level. For more information, see AUTOTITLE. -
Configure the Azure DevOps MCP server by adding an
adoobject to your MCP configuration with the tools you want {% data variables.product.prodname_copilot_short %} to use.
{
"mcpServers": {
"ado": {
"type": "local",
"command": "npx",
"args": ["-y", "@azure-devops/mcp", "<your-azure-devops-organization>", "-a", "azcli"],
"tools": ["wit_get_work_item", "wit_get_work_items_batch_by_ids", ...]
}
}
}The Atlassian MCP server gives {% data variables.product.prodname_copilot_short %} authenticated access to your Atlassian apps, including Jira, Compass, and Confluence.
For more information about authenticating to the Atlassian MCP server using an API key, see Configuring authentication via API token in the Atlassian documentation.
// If you copy and paste this example, you will need to remove the comments prefixed with `//`, which are not valid JSON.
{
"mcpServers": {
"atlassian-rovo-mcp": {
"command": "npx",
"type": "local",
"tools": ["*"],
"args": [
"mcp-remote@latest",
"https://mcp.atlassian.com/v1/mcp",
// We can use the $ATLASSIAN_API_KEY environment variable which is passed
// to the server because of the `env` value below.
"--header",
"Authorization: Basic $ATLASSIAN_API_KEY"
],
"env": {
// The value of the `COPILOT_MCP_ATLASSIAN_API_KEY` secret will be passed
// to the server command as an environment variable
// called `ATLASSIAN_API_KEY`.
"ATLASSIAN_API_KEY": "$COPILOT_MCP_ATLASSIAN_API_KEY"
}
}
}
}If you have already configured MCP servers in {% data variables.product.prodname_vscode_shortname %}, you can leverage a similar configuration for your repository MCP settings on {% data variables.product.github %}.
Depending on how {% data variables.product.prodname_vscode_shortname %} is configured, you may be able to find your MCP settings in your repository's .vscode/mcp.json file, or in your machine's private settings.json file.
To adapt the configuration for repository MCP settings on {% data variables.product.github %}, you will need to:
- Add a
toolskey for each MCP server, specifying which tools will be available to {% data variables.product.prodname_copilot_short %}. - If you've configured
inputs, switch to usingenvdirectly. - If you've configured an
envFile, switch to usingenvdirectly. - Update any references to
inputsin yourargsconfiguration to refer to environment variables fromenvinstead.
For more information on MCP in {% data variables.product.prodname_vscode_shortname %}, see the {% data variables.product.prodname_vscode_shortname %} docs.
Once you've set up your MCP configuration, you should test it to make sure it is set up correctly.
- Create an issue in the repository, then assign it to {% data variables.product.prodname_copilot_short %}.
- Wait a few seconds, and {% data variables.product.prodname_copilot_short %} will leave an 👀 reaction on the issue.
- Wait a few more seconds, and {% data variables.product.prodname_copilot_short %} will create a pull request, which will appear in the issue's timeline.
- Click the created pull request in the timeline, and wait until a "Copilot started work" timeline event appears.
- Click View session to open the {% data variables.copilot.copilot_cloud_agent %} logs.
- Click the ellipsis button (...) at the top right of the log viewer, then click {% data variables.product.prodname_copilot_short %} in the sidebar.
- Click the Start MCP Servers step to expand the logs.
- If your MCP servers have been started successfully, you will see their tools listed at the bottom of the logs.
If your MCP servers require any dependencies that are not installed on the {% data variables.product.prodname_actions %} runner by default, such as uv and pipx, or that need special setup steps, you may need to create a copilot-setup-steps.yml Actions workflow file to install them. For more information, see AUTOTITLE.
- Open a pull request in the repository.
- Request a review from {% data variables.product.prodname_copilot_short %}.
- Open the linked review session from the pull request timeline by clicking View session. In the session logs, review the "Setting up environment" section to see which MCP servers and tools were started and called.
The {% data variables.product.github %} MCP server is enabled by default and connects to {% data variables.product.github %} with a specially scoped token that only has read-only access to the current repository.
If you want to allow {% data variables.product.prodname_copilot_short %} to access data outside the current repository, you can give it a {% data variables.product.pat_generic %} with wider access.
-
Create a {% data variables.product.pat_generic %} with the appropriate permissions. We recommend using a {% data variables.product.pat_v2 %}, where you can limit the token's access to read-only permissions on specific repositories. For more information on {% data variables.product.pat_generic_plural %}, see AUTOTITLE. {% data reusables.repositories.navigate-to-repo %} {% data reusables.repositories.sidebar-settings %}
-
In the "Code & automation" section of the sidebar, click {% data variables.product.prodname_copilot_short %} then MCP servers.
-
Add your configuration in the "MCP configuration" section. For example, you can add the following:
// If you copy and paste this example, you will need to remove the comments prefixed with `//`, which are not valid JSON. { "mcpServers": { "github-mcp-server": { "type": "http", // Remove "/readonly" to enable wider access to all tools. // Then, use the "X-MCP-Toolsets" header to specify which toolsets you'd like to include. // Use the "tools" field to select individual tools from the toolsets. "url": "https://api.githubcopilot.com/mcp/readonly", "tools": ["*"], "headers": { "X-MCP-Toolsets": "repos,issues,users,pull_requests,code_security,secret_protection,actions,web_search" } } } }
For more information on toolsets, refer to the README in the {% data variables.product.github %} Remote MCP Server documentation.
-
Click Save MCP configuration.
-
Add an Agents secret called
COPILOT_MCP_GITHUB_PERSONAL_ACCESS_TOKENwith your {% data variables.product.pat_generic %} as the value. You can configure this at either the organization or repository level. For more information, see AUTOTITLE.
For information on using the {% data variables.product.github %} MCP server in other environments, see AUTOTITLE.
Note
Support for agent skills and MCP servers with {% data variables.copilot.copilot_code-review_short %} is in {% data variables.release-phases.public_preview %} and subject to change.
In repository settings, use of MCP tools by {% data variables.copilot.copilot_code-review_short %} is enabled by default.
Disable this setting if you want the configured MCP servers available only for {% data variables.copilot.copilot_cloud_agent %}, and not for {% data variables.copilot.copilot_code-review_short %}.
If you disable this setting, {% data variables.copilot.copilot_code-review_short %} won't call MCP tools for pull request reviews in that repository, including tools from the default {% data variables.product.github %} and Playwright MCP servers.
{% data reusables.repositories.navigate-to-repo %} {% data reusables.repositories.sidebar-settings %}
- In the "Code & automation" section of the sidebar, click {% data variables.product.prodname_copilot_short %} then Code review.
- Click the Allow Copilot to use MCP tools when reviewing pull requests toggle to disable the setting.