Skip to content

Commit 83634fe

Browse files
saritaiCopilotsunbrye
authored
New Copilot CLI article: Adding MCP servers for Copilot CLI (#59810)
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Co-authored-by: Sunbrye Ly <56200261+sunbrye@users.noreply.github.com>
1 parent cf11c1c commit 83634fe

6 files changed

Lines changed: 111 additions & 0 deletions

File tree

content/copilot/concepts/context/mcp.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ The {% data variables.product.github %} MCP Registry is a curated list of MCP se
9999
100100
## Next steps
101101

102+
* [AUTOTITLE](/copilot/how-tos/copilot-cli/customize-copilot/add-mcp-servers)
102103
* [AUTOTITLE](/copilot/how-tos/context/model-context-protocol/extending-copilot-chat-with-mcp)
103104
* [AUTOTITLE](/copilot/how-tos/context/model-context-protocol/using-the-github-mcp-server)
104105
* [AUTOTITLE](/copilot/tutorials/enhancing-copilot-agent-mode-with-mcp)
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
---
2+
title: Adding MCP servers for {% data variables.copilot.copilot_cli %}
3+
shortTitle: Add MCP servers
4+
allowTitleToDifferFromFilename: true
5+
intro: 'Extend {% data variables.product.prodname_copilot_short %}''s capabilities by connecting Model Context Protocol (MCP) servers to provide additional tools and context.'
6+
versions:
7+
feature: copilot
8+
topics:
9+
- Copilot
10+
contentType: how-tos
11+
category:
12+
- Configure Copilot CLI # Copilot CLI bespoke page
13+
- Author and optimize with Copilot # Copilot discovery page
14+
---
15+
16+
The Model Context Protocol (MCP) is an open standard that defines how applications share context with large language models (LLMs). You can connect MCP servers to {% data variables.copilot.copilot_cli %} to give {% data variables.product.prodname_copilot_short %} access to external tools, data sources, and services. For an overview of MCP, see [AUTOTITLE](/copilot/concepts/about-mcp).
17+
18+
## Adding an MCP server
19+
20+
> [!NOTE]
21+
> The {% data variables.product.github %} MCP server is built into {% data variables.copilot.copilot_cli_short %} and is already available without any additional configuration. The steps below are for adding other MCP servers.
22+
23+
You can add MCP servers using the interactive `/mcp add` command within the CLI, or by editing the configuration file directly.
24+
25+
For installation instructions, available tools, and URLs for specific MCP servers, see the [{% data variables.product.github %} MCP Registry](https://github.com/mcp).
26+
27+
### Using the `/mcp add` command
28+
29+
1. In interactive mode, enter `/mcp add`. A configuration form is displayed. Use <kbd>Tab</kbd> to navigate between fields.
30+
1. Next to **Server Name**, enter a unique name for the MCP server. This is the name you will use to refer to the server.
31+
1. Next to **Server Type**, select a type by pressing the corresponding number. The following types are available:
32+
33+
* **Local** or **STDIO**: starts a local process and communicates over standard input/output (`stdin`/`stdout`). Both options work the same way. **STDIO** is the standard MCP protocol type name, so choose this if you want your configuration to be compatible with {% data variables.product.prodname_vscode_shortname %}, the {% data variables.copilot.copilot_coding_agent %}, and other MCP clients.
34+
* **HTTP** or **SSE**: connects to a remote MCP server. **HTTP** uses the Streamable HTTP transport. **SSE** uses the legacy HTTP with Server-Sent Events transport, which is deprecated in the MCP specification but still supported for backwards compatibility. <!-- markdownlint-disable-line GHD046 -->
35+
36+
1. The remaining fields depend on the server type you selected:
37+
38+
* If you chose **Local** or **STDIO**:
39+
40+
* Next to **Command**, enter the command to start the server, including any arguments. For example, `npx @playwright/mcp@latest`. This corresponds to both the `command` and `args` properties in the JSON configuration file.
41+
* Next to **Environment Variables**, optionally specify environment variables the server needs, such as API keys or tokens, as JSON key-value pairs. For example, `{"API_KEY": "YOUR-API-KEY"}`. The `PATH` variable is automatically inherited from your environment. All other environment variables must be configured here.
42+
43+
* If you chose **HTTP** or **SSE**:
44+
45+
* Next to **URL**, paste the remote server URL. For example, `https://mcp.context7.com/mcp`.
46+
* Next to **HTTP Headers**, optionally specify HTTP headers as JSON. For example, `{"CONTEXT7_API_KEY": "YOUR-API-KEY"}`.
47+
48+
1. Next to **Tools**, specify which tools from the server should be available. Enter `*` to include all tools, or provide a comma-separated list of tool names (no quotes needed). The default is `*`.
49+
1. Press <kbd>Ctrl</kbd>+<kbd>S</kbd> to save the configuration. The MCP server is added and available immediately without restarting the CLI.
50+
51+
### Editing the configuration file
52+
53+
You can also add MCP servers by editing the configuration file at `~/.copilot/mcp-config.json`. This is useful if you want to share configurations or add multiple servers at once.
54+
55+
The following example shows a configuration file with a local server and a remote HTTP server:
56+
57+
```json copy
58+
{
59+
"mcpServers": {
60+
"playwright": {
61+
"type": "local",
62+
"command": "npx",
63+
"args": ["@playwright/mcp@latest"],
64+
"env": {},
65+
"tools": ["*"]
66+
},
67+
"context7": {
68+
"type": "http",
69+
"url": "https://mcp.context7.com/mcp",
70+
"headers": {
71+
"CONTEXT7_API_KEY": "YOUR-API-KEY"
72+
},
73+
"tools": ["*"]
74+
}
75+
}
76+
}
77+
```
78+
79+
For more information on MCP server configuration, see [AUTOTITLE](/copilot/how-tos/use-copilot-agents/coding-agent/extend-coding-agent-with-mcp#writing-a-json-configuration-for-mcp-servers).
80+
81+
## Managing MCP servers
82+
83+
You can manage your configured MCP servers using the following `/mcp` commands in {% data variables.copilot.copilot_cli_short %}.
84+
85+
* **List configured MCP servers:** Use the command `/mcp show`. This displays all configured MCP servers and their current status.
86+
87+
* **View details about a specific server:** Use the command `/mcp show SERVER-NAME`. This displays the status of the specified server and the list of tools it provides.
88+
89+
* **Edit a server's configuration:** Use the command `/mcp edit SERVER-NAME`.
90+
91+
* **Delete a server:** Use the command `/mcp delete SERVER-NAME`.
92+
93+
* **Disable a server:** Use the command `/mcp disable SERVER-NAME`. A disabled server remains configured but is not used by {% data variables.product.prodname_copilot_short %} for the current session.
94+
95+
* **Enable a previously disabled server:** Use the command `/mcp enable SERVER-NAME`.
96+
97+
## Using MCP servers
98+
99+
Once you have added an MCP server, {% data variables.product.prodname_copilot_short %} can automatically use the tools it provides when relevant to your prompt. You can also directly reference an MCP server and specific tools in a prompt to ensure they are used.
100+
101+
## Further reading
102+
103+
* [AUTOTITLE](/copilot/concepts/about-mcp)
104+
* [AUTOTITLE](/copilot/how-tos/provide-context/use-mcp/extend-copilot-chat-with-mcp)
105+
* [AUTOTITLE](/copilot/how-tos/use-copilot-agents/coding-agent/extend-coding-agent-with-mcp)

content/copilot/how-tos/copilot-cli/customize-copilot/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ children:
1010
- /add-custom-instructions
1111
- /use-hooks
1212
- /create-skills
13+
- /add-mcp-servers
1314
- /create-custom-agents-for-cli
1415
- /plugins-finding-installing
1516
- /plugins-creating

content/copilot/how-tos/copilot-cli/use-copilot-cli.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,8 @@ To extend the functionality available to you in {% data variables.copilot.copilo
270270
271271
Details of your configured MCP servers are stored in the `mcp-config.json` file, which is located, by default, in the `~/.copilot` directory. This location can be changed by setting the `XDG_CONFIG_HOME` environment variable. For information about the JSON structure of a server definition, see [AUTOTITLE](/copilot/how-tos/use-copilot-agents/coding-agent/extend-coding-agent-with-mcp#writing-a-json-configuration-for-mcp-servers).
272272
273+
For more detailed information on adding and managing MCP servers in {% data variables.copilot.copilot_cli_short %}, see [AUTOTITLE](/copilot/how-tos/copilot-cli/customize-copilot/add-mcp-servers).
274+
273275
### Context management
274276
275277
{% data variables.copilot.copilot_cli_short %} provides several slash commands to help you monitor and manage your context window:

content/copilot/how-tos/provide-context/use-mcp/extend-copilot-chat-with-mcp.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,7 @@ For more information on creating and configuring your own MCP servers, see [the
323323

324324
## Further reading
325325

326+
* [AUTOTITLE](/copilot/how-tos/copilot-cli/customize-copilot/add-mcp-servers)
326327
* [AUTOTITLE](/copilot/using-github-copilot/coding-agent/extending-copilot-coding-agent-with-mcp)
327328
* [AUTOTITLE](/copilot/customizing-copilot/using-model-context-protocol/using-the-github-mcp-server)
328329
* [AUTOTITLE](/copilot/tutorials/enhancing-copilot-agent-mode-with-mcp)

content/copilot/how-tos/use-copilot-agents/coding-agent/extend-coding-agent-with-mcp.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,7 @@ For information on using the {% data variables.product.github %} MCP server in o
339339

340340
## Next steps
341341

342+
* [AUTOTITLE](/copilot/how-tos/copilot-cli/customize-copilot/add-mcp-servers)
342343
* [AUTOTITLE](/copilot/how-tos/use-copilot-agents/coding-agent/create-custom-agents)
343344
* [AUTOTITLE](/copilot/customizing-copilot/customizing-the-development-environment-for-copilot-coding-agent)
344345
* [AUTOTITLE](/copilot/customizing-copilot/extending-copilot-chat-with-mcp)

0 commit comments

Comments
 (0)