Only this pageAll pages
Powered by GitBook
1 of 7

GitBook MCP

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Development

Prerequisites

  • Supported OS: macOS (tested), Linux (expected), Windows (expected)

  • Node.js: 22.x or higher (LTS recommended)

  • npm: Latest version

  • GitBook API token:

Installation

Development

Debugging

VS Code MCP Integration (Development)

To use this MCP server in VS Code for development:

  • Use node as the command when running locally. The first argument should be the path to the compiled JavaScript output (e.g., dist/index.js).

For production or published usage, use npx instead of node:

Testing

There are currently no unit or integration tests; running npm run test only checks that the TypeScript code compiles successfully.

Contributing

  1. Fork the repository

  2. Create a feature branch

  3. Make your changes

  4. Submit a pull request

Get from GitBook
git clone https://github.com/rickysullivan/gitbook-mcp.git
cd gitbook-mcp
npm install
npm run setup
# Add your GITBOOK_API_TOKEN to .env.local (for local development only)
npm run dev
DEBUG=1 npm run dev
{
    "servers": {
        "gitbook-mcp-dev": {
            "type": "stdio",
            "command": "node",
            "args": [
                "/my/path/to/gitbook-mcp/dist/index.js",
                "--organization-id=your_organization_id"
            ],
            "env": {
                "GITBOOK_API_TOKEN": "gb_api_your_token_here"
            }
        }
    }
}
{
    "servers": {
        "gitbook-mcp": {
            "type": "stdio",
            "command": "npx",
            "args": ["gitbook-mcp", "--organization-id=your_organization_id"],
            "env": {
                "GITBOOK_API_TOKEN": "gb_api_your_token_here"
            }
        }
    }
}
npm run test

GitBook MCP Server Reference

A Model Context Protocol (MCP) server that provides access to GitBook's API for AI assistants and LLM applications.

Reference Documentation

  • API

Configuration
Error Codes
Development
AI Client Integration
Changelog

AI Client Integration

This section provides reference instructions for setting up the GitBook MCP server in popular AI clients. Use these configuration snippets to connect the MCP server to your preferred environment.

GitHub Copilot (VS Code)

Add the following to your VS Code MCP settings:

Claude Desktop

Add to your Claude Desktop configuration (~/Library/Application Support/Claude/claude_desktop_config.json on macOS):

JetBrains IDEs (GitHub Copilot plugin)

Add to your GitHub Copilot MCP settings for JetBrains IDEs (e.g., ~/.config/github-copilot/intellij/mcp.json):

JetBrains AI Assistant

Add to your JetBrains AI Assistant MCP configuration (see JetBrains documentation for the exact path):


  • Replace your_organization_id_here and gb_api_your_token_here with your actual credentials.

  • For more details, see the .

  • To obtain your credentials, see the .

Error Codes

Error Code
Description
Resolution

401

Unauthorized - Invalid API token

Verify GITBOOK_API_TOKEN is correct

403

Forbidden - Insufficient permissions

Check space/organization access permissions

404

Not Found - Resource doesn't exist

Verify space/page/collection IDs are correct

Common Issues

  • Token Issues: Ensure token starts with gb_live_, is not expired, and has correct permissions.

  • ID Resolution: Use list_organizations and list_spaces to find valid IDs.

  • Configuration Issues: Verify environment variables and CLI arguments.

{
    "servers": {
        "gitbook-mcp": {
            "type": "stdio",
            "command": "npx",
            "args": [
                "gitbook-mcp",
                "--organization-id=your_organization_id_here"
            ],
            "env": {
                "GITBOOK_API_TOKEN": "gb_api_your_token_here"
            }
        }
    }
}

429

Rate Limited - Too many requests

Implement request throttling

500

Internal Server Error

Check server logs for detailed error information

Configuration Reference
GitBook API documentation
{
    "mcpServers": {
        "gitbook-mcp": {
            "command": "npx",
            "args": ["gitbook-mcp", "--organization-id=your_organization_id"],
            "env": {
                "GITBOOK_API_TOKEN": "gb_api_your_token_here"
            }
        }
    }
}
{
    "servers": {
        "gitbook-mcp": {
            "command": "npx",
            "args": [
                "gitbook-mcp",
                "--organization-id=your_organization_id_here"
            ],
            "env": {
                "GITBOOK_API_TOKEN": "gb_api_your_token_here"
            }
        }
    }
}

Changelog

1.0.0 (2025-06-13)

  • First public release

  • Implements all documented tools and prompts

  • Supports configuration via CLI, environment, and config files

  • Includes error handling and troubleshooting reference

Configuration

Environment Variables

Variable
Required
Type
Description

GITBOOK_API_TOKEN

Yes

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

CLI Arguments

Argument
Alias
Type
Description

Example:

Configuration Files

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

  • .github/copilot-instructions.md

  • .cursorrules

  • .cursor/rules/rules.md

Format Example:

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

.cursor/rules/instructions.md

string

