Skip to content

Commit 7984b06

Browse files
isaacmbrownCopilotjc-clark
authored
Giving CCA access to resources in an organization (#60757)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Joe Clark <31087804+jc-clark@users.noreply.github.com>
1 parent 15e9917 commit 7984b06

5 files changed

Lines changed: 132 additions & 27 deletions

File tree

content/copilot/how-tos/use-copilot-agents/cloud-agent/customize-the-agent-environment.md

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ redirect_from:
1313
- /copilot/how-tos/agents/copilot-coding-agent/customize-the-agent-environment
1414
- /copilot/how-tos/agents/coding-agent/customize-the-agent-environment
1515
contentType: how-tos
16-
category:
16+
category:
1717
- Configure Copilot
1818
---
1919

@@ -110,28 +110,7 @@ In its ephemeral development environment, {% data variables.product.prodname_cop
110110

111111
You can use a Copilot setup steps file to deterministically install tools or dependencies before {% data variables.product.prodname_copilot_short %} starts work. To do this, add `steps` to the `copilot-setup-steps` job:
112112

113-
```yaml
114-
# ...
115-
116-
jobs:
117-
copilot-setup-steps:
118-
# ...
119-
120-
# You can define any steps you want, and they will run before the agent starts.
121-
# If you do not check out your code, Copilot will do this for you.
122-
steps:
123-
- name: Checkout code
124-
uses: {% data reusables.actions.action-checkout %}
125-
126-
- name: Set up Node.js
127-
uses: {% data reusables.actions.action-setup-node %}
128-
with:
129-
node-version: "20"
130-
cache: "npm"
131-
132-
- name: Install JavaScript dependencies
133-
run: npm ci
134-
```
113+
{% data reusables.copilot.cloud-agent.install-dependencies %}
135114

136115
## Upgrading to larger {% data variables.product.prodname_dotcom %}-hosted {% data variables.product.prodname_actions %} runners
137116

@@ -158,14 +137,14 @@ By default, {% data variables.product.prodname_copilot_short %} works in a stand
158137

159138
## Using self-hosted {% data variables.product.prodname_actions %} runners
160139

161-
You can run {% data variables.copilot.copilot_cloud_agent %} on self-hosted runners. You may want to do this to match how you run CI/CD workflows on {% data variables.product.prodname_actions %}, or to give {% data variables.product.prodname_copilot_short %} access to internal resources on your network.
140+
You can run {% data variables.copilot.copilot_cloud_agent %} on self-hosted runners. You may want to do this to match how you run CI/CD workflows on {% data variables.product.prodname_actions %}, or to give {% data variables.product.prodname_copilot_short %} access to internal resources on your network.
162141

163142
We recommend that you only use {% data variables.copilot.copilot_cloud_agent %} with ephemeral, single-use runners that are not reused for multiple jobs. Most customers set this up using ARC (Actions Runner Controller) or the {% data variables.product.prodname_actions %} Runner Scale Set Client. For more information, see [AUTOTITLE](/actions/reference/runners/self-hosted-runners#supported-autoscaling-solutions).
164143

165144
> [!NOTE]
166145
> {% data variables.copilot.copilot_cloud_agent %} is only compatible with Ubuntu x64 and Windows 64-bit runners. Runners with macOS or other operating systems are not supported.
167146

168-
1. Configure network security controls for your {% data variables.product.prodname_actions %} runners to ensure that {% data variables.copilot.copilot_cloud_agent %} does not have open access to your network or the public internet.
147+
1. Configure network security controls for your {% data variables.product.prodname_actions %} runners to ensure that {% data variables.copilot.copilot_cloud_agent %} does not have open access to your network or the public internet.
169148

170149
You must configure your firewall to allow connections to the [standard hosts required for {% data variables.product.prodname_actions %} self-hosted runners](/actions/reference/runners/self-hosted-runners#accessible-domains-by-function), plus the following hosts:
171150

@@ -193,7 +172,7 @@ We recommend that you only use {% data variables.copilot.copilot_cloud_agent %}
193172

194173
## Switching {% data variables.product.prodname_copilot_short %} to a Windows development environment
195174

196-
By default, {% data variables.product.prodname_copilot_short %} uses an Ubuntu Linux-based development environment.
175+
By default, {% data variables.product.prodname_copilot_short %} uses an Ubuntu Linux-based development environment.
197176

198177
You may want to use a Windows development environment if you're building software for Windows or your repository uses a Windows-based toolchain so {% data variables.product.prodname_copilot_short %} can build your project, run tests and validate its work.
199178

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@ The [Sentry MCP server](https://github.com/getsentry/sentry-mcp) gives {% data v
129129
// We can use the $SENTRY_HOST environment variable which is passed to
130130
// the server because of the `env` value below.
131131
"args": ["@sentry/mcp-server@latest", "--host=$SENTRY_HOST"],
132-
"tools": ["get_issue_details", "get_issue_summary"],
133132
"env": {
134133
// We can specify an environment variable value as a string...
135134
"SENTRY_HOST": "https://contoso.sentry.io",
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
---
2+
title: 'Giving GitHub Copilot cloud agent access to resources in your organization'
3+
shortTitle: 'Give access to resources'
4+
intro: 'Get more out of {% data variables.product.prodname_copilot_short %} by giving it access to approved MCP servers and internal packages.'
5+
versions:
6+
feature: copilot
7+
contentType: tutorials
8+
category:
9+
- Manage Copilot for a team
10+
- Roll Copilot out at scale
11+
---
12+
13+
{% data variables.copilot.copilot_cloud_agent %} can connect to MCP servers, use private packages, and access external services, but only if your organization's repositories are configured to allow it.
14+
15+
Although much of the configuration below is done at the repository level, organization owners have control over which resources are in scope and who can configure access to them.
16+
17+
## Example scenario
18+
19+
Your organization uses Sentry to track bugs in your Node app. New exceptions are raised as issues on {% data variables.product.github %}, and your developers want to assign these issues to {% data variables.product.prodname_copilot_short %}.
20+
21+
You want {% data variables.product.prodname_copilot_short %} to:
22+
23+
* Connect to the Sentry MCP server so it can access details on your Sentry instance
24+
* Install dependencies, including private packages hosted on {% data variables.product.github %}, to build your app and run tests
25+
* Follow your organization's conventions for error-handling
26+
27+
## Storing secrets securely
28+
29+
By default, the scope of {% data variables.product.prodname_copilot_short %}'s authentication token is limited to the repository where it's running. This means that {% data variables.product.prodname_copilot_short %} won't be able to authenticate to external systems or access private, organization-scoped packages.
30+
31+
Repository administrators should add variables and secrets that {% data variables.product.prodname_copilot_short %} requires to a dedicated `copilot` {% data variables.product.prodname_actions %} environment. {% data variables.product.prodname_copilot_short %} can access this data in its setup and task execution. It won't be able to access variables or secrets outside this environment, such as organization-wide {% data variables.product.prodname_actions %} secrets.
32+
33+
### Example: Save a secret
34+
35+
A repository administrator saves an authentication token for the organization's Sentry instance.
36+
37+
1. Go to the **Environments** section of the repository settings.
38+
1. Create a new environment called `copilot`.
39+
1. Save an access token for your Sentry instance in an environment secret called `COPILOT_MCP_SENTRY_ACCESS_TOKEN`.
40+
41+
> [!TIP] We don't need to save a token for our private {% data variables.product.prodname_registry %} registry, which we'll access using the standard {% data variables.product.prodname_actions %} `GITHUB_TOKEN`. However, you would want to save an authentication token if you were using an external package registry.
42+
43+
## Configuring access to MCP servers
44+
45+
Organization and enterprise owners can set a policy to allow users to configure access to MCP servers. If this policy is enabled, users can configure MCP servers for {% data variables.copilot.copilot_cloud_agent %} in repository settings or in custom agent profiles. For organization-wide consistency, we recommend creating **custom agent profiles** at the organization or enterprise level.
46+
47+
A session using a custom agent has access to MCP servers configured in **both** the repository settings and the agent profile. However, the more use cases you cover with organization-wide custom agents, the less users will need to configure ad hoc access to MCP servers in repository settings.
48+
49+
We recommend browsing the [{% data variables.product.github %} MCP Registry](https://github.com/mcp) to find trusted, highly rated options.
50+
51+
### Example: Create a custom agent
52+
53+
An organization owner creates a custom agent profile for the Sentry agent. It has access to the Sentry MCP server and custom instructions for the organization's error-handling conventions.
54+
55+
1. Create a repository called `.github-private` in your organization. Optionally, an enterprise owner can set this repository as the source for all custom agents in the enterprise.
56+
1. In the repository, add an `agent.md` file with a profile like the following. This includes configuration for the MCP server, which references the secret we saved.
57+
58+
``` text
59+
---
60+
name: sentry-error-fixer
61+
description: Proposed fixes for exception issues raised from Sentry
62+
mcp-servers:
63+
sentry:
64+
type: 'local'
65+
command: 'npx'
66+
args: ['@sentry/mcp-server@latest']
67+
env:
68+
SENTRY_ACCESS_TOKEN: {% raw %}${{ secrets.COPILOT_MCP_SENTRY_ACCESS_TOKEN }}{% endraw %}
69+
---
70+
71+
You are an error resolution specialist. When you're assigned an issue created by our Sentry integration, check for error details and stack traces using the MCP server, then propose a fix.
72+
73+
Make sure you check that your proposed fix works by building the site with `npm run build` and running the test suite in `npm test`.
74+
```
75+
76+
1. When developers assign an issue to {% data variables.product.prodname_copilot_short %}, they can select the custom agent from a dropdown.
77+
78+
## Installing private packages
79+
80+
The best way to give {% data variables.product.prodname_copilot_short %} access to a project's dependencies is to install them in a `copilot-setup-steps.yml` workflow file. This file defines how the environment is set up before {% data variables.product.prodname_copilot_short %} starts working.
81+
82+
To allow the workflow to pull your private, organization-scoped packages, you will update the package settings to make sure that the repository's `GITHUB_TOKEN` has access to the package. This is more secure than using a long-lived {% data variables.product.pat_generic %} with organization permissions.
83+
84+
### Example: Install Node dependencies
85+
86+
A developer creates a workflow to install the Node dependencies defined in a repository's `package-lock.json` file. This includes private, organization-scoped packages hosted on {% data variables.product.github %}.
87+
88+
1. The developer creates a `copilot-setup-steps.yml` file in the repository.
89+
1. They add steps for installing the project's dependencies. For example:
90+
91+
{% data reusables.copilot.cloud-agent.install-dependencies %}
92+
93+
1. An organization administrator ensures that the repository has access to the organization's private packages by granting access to the repository in each package's settings. See [AUTOTITLE](/packages/learn-github-packages/configuring-a-packages-access-control-and-visibility#github-actions-access-for-packages-scoped-to-organizations).
94+
95+
>[!TIP] If you need to access packages that are hosted internally within your corporate network, you may need to run {% data variables.copilot.copilot_cloud_agent %} on self-hosted {% data variables.product.prodname_actions %} runners.
96+
97+
## Controlling who can configure these settings
98+
99+
Now you have seen how access to resources is controlled at the repository and organization levels, consider how much scope you want to give users to manage these settings.
100+
101+
1. **Choose which repositories have access** to {% data variables.copilot.copilot_cloud_agent %}. If you're concerned about a specific repository, you can block it for all users.
102+
1. **Consider who gets admin access** to these repositories. You can control this at the organization level by creating a team with the **All-repository admin** custom role. These users will be able to manage configuration _settings_, such as MCP configuration and `copilot` environments, in every repository.
103+
1. **Use rulesets and CODEOWNERS files** to control edits of configuration _files_, such as `copilot-setup-steps.yml`, which anyone with write access can edit by default.
104+
1. **Review the default firewall**. The firewall doesn't affect connections to MCP servers or setup steps in `copilot-setup-steps.yml`, but it does limit {% data variables.product.prodname_copilot_short %}'s access to the Internet during task execution. See [AUTOTITLE](/copilot/how-tos/use-copilot-agents/cloud-agent/customize-the-agent-firewall).

content/copilot/tutorials/cloud-agent/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ children:
1010
- /pilot-cloud-agent
1111
- /improve-a-project
1212
- /build-guardrails
13+
- /give-access-to-resources
1314
contentType: tutorials
1415
redirect_from:
1516
- /copilot/tutorials/coding-agent
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
```yaml
2+
# ...
3+
4+
jobs:
5+
copilot-setup-steps:
6+
# ...
7+
8+
# You can define any steps you want, and they will run before the agent starts.
9+
# If you do not check out your code, Copilot will do this for you.
10+
steps:
11+
- name: Checkout code
12+
uses: {% data reusables.actions.action-checkout %}
13+
14+
- name: Set up Node.js
15+
uses: {% data reusables.actions.action-setup-node %}
16+
with:
17+
node-version: "20"
18+
cache: "npm"
19+
20+
- name: Install JavaScript dependencies
21+
run: npm ci
22+
```

0 commit comments

Comments
 (0)