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

# Tools Reference

> Complete API reference for Greptile's 11 MCP tools

Complete reference for all tools provided by the Greptile MCP server.

<Note>
  This reference is sourced from [Greptile's official MCP documentation](https://greptile.com/docs/mcp/tool-reference). Parameters are inputs you provide when calling a tool; responses are the data returned.
</Note>

## Tools by Category

<Tabs>
  <Tab title="Custom Context">
    **4 tools for managing coding patterns and organizational standards**

    ### list\_custom\_context

    List your organization's custom context entries.

    <AccordionGroup>
      <Accordion title="Input Parameters">
        | Parameter           | Type    | Required | Description                          |
        | ------------------- | ------- | -------- | ------------------------------------ |
        | `type`              | string  | No       | `CUSTOM_INSTRUCTION` or `PATTERN`    |
        | `greptileGenerated` | boolean | No       | Filter by Greptile-generated content |
        | `limit`             | number  | No       | Max results (1-100, default 20)      |
        | `offset`            | number  | No       | Skip results for pagination          |
      </Accordion>

      <Accordion title="Response Format">
        ```json theme={}
        {
          "customContexts": [
            {
              "id": "memory_9a7fe8b3-4cc6-4c1a-9c4c-8b7f3d2e1a6c",
              "type": "CUSTOM_INSTRUCTION",
              "body": "Use async/await instead of Promise.then()",
              "status": "ACTIVE",
              "scopes": {"AND": [{"operator": "MATCHES", "field": "filepath", "value": "**/*.js"}]},
              "evidenceCount": 15,
              "commentsCount": 8,
              "createdAt": "2024-12-15T10:30:00Z"
            }
          ],
          "total": 20
        }
        ```
      </Accordion>
    </AccordionGroup>

    ***

    ### get\_custom\_context

    Get detailed information about a specific custom context entry.

    <AccordionGroup>
      <Accordion title="Input Parameters">
        | Parameter         | Type   | Required | Description       |
        | ----------------- | ------ | -------- | ----------------- |
        | `customContextId` | string | Yes      | Custom context ID |
      </Accordion>

      <Accordion title="Response Format">
        ```json theme={}
        {
          "customContext": {
            "id": "ctx_123",
            "type": "CUSTOM_INSTRUCTION",
            "body": "Always use proper error handling",
            "status": "ACTIVE",
            "scopes": {"AND": []},
            "createdAt": "2024-01-01T00:00:00Z",
            "linkedComments": [
              {
                "id": "comment_456",
                "filePath": "src/utils.js",
                "mergeRequestId": "mr_789"
              }
            ]
          }
        }
        ```
      </Accordion>
    </AccordionGroup>

    ***

    ### search\_custom\_context

    Search custom context by content.

    <AccordionGroup>
      <Accordion title="Input Parameters">
        | Parameter | Type   | Required | Description                    |
        | --------- | ------ | -------- | ------------------------------ |
        | `query`   | string | Yes      | Search term                    |
        | `limit`   | number | No       | Max results (1-50, default 10) |
      </Accordion>

      <Accordion title="Response Format">
        ```json theme={}
        {
          "customContexts": [...],
          "query": "error handling",
          "total": 3
        }
        ```
      </Accordion>
    </AccordionGroup>

    ***

    ### create\_custom\_context

    Create a new custom context entry.

    <AccordionGroup>
      <Accordion title="Input Parameters">
        | Parameter  | Type   | Required | Description                                                       |
        | ---------- | ------ | -------- | ----------------------------------------------------------------- |
        | `type`     | string | No       | `CUSTOM_INSTRUCTION` or `PATTERN` (default: `CUSTOM_INSTRUCTION`) |
        | `body`     | string | No       | Context content                                                   |
        | `scopes`   | object | No       | Where context applies (see format below)                          |
        | `status`   | string | No       | `ACTIVE`, `INACTIVE`, or `SUGGESTED`                              |
        | `metadata` | object | No       | Additional metadata                                               |

        **Scopes Format:**

        ```json theme={}
        {
          "scopes": {
            "AND": [
              {"operator": "MATCHES", "field": "filepath", "value": "**/*.js"}
            ]
          }
        }
        ```
      </Accordion>
    </AccordionGroup>
  </Tab>

  <Tab title="Pull Requests">
    **3 tools for accessing PR data and metadata**

    ### list\_merge\_requests / list\_pull\_requests

    List merge/pull requests. Both tool names work identically.

    <AccordionGroup>
      <Accordion title="Input Parameters">
        | Parameter       | Type   | Required | Description                     |
        | --------------- | ------ | -------- | ------------------------------- |
        | `name`          | string | No\*     | Repository name (owner/repo)    |
        | `remote`        | string | No\*     | `github` or `gitlab`            |
        | `defaultBranch` | string | No\*     | Repository default branch       |
        | `remoteUrl`     | string | No       | Self-hosted instance URL        |
        | `state`         | string | No       | `open`, `closed`, or `merged`   |
        | `limit`         | number | No       | Max results (1-100, default 20) |
        | `offset`        | number | No       | Skip results for pagination     |

        <Note>
          \*Repository parameters (name, remote, defaultBranch) must be provided together or omitted entirely.
        </Note>
      </Accordion>

      <Accordion title="Response Format">
        ```json theme={}
        {
          "mergeRequests": [
            {
              "id": "mr_123",
              "number": 45,
              "title": "Fix authentication bug",
              "state": "open",
              "isDraft": false,
              "authorLogin": "developer",
              "repository": {"name": "owner/repo", "remote": "github"},
              "stats": {"changedFiles": 3, "additions": 45, "deletions": 12},
              "commentsCount": 2,
              "reviewsCount": 1,
              "createdAt": "2024-01-01T00:00:00Z"
            }
          ],
          "total": 15
        }
        ```
      </Accordion>
    </AccordionGroup>

    ***

    ### get\_merge\_request

    Get detailed information about a specific PR.

    <AccordionGroup>
      <Accordion title="Input Parameters">
        | Parameter       | Type   | Required | Description                  |
        | --------------- | ------ | -------- | ---------------------------- |
        | `name`          | string | Yes      | Repository name (owner/repo) |
        | `remote`        | string | Yes      | `github` or `gitlab`         |
        | `defaultBranch` | string | Yes      | Default branch               |
        | `prNumber`      | number | Yes      | Pull request number          |
        | `remoteUrl`     | string | No       | Self-hosted instance URL     |
      </Accordion>

      <Accordion title="Response Format">
        ```json theme={}
        {
          "mergeRequest": {
            "number": 45,
            "title": "Fix authentication bug",
            "description": "...",
            "state": "open",
            "authorLogin": "developer",
            "branches": {"source": "feature/auth-fix", "target": "main"},
            "stats": {"changedFiles": 3, "additions": 45, "deletions": 12},
            "labels": ["bug"],
            "greptileComments": [...],
            "codeReviews": [...]
          }
        }
        ```
      </Accordion>
    </AccordionGroup>

    ***

    ### list\_merge\_request\_comments

    Get comments for a specific PR.

    <AccordionGroup>
      <Accordion title="Input Parameters">
        | Parameter           | Type    | Required | Description                   |
        | ------------------- | ------- | -------- | ----------------------------- |
        | `name`              | string  | Yes      | Repository name               |
        | `remote`            | string  | Yes      | `github` or `gitlab`          |
        | `defaultBranch`     | string  | Yes      | Default branch                |
        | `prNumber`          | number  | Yes      | Pull request number           |
        | `greptileGenerated` | boolean | No       | Filter Greptile comments only |
        | `addressed`         | boolean | No       | Filter by addressed status    |
        | `remoteUrl`         | string  | No       | Self-hosted instance URL      |
      </Accordion>

      <Accordion title="Response Format">
        ```json theme={}
        {
          "comments": [
            {
              "id": "comment_123",
              "body": "Consider using async/await here",
              "authorLogin": "greptile-bot",
              "filePath": "src/utils.js",
              "lineStart": 45,
              "lineEnd": 47,
              "greptileGenerated": true,
              "addressed": false,
              "createdAt": "2024-01-01T00:00:00Z",
              "linkedMemory": {
                "id": "memory_789",
                "type": "CUSTOM_INSTRUCTION",
                "body": "Always use async/await"
              }
            }
          ],
          "total": 3
        }
        ```
      </Accordion>
    </AccordionGroup>
  </Tab>

  <Tab title="Code Reviews">
    **3 tools for managing review lifecycle**

    ### list\_code\_reviews

    List code reviews.

    <AccordionGroup>
      <Accordion title="Input Parameters">
        | Parameter       | Type   | Required | Description                                                                          |
        | --------------- | ------ | -------- | ------------------------------------------------------------------------------------ |
        | `name`          | string | No       | Repository name                                                                      |
        | `remote`        | string | No       | `github` or `gitlab`                                                                 |
        | `defaultBranch` | string | No       | Default branch                                                                       |
        | `prNumber`      | number | No       | Filter by PR                                                                         |
        | `status`        | string | No       | `PENDING`, `REVIEWING_FILES`, `GENERATING_SUMMARY`, `COMPLETED`, `FAILED`, `SKIPPED` |
        | `limit`         | number | No       | Max results (1-100, default 20)                                                      |
        | `offset`        | number | No       | Skip results                                                                         |
      </Accordion>

      <Accordion title="Response Format">
        ```json theme={}
        {
          "codeReviews": [
            {
              "id": "review_123",
              "status": "COMPLETED",
              "createdAt": "2024-01-01T00:00:00Z",
              "completedAt": "2024-01-01T01:00:00Z",
              "mergeRequest": {
                "prNumber": 45,
                "title": "Fix authentication bug",
                "repository": {"name": "owner/repo"}
              }
            }
          ],
          "total": 8
        }
        ```
      </Accordion>
    </AccordionGroup>

    ***

    ### get\_code\_review

    Get detailed code review information.

    <AccordionGroup>
      <Accordion title="Input Parameters">
        | Parameter      | Type   | Required | Description    |
        | -------------- | ------ | -------- | -------------- |
        | `codeReviewId` | string | Yes      | Code review ID |
      </Accordion>

      <Accordion title="Response Format">
        ```json theme={}
        {
          "codeReview": {
            "id": "review_123",
            "body": "## Summary\n\nThis PR fixes...",
            "status": "COMPLETED",
            "createdAt": "2024-01-01T00:00:00Z",
            "completedAt": "2024-01-01T01:00:00Z",
            "mergeRequest": {
              "prNumber": 45,
              "title": "Fix authentication bug",
              "repository": {"name": "owner/repo", "remote": "github"}
            }
          }
        }
        ```
      </Accordion>
    </AccordionGroup>

    ***

    ### trigger\_code\_review

    Start a new code review on a PR.

    <AccordionGroup>
      <Accordion title="Input Parameters">
        | Parameter       | Type   | Required | Description              |
        | --------------- | ------ | -------- | ------------------------ |
        | `name`          | string | Yes      | Repository name          |
        | `remote`        | string | Yes      | `github` or `gitlab`     |
        | `defaultBranch` | string | Yes      | Default branch           |
        | `prNumber`      | number | Yes      | Pull request number      |
        | `branch`        | string | No       | Working branch           |
        | `remoteUrl`     | string | No       | Self-hosted instance URL |
      </Accordion>

      <Accordion title="Response Format">
        ```json theme={}
        {
          "success": true,
          "message": "Code review triggered successfully",
          "repository": {"name": "owner/repo", "remote": "github"},
          "prNumber": 45
        }
        ```
      </Accordion>
    </AccordionGroup>
  </Tab>

  <Tab title="Comments">
    **1 tool for searching review feedback**

    ### search\_greptile\_comments

    Search across all Greptile review comments.

    <AccordionGroup>
      <Accordion title="Input Parameters">
        | Parameter          | Type    | Required | Description                                |
        | ------------------ | ------- | -------- | ------------------------------------------ |
        | `query`            | string  | Yes      | Search term                                |
        | `limit`            | number  | No       | Max results (1-50, default 10)             |
        | `includeAddressed` | boolean | No       | Include resolved comments (default: false) |
      </Accordion>

      <Accordion title="Response Format">
        ```json theme={}
        {
          "comments": [
            {
              "id": "34567890",
              "body": "Consider adding input validation...",
              "authorLogin": "greptile-bot",
              "filePath": "src/auth/login.js",
              "lineStart": 45,
              "lineEnd": 47,
              "addressed": false,
              "createdAt": "2024-12-14T09:15:00Z",
              "mergeRequest": {
                "prNumber": 156,
                "title": "Add user authentication endpoint",
                "repository": {"name": "myorg/backend"}
              },
              "linkedMemory": {
                "id": "memory_security_001",
                "type": "PATTERN",
                "body": "Always validate and sanitize user inputs"
              }
            }
          ],
          "query": "security",
          "total": 8
        }
        ```
      </Accordion>
    </AccordionGroup>
  </Tab>
</Tabs>

## Error Responses

All tools return errors in standard JSON-RPC format:

```json theme={}
{
  "jsonrpc": "2.0",
  "id": 1,
  "error": {
    "code": -32601,
    "message": "Method not found"
  }
}
```

| Code     | Meaning                                 |
| -------- | --------------------------------------- |
| `-32700` | Parse error                             |
| `-32600` | Invalid request                         |
| `-32601` | Method not found                        |
| `-32602` | Invalid parameters                      |
| `-32603` | Internal error (includes auth failures) |

## Quick Reference

| Tool                          | Category       | Purpose                  |
| ----------------------------- | -------------- | ------------------------ |
| `list_custom_context`         | Custom Context | List all coding patterns |
| `get_custom_context`          | Custom Context | Get pattern details      |
| `search_custom_context`       | Custom Context | Search patterns          |
| `create_custom_context`       | Custom Context | Create new pattern       |
| `list_merge_requests`         | Pull Requests  | List PRs                 |
| `get_merge_request`           | Pull Requests  | Get PR details           |
| `list_merge_request_comments` | Pull Requests  | Get PR comments          |
| `list_code_reviews`           | Code Reviews   | List reviews             |
| `get_code_review`             | Code Reviews   | Get review details       |
| `trigger_code_review`         | Code Reviews   | Start new review         |
| `search_greptile_comments`    | Comments       | Search feedback          |
