Skip to content

Commit 0719a91

Browse files
Fixing up var sub for MCP in CCA (#60015)
Co-authored-by: Joe Clark <31087804+jc-clark@users.noreply.github.com>
1 parent 7ecd7d9 commit 0719a91

File tree

2 files changed

+25
-18
lines changed

2 files changed

+25
-18
lines changed

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

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -81,18 +81,27 @@ The configuration object can contain the following keys:
8181
**Local MCP specific keys**
8282
* `command` (`string`): Required. The command to run to start the MCP server.
8383
* `args` (`string[]`): Required. The arguments to pass to the `command`.
84-
* `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 either of the following:
85-
* The name of a secret you have configured in your {% data variables.product.prodname_copilot_short %} environment, beginning with `COPILOT_MCP_`.
86-
* The name of a variable you have configured in your {% data variables.product.prodname_copilot_short %} environment, beginning with `COPILOT_MCP_`.
84+
* `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:
85+
* A substitution reference to a secret or variable in your {% data variables.product.prodname_copilot_short %} environment, such as `$COPILOT_MCP_API_KEY` or `${COPILOT_MCP_API_KEY}`. Referenced names must start with `COPILOT_MCP_`.
86+
* A literal string value.
8787

8888
**Remote MCP specific keys**
8989
* `url` (`string`): Required. The MCP server's URL.
90-
* `headers` (`object`): Optional. The headers to attach to requests to the server. This object should map the name of header keys to either of the following:
91-
* The name of a secret you have configured in your {% data variables.product.prodname_copilot_short %} environment, beginning with `COPILOT_MCP_` preceded by a `$`.
92-
* The name of a variable you have configured in your {% data variables.product.prodname_copilot_short %} environment, beginning with `COPILOT_MCP_` preceded by a `$`.
93-
* A string value.
90+
* `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:
91+
* A substitution reference to a secret or variable in your {% data variables.product.prodname_copilot_short %} environment, such as `$COPILOT_MCP_API_KEY` or `${COPILOT_MCP_API_KEY}`. Referenced names must start with `COPILOT_MCP_`.
92+
* A literal string value.
9493

95-
Note that all `string` and `string[]` fields besides `tools` & `type` support substitution with a variable or secret you have configured in your {% data variables.product.prodname_copilot_short %} environment, beginning with `COPILOT_MCP_` preceded by a `$`.
94+
Note that all `string` and `string[]` fields besides `tools` & `type` support substitution with a variable or secret you have configured in your {% data variables.product.prodname_copilot_short %} environment.
95+
96+
### Variable substitution
97+
98+
The following syntax patterns are supported for referencing environment variables configured in your {% data variables.product.prodname_copilot_short %} environment:
99+
100+
| Syntax | Example |
101+
| ----------- | ------------ |
102+
| `$VAR` | `$COPILOT_MCP_API_KEY` |
103+
| `${VAR}` | `${COPILOT_MCP_API_KEY}`|
104+
| `${VAR:-default}` | `${COPILOT_MCP_API_KEY:-fallback_value}` |
96105

97106
## Example configurations
98107

@@ -121,13 +130,11 @@ The [Sentry MCP server](https://github.com/getsentry/sentry-mcp) gives {% data v
121130
"args": ["@sentry/mcp-server@latest", "--host=$SENTRY_HOST"],
122131
"tools": ["get_issue_details", "get_issue_summary"],
123132
"env": {
124-
// We can specify an environment variable value as
125-
// a variable in your {% data variables.product.prodname_copilot_short %} environment
126-
// where `COPILOT_MCP_SENTRY_HOST` = "https://contoso.sentry.io"...
127-
"SENTRY_HOST": "COPILOT_MCP_SENTRY_HOST",
128-
// or refer to a secret with a name starting with
129-
// `COPILOT_MCP_`.
130-
"SENTRY_ACCESS_TOKEN": "COPILOT_MCP_SENTRY_ACCESS_TOKEN"
133+
// We can specify an environment variable value as a string...
134+
"SENTRY_HOST": "https://contoso.sentry.io",
135+
// or refer to a variable or secret in your {% data variables.product.prodname_copilot_short %} environment
136+
// with a name starting with `COPILOT_MCP_`
137+
"SENTRY_ACCESS_TOKEN": "$COPILOT_MCP_SENTRY_ACCESS_TOKEN"
131138
}
132139
}
133140
}
@@ -158,7 +165,7 @@ The [Notion MCP server](https://github.com/makenotion/notion-mcp-server) gives {
158165
"env": {
159166
// The value of the `COPILOT_MCP_NOTION_API_KEY` secret will be passed to the
160167
// server command as an environment variable called `NOTION_API_KEY`
161-
"NOTION_API_KEY": "COPILOT_MCP_NOTION_API_KEY"
168+
"NOTION_API_KEY": "$COPILOT_MCP_NOTION_API_KEY"
162169
},
163170
"tools": ["*"]
164171
}

content/copilot/reference/custom-agents-configuration.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,14 +120,14 @@ For compatibility, the `stdio` type used by Claude Code and {% data variables.pr
120120

121121
Both the repository-level MCP JSON configuration and the {% data variables.copilot.copilot_custom_agent_short %} YAML configuration support the following syntax patterns:
122122

123-
* `COPILOT_MCP_ENV_VAR_VALUE` - Environment variable only (not recommended due to header differences)
124123
* `$COPILOT_MCP_ENV_VAR_VALUE` - Environment variable and header
125124
* `${COPILOT_MCP_ENV_VAR_VALUE}` - Environment variable and header (Claude Code syntax)
125+
* `${COPILOT_MCP_ENV_VAR_VALUE:-default}` - Environment variable and header with default
126126

127127
The {% data variables.copilot.copilot_custom_agent_short %} YAML configuration supports the following additional syntax patterns:
128128

129129
* `{% raw %}${{ secrets.COPILOT_MCP_ENV_VAR_VALUE }}{% endraw %}` - Environment variable and header
130-
* `{% raw %}${{ var.COPILOT_MCP_ENV_VAR_VALUE }}{% endraw %}` - Environment variable and header
130+
* `{% raw %}${{ vars.COPILOT_MCP_ENV_VAR_VALUE }}{% endraw %}` - Environment variable and header
131131

132132
## Example {% data variables.copilot.agent_profile %} configurations
133133

0 commit comments

Comments
 (0)