> ## Documentation Index
> Fetch the complete documentation index at: https://agents.nanonets.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# GitHub Open Pull Request

> Opens a GitHub pull request from a branch; the connector never merges it.

Opens a pull request from an `agent/` branch (`head`) into `base`. The connector never merges pull requests — a person reviews and merges it on GitHub. Typical flow: `github_create_branch` → `github_commit_files` → `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 Pull requests (write) permission. The pull request is authored by the app's bot account.

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.
* `head` (required): branch with the changes, in the same repository; must start with `agent/`.
* `base` (optional): branch to merge into. Default: the repository's default branch.
* `title` (required): pull request title.
* `body` (optional): description in Markdown.
* `draft` (optional): open as a draft. Default `false`.

## Output

* `pull_request`: number, title, state, URL, author (the app's bot), head/base branch, draft flag, and last-updated time.

## Limits and side effects

* **Writes**: opens a real pull request, which notifies watchers and may trigger CI. It never merges, approves or pushes code.
* `owner`/`repo` must be plain GitHub names (letters, numbers, `.`, `_`, `-`); anything else is rejected before any API call.
* `head` and `base` 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 `-`). Cross-repository heads (`fork-owner:branch`) are not supported.
* `title` cannot be blank.

## 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.
* Blank `title`, an invalid `head`/`base` branch name, or a `head` that does not start with `agent/`.
* GitHub refuses the pull request (422) when `head` has no commits beyond `base`, a pull request for `head` is already open, or a branch does not exist.
* 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).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.