Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Supported OS: macOS (tested), Linux (expected), Windows (expected)
Node.js: 22.x or higher (LTS recommended)
npm: Latest version
GitBook API token:
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:
There are currently no unit or integration tests; running npm run test only checks that the TypeScript code compiles successfully.
Fork the repository
Create a feature branch
Make your changes
Submit a pull request
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 devDEBUG=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 testA Model Context Protocol (MCP) server that provides access to GitBook's API for AI assistants and LLM applications.
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.
Add the following to your VS Code MCP settings:
Add to your Claude Desktop configuration (~/Library/Application Support/Claude/claude_desktop_config.json on macOS):
Add to your GitHub Copilot MCP settings for JetBrains IDEs (e.g., ~/.config/github-copilot/intellij/mcp.json):
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 .
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
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
{
"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"
}
}
}
}GITBOOK_API_TOKEN
Yes
Environment variables can be set in .env.local, .env, or your system environment.
Example:
The following files can be used to provide project-based configuration context:
.github/copilot-instructions.md
.cursorrules
.cursor/rules/rules.md
Format Example:
Configuration precedence (highest to lowest):
CLI Arguments
Configuration Files
Environment Variables
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.mdstring
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-herelist_organizations)Behavior: 📖 Read-only, 🔄 Idempotent, 🌐 Open-world
Description: Lists all accessible GitBook organizations.
Parameters: None
Returns:
list_spaces)Behavior: 📖 Read-only, 🔄 Idempotent, 🌐 Open-world
Description: Lists spaces, optionally filtered by organization.
Parameters:
organizationId
get_space)Behavior: 📖 Read-only, 🔄 Idempotent, 🌐 Open-world
Description: Retrieves detailed information about a specific space.
Parameters:
spaceId
get_space_content)Behavior: 📖 Read-only, 🔄 Idempotent, 🌐 Open-world
Description: Retrieves the content structure and pages of a space.
Parameters:
spaceId
search_content)Behavior: 📖 Read-only, 🔄 Idempotent, 🌐 Open-world
Description: Searches for content within a space using full-text search.
Parameters:
query
get_page_content)Behavior: 📖 Read-only, 🔄 Idempotent, 🌐 Open-world
Description: Retrieves the content of a specific page.
Parameters:
pageId
get_page_by_path)Behavior: 📖 Read-only, 🔄 Idempotent, 🌐 Open-world
Description: Retrieves page content using the page path.
Parameters:
pagePath
get_space_files)Behavior: 📖 Read-only, 🔄 Idempotent, 🌐 Open-world
Description: Lists all files in a space.
Parameters:
spaceId
get_file)Behavior: 📖 Read-only, 🔄 Idempotent, 🌐 Open-world
Description: Retrieves details of a specific file.
Parameters:
fileId
list_collections)Behavior: 📖 Read-only, 🔄 Idempotent, 🌐 Open-world
Description: Lists all accessible collections.
Parameters:
organizationId
get_collection)Behavior: 📖 Read-only, 🔄 Idempotent, 🌐 Open-world
Description: Retrieves details of a specific collection.
Parameters:
collectionId
get_collection_spaces)Behavior: 📖 Read-only, 🔄 Idempotent, 🌐 Open-world
Description: Lists all spaces within a collection.
Parameters:
collectionId
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)Description: Identifies gaps and missing content in documentation.
Parameters:
spaceId (optional): The ID of the space to analyze (uses default if configured)
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)Description: Generates comprehensive summaries of GitBook spaces.
Parameters:
spaceId (optional): The ID of the space to summarize (uses default if configured)
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)
Returns:
Returns:
Returns:
spaceId (optional): The ID of the space to search (uses default if configured)
Returns:
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:
spaceId (optional): The ID of the space containing the page
Returns:
Returns:
spaceId (optional): The ID of the space containing the file
Returns:
Returns:
Returns:
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.
comparisonSourceReturns:
A detailed gap analysis including missing topics, incomplete sections, and suggestions for new content areas.
auditCriteriaReturns:
A comprehensive quality assessment including content quality, outdated information, and style recommendations.
summaryTypeReturns:
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"
}
]
}