Skip to main content
A GitHub grant lets an agent clone, build, commit, push, and open pull requests with 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

  1. In the sidebar, click Integrations, then click Add integration.
  2. Choose GitHub and click Continue.
  3. On GitHub, choose the organization or user account and the repositories the app can reach. Approve the installation.
  4. Back on Integrations, confirm that the GitHub row shows State as Active.
Connecting grants nothing to any agent. You can connect several GitHub accounts, for example one per GitHub organization, and grant each separately. For the API flow and connection states, see Integrations.

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.
  1. Open the agent. On Configuration, find Integrations and click Add integration access.
  2. Click Select next to the GitHub connection.
  3. Set Access level to Read only, Read and write, or Full: everything the installation allows.
  4. Clear All authorized repositories and pick the repositories, or keep it to cover the whole installation.
  5. Click Use this access, then click Save new version.
A new version replaces the whole definition, so send every field you want to keep. Name repositories as 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, or git 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

  • git receives the token through a credential helper when it talks to github.com. The helper refuses repositories outside the grant, even within the same installation.
  • gh receives 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.
When a session holds several GitHub connections, each serves its own account’s repositories.

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

  1. 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_count is how many repositories the connection can reach.
  2. Start a session and ask the agent to run:
What success means: 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 a github 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.
The session’s opening message is the automation’s prompt followed by the GitHub event as JSON, so the agent knows which issue or pull request to work on. See GitHub triggers. If the event source’s health is 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.
See Limits for every other limit.

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.