# get_knowledge

URL: https://codepanel.ai/docs/mcp-server/get_knowledge

The CodePanel MCP tool that returns a repository's review rules, notes, verdicts and learnings as one Markdown document with a version.

`get_knowledge` returns everything CodePanel's reviewers are told about a repository beyond the diff: its rules, notes, the verdicts on past findings and its learnings, as one Markdown document and as structured data. Call it before you edit that context. It needs `repo` and the `read` scope.

## When to call it

- **Before `replace_knowledge`.** The document carries a version comment, and `replace_knowledge` refuses a copy that is older than what is stored. Read it right before you edit.
- **To compact or dedupe the repository's rules and notes.** The tool's own description suggests it: merge repeats, fix stale or vague entries, send the whole document back.
- **To see what the reviewers have been told.** The `## Learnings` and `## Verdicts` sections show what the orchestrator will weigh on the files a pull request changes.

## Inputs

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `repo` | string | yes | Repository as owner/name |

It only reads: the server marks it `readOnlyHint: true`, so clients that ask before a write can run it without asking.

A repository you haven't connected, or one that isn't yours, is refused.

## What it returns

One object. `markdown` is the whole document; the other fields are the same data parsed.

| Field | Meaning |
| --- | --- |
| `repo` | The `owner/name` |
| `markdown` | The document. Its first lines hold `<!-- knowledge-version: … -->` |
| `rules` | This repository's rules: `name`, `rule`, `enabled`. A rule heading ending in `(disabled)` is `enabled: false` |
| `accountRules` | The enabled rules that apply to all your repositories: `name`, `rule`. Read-only here |
| `notes` | `type` (`custom_rules`, `conventions`, `patterns` or `architecture`), `content` and `source` (`user`, or `learned` when CodePanel wrote it) |
| `verdicts` | The most recent ratings and dismissals on this repository's findings, at most 50: `ref`, `prNumber`, `file`, `line`, `kind`, `reason`, `by`, `message`, `note`, `at` |
| `learnings` | The same list `list_learnings` returns, with `state` for each |

Only `## Rules` and `## Notes` are editable. Account rules, verdicts and learnings are context: change a verdict by re-rating its finding with [`rate_finding`](/docs/mcp-server/rate_finding), and change learnings with [`add_learning`](/docs/mcp-server/add_learning) and [`rate_learning`](/docs/mcp-server/rate_learning). Rules that live in `.codepanel/rules.md` on the base branch are not in the document: edit them in the repository.

The version is a hash of the repository's rules and notes only. A new verdict or learning doesn't change it, so a copy of the document doesn't go stale when a review is rated.

## Examples

These responses come from a test account on a local backend. The `markdown` string and the `learnings` and `verdicts` arrays are trimmed here: the full response lists learnings L1 to L4 and two verdicts, and the `markdown` repeats them.

```json title="Call"
{
  "repo": "codepanel-dev/web-app"
}
```

```json title="Result (trimmed)"
{
  "accountRules": [
    {
      "name": "No secrets in logs",
      "rule": "Never log request bodies, tokens or passwords; redact them with lib/redact.ts."
    }
  ],
  "learnings": [
    {
      "createdAt": 1794528057488,
      "number": 2,
      "prNumber": 139,
      "ref": "L2",
      "scope": "src/flags/",
      "source": "api",
      "state": {
        "needs": "an up from a person, or an up from another identity on another pull request",
        "status": "candidate"
      },
      "text": "Feature flags in src/flags/ are read on every request, never cached, so findings about stale flag values there are false positives."
    }
  ],
  "markdown": "# CodePanel knowledge: codepanel-dev/web-app\n\n<!-- knowledge-version: a0286f9f -->\n\nWhat CodePanel's reviewers are told about this repository beyond the diff. ...",
  "notes": [
    {
      "content": "Vite + React frontend in src/components and src/routes; the API lives in src/server and runs in the same Node process.",
      "source": "user",
      "type": "architecture"
    },
    {
      "content": "Data fetching goes through hooks in src/hooks; components never call fetch directly.",
      "source": "learned",
      "type": "conventions"
    }
  ],
  "repo": "codepanel-dev/web-app",
  "rules": [
    {
      "enabled": true,
      "name": "Named exports only",
      "rule": "Components and modules use named exports; no default exports."
    },
    {
      "enabled": false,
      "name": "Tests beside code",
      "rule": "A test file sits next to the module it tests, named *.test.ts."
    }
  ],
  "verdicts": []
}
```

The `rules` array holds a disabled rule, which the document writes as `### Tests beside code (disabled)`. Enabling it is an edit to that heading, shown on [`replace_knowledge`](/docs/mcp-server/replace_knowledge).

## The same step without MCP

| Surface | Form |
| --- | --- |
| CLI | `codepanel knowledge <owner/name>` prints the document; `--json` gives the full response ([CLI](/docs/cli)) |
| HTTP API | [`GET /knowledge`](/docs/api#get-knowledge) |

## What the server tells your agent

The description your agent reads when it lists the tools:

> A repository's review knowledge: `markdown` is one document with its review rules, notes and the verdicts on past findings, and rules, accountRules, notes and verdicts are the same data structured. Read it to see what CodePanel's reviewers are told about the repo, then improve it: compact, dedupe, fix stale or vague entries, and send the whole edited document back with replace_knowledge. The verdicts and learnings sections are read-only context (re-rate findings with rate_finding to change a verdict; use add_learning and rate_learning for learnings). Rules committed in `.codepanel/rules.md` are edited in the repository, not here.

## Related

- [`replace_knowledge`](/docs/mcp-server/replace_knowledge): send the edited document back.
- [`list_learnings`](/docs/mcp-server/list_learnings): just the learnings, with their state.
- [`rate_finding`](/docs/mcp-server/rate_finding): how a verdict in the document changes.
- [Repo context and custom rules](/docs/repo-context): what each kind of context does in a review.
- [MCP server](/docs/mcp-server): install, sign-in and every other tool.
