git and gh in its sandbox. It can also offer GitHub’s MCP tools for API work. Each session receives its own short-lived token. The token can’t do more than the GitHub App installation allows, the access level you grant, and the repositories you pick.
The TypeScript samples assume the rl client from Client setup.
Before you begin
- You need the organization developer or admin role to connect GitHub and to change an agent’s access. See Organizations and roles.
- You need a GitHub account that can install the GitHub App on the target organization or user account. Some organizations require an owner to approve new apps.
- If your environment restricts outbound network access, you need to be able to change its network policy. See Allow GitHub hosts.
What limits a session’s access
Each layer can only narrow the one above it.Connect GitHub
- In the sidebar, click Integrations, then click Add integration.
- Choose GitHub and click Continue.
- On GitHub, choose the organization or user account and the repositories the app can reach. Approve the installation.
- Back on Integrations, confirm that the GitHub row shows State as Active.
Grant GitHub to an agent
Choose the least access that completes the task.
Pick repositories whenever you can. Without a repository list, the grant reaches every repository in the installation, including repositories added to it later.
- Console
- TypeScript
- cURL
- Open the agent. On Configuration, find Integrations and click Add integration access.
- Click Select next to the GitHub connection.
- Set Access level to Read only, Read and write, or Full: everything the installation allows.
- Clear All authorized repositories and pick the repositories, or keep it to cover the whole installation.
- Click Use this access, then click Save new version.
owner/name, up to 500. To find names, list the connection’s repositories.
To give different sessions of the same agent different repositories or accounts, grant GitHub through a vault instead. See Grant through a vault.
Allow GitHub hosts
A GitHub grant supplies a credential, not network access. If the environment’s network policy limits outbound traffic, allow these hosts, orgit and gh can’t reach GitHub:
listIntegrationProviders returns the same list as egress_hosts for github. GitHub MCP tools run outside the sandbox and don’t need these rules.
How the token reaches git and gh
gitreceives the token through a credential helper when it talks togithub.com. The helper refuses repositories outside the grant, even within the same installation.ghreceives the token only for the command being run. It isn’t stored in the sandbox’s environment or written to disk.- Tokens are short-lived and are fetched when a command needs one, so long sessions keep working.
- The model never receives the token in its context. A command the agent runs could still print it, so treat anything in the sandbox as visible to the agent.
Choose sandbox or MCP tools
A new agent turns GitHub MCP tools off with
disabled_integration_mcp_providers: ["github"], because most GitHub work runs in the sandbox. The grant still authenticates git and gh.
To turn GitHub MCP tools on, select GitHub MCP tools under the GitHub connection in the agent’s Integrations section, then click Save new version. In the API, send a version whose disabled_integration_mcp_providers leaves out github. On a new version, leaving the field out entirely turns every provider’s MCP tools on. See Tools.
Verify access
-
On Integrations, open the GitHub row’s actions menu and click Check. A passing check means GitHub issued a token. The API response’s
resource_countis how many repositories the connection can reach. -
Start a session and ask the agent to run:
git ls-remote prints a commit hash for the repository. That proves network access, a token, and a grant that includes the repository. gh auth status alone doesn’t prove repository access or write permission. To check write access, ask the agent to push a branch.
Multi-agent sessions
Subagents share the root session’s sandbox. A copy of the same agent inherits the parent’s GitHub grant. A different agent from the roster uses only its own grants. See Multi-agent.Start work from GitHub
Connecting GitHub also adds a GitHub event source. An automation with agithub trigger on that source starts a session when a matching event arrives, such as a pull request opened against main or an issue labeled agent. Filter by repository, action, branch, label, sender, and more, and give the automation an agent version that holds the GitHub grant.
setup_required, the GitHub App is waiting for you to approve its event permissions. Approve the update in GitHub, then click Check on the connection.
What can go wrong
For all error codes, see Errors.
Limits
- A grant can list up to 500 repositories.
- An agent can hold up to 25 integration connections.
Next steps
Integrations
Connect, check, reconnect, and disconnect accounts.
Fix a GitHub issue
Walk through an agent that fixes an issue and opens a pull request.
Environments
Set up the sandbox and its network policy.
Vaults and credentials
Grant GitHub per session, or add other secrets.