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

# Run local reviews with MCP

> Use Qodo Agentic Toolbox with MCP to review uncommitted or unpushed code changes before creating a pull request. Retrieve review findings and link them to a pull request.

A local review lets you review code changes before creating a pull request. Your MCP client collects the Git diff from your local worktree and sends it to Qodo for review against a pushed base commit. When the review completes, your client retrieves the findings, which can also be linked to an open pull request.

The Qodo MCP server can't read your worktree directly. Your MCP client collects the diff locally with Git commands and sends the diff inline. You don't need the Qodo CLI or another MCP server.

Before you start, connect your client to the Qodo MCP server. For more information, see [Connect Qodo Agentic Toolbox with MCP](https://docs.qodo.ai/agentic-toolbox/connect-mcp.md).

## How a local review runs

A local review is asynchronous. The start call returns a receipt, not the review.

**1. Start the review**

Call `start-pre-pr-review`. It returns an operation receipt with an `operation_id`.

**2. Poll for completion**

Call `get-managed-agent-operation` with the `operation_id` until `terminal` is `true`. Wait at least `poll_interval_seconds` between calls. Polling sooner returns `MT-RATE-LIMITED` with a retry delay.

**3. Read the findings**

When `status` is `completed` and `result_available` is `true`, call `get-managed-agent-result` to read the findings.

Each lifecycle response includes:

| Field | Description |
| - | - |
| `status` | One of `working`, `input_required`, `completed`, `failed`, or `cancelled`. |
| `terminal` | `true` when the status is `completed`, `failed`, or `cancelled`. |
| `result_available` | `true` only when the review completed. No result exists before completion. |
| `poll_interval_seconds` | The minimum wait between polls. |
| `expires_at` | When the operation expires. While the review is still running, `expiry_may_extend` is `true`. |
| `error` | The error code and message when the review failed. |

When a review fails, don't start another attempt automatically. A validation error (`MT-VALIDATION`) describes what to change in the request. Don't retry unchanged input.

### Read the result

`get-managed-agent-result` returns the result as JSON in chunks of up to 32 KiB:

**1. Fetch the first chunk**

Call it with the `operation_id`.

**2. Follow the cursor**

While `next_cursor` is not `null`, call it again with `cursor` set to `next_cursor`.

**3. Concatenate the chunks**

Concatenate the `chunk` values in order.

**4. Verify and parse**

Verify the SHA-256 digest of the combined text against `sha256`, then parse it as JSON.

Each finding in the result has an `id`. For local findings, `meta.local_review_ids` maps each finding `id` to the `local_review_id` you need to dismiss the finding or mark it as implemented.

### Cancel or find a review

Use these tools to cancel an active review or find its operation ID.

* `cancel-managed-agent-operation`: Requests cancellation of a review. The response doesn't confirm that the remote review stopped, so poll the operation to see its terminal status.
* `list-managed-agent-operations`: Lists the `operation_id` values of your active local reviews. Completed and expired reviews aren't included.

## Start a review

Use `start-pre-pr-review` to submit a local review. The request includes a unique `request_id` and a params `object` containing the repository, base commit, and Git diff."

### Required fields

| Field | Description |
| - | - |
| `request_id` | A stable key for this review, up to 256 characters. To retry after a timeout or reconnect, reuse the same `request_id` with the same arguments. |
| `params.repo_full_name` | The repository as `org/repo`, or `org/project/repo` for Azure DevOps. |
| `params.base_sha` | The full 40- or 64-character commit SHA that the diff is based on. This commit must be pushed to your Git provider, because Qodo clones it. |
| `params.diff` | The inline Git unified diff of your changes on top of `base_sha`. |

### Common optional fields

| Field | Description |
| - | - |
| `params.branch` | The name of your local branch. Required to save findings and to link them to a PR. |
| `params.commit_sha` | Your local `HEAD` from `git rev-parse --verify HEAD`. It can be unpushed. Required to link findings to a PR. |
| `params.comparison_branch` | The pull request's target branch. Accepted forms include `main`, `origin/main`, and `refs/heads/main`. Use the same value across reviews. Required to link findings to a PR. Offered only when the server advertises local review history. |
| `params.title`, `params.description` | The title and description of the change. |
| `params.context_refs` | Up to 50 ticket keys or HTTP(S) links to the ticket, spec, or design behind the change. |
| `params.session_context` | The coding-session context: `summary` or `notes`, `decisions` (up to 50), and `recent_work` (up to 50 items describing what changed since the previous review). |
| `params.review_scope` | A description of what the diff covers. See [Collect the diff](#collect-the-diff). |
| `params.depth` | `fast` for a single-model review or `deep` for a multi-model review. Omit it to use your deployment's default. |

### Important notes

The start tool's schema can change between deployments. Before you send optional fields, read the live schema that your client receives from the server, and send only the fields it lists.

`start-pre-pr-review` doesn't take an `idempotency_key` argument. `request_id` is its retry key. If you also send `io.qodo/idempotency-key` in the request `_meta`, it must match `request_id`.

## Collect the diff

Your MCP client must collect and send a Git diff that Qodo can apply to `base_sha`. Follow these guidelines to ensure the diff is accepted:

**1. Generate the diff**

Run `git -c core.quotePath=false diff --src-prefix=a/ --dst-prefix=b/ <base_sha>` so that every file header uses unquoted `a/` and `b/` paths.

**2. Include all relevant changes**

Include committed changes since `base_sha`, staged and unstaged changes, and patches for untracked files you want reviewed.

**3. Send the diff inline**

Send the diff text inline, never a local file path.

**4. Exclude unsupported files**

Exclude files that Qodo rejects: `.env*` files, credentials, private keys, and other sensitive files; binary files; symlinks; and files whose names produce quoted or ambiguous Git headers.

**5. Report omissions in review\_scope**

Report what you left out in `review_scope`:

| Field | Description |
| - | - |
| `stream_id` | Required in `review_scope`. A stable 64-character hexadecimal ID for this worktree. It isn't a credential. |
| `paths` | The Git pathspecs you reviewed. Empty means the whole worktree. |
| `excluded_files` | Every file you left out of the diff. |
| `skipped_files` | The reason for each omission, as `file` and `why`. Each `file` must also appear in `excluded_files`. |
| `allowed_sensitive_files` | Exact paths of sensitive files that the user explicitly approved for this review. |
| `complete` | Set to `false` when collection hit a limit or you can't confirm what the diff covers. |

Omitted files aren't reviewed. Don't describe them as reviewed or clean.

### Size limits

| Limit | Value |
| - | - |
| `diff` | 4 MiB of UTF-8 text. |
| `incremental_diff` | 4 MiB of UTF-8 text. |
| `description` | 65,536 characters. |
| Other text fields | 16,384 characters each. |
| MCP request body | 8 MiB by default. Your deployment can configure a different limit. |

A request body over the limit returns HTTP `413` with the error code `MT-VALIDATION`. A `diff` over 4 MiB returns `MT-VALIDATION`. To fit the limits, narrow the review with `review_scope.paths` and report the rest in `excluded_files`.

## Save local review findings and link to a pull request

Qodo saves the findings of a local review only when the request includes `branch`. Without a branch, the review still returns findings, but they're not saved and can't be linked to a PR later.

When the review completes, Qodo links its findings to an open PR if all of these conditions are met:

* The request includes `branch`, `comparison_branch`, and `commit_sha`.
* Exactly one open PR merges `branch` into `comparison_branch`, and its head commit equals `commit_sha`.
* The PR's source branch is in the same repository. PRs from forks aren't linked.

If your deployment doesn't offer `comparison_branch`, Qodo doesn't link local findings to an open PR when the review completes.

When Qodo reviews the PR later, it carries over local findings from the last 7 days whose code appears in the PR diff. Findings recorded as implemented or outdated aren't carried over as open findings. Dismissing a finding doesn't stop it from being carried over.

## Resolve local findings

Use `pr-review-dismiss` or `pr-review-mark-implemented` to close local findings. Pass the finding IDs, the `local_review_id` of the review that raised them, and an `idempotency_key`. Batch only findings from the same local review in one call. For more information, see [Qodo tools reference](https://docs.qodo.ai/agentic-toolbox/qodo-tools-reference.md#pr-review-tools).

## Track local review findings in Code review analytics

The Code review analytics dashboard shows how many findings Qodo raised in local reviews before a PR existed, in the Where findings were raised view. It counts local findings that are linked to a PR. For more information, see [Qodo code review analytics](https://docs.qodo.ai/governance/code-review-analytics.md).

## Related resources

* [Connect Qodo Agentic Toolbox with MCP](https://docs.qodo.ai/agentic-toolbox/connect-mcp.md): Connect your MCP client to the Qodo MCP server.
* [Reviewer skill](https://docs.qodo.ai/agentic-toolbox/agentic-toolbox-codebase-review-skill.md): Learn what a local review checks and when to use it.
* [Qodo tools reference](https://docs.qodo.ai/agentic-toolbox/qodo-tools-reference.md): Find the CLI and MCP names of every Qodo tool.


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