Labsco
rickysullivan logo

GitBook

โ˜… 25

from rickysullivan

Access and manage GitBook spaces and content using the GitBook API.

๐Ÿ”ฅ๐Ÿ”ฅ๐Ÿ”ฅโœ“ VerifiedAccount requiredAdvanced setup

GitBook MCP Server Reference

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

Overview

The GitBook MCP server enables programmatic access to GitBook Organizations, Spaces, Collections, and Content through a standardized MCP interface. It provides 12 tools for content operations and 6 AI-powered prompts for documentation workflows.

API Reference

Tools

The GitBook MCP server provides 12 tools organized into functional categories. Each tool includes behavioral hints:

  • ๐Ÿ“– Read-only: Tool only reads data and doesn't modify anything
  • ๐Ÿ”„ Idempotent: Repeated calls with same args have no additional effect with the same result
  • ๐ŸŒ Open-world: Tool interacts with external entities

Organization Discovery

List Organizations (list_organizations) ๐Ÿ“– ๐Ÿ”„ ๐ŸŒ

Lists all accessible GitBook organizations.

Parameters: None

Returns:

Copy & paste โ€” that's it
{
    "organizations": [
        {
            "id": "string",
            "title": "string",
            "urls": {
                "app": "string",
                "public": "string"
            }
        }
    ]
}

Space Management

List Spaces (list_spaces) ๐Ÿ“– ๐Ÿ”„ ๐ŸŒ

Lists spaces, optionally filtered by organization.

Parameters:

  • organizationId (optional): Organization ID to filter spaces

Returns:

Copy & paste โ€” that's it
{
    "spaces": [
        {
            "id": "string",
            "title": "string",
            "visibility": "string",
            "urls": {
                "app": "string",
                "public": "string"
            }
        }
    ]
}
Get Space Details (get_space) ๐Ÿ“– ๐Ÿ”„ ๐ŸŒ

Retrieves detailed information about a specific space.

Parameters:

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

Returns:

Copy & paste โ€” that's it
{
    "id": "string",
    "title": "string",
    "description": "string",
    "visibility": "string",
    "urls": {
        "app": "string",
        "public": "string"
    }
}
Get Space Content (get_space_content) ๐Ÿ“– ๐Ÿ”„ ๐ŸŒ

Retrieves the content structure and pages of a space.

Parameters:

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

Returns:

Copy & paste โ€” that's it
{
    "pages": [
        {
            "id": "string",
            "title": "string",
            "slug": "string",
            "path": "string"
        }
    ]
}
Search Content (search_content) ๐Ÿ“– ๐Ÿ”„ ๐ŸŒ

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:

Copy & paste โ€” that's it
{
    "results": [
        {
            "id": "string",
            "title": "string",
            "excerpt": "string",
            "url": "string"
        }
    ]
}

Content Retrieval

Get Page Content (get_page_content) ๐Ÿ“– ๐Ÿ”„ ๐ŸŒ

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:

Copy & paste โ€” that's it
{
    "id": "string",
    "title": "string",
    "content": "string",
    "format": "string"
}
Get Page by Path (get_page_by_path) ๐Ÿ“– ๐Ÿ”„ ๐ŸŒ

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:

Copy & paste โ€” that's it
{
    "id": "string",
    "title": "string",
    "content": "string",
    "path": "string"
}

File Management

Get Space Files (get_space_files) ๐Ÿ“– ๐Ÿ”„ ๐ŸŒ

Lists all files in a space.

Parameters:

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

Returns:

Copy & paste โ€” that's it
{
    "files": [
        {
            "id": "string",
            "name": "string",
            "downloadURL": "string",
            "size": "number"
        }
    ]
}
Get File Details (get_file) ๐Ÿ“– ๐Ÿ”„ ๐ŸŒ

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:

Copy & paste โ€” that's it
{
    "id": "string",
    "name": "string",
    "downloadURL": "string",
    "size": "number",
    "uploadedAt": "string"
}

