> For the complete documentation index, see [llms.txt](https://rickysullivan.gitbook.io/gitbook-mcp/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://rickysullivan.gitbook.io/gitbook-mcp/api.md).

# API

## Tools

### Organization Discovery

#### List Organizations (`list_organizations`)

* **Behavior:** 📖 Read-only, 🔄 Idempotent, 🌐 Open-world
* **Description:** Lists all accessible GitBook organizations.
* **Parameters:** None
* **Returns:**

```json
{
    "organizations": [
        {
            "id": "string",
            "title": "string",
            "urls": {
                "app": "string",
                "public": "string"
            }
        }
    ]
}
```

### Space Management

#### List Spaces (`list_spaces`)

* **Behavior:** 📖 Read-only, 🔄 Idempotent, 🌐 Open-world
* **Description:** Lists spaces, optionally filtered by organization.
* **Parameters:**
  * `organizationId` (optional): Organization ID to filter spaces
* **Returns:**

```json
{
    "spaces": [
        {
            "id": "string",
            "title": "string",
            "visibility": "string",
            "urls": {
                "app": "string",
                "public": "string"
            }
        }
    ]
}
```

#### Get Space Details (`get_space`)

* **Behavior:** 📖 Read-only, 🔄 Idempotent, 🌐 Open-world
* **Description:** Retrieves detailed information about a specific space.
* **Parameters:**
  * `spaceId` (required): The ID of the space to retrieve
* **Returns:**

```json
{
    "id": "string",
    "title": "string",
    "description": "string",
    "visibility": "string",
    "urls": {
        "app": "string",
        "public": "string"
    }
}
```

#### Get Space Content (`get_space_content`)

* **Behavior:** 📖 Read-only, 🔄 Idempotent, 🌐 Open-world
* **Description:** Retrieves the content structure and pages of a space.
* **Parameters:**
  * `spaceId` (optional): The ID of the space (uses default if configured)
* **Returns:**

```json
{
    "pages": [
        {
            "id": "string",
            "title": "string",
            "slug": "string",
            "path": "string"
        }
    ]
}
```

#### Search Content (`search_content`)

* **Behavior:** 📖 Read-only, 🔄 Idempotent, 🌐 Open-world
* **Description:** Searches for content within a space using full-text search.
* **Parameters:**
  * `query` (required): Search query string
  * `spaceId` (optional): The ID of the space to search (uses default if configured)
* **Returns:**

```json
{
    "results": [
        {
            "id": "string",
            "title": "string",
            "excerpt": "string",
            "url": "string"
        }
    ]
}
```

### Content Retrieval

#### Get Page Content (`get_page_content`)

* **Behavior:** 📖 Read-only, 🔄 Idempotent, 🌐 Open-world
* **Description:** Retrieves the content of a specific page.
* **Parameters:**
  * `pageId` (required): The ID of the page to retrieve
  * `spaceId` (optional): The ID of the space containing the page
  * `format` (optional): Output format (`"document"` or `"markdown"`, defaults to `"document"`)
  * `metadata` (optional): Include revision metadata (boolean, defaults to `false`)
  * `computed` (optional): Include computed revision data (boolean, defaults to `false`)
* **Returns:**

```json
{
    "id": "string",
    "title": "string",
    "content": "string",
    "format": "string"
}
```

#### Get Page by Path (`get_page_by_path`)

* **Behavior:** 📖 Read-only, 🔄 Idempotent, 🌐 Open-world
* **Description:** Retrieves page content using the page path.
* **Parameters:**
  * `pagePath` (required): The path of the page to retrieve
  * `spaceId` (optional): The ID of the space containing the page
* **Returns:**

```json
{
    "id": "string",
    "title": "string",
    "content": "string",
    "path": "string"
}
```

### File Management

#### Get Space Files (`get_space_files`)

* **Behavior:** 📖 Read-only, 🔄 Idempotent, 🌐 Open-world
* **Description:** Lists all files in a space.
* **Parameters:**
  * `spaceId` (optional): The ID of the space (uses default if configured)
* **Returns:**

```json
{
    "files": [
        {
            "id": "string",
            "name": "string",
            "downloadURL": "string",
            "size": "number"
        }
    ]
}
```

#### Get File Details (`get_file`)

* **Behavior:** 📖 Read-only, 🔄 Idempotent, 🌐 Open-world
* **Description:** Retrieves details of a specific file.
* **Parameters:**
  * `fileId` (required): The ID of the file to retrieve
  * `spaceId` (optional): The ID of the space containing the file
* **Returns:**

```json
{
    "id": "string",
    "name": "string",
    "downloadURL": "string",
    "size": "number",
    "uploadedAt": "string"
}
```

### Collection Management

#### List Collections (`list_collections`)

* **Behavior:** 📖 Read-only, 🔄 Idempotent, 🌐 Open-world
* **Description:** Lists all accessible collections.
* **Parameters:**
  * `organizationId` (optional): Organization ID to filter collections
* **Returns:**

```json
{
    "collections": [
        {
            "id": "string",
            "title": "string",
            "description": "string"
        }
    ]
}
```

#### Get Collection Details (`get_collection`)

* **Behavior:** 📖 Read-only, 🔄 Idempotent, 🌐 Open-world
* **Description:** Retrieves details of a specific collection.
* **Parameters:**
  * `collectionId` (required): The ID of the collection to retrieve
* **Returns:**

```json
{
    "id": "string",
    "title": "string",
    "description": "string",
    "spaces": "number"
}
```

#### Get Collection Spaces (`get_collection_spaces`)

* **Behavior:** 📖 Read-only, 🔄 Idempotent, 🌐 Open-world
* **Description:** Lists all spaces within a collection.
* **Parameters:**
  * `collectionId` (required): The ID of the collection
* **Returns:**

```json
{
    "spaces": [
        {
            "id": "string",
            "title": "string",
            "visibility": "string"
        }
    ]
}
```

## Prompts

### Fetch Documentation (`fetch_documentation`)

* **Description:** Fetches and analyzes GitBook documentation content for specific topics.
* **Parameters:**
  * `topic` (required): The topic or subject to search for and analyze
  * `spaceId` (optional): The ID of the space to search (uses default if configured)
  * `includeStructure` (optional): Set to "true" to include space structure
* **Returns:**
  * A comprehensive analysis of documentation related to the specified topic, including relevant pages, content summaries, and improvement areas.

### Analyze Content Gaps (`analyze_content_gaps`)

* **Description:** Identifies gaps and missing content in documentation.
* **Parameters:**
  * `spaceId` (optional): The ID of the space to analyze (uses default if configured)
  * `comparisonSource` (optional): Source to compare against (default: "internal analysis")
* **Returns:**
  * A detailed gap analysis including missing topics, incomplete sections, and suggestions for new content areas.

### Content Audit (`content_audit`)

* **Description:** Performs quality audits of documentation content.
* **Parameters:**
  * `spaceId` (optional): The ID of the space to audit (uses default if configured)
  * `auditCriteria` (optional): Specific criteria to audit (default: "general quality and consistency")
* **Returns:**
  * A comprehensive quality assessment including content quality, outdated information, and style recommendations.

### Documentation Summary (`documentation_summary`)

* **Description:** Generates comprehensive summaries of GitBook spaces.
* **Parameters:**
  * `spaceId` (optional): The ID of the space to summarize (uses default if configured)
  * `summaryType` (optional): Type of summary - "overview", "technical", "user-guide", or "custom" (default: "overview")
* **Returns:**
  * A structured summary including space structure, main topics, and target audience.

### Content Optimization (`content_optimization`)

* **Description:** Optimizes content for SEO, readability, structure, or performance.
* **Parameters:**
  * `spaceId` (optional): The ID of the space to optimize (uses default if configured)
  * `optimizationType` (required): Type of optimization - "SEO", "readability", "structure", or "performance"
  * `targetMetrics` (optional): Specific metrics or goals to optimize for
* **Returns:**
  * Optimization recommendations including improvement strategies and implementation guidance.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://rickysullivan.gitbook.io/gitbook-mcp/api.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
