You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/copilot/customizing-copilot/extending-copilot-coding-agent-with-mcp.md
+87-13Lines changed: 87 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -33,26 +33,47 @@ Once you've configured an MCP server, {% data variables.product.prodname_copilot
33
33
34
34
We recommend that you restrict your servers to read-only tools. You can use the `tools` configuration option to only expose known, safe tools to {% data variables.product.prodname_copilot_short %}.
35
35
36
-
## Setting up MCP servers in a repository
36
+
## About setting up MCP servers in a repository
37
37
38
-
As a repository administrator, you can configure MCP servers for use within your repository. This is done via JSON configuration that specifies the details of the MCP servers you want to use.
38
+
As a repository administrator, you can configure MCP servers for use within your repository. This is done via 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 %}.
39
39
40
40
Once MCP servers are configured for use within a repository, the tools specified in the configuration will be available to {% data variables.copilot.copilot_coding_agent %} on each assigned task.
41
41
42
42
### Creating your JSON MCP configuration
43
43
44
44
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, `playwright`), and the value is an object with the configuration for that MCP server.
45
45
46
+
```json copy
47
+
{
48
+
"mcpServers": {
49
+
"MCP SERVER 1": {
50
+
"command": "VALUE",
51
+
"args": [ VALUES ],
52
+
...
53
+
},
54
+
"MCP SERVER 2": {
55
+
"command": "VALUE",
56
+
"args": [ VALUES ],
57
+
...
58
+
},
59
+
...
60
+
}
61
+
}
62
+
```
63
+
46
64
The configuration object can contain the following keys:
47
65
48
66
*`command` (`string`): The command to run to start the MCP server.
49
67
*`args` (`string[]`): The arguments to pass to the `command`.
50
68
*`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 recommend that you allowlist specific tools, but you can also enable all tools by including `*` in the array.
69
+
*`type` (`string`): Optional field. {% data variables.copilot.copilot_coding_agent %} only accepts `"local"`.
51
70
*`env` (`object`): 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 either of the following:
52
71
* The name of a {% data variables.product.prodname_actions %} secret you have configured, beginning with `COPILOT_MCP_`.
53
72
* A string value.
54
73
55
-
#### Example: Playwright
74
+
## Example configurations
75
+
76
+
### Example: Playwright
56
77
57
78
The [Playwright MCP server](https://github.com/microsoft/playwright-mcp) provides tools which allow {% data variables.product.prodname_copilot_short %} to browse the internet.
58
79
@@ -68,7 +89,7 @@ The [Playwright MCP server](https://github.com/microsoft/playwright-mcp) provide
68
89
}
69
90
```
70
91
71
-
####Example: Sentry
92
+
### Example: Sentry
72
93
73
94
The [Sentry MCP server](https://github.com/getsentry/sentry-mcp) gives {% data variables.product.prodname_copilot_short %} authenticated access to exceptions recorded in [Sentry](https://sentry.io).
74
95
@@ -94,7 +115,7 @@ The [Sentry MCP server](https://github.com/getsentry/sentry-mcp) gives {% data v
94
115
}
95
116
```
96
117
97
-
####Example: Notion
118
+
### Example: Notion
98
119
99
120
The [Notion MCP server](https://github.com/makenotion/notion-mcp-server) gives {% data variables.product.prodname_copilot_short %} authenticated access to notes and other content from [Notion](https://notion.so).
100
121
@@ -125,22 +146,75 @@ The [Notion MCP server](https://github.com/makenotion/notion-mcp-server) gives {
125
146
}
126
147
```
127
148
128
-
#### Reusing your MCP configuration from {% data variables.product.prodname_vscode %}
129
-
130
-
If you have already configured MCP servers in {% data variables.product.prodname_vscode_shortname %}, you can leverage similar configuration for {% data variables.copilot.copilot_coding_agent %}.
149
+
### Example: Azure
150
+
151
+
The [Azure MCP server](https://github.com/Azure/azure-mcp) creates a seamless connection between {% data variables.product.prodname_copilot_short %} and key Azure services such as Azure Cosmos DB and the Azure Storage platform.
152
+
153
+
To use the Azure MCP with {% data variables.copilot.copilot_coding_agent %}, you must update the repository's `copilot-setup-steps.yml` file to include an Azure login workflow step.
154
+
155
+
1. Configure OIDC in a Microsoft Entra application, trusting {% data variables.product.github %}. See [Use the Azure Login action with OpenID Connect](https://learn.microsoft.com/en-us/azure/developer/github/connect-from-azure-openid-connect).
156
+
1. Add a `.github/workflows/copilot-setup-steps.yml` Actions workflow file in your repository if you do not already have one.
157
+
1. Add an Azure login step to the `copilot-setup-steps` workflow job.
This configuration ensures the `azure/login` action is executed when {% data variables.copilot.copilot_coding_agent %} runs.
182
+
183
+
1. In your repository’s {% data variables.product.prodname_copilot_short %} environment, add secrets for your `AZURE_CLIENT_ID`, `AZURE_TENANT_ID` and `AZURE_SUBSCRIPTION_ID`.
184
+
1. Configure the Azure MCP server by adding an `azure` object to your MCP configuration.
185
+
186
+
```json copy
187
+
{
188
+
"mcpServers": {
189
+
"Azure MCP Server": {
190
+
"command": "npx",
191
+
"args": [
192
+
"-y",
193
+
"@azure/mcp@latest",
194
+
"server",
195
+
"start"
196
+
]
197
+
}
198
+
}
199
+
}
200
+
```
201
+
202
+
## Reusing your MCP configuration from {% data variables.product.prodname_vscode %}
203
+
204
+
If you have already configured MCP servers in {% data variables.product.prodname_vscode_shortname %}, you can leverage a similar configuration for {% data variables.copilot.copilot_coding_agent %}.
131
205
132
206
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.
133
207
134
208
To adapt the configuration for {% data variables.copilot.copilot_coding_agent %}, you will need to:
135
209
136
-
1. Add a `tools` key for each MCP server, specifying the tools that should be available to {% data variables.product.prodname_copilot_short %}.
210
+
1. Add a `tools` key for each MCP server, specifying which tools will be available to {% data variables.product.prodname_copilot_short %}.
137
211
1. If you've configured `inputs`, switch to using `env` directly.
138
212
1. If you've configured an `envFile`, switch to using `env` directly.
139
213
1. Update any references to `inputs` in your `args` configuration to refer to environment variables from `env` instead.
140
214
141
215
For more information on MCP in {% data variables.product.prodname_vscode_shortname %}, see the [{% data variables.product.prodname_vscode_shortname %} docs](https://code.visualstudio.com/docs/copilot/chat/mcp-servers).
142
216
143
-
###Adding your configuration to your repository
217
+
## Adding your configuration to your repository
144
218
145
219
Repository administrators can configure MCP servers by following these steps:
146
220
@@ -168,7 +242,7 @@ You must be a repository administrator to configure a {% data variables.product.
168
242
1. Under "Environment secrets", click **Add environment secret**.
169
243
1. Give the secret a name beginning `COPILOT_MCP_`, add the secret value, then click **Add secret**.
170
244
171
-
###Validating your MCP configuration
245
+
## Validating your MCP configuration
172
246
173
247
Once you've set up your MCP configuration, you should test it to make sure it is set up correctly.
174
248
@@ -181,7 +255,7 @@ Once you've set up your MCP configuration, you should test it to make sure it is
181
255
1. Click the **Start MCP Servers** step to expand the logs.
182
256
1. If your MCP servers have been started successfully, you will see their tools listed at the bottom of the logs.
183
257
184
-
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` to install them. For more information, see [AUTOTITLE](/copilot/customizing-copilot/customizing-the-development-environment-for-copilot-coding-agent).
258
+
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](/copilot/customizing-copilot/customizing-the-development-environment-for-copilot-coding-agent).
185
259
186
260
## Customizing the built-in {% data variables.product.github %} MCP server
187
261
@@ -202,7 +276,7 @@ If you want to allow {% data variables.product.prodname_copilot_short %} to acce
202
276
1. Under "Environment secrets", click **Add environment secret**.
203
277
1. Call the secret `COPILOT_MCP_GITHUB_PERSONAL_ACCESS_TOKEN`, enter your {% data variables.product.pat_generic %} in the "Value" field, then click **Add secret**.
204
278
205
-
## Best practices for using MCP servers in {% data variables.copilot.copilot_coding_agent %}
279
+
## Best practices
206
280
207
281
* Enabling third-party MCP servers for use may impact the performance of the agent and the quality of the outputs. Review the third-party MCP server thoroughly and ensure that it meets your organization’s requirements.
0 commit comments