Collection Management

List Collections (list_collections) ๐Ÿ“– ๐Ÿ”„ ๐ŸŒ

Lists all accessible collections.

Parameters:

  • organizationId (optional): Organization ID to filter collections

Returns:

Copy & paste โ€” that's it
{
    "collections": [
        {
            "id": "string",
            "title": "string",
            "description": "string"
        }
    ]
}
Get Collection Details (get_collection) ๐Ÿ“– ๐Ÿ”„ ๐ŸŒ

Retrieves details of a specific collection.

Parameters:

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

Returns:

Copy & paste โ€” that's it
{
    "id": "string",
    "title": "string",
    "description": "string",
    "spaces": "number"
}
Get Collection Spaces (get_collection_spaces) ๐Ÿ“– ๐Ÿ”„ ๐ŸŒ

Lists all spaces within a collection.

Parameters:

  • collectionId (required): The ID of the collection

Returns:

Copy & paste โ€” that's it
{
    "spaces": [
        {
            "id": "string",
            "title": "string",
            "visibility": "string"
        }
    ]
}

Prompts

The GitBook MCP server provides 6 AI-powered prompts for documentation workflows:

Fetch Documentation (fetch_documentation)

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 and sections
  • Content summaries
  • Gaps or areas needing improvement

Analyze Content Gaps (analyze_content_gaps)

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 and incomplete sections
  • Coverage gaps prioritized by importance
  • Suggestions for new content areas

Content Audit (content_audit)

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 and consistency review
  • Outdated information identification
  • Writing style and formatting recommendations

Documentation Summary (documentation_summary)

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 and content organization
  • Main topics and themes
  • Target audience and use cases

Content Optimization (content_optimization)

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:

  • Specific improvement strategies
  • Priority-ranked optimization opportunities
  • Implementation guidance

Development

Prerequisites

Installation & Setup

Copy & paste โ€” that's it
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)

Development

Copy & paste โ€” that's it
npm run dev

Debugging

Copy & paste โ€” that's it
DEBUG=1 npm run dev

Add the MCP to VS Code for development

You will need to use node as the command when running locally. The first arg should be the path to the compiled JavaScript output (e.g., dist/index.js).

Copy & paste โ€” that's it
{
    "servers": {
        "gitbook-mcp-dev": {
            "type": "stdio",
            "command": "node",
            "args": [
                "/my/path/to/gitbook-mcp/dist/index.js",
                "--organization-id=Luj2l6y6cIUPXJwbC574"
            ],
            "env": {
                "GITBOOK_API_TOKEN": "gb_api_UHEGTNsMg0ONPTnm0LpsJNBCCikQyOMkBTtZNDAB"
            }
        }
    }
}

Testing

There are currently no unit or integration tests; running npm run test only checks that the TypeScript code compiles successfully (type-check/build verification), and does not execute any actual tests.

Copy & paste โ€” that's it
npm run test

Error Handling

Common Error Codes

Error CodeDescriptionResolution
401Unauthorized - Invalid API tokenVerify GITBOOK_API_TOKEN is correct
403Forbidden - Insufficient permissionsCheck space/organization access permissions
404Not Found - Resource doesn't existVerify space/page/collection IDs are correct
429Rate Limited - Too many requestsImplement request throttling
500Internal Server ErrorCheck server logs for detailed error information

Troubleshooting

Token Issues:

  • Ensure token starts with gb_live_
  • Verify token has not expired
  • Check token permissions in GitBook settings

ID Resolution:

  • Use list_organizations to find valid organization IDs
  • Use list_spaces to find valid space IDs
  • Use get_space_content to find valid page IDs

Configuration Issues:

  • Verify environment variables are properly set
  • Check file permissions on configuration files
  • Ensure CLI arguments are properly formatted

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Submit a pull request

License

MIT License - see the LICENSE file for details.

Related Documentation

Disclaimer

This project is independently developed and is not officially affiliated with, endorsed by, or sponsored by GitBook.