mcpbook
このMCPサーバーは、GitBookコンテンツをAIアシスタント向けに提供するためのもので、ドキュメントをスクレイピングしてインデックス化し、検索可能にします。自動検出、進化した検索機能、REST APIの提供により、効率的なワークフローを実現します。
GitHubスター
3
ユーザー評価
未評価
フォーク
1
イシュー
0
閲覧数
1
お気に入り
0
GitBook MCP Server
An MCP (Model Context Protocol) server that exposes GitBook content for AI assistants. This server scrapes and indexes GitBook documentation, making it searchable and accessible through MCP tools.
Features
- Universal GitBook Support: Works with any public GitBook site
- Smart Domain Detection: Automatically detects and brands for your content
- Advanced Search: Fuzzy search with stemming, normalization, and ranking
- Markdown Preservation: Converts HTML to clean markdown with formatting preserved
- Code Block Extraction: Syntax highlighting and language detection for code examples
- REST API: HTTP endpoints alongside MCP for web integration
- Intelligent Caching: Only re-scrapes changed content for performance
- Parallel Processing: Fast scraping with configurable concurrency
- MCP Prompts: Pre-built prompts for documentation workflows
- Respectful Scraping: Rate limiting and error handling built-in
Installation
npm install
npm run build
Configuration
Quick Start (Auto-Detection)
For most GitBooks, just set the URL and let auto-detection handle the rest:
cp .env.example .env
# Edit GITBOOK_URL in .env
echo "GITBOOK_URL=https://docs.yoursite.com" > .env
The server will automatically:
- Detect your domain and generate appropriate tool names
- Extract relevant keywords from your content
- Create contextual descriptions for better LLM integration
Advanced Configuration
Copy .env.example
to .env
and customize:
cp .env.example .env
Essential settings:
GITBOOK_URL
- Target GitBook URL (required)AUTO_DETECT_DOMAIN=true
- Let the server detect your domain (recommended)AUTO_DETECT_KEYWORDS=true
- Extract keywords from content (recommended)
Performance settings:
CACHE_TTL_HOURS=1
- Cache expiration timeMAX_CONCURRENT_REQUESTS=5
- Parallel scraping limitSCRAPING_DELAY_MS=100
- Delay between requests
Branding (optional - auto-detected if not set):
SERVER_NAME
- Custom server nameSERVER_DESCRIPTION
- Custom descriptionDOMAIN_KEYWORDS
- Comma-separated keywordsTOOL_PREFIX
- Prefix for tool names (e.g.,api_
→api_search_content
)
Examples
Generic Documentation:
GITBOOK_URL=https://docs.yourcompany.com
AUTO_DETECT_DOMAIN=true
AUTO_DETECT_KEYWORDS=true
API Documentation:
GITBOOK_URL=https://api-docs.yourservice.com
SERVER_NAME=yourservice-api-docs
DOMAIN_KEYWORDS=api,rest,graphql,endpoints,reference
TOOL_PREFIX=api_
Product Documentation:
GITBOOK_URL=https://help.yourproduct.com
SERVER_NAME=yourproduct-help
DOMAIN_KEYWORDS=help,tutorial,guide,troubleshooting
TOOL_PREFIX=help_
Usage
Running the Server
npm start
Installing in Claude Desktop
- Build the project:
npm run build
- Add to your
claude_desktop_config.json
:
{
"mcpServers": {
"gitbook": {
"command": "node",
"args": ["/absolute/path/to/your/mcpbook/dist/index.js"],
"env": {}
}
}
}
Config file locations:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json
- Windows:
%APPDATA%\Claude\claude_desktop_config.json
Global Installation
npm install -g .
Then in Claude Desktop config:
{
"mcpServers": {
"gitbook": {
"command": "gitbook-mcp-server"
}
}
}
Testing with MCP Inspector
npx @modelcontextprotocol/inspector node dist/index.js
Running as REST API
# Start REST API server on port 3000
npm run start:api
# Or specify custom port
PORT=8080 npm run start:api
The REST API provides HTTP endpoints for all MCP functionality:
# API documentation
curl http://localhost:3000/api
# Search content
curl "http://localhost:3000/api/search?q=authentication"
# Get specific page
curl http://localhost:3000/api/page/sdk/websdk
# Get page as markdown
curl http://localhost:3000/api/page/sdk/websdk/markdown
# Get code blocks from page
curl http://localhost:3000/api/page/api/endpoints/code
# List all sections
curl http://localhost:3000/api/sections
# Get pages in a section
curl http://localhost:3000/api/sections/SDK/pages
# Server status and stats
curl http://localhost:3000/api/status
# Refresh content cache
curl -X POST http://localhost:3000/api/refresh
Available Tools
The server exposes MCP tools with automatic prefixing based on your content:
Auto-detected examples:
- For
docs.stripe.com
→stripe_search_content
,stripe_get_page
- For
docs.yourapi.com
→api_search_content
,api_get_page
- For generic sites →
docs_search_content
,docs_get_page
Core Tools:
{prefix}_search_content
- Advanced search across all contentquery
(string): Search query with fuzzy matching and stemming
{prefix}_get_page
- Get a specific page by pathpath
(string): Page path (e.g., "/api/authentication")
{prefix}_list_sections
- Get the complete table of contents{prefix}_get_section_pages
- Get all pages in a sectionsection
(string): Section name (e.g., "API Reference")
{prefix}_refresh_content
- Force refresh of cached content{prefix}_get_code_blocks
- Extract code blocks with syntax highlightingpath
(string): Page path (e.g., "/api/authentication")
{prefix}_get_markdown
- Get page content as formatted markdownpath
(string): Page path (e.g., "/api/authentication")
MCP Prompts:
explain_section
- Generate comprehensive section tutorialssummarize_page
- Create concise page summariescompare_sections
- Compare different documentation sectionsapi_reference
- Format content as API documentationquick_start_guide
- Generate quick start guides
Example Usage
With auto-detection, tool names adapt to your content:
# For API documentation (auto-detected)
{"tool": "api_search_content", "arguments": {"query": "authentication"}}
{"tool": "api_get_page", "arguments": {"path": "/auth/oauth"}}
# For product docs (auto-detected)
{"tool": "product_search_content", "arguments": {"query": "billing"}}
{"tool": "product_get_section_pages", "arguments": {"section": "Getting Started"}}
# Generic documentation
{"tool": "docs_search_content", "arguments": {"query": "installation"}}
{"tool": "docs_refresh_content", "arguments": {}}
AI Integration
The server is designed for optimal AI assistant integration:
When the AI will use your MCP:
- Questions about your specific product/API (detected from content)
- Searches using keywords found in your documentation
- Requests for tutorials, guides, or references related to your domain
Smart tool descriptions:
- Auto-generated descriptions include your domain keywords
- Tool names reflect your content type (API, product docs, etc.)
- Enhanced context helps AI choose the right MCP server
Architecture
GitBookScraper
: Handles web scraping, content extraction, and markdown conversionContentStore
: Manages content storage and advanced search functionalityGitBookMCPServer
: Main MCP server implementation with tool handlersGitBookRestAPI
: Express.js REST API server with HTTP endpointsDomainDetector
: Auto-detection of domain branding and keywordsTextProcessor
: Content processing with stemming and normalization
Development
# Development mode with auto-reload
npm run dev
# Build
npm run build
# Run built version
npm start
How It Works
- Domain Detection: Analyzes your GitBook content to detect domain and keywords
- Parallel Scraping: Efficiently scrapes all pages using configurable concurrency
- Smart Indexing: Processes content with stemming, normalization, and fuzzy search
- Change Detection: Only re-scrapes modified pages for optimal performance
- MCP Integration: Exposes domain-specific tools and prompts for AI assistants
Universal GitBook Support
This MCP server works with any public GitBook, including:
- Product Documentation (Stripe, Twilio, etc.)
- API References (REST, GraphQL APIs)
- Developer Guides (SDKs, frameworks)
- Help Centers (Support documentation)
- Internal Wikis (Company knowledge bases)
- Technical Blogs (Engineering documentation)
Auto-detection examples:
docs.stripe.com
→ Stripe API documentation toolsdocs.react.dev
→ React development toolshelp.github.com
→ GitHub support toolsapi.yourcompany.com
→ Your API reference tools
Limitations
- Public GitBooks only - Requires publicly accessible GitBook sites
- Static content - Not API-based, scrapes published HTML
- Manual refresh - No real-time updates (use
refresh_content
tool) - Text-focused - Extracts text content, not complex interactive elements
Deployment Options
Local Development:
npm run dev # Development mode with auto-reload
Production MCP Server:
npm run build && npm start
Production REST API:
npm run build && npm run start:api
Docker (optional):
FROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY dist/ ./dist/
CMD ["npm", "start"]
Claude Desktop Integration:
{
"mcpServers": {
"your-docs": {
"command": "node",
"args": ["/path/to/your/dist/index.js"],
"env": {
"GITBOOK_URL": "https://docs.yoursite.com"
}
}
}
}
License
MIT
Official @thecookingsenpai primary account I lost the access to my main (under funny circumstances).
40
フォロワー
110
リポジトリ
7
Gist
0
貢献数