gitbook-mcp
Provides tools for managing GitBook documentation, including spaces, pages, change requests, reviews, comments, Git Sync, organizations, and content import.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@gitbook-mcp Create a new change request for the onboarding guide"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
gitbook-mcp
MCP Server for full GitBook API automation. Exposes 39 tools that allow AI agents (Claude Code, Cursor, etc.) to manage documentation, change requests, reviews, and Git Sync programmatically.
Quickstart
# 1. Clone
git clone <your-repo-url>
cd gitbook-mcp
# 2. Install and build
npm install
npm run build
# 3. Configure
cp .env.example .env
# Edit .env with your token (see "Configuration" below)
# 4. Run
npm startRelated MCP server: GitHub MCP Agent Server
Configuration
Environment variables
Variable | Required | Description |
| Yes | GitBook API token |
| No | Default organization ID |
| No | Default space ID |
| No | API base URL (default: |
Get your token
Create a new API Token
Copy the token to your
.env
.env example
GITBOOK_API_TOKEN=gb_api_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
GITBOOK_DEFAULT_SPACE_ID=
GITBOOK_DEFAULT_ORG_ID=AI Agent Integration
Claude Code
Add to .mcp.json in your project root:
{
"mcpServers": {
"gitbook": {
"command": "node",
"args": ["/path/to/gitbook-mcp/dist/index.js"],
"env": {
"GITBOOK_API_TOKEN": "${GITBOOK_API_TOKEN}",
"GITBOOK_DEFAULT_ORG_ID": ""
}
}
}
}Claude Code resolves ${GITBOOK_API_TOKEN} from shell environment variables. Add to your ~/.bashrc or ~/.zshrc:
export GITBOOK_API_TOKEN="your-token-here"Cursor
Add to ~/.cursor/mcp.json (global) or .cursor/mcp.json (project):
{
"mcpServers": {
"gitbook": {
"command": "node",
"args": ["/path/to/gitbook-mcp/dist/index.js"],
"env": {
"GITBOOK_API_TOKEN": "your-token-here",
"GITBOOK_DEFAULT_ORG_ID": ""
}
}
}
}In Cursor,
${VAR}interpolation is not supported. Place the token directly in the JSON.
Other MCP clients
Any client compatible with MCP via stdio transport will work. The server reads stdin/stdout following the MCP protocol.
Tools
Spaces (6)
Tool | Description |
| Get space details |
| Update title, visibility |
| Create new space in an org |
| Duplicate an existing space |
| List spaces in an org |
| Search content within a space |
Pages (8)
Tool | Description |
| Full page tree of a space |
| List pages (with pagination) |
| Read page by ID |
| Read page by URL path (e.g., |
| Outgoing links from a page |
| Pages linking to a page (backlinks) |
| List files (images, attachments) |
| File details and download URL |
Change Requests (6)
Tool | Description |
| Create new CR (similar to PR/draft) |
| List CRs of a space |
| CR details |
| Update CR title/status |
| Merge CR into main content |
| Sync CR with latest content |
Reviews (5)
Tool | Description |
| List reviews of a CR |
| Approve, request changes, or comment |
| List requested reviewers |
| Request review from specific users |
| Remove reviewer from a CR |
Comments (6)
Tool | Description |
| List comments (space or CR) |
| Post comment (supports markdown) |
| Edit existing comment |
| Delete comment |
| List replies to a comment |
| Reply to a comment |
Git Sync (3)
Tool | Description |
| Import content from a Git repo to a space |
| Export content from a space to a Git repo |
| Git Sync status and configuration |
Organizations (4)
Tool | Description |
| Organization details |
| List collections in an org |
| Collection details |
| Ask GitBook AI about the documentation |
Content Import (1)
Tool | Description |
| Import content from a URL into the org |
Architecture
src/
├── index.ts # Entrypoint — stdio transport
├── server.ts # McpServer creation
├── config.ts # Environment variable loading
├── client/
│ ├── gitbook-client.ts # HTTP client for GitBook API v1
│ └── types.ts # API response types
├── tools/
│ ├── index.ts # Registration of all 39 tools
│ ├── spaces.ts # 6 tools
│ ├── pages.ts # 8 tools
│ ├── change-requests.ts # 6 tools
│ ├── reviews.ts # 5 tools
│ ├── comments.ts # 6 tools
│ ├── git-sync.ts # 3 tools
│ ├── organizations.ts # 4 tools
│ └── content-import.ts # 1 tool
├── schemas/
│ └── index.ts # Reusable Zod schemas
└── utils/
├── errors.ts # API error handling
└── pagination.ts # Pagination helpersScripts
Command | Description |
| Compile TypeScript to |
| Start MCP server via stdio |
| Compile in watch mode (development) |
| Open MCP Inspector for debugging |
Requirements
Node.js >= 18.0.0
npm
Dependencies
Package | Version | Usage |
| ^1.12.0 | Official MCP SDK |
| ^3.24.0 | Schema validation |
| ^5.7.0 | (dev) Compilation |
Debug
MCP Inspector
npm run inspectOpens a web interface to test tools interactively.
Error logs
The server sends formatted errors back to the MCP client. GitBook API errors include:
HTTP status code
Failed endpoint
GitBook error message
Common issues
Problem | Solution |
| Set the environment variable or create the |
| Invalid or expired token — generate a new one |
| Token lacks permission for the resource |
| Incorrect space/page/org ID |
| Run |
Update
cd ~/gitbook-mcp
git pull
npm install
npm run buildLicense
MIT
Available Tools
39 toolsask_aiB
Ask GitBook AI a question about the organization's documentation content
Inputs: orgId (required), query (required).
create_change_requestB
Create a new change request (similar to a PR/draft) in a GitBook space
Inputs: spaceId (required), subject.
create_spaceA
Create a new GitBook space in an organization
Inputs: orgId (required), title (required), visibility.
delete_commentA
Delete a comment (DESTRUCTIVE: cannot be undone)
Inputs: spaceId (required), commentId (required), changeRequestId.
duplicate_spaceA
Duplicate an existing GitBook space (creates a full copy)
Inputs: spaceId (required).
get_change_requestA
Get details of a specific change request
Inputs: spaceId (required), changeRequestId (required).
get_collectionA
Get details of a specific collection in a GitBook organization
Inputs: orgId (required), collectionId (required).
get_fileA
Get details and download URL for a specific file in a GitBook space
Inputs: fileId (required), spaceId (required), changeRequestId.
get_git_infoB
Get Git sync configuration and status for a GitBook space
Inputs: spaceId (required).
get_organizationA
Get details of a GitBook organization
Inputs: orgId (required).
get_page_backlinksA
Get all pages that link to a specific page (backlinks)
Inputs: pageId (required), spaceId (required), changeRequestId.
get_page_by_idA
Get a specific page by its ID from a GitBook space (or change request)
Inputs: pageId (required), spaceId (required), changeRequestId.
get_page_by_pathA
Get a specific page by its URL path from a GitBook space (or change request)
Inputs: spaceId (required), pagePath (required), changeRequestId.
get_page_linksB
Get all outgoing links from a page
Inputs: pageId (required), spaceId (required), changeRequestId.
get_spaceA
Get details of a GitBook space by its ID
Inputs: spaceId (required).
get_space_revisionC
Get the full content tree of a GitBook space (or change request)
Inputs: spaceId (required), changeRequestId.
git_exportB
Export GitBook space content to a Git repository
Inputs: url (required), spaceId (required).
git_importA
Import content from a Git repository into a GitBook space (DESTRUCTIVE: overwrites existing content)
Inputs: url (required), spaceId (required).
import_contentA
Import content into a GitBook organization from a URL (DESTRUCTIVE: may overwrite existing content depending on target)
Inputs: url (required), orgId (required), spaceId.
list_change_requestsA
List change requests in a GitBook space
Inputs: spaceId (required), page, limit.
list_collectionsA
List all collections in a GitBook organization
Inputs: orgId (required), page, limit.
list_comment_repliesA
List replies to a specific comment
Inputs: spaceId (required), commentId (required), page, limit, +1 more.
list_commentsA
List comments on a GitBook space or change request
Inputs: spaceId (required), page, limit, changeRequestId.
list_filesA
List all files (images, attachments) in a GitBook space (or change request)
Inputs: spaceId (required), page, limit, changeRequestId.
list_pagesB
List all pages in a GitBook space (or change request)
Inputs: spaceId (required), page, limit, changeRequestId.
list_requested_reviewersB
List users who have been requested to review a change request
Inputs: spaceId (required), changeRequestId (required).
list_reviewsA
List reviews on a change request
Inputs: spaceId (required), changeRequestId (required), page, limit.
list_spacesB
List all spaces in a GitBook organization
Inputs: orgId (required), page, limit.
merge_change_requestB
Merge a change request into the main content (DESTRUCTIVE: publishes changes)
Inputs: spaceId (required), changeRequestId (required).
post_commentA
Post a new comment on a GitBook space or change request
Inputs: body (required), spaceId (required), changeRequestId.
post_comment_replyA
Post a reply to an existing comment
Inputs: body (required), spaceId (required), commentId (required), changeRequestId.
remove_reviewerA
Remove a requested reviewer from a change request (DESTRUCTIVE)
Inputs: userId (required), spaceId (required), changeRequestId (required).
request_reviewersB
Request specific users to review a change request
Inputs: spaceId (required), userIds (required), changeRequestId (required).
search_space_contentB
Search for content within a GitBook space
Inputs: query (required), spaceId (required), page, limit.
submit_reviewA
Submit a review on a change request (approve, request changes, or comment)
Inputs: status (required), spaceId (required), changeRequestId (required), comment.
sync_change_requestB
Sync/update a change request with the latest main content
Inputs: spaceId (required), changeRequestId (required).
update_change_requestB
Update a change request's properties (subject, status, etc.)
Inputs: spaceId (required), changeRequestId (required), status, subject.
update_commentA
Update an existing comment (uses PUT as per GitBook API)
Inputs: body (required), spaceId (required), commentId (required), changeRequestId.
update_spaceB
Update a GitBook space's properties (title, visibility, etc.)
Inputs: spaceId (required), title, visibility.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 39 tools
Most tools target distinct resource-action pairs, but a few overlaps exist: get_page_by_id vs get_page_by_path both retrieve pages, and git_import vs import_content both perform destructive imports from different sources. These are minor confusions, as the descriptions clarify the differences.
The naming convention is predominantly verb_noun in snake_case (e.g., get_space, create_change_request, list_comments), which is consistent. However, git_import and git_export break the pattern by placing the noun first, and ask_ai is slightly anomalous. Overall, the style is readable and predictable with only minor deviations.
With 39 tools, this server is heavily over-scoped for an MCP server. The domain of GitBook is broad, but the tool count exceeds the typical range and feels unwieldy. Many tools are narrowly focused (e.g., list_requested_reviewers vs remove_reviewer), and consolidation could reduce the count while maintaining functionality.
Significant gaps exist in page management: there are no tools to create, update, or delete pages directly. While change requests are well-covered, the inability to manage pages is a critical omission. Also missing are delete operations for spaces and change requests, limiting lifecycle completeness.
Maintenance
Related MCP Connectors
MCP server for your apps' tools and custom tools, plus hosted AI agents and approval-gated workflows
MCP server for agentverse documentation, generated by doc2mcp.
MCP server connecting AI agents to 100+ apps (Gmail, Slack, Notion, GitHub) via one-click OAuth.
MCP server exposing the Backtest360 engine API as tools for AI agents.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceMCP server that equips AI agents with dev workflow tools including GitHub project management, conventional commits, visual regression testing, Jira/Confluence integration, and a persistent memory knowledge graph.11 npmMIT
- AlicenseBqualityCmaintenanceMCP server that exposes GitHub operations as tools for AI agents, enabling code search, issue management, and PR review.1236 PyPIMIT
- AlicenseNot gradedqualityBmaintenanceMCP server for structured document management of markdown and YAML files, with RBAC, git-based approval workflows, and semantic search, enabling agents to read, edit, and maintain documents under governance.MIT
- FlicenseNot gradedqualityBmaintenanceMCP server for AI DevTool workflow, exposing tools and resources for code review, repository chat, and repository operations.1-