Skip to content

Commit 084fffc

Browse files
hubwriterCopilotnhu-do
authored
Copilot coding agent: Add Azure MCP server example (#55731)
Co-authored-by: Copilot <[email protected]> Co-authored-by: Nhu Do <[email protected]>
1 parent 8bd7da7 commit 084fffc

File tree

1 file changed

+87
-13
lines changed

1 file changed

+87
-13
lines changed

content/copilot/customizing-copilot/extending-copilot-coding-agent-with-mcp.md

Lines changed: 87 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,26 +33,47 @@ Once you've configured an MCP server, {% data variables.product.prodname_copilot
3333

3434
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 %}.
3535

36-
## Setting up MCP servers in a repository
36+
## About setting up MCP servers in a repository
3737

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 %}.
3939

4040
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.
4141

4242
### Creating your JSON MCP configuration
4343

4444
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.
4545

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+
4664
The configuration object can contain the following keys:
4765

4866
* `command` (`string`): The command to run to start the MCP server.
4967
* `args` (`string[]`): The arguments to pass to the `command`.
5068
* `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"`.
5170
* `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:
5271
* The name of a {% data variables.product.prodname_actions %} secret you have configured, beginning with `COPILOT_MCP_`.
5372
* A string value.
5473

55-
#### Example: Playwright
74+
## Example configurations
75+
76+
### Example: Playwright
5677

5778
The [Playwright MCP server](https://github.com/microsoft/playwright-mcp) provides tools which allow {% data variables.product.prodname_copilot_short %} to browse the internet.
5879

@@ -68,7 +89,7 @@ The [Playwright MCP server](https://github.com/microsoft/playwright-mcp) provide
6889
}
6990
```
7091

71-
#### Example: Sentry
92+
### Example: Sentry
7293

7394
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).
7495

@@ -94,7 +115,7 @@ The [Sentry MCP server](https://github.com/getsentry/sentry-mcp) gives {% data v
94115
}
95116
```
96117

97-
#### Example: Notion
118+
### Example: Notion
98119

99120
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).
100121

@@ -125,22 +146,75 @@ The [Notion MCP server](https://github.com/makenotion/notion-mcp-server) gives {
125146
}
126147
```
127148

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.
158+
159+
```yaml copy
160+
on:
161+
workflow_dispatch:
162+
permissions:
163+
id-token: write
164+
contents: read
165+
jobs:
166+
copilot-setup-steps:
167+
runs-on: ubuntu-latest
168+
permissions:
169+
id-token: write
170+
contents: read
171+
environment: Copilot
172+
steps:
173+
- name: Azure login
174+
uses: azure/login@a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0
175+
with:
176+
client-id: ${{ secrets.AZURE_CLIENT_ID }}
177+
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
178+
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
179+
```
180+
181+
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 %}.
131205

132206
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.
133207

134208
To adapt the configuration for {% data variables.copilot.copilot_coding_agent %}, you will need to:
135209

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 %}.
137211
1. If you've configured `inputs`, switch to using `env` directly.
138212
1. If you've configured an `envFile`, switch to using `env` directly.
139213
1. Update any references to `inputs` in your `args` configuration to refer to environment variables from `env` instead.
140214

141215
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).
142216

143-
### Adding your configuration to your repository
217+
## Adding your configuration to your repository
144218

145219
Repository administrators can configure MCP servers by following these steps:
146220

@@ -168,7 +242,7 @@ You must be a repository administrator to configure a {% data variables.product.
168242
1. Under "Environment secrets", click **Add environment secret**.
169243
1. Give the secret a name beginning `COPILOT_MCP_`, add the secret value, then click **Add secret**.
170244

171-
### Validating your MCP configuration
245+
## Validating your MCP configuration
172246

173247
Once you've set up your MCP configuration, you should test it to make sure it is set up correctly.
174248

@@ -181,7 +255,7 @@ Once you've set up your MCP configuration, you should test it to make sure it is
181255
1. Click the **Start MCP Servers** step to expand the logs.
182256
1. If your MCP servers have been started successfully, you will see their tools listed at the bottom of the logs.
183257

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).
185259

186260
## Customizing the built-in {% data variables.product.github %} MCP server
187261

@@ -202,7 +276,7 @@ If you want to allow {% data variables.product.prodname_copilot_short %} to acce
202276
1. Under "Environment secrets", click **Add environment secret**.
203277
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**.
204278

205-
## Best practices for using MCP servers in {% data variables.copilot.copilot_coding_agent %}
279+
## Best practices
206280

207281
* 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.
208282

0 commit comments

Comments
 (0)