Skip to content

Commit 444e74a

Browse files
almaleksiasaritai
andauthored
Add docs for new ways of adding and managing MCPs in Copilot CLI (#61336)
Co-authored-by: Sarita Iyer <66540150+saritai@users.noreply.github.com>
1 parent 024719b commit 444e74a

1 file changed

Lines changed: 110 additions & 2 deletions

File tree

content/copilot/how-tos/copilot-cli/customize-copilot/add-mcp-servers.md

Lines changed: 110 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,15 @@ The Model Context Protocol (MCP) is an open standard that defines how applicatio
2222
2323
If your organization or enterprise has configured a registry URL and allowlist policy, those settings apply to {% data variables.copilot.copilot_cli_short %}. The configured registry URL will appear as a discovery source, and only servers permitted by the allowlist policy can run.
2424

25-
You can add MCP servers using the interactive `/mcp add` command within the CLI, or by editing the configuration file directly.
25+
You can add MCP servers in the following ways:
26+
* [Using the `/mcp add` command](#using-the-mcp-add-command)
27+
* [Using the `copilot mcp add` subcommand](#using-the-copilot-mcp-add-subcommand)
28+
* [Editing the configuration file](#editing-the-configuration-file)
29+
* [Searching and installing from the registry (experimental)](#searching-and-installing-from-the-registry)
2630

2731
For installation instructions, available tools, and URLs for specific MCP servers, see the [{% data variables.product.github %} MCP Registry](https://github.com/mcp).
2832

33+
2934
### Using the `/mcp add` command
3035

3136
1. In interactive mode, enter `/mcp add`. A configuration form is displayed. Use <kbd>Tab</kbd> to navigate between fields.
@@ -50,6 +55,59 @@ For installation instructions, available tools, and URLs for specific MCP server
5055
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 `*`.
5156
1. Press <kbd>Ctrl</kbd>+<kbd>S</kbd> to save the configuration. The MCP server is added and available immediately without restarting the CLI.
5257

58+
### Using the `copilot mcp add` subcommand
59+
60+
You can add MCP servers from the terminal using the `copilot mcp add` subcommand, without entering interactive mode. The server is added to the user configuration at `~/.copilot/mcp-config.json`.
61+
62+
For local (stdio) servers, provide the command after `--`:
63+
64+
```shell copy
65+
copilot mcp add SERVER-NAME -- COMMAND [ARGS...]
66+
```
67+
68+
For remote (HTTP/SSE) servers, specify the transport and provide the URL:
69+
70+
```shell copy
71+
copilot mcp add --transport http SERVER-NAME URL
72+
```
73+
74+
You can also pass additional options:
75+
76+
* `--env KEY=VALUE`: Set environment variables for the server. Repeat for multiple variables.
77+
* `--header "HEADER: VALUE"`: Set HTTP headers for remote servers. Repeat for multiple headers.
78+
* `--transport TRANSPORT`: Set the transport type (`stdio`, `http`, or `sse`). The default is `stdio`.
79+
* `--tools TOOLS`: Specify which tools to enable. Use `*` for all tools (default), a comma-separated list, or `""` for none.
80+
* `--timeout MS`: Set a timeout in milliseconds.
81+
82+
#### Examples
83+
84+
Add a local stdio server:
85+
86+
```shell copy
87+
copilot mcp add context7 -- npx -y @upstash/context7-mcp
88+
```
89+
90+
Add a local server with environment variables:
91+
92+
```shell copy
93+
copilot mcp add github -e GITHUB_PERSONAL_ACCESS_TOKEN=YOUR_GITHUB_PAT -- docker run -i --rm -e GITHUB_PERSONAL_ACCESS_TOKEN ghcr.io/github/github-mcp-server
94+
```
95+
96+
Add a remote HTTP server:
97+
98+
```shell copy
99+
copilot mcp add --transport http notion \
100+
https://mcp.notion.com/mcp
101+
```
102+
103+
Add a remote server with an authorization header:
104+
105+
```shell copy
106+
copilot mcp add --transport http \
107+
--header "Authorization: Bearer YOUR-TOKEN" \
108+
stripe https://mcp.stripe.com
109+
```
110+
53111
### Editing the configuration file
54112

55113
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.
@@ -80,9 +138,31 @@ The following example shows a configuration file with a local server and a remot
80138

81139
For more information on MCP server configuration, see [AUTOTITLE](/copilot/how-tos/use-copilot-agents/cloud-agent/extend-cloud-agent-with-mcp#writing-a-json-configuration-for-mcp-servers).
82140

141+
### Searching and installing from the registry
142+
143+
> [!NOTE]
144+
> The `/mcp search` command is currently an experimental feature. To use it, start {% data variables.copilot.copilot_cli_short %} with the `--experimental` command line option, or enter `/experimental on` during a session.
145+
146+
You can discover and install MCP servers directly from the [{% data variables.product.github %} MCP Registry](https://github.com/mcp) using the `/mcp search` command in interactive mode. This lets you browse available servers, view their details, and install them without manually filling out the configuration form.
147+
148+
If your organization has configured a custom MCP registry URL, `/mcp search` connects to that registry instead of the default {% data variables.product.github %} registry.
149+
150+
1. In interactive mode, enter `/mcp search` to browse top servers by stars, or `/mcp search QUERY` to search for a specific server. For example:
151+
152+
```text
153+
/mcp search context7
154+
```
155+
156+
1. A keyboard-navigable list of matching servers is displayed. Use the arrow keys to browse the results.
157+
1. Select a server to open its configuration form. The form is pre-populated with the server's configuration from the registry. Fill in any required fields, such as API keys or tokens.
158+
1. Press <kbd>Ctrl</kbd>+<kbd>S</kbd> to save. The server is added to your `mcp-config.json` and started immediately.
159+
160+
83161
## Managing MCP servers
84162

85-
You can manage your configured MCP servers using the following `/mcp` commands in {% data variables.copilot.copilot_cli_short %}.
163+
You can manage your configured MCP servers using the `/mcp` commands in interactive mode or the `copilot mcp` subcommands from the terminal.
164+
165+
### Using `/mcp` commands in interactive mode
86166

87167
* **List configured MCP servers:** Use the command `/mcp show`. This displays all configured MCP servers and their current status.
88168

@@ -96,6 +176,34 @@ You can manage your configured MCP servers using the following `/mcp` commands i
96176

97177
* **Enable a previously disabled server:** Use the command `/mcp enable SERVER-NAME`.
98178

179+
### Using `copilot mcp` subcommands from the terminal
180+
181+
You can also manage MCP servers from the terminal without entering interactive mode.
182+
183+
* **List all configured servers:**
184+
185+
```shell copy
186+
copilot mcp list
187+
```
188+
189+
Lists servers from all configuration sources (user, workspace, and plugin). Add `--json` for JSON output.
190+
191+
* **View server details:**
192+
193+
```shell copy
194+
copilot mcp get SERVER-NAME
195+
```
196+
197+
Shows a server's type, status, and available tools. Add `--json` for JSON output.
198+
199+
* **Remove a server:**
200+
201+
```shell copy
202+
copilot mcp remove SERVER-NAME
203+
```
204+
205+
Removes the server from the user configuration.
206+
99207
## Using MCP servers
100208

101209
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.

0 commit comments

Comments
 (0)