Skip to main content
Creates a new branch from another branch — the first step of changing code: create a branch, commit to it with github_commit_files, then open a pull request with github_open_pull_request.

Authentication and enablement

Requires a connected native GitHub integration (mcp:github) — a first-party GitHub App connection, not Composio. The connector is shown on Trail and to Nanonets superadmins; it is hidden from Nanonets customers during rollout. Connecting opens GitHub’s install page for the Trail GitHub App, where the user picks the account and either all repositories or only selected ones. Tools act as the app’s bot account through short-lived installation tokens — not as the connecting user — and reach only the repositories of that installation. To change which repositories are included, edit the installation on GitHub (the account’s or organization’s installed GitHub Apps settings) or reconnect. If an organization owner still has to approve the app, calls fail until they do; if the app was uninstalled or suspended, calls fail until GitHub is reconnected. Relies on the app’s Contents (write) permission. This tool changes code or runs CI, so it works only after someone with permission to update connections turns on Allow code changes for the GitHub connection on the connectors page. It is off for every new connection, because code an agent pushes can run in the repository’s CI with the repository’s secrets. Until it is on, calls fail with an error that says so.

Inputs

  • owner (required): repository owner (user or organization).
  • repo (required): repository name.
  • branch (required): new branch name starting with agent/, e.g. agent/add-sales-pipeline.
  • from (optional): existing branch to start from. Default: the repository’s default branch.

Output

  • branch: the branch created.
  • from: the branch it started from.
  • sha: the commit the new branch points at.

Limits and side effects

  • Writes: creates a branch ref. It does not change any existing branch, including the default branch.
  • branch must start with agent/. Agents only create and write to agent/ branches, so they stay off the default, release and staging branches and off branches people opened pull requests from.
  • owner/repo must be plain GitHub names (letters, numbers, ., _, -); anything else is rejected before any API call.
  • branch and from must be valid branch names (git’s ref-name rules: letters, numbers, ., _, /, -; no .., no empty part (a//b, leading or trailing /), no part starting or ending with . (so ./main is refused), no .lock suffix, no leading -). from must be a branch, not a tag or commit SHA.
  • Fails if the branch already exists — never moves an existing branch.

Expected errors

  • No GitHub connection, a connection still waiting for an organization owner to approve the app, or an app that was uninstalled or suspended (reconnect GitHub).
  • Invalid owner/repo format.
  • Code changes are not turned on for the connection.
  • Invalid branch or from name, or a branch that does not start with agent/.
  • The branch already exists.
  • from does not exist (404).
  • A ruleset restricting branch creation blocks it (403).
  • GitHub API errors surface as the tool’s error, rewritten to say what to fix: not found or no access to that repository (404), not allowed — missing app permission, protected branch or org policy (403), GitHub refused the change (409/422, with GitHub’s message), the repository is empty (no commits yet, HTTP 409), rate limit reached with the retry time (including GitHub’s secondary limits, which ask for a one-minute wait), rejected app credentials (reconnect).