Before you start
- You need an API key for a GitHub Cloud organization; requesting a review needs an agentic key. See Authentication for keys and Conventions for base URLs, pagination, errors, and rate limits.
- The curl examples and the Python script read the key from
CODERABBIT_API_KEYand the API host fromCODERABBIT_API_HOST, the variables that Set up your shell sets for your region. The CLI examples use thecoderabbit apicommand. Each step also names its tool on the hosted MCP server. - The examples use repository ID
123456789and pull request42.
1. Find the repository ID
Pull request operations take the repositoryâs numeric GitHub ID, not its name. List repositories returns the repositories where CodeRabbit is installed and you have read access on GitHub.id of the repository you want. Itâs GitHubâs numeric repository ID, not the node_id. The list has no name filter, so to look up a repository by name, filter the response on full_name:
next_page_token as described in Pagination. To check a single ID, call Get a repository.
MCP tools: list_repositories, get_repository.
2. Find the pull request
List pull requests returns open pull requests. Setstate for closed or merged pull requests, and head_branch to find the pull request for a branch; add head_owner to tell forks apart.
coverage.complete is false, coverage.limitations says what the search couldnât cover; narrow the filters and search again.
To read one pull request, call Get a pull request with the repository ID and the pull requestâs number. The id field in pull request responses is GitHubâs internal ID and doesnât work in paths.
include selects the sections to return: checks (the default), threads, both, or none. Review threads default to unresolved threads that CodeRabbit started. Set thread_author=all, thread_state=all, or thread_include_outdated=true to widen that.
threads.next_page_token as thread_page_token with the same filters. If the pull requestâs head commit moves while you page, the API returns 409 head_changed; start again without the token. A threadâs replies_complete is false when the response holds only part of the replies. To read the whole discussion, call List all comments in a pull-request review thread with the threadâs id: it returns the root comment and every reply, and pages with its own page_token, separate from thread_page_token.
The reviews section shows what GitHub reports. To find out whether CodeRabbit finished reviewing the current head, use the review status in step 4.
MCP tools: list_pull_requests, get_pull_request, and list_pull_request_review_thread_comments. list_pull_requests and get_pull_request take GitHub URLs instead of a repository ID and pull request number. list_pull_request_review_thread_comments takes the repository ID, the pull request number, and the threadâs id, as the API does.
3. Request a review
Request a review asks CodeRabbit to review the pull requestâs current head. The pull request must be open.202 response means CodeRabbit accepted the request, not that the review finished. observed_head_sha is the pull requestâs head when you sent the request. CodeRabbit handles the request like a new push to the pull request and reviews whatever the head is when the review starts.
The API canât review an older commit or cancel a review.
MCP tool: request_pull_request_review. The connection needs the reviews:write scope; the review scope for local reviews doesnât include it.
4. Follow the review status
Get review status returns the pull requestâs current head and CodeRabbitâs latest review status for it. Itâs the status that Triage shows, but it doesnât depend on anyone using Triage: CodeRabbit records it as pull request events arrive.
Read the response with these rules:
- The current head is reviewed when
statusiscompletedandtarget_commit_shaequalshead_sha. completeddoesnât tell you what CodeRabbit posted. Read the summary in step 5 and the review threads from step 2.review: nullmeans CodeRabbit has no status for the pull requestâs current commit, for example because it hasnât recorded the pull request yet or because the last status belongs to an older commit. It doesnât prove that no review ran.updated_atis when the status last changed, not when you read it.
get_pull_request_review.
5. Read the summary
Get the review summary returns CodeRabbitâs latest summary comment on the pull request, the comment that carries the walkthrough.summary.body_markdown holds its Markdown without the hidden markers, and summary.source_url links to the comment on GitHub.
summary: null means CodeRabbit hasnât posted a summary comment. summary.reviewed_commit_sha is null when the commit the summary describes is unknown, so use step 4 to check that the review covers the current head.
MCP tool: get_pull_request_review_summary.
6. Read the Change Stack
Get the Change Stack returns the latest saved Change Stack for the pull request: its title and summary,groups of ordered layers, each layerâs files, line ranges, dependencies (depends_on), and Mermaid diagrams. The call never builds a Change Stack; artifact: null means none is saved.
artifact before you use it:
An outdated Change Stack stays readable. See Snapshots and freshness for how versions relate to the live pull request.
MCP tool:
get_pull_request_change_stack.
7. Read a layerâs diff
Get a layerâs diff returns unified patches for the files in one layer. Use thesnapshot_id, the group id, and the layer id from the same Change Stack response. Layer IDs are unique only within their group. For example, to pick the first layer of the first group:
data has an availability: available files carry a patch, and unavailable files are ones GitHub couldnât supply a patch for, not empty diffs. Add path to get one file of the layer. Results page by file, 50 files per page by default.
If the snapshot is gone or doesnât record its commits, the call returns 404 not_found; it doesnât fall back to a newer Change Stack. Read the Change Stack again for a current snapshot_id.
MCP tool: get_pull_request_change_stack_layer_diff.
Check every open pull request
This Python script combines steps 2 and 4: it lists every open pull request in a repository and reports whether CodeRabbit finished reviewing each oneâs current head, and why not when it hasnât. It needs therequests package and reads the key and host from CODERABBIT_API_KEY and CODERABBIT_API_HOST. Set CODERABBIT_API_HOST to the host of your region, without /v1; see Base URLs and regions.
check_reviews.py
403 stops the script and prints the error, because retrying canât fix a key that the operation doesnât accept. The script collects every page before it reads any status, so page tokens donât expire while it works, and it keys pull requests by number because a live listing can repeat one. Each status read counts toward your rate limit: on a repository with many open pull requests, the script pauses at each 429 for the time in Retry-After, then sends the same request again.
Handle errors
All errors in this flow use the error format described in Errors. The common ones:Whatâs next
Run coding tasks
Create a Coding Agent task, review its plan, and deliver its patch through the API.
Connect an MCP client
Connect an AI agent to CodeRabbit and call these operations as MCP tools.
Handle responses
Look up base URLs, pagination, error formats, and rate limits for every operation.