> 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/configuration.md).

# Configuration

## Environment Variables

<table><thead><tr><th width="272.328125">Variable</th><th width="75.1953125">Required</th><th width="84.1953125">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>GITBOOK_API_TOKEN</code></td><td>Yes</td><td>string</td><td>GitBook API token (obtain from https://app.gitbook.com/account/developer)</td></tr><tr><td><code>GITBOOK_ORGANIZATION_ID</code></td><td>No</td><td>string</td><td>Default organization ID for operations</td></tr><tr><td><code>GITBOOK_SPACE_ID</code></td><td>No</td><td>string</td><td>Default space ID for single-space projects</td></tr></tbody></table>

* Environment variables can be set in `.env.local`, `.env`, or your system environment.

## CLI Arguments

| Argument            | Alias     | Type   | Description                  |
| ------------------- | --------- | ------ | ---------------------------- |
| `--organization-id` | `--org`   | string | Organization ID to work with |
| `--space-id`        | `--space` | string | Default space for operations |

**Example:**

```bash
node dist/index.js --organization-id your-org-id --space-id your-space-id
```

## Configuration Files

The following files can be used to provide project-based configuration context:

* `.github/copilot-instructions.md`
* `.cursorrules`
* `.cursor/rules/rules.md`
* `.cursor/rules/instructions.md`

**Format Example:**

```markdown
## GitBook Configuration

For GitBook MCP operations, use the following configuration:

- organization-id: your-org-id-here
- space-id: your-space-id-here
```

## Precedence

Configuration precedence (highest to lowest):

1. CLI Arguments
2. Configuration Files
3. Environment Variables

## Default Parameter Behavior

When `GITBOOK_ORGANIZATION_ID` or `GITBOOK_SPACE_ID` are configured:

* Tools with optional ID parameters can omit them
* Configured defaults are used automatically
* Explicit parameters override defaults


---

# 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/configuration.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.