GitBook API token (obtain from https://app.gitbook.com/account/developer)

GITBOOK_ORGANIZATION_ID

No

string

Default organization ID for operations

GITBOOK_SPACE_ID

No

string

Default space ID for single-space projects

--organization-id

--org

string

Organization ID to work with

--space-id

--space

string

Default space for operations

node dist/index.js --organization-id your-org-id --space-id your-space-id
## GitBook Configuration

For GitBook MCP operations, use the following configuration:

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

API

Tools

Organization Discovery

List Organizations (list_organizations)

  • Behavior: 📖 Read-only, 🔄 Idempotent, 🌐 Open-world

  • Description: Lists all accessible GitBook organizations.

  • Parameters: None

  • Returns:

Space Management

List Spaces (list_spaces)

  • Behavior: 📖 Read-only, 🔄 Idempotent, 🌐 Open-world

  • Description: Lists spaces, optionally filtered by organization.

  • Parameters:

    • organizationId

Get Space Details (get_space)

  • Behavior: 📖 Read-only, 🔄 Idempotent, 🌐 Open-world

  • Description: Retrieves detailed information about a specific space.

  • Parameters:

    • spaceId

Get Space Content (get_space_content)

  • Behavior: 📖 Read-only, 🔄 Idempotent, 🌐 Open-world

  • Description: Retrieves the content structure and pages of a space.

  • Parameters:

    • spaceId

Search Content (search_content)

  • Behavior: 📖 Read-only, 🔄 Idempotent, 🌐 Open-world

  • Description: Searches for content within a space using full-text search.

  • Parameters:

    • query

Content Retrieval

Get Page Content (get_page_content)

  • Behavior: 📖 Read-only, 🔄 Idempotent, 🌐 Open-world

  • Description: Retrieves the content of a specific page.

  • Parameters:

    • pageId

Get Page by Path (get_page_by_path)

  • Behavior: 📖 Read-only, 🔄 Idempotent, 🌐 Open-world

  • Description: Retrieves page content using the page path.

  • Parameters:

    • pagePath

File Management

Get Space Files (get_space_files)

  • Behavior: 📖 Read-only, 🔄 Idempotent, 🌐 Open-world

  • Description: Lists all files in a space.

  • Parameters:

    • spaceId

Get File Details (get_file)

  • Behavior: 📖 Read-only, 🔄 Idempotent, 🌐 Open-world

  • Description: Retrieves details of a specific file.

  • Parameters:

    • fileId

Collection Management

List Collections (list_collections)

  • Behavior: 📖 Read-only, 🔄 Idempotent, 🌐 Open-world

  • Description: Lists all accessible collections.

  • Parameters:

    • organizationId

Get Collection Details (get_collection)

  • Behavior: 📖 Read-only, 🔄 Idempotent, 🌐 Open-world

  • Description: Retrieves details of a specific collection.

  • Parameters:

    • collectionId

Get Collection Spaces (get_collection_spaces)

  • Behavior: 📖 Read-only, 🔄 Idempotent, 🌐 Open-world

  • Description: Lists all spaces within a collection.

  • Parameters:

    • collectionId

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

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)

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)

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)

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)

(optional): Organization ID to filter spaces
  • Returns:

  • (required): The ID of the space to retrieve
  • Returns:

  • (optional): The ID of the space (uses default if configured)
  • Returns:

  • (required): Search query string
  • spaceId (optional): The ID of the space to search (uses default if configured)

  • Returns:

  • (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:

  • (required): The path of the page to retrieve
  • spaceId (optional): The ID of the space containing the page

  • Returns:

  • (optional): The ID of the space (uses default if configured)
  • Returns:

  • (required): The ID of the file to retrieve
  • spaceId (optional): The ID of the space containing the file

  • Returns:

  • (optional): Organization ID to filter collections
  • Returns:

  • (required): The ID of the collection to retrieve
  • Returns:

  • (required): The ID of the collection
  • Returns:

  • 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.

  • 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.

  • auditCriteria
    (optional): Specific criteria to audit (default: "general quality and consistency")
  • Returns:

    • A comprehensive quality assessment including content quality, outdated information, and style recommendations.

  • 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.

  • 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.

  • {
        "organizations": [
            {
                "id": "string",
                "title": "string",
                "urls": {
                    "app": "string",
                    "public": "string"
                }
            }
        ]
    }
    {
        "spaces": [
            {
                "id": "string",
                "title": "string",
                "visibility": "string",
                "urls": {
                    "app": "string",
                    "public": "string"
                }
            }
        ]
    }
    {
        "id": "string",
        "title": "string",
        "description": "string",
        "visibility": "string",
        "urls": {
            "app": "string",
            "public": "string"
        }
    }
    {
        "pages": [
            {
                "id": "string",
                "title": "string",
                "slug": "string",
                "path": "string"
            }
        ]
    }
    {
        "results": [
            {
                "id": "string",
                "title": "string",
                "excerpt": "string",
                "url": "string"
            }
        ]
    }
    {
        "id": "string",
        "title": "string",
        "content": "string",
        "format": "string"
    }
    {
        "id": "string",
        "title": "string",
        "content": "string",
        "path": "string"
    }
    {
        "files": [
            {
                "id": "string",
                "name": "string",
                "downloadURL": "string",
                "size": "number"
            }
        ]
    }
    {
        "id": "string",
        "name": "string",
        "downloadURL": "string",
        "size": "number",
        "uploadedAt": "string"
    }
    {
        "collections": [
            {
                "id": "string",
                "title": "string",
                "description": "string"
            }
        ]
    }
    {
        "id": "string",
        "title": "string",
        "description": "string",
        "spaces": "number"
    }
    {
        "spaces": [
            {
                "id": "string",
                "title": "string",
                "visibility": "string"
            }
        ]
    }