- Overview
- Prerequisites
- BookStack Server Requirements
- Installation Methods
- Configuration
- Authentication Setup
- Claude Integration
- Advanced Configuration
- Development Setup
- Deployment Options
- Troubleshooting
- FAQ
The BookStack MCP Server provides comprehensive access to BookStack's knowledge management capabilities through the Model Context Protocol (MCP). This guide covers everything you need to set up and configure the server for optimal performance.
- 47 MCP Tools covering all BookStack API endpoints
- Resource Access for dynamic content retrieval
- Rate Limiting with configurable limits
- Comprehensive Validation using Zod schemas
- Error Handling with retry logic
- TypeScript Support with complete type definitions
- Node.js: 18.0.0 or higher
- npm: 9.0.0 or higher
- Operating System: Linux, macOS, or Windows
- Memory: Minimum 512MB RAM (1GB recommended)
- Storage: 100MB for installation + log storage
- BookStack Instance: Running and accessible
- BookStack API: Enabled with valid token
- Network Access: HTTP/HTTPS connection to BookStack
# Check Node.js version
node --version # Should be 18.0.0+
# Check npm version
npm --version # Should be 9.0.0+
# Check system resources
free -h # Linux/macOS- Recommended: Latest stable version of BookStack
- API Version: v1 (current)
⚠️ Note: This server uses modern BookStack API features including the system endpoint for health checks. Please ensure you're running a recent version of BookStack.
Your BookStack instance must have:
-
API Access Enabled
// In BookStack .env file API_REQUESTS_PER_MIN=180 API_DEFAULT_ITEM_COUNT=100
-
API Rate Limits (optional - adjust if needed)
// In BookStack .env file - adjust based on your usage API_REQUESTS_PER_MIN=180
-
User Permissions
- API user must have appropriate permissions
- Recommended: Admin role for full access
- Minimum: View permissions for content areas
-
Log into BookStack as admin or privileged user
-
Navigate to: Profile → API Tokens
-
Create New Token:
- Name:
mcp-server-token - Description:
Token for MCP server access - Expiry: Set appropriate expiry (optional)
- Name:
-
Combine Token Parts: BookStack provides a Token ID and Token Secret
Important: You need to combine these as
{token_id}:{token_secret}Example:
- Token ID:
AbCdEf123456 - Token Secret:
xyz789secretkey - Final Token:
AbCdEf123456:xyz789secretkey
- Token ID:
-
Save Token: Store the combined token securely for configuration
💡 Token Format: The API token must be in the format
{token_id}:{token_secret}as shown in BookStack's API documentation.
# Install globally for system-wide access
npm install -g bookstack-mcp-server
# Verify installation
bookstack-mcp-server --version# Create project directory
mkdir my-bookstack-mcp
cd my-bookstack-mcp
# Install locally
npm install bookstack-mcp-server
# Or install from source
git clone https://github.com/pnocera/bookstack-mcp-server.git
cd bookstack-mcp-server
npm install
npm run build# Clone repository
git clone https://github.com/pnocera/bookstack-mcp-server.git
cd bookstack-mcp-server
# Install dependencies
npm install
# Build project
npm run build
# Run development server
npm run devCreate a .env file in your project directory:
# BookStack API Configuration
BOOKSTACK_BASE_URL=http://localhost:8080/api
BOOKSTACK_API_TOKEN=your-api-token-here
BOOKSTACK_TIMEOUT=30000
# Server Configuration
SERVER_NAME=bookstack-mcp-server
SERVER_VERSION=1.0.0
SERVER_PORT=3000
# Rate Limiting
RATE_LIMIT_REQUESTS_PER_MINUTE=60
RATE_LIMIT_BURST_LIMIT=10
# Validation
VALIDATION_ENABLED=true
VALIDATION_STRICT_MODE=false
# Logging
LOG_LEVEL=info
LOG_FORMAT=pretty
# Context7 Integration
CONTEXT7_ENABLED=true
CONTEXT7_LIBRARY_ID=/bookstack/bookstack
CONTEXT7_CACHE_TTL=3600
# Security
CORS_ENABLED=true
CORS_ORIGIN=*
HELMET_ENABLED=true
# Development
NODE_ENV=development
DEBUG=false-
BOOKSTACK_BASE_URL: Full URL to BookStack API endpoint
- Format:
http://yourserver.com/api - Include
/apisuffix - Use HTTPS in production
- Format:
-
BOOKSTACK_API_TOKEN: API token from BookStack
- Generate in BookStack admin panel
- Keep secure and rotate regularly
-
BOOKSTACK_TIMEOUT: Request timeout in milliseconds
- Default: 30000 (30 seconds)
- Increase for slow networks
-
RATE_LIMIT_REQUESTS_PER_MINUTE: Maximum requests per minute
- Default: 60
- Adjust based on BookStack limits
-
RATE_LIMIT_BURST_LIMIT: Concurrent request limit
- Default: 10
- Prevents overwhelming BookStack
-
LOG_LEVEL: Logging verbosity
- Options:
error,warn,info,debug - Use
infofor production
- Options:
-
LOG_FORMAT: Log output format
- Options:
json,pretty - Use
jsonfor production logs
- Options:
-
VALIDATION_ENABLED: Enable input validation
- Default:
true - Always keep enabled
- Default:
-
VALIDATION_STRICT_MODE: Strict validation mode
- Default:
false - Enable for additional safety
- Default:
-
Create Service Account (recommended)
Email: mcp-service@yourcompany.com Name: MCP Service Account Role: Admin (or custom role with required permissions) -
Generate API Token
- Login as service account
- Go to Profile → API Tokens
- Create token with descriptive name
- Important: Combine the Token ID and Token Secret as
{token_id}:{token_secret} - Store the combined token securely
- Storage: Use environment variables or secure vault
- Rotation: Implement regular token rotation
- Monitoring: Monitor token usage and access
The API user needs these minimum permissions:
- Books: View, Create, Update, Delete
- Pages: View, Create, Update, Delete
- Chapters: View, Create, Update, Delete
- Shelves: View, Create, Update, Delete
- Users: View (for user management tools)
- System: View (for system info tools)
Add to your Claude Desktop configuration:
Edit claude_desktop_config.json:
{
"mcpServers": {
"bookstack": {
"command": "bookstack-mcp-server",
"env": {
"BOOKSTACK_BASE_URL": "http://localhost:8080/api",
"BOOKSTACK_API_TOKEN": "your-api-token-here"
}
}
}
}# Add server configuration
claude mcp add bookstack bookstack-mcp-server \
--env BOOKSTACK_BASE_URL=http://localhost:8080/api \
--env BOOKSTACK_API_TOKEN=your-api-token-here
# Verify configuration
claude mcp listFor Claude Code MCP support:
# Add as MCP server
claude mcp add-json bookstack '{
"type": "stdio",
"command": "npx",
"args": ["bookstack-mcp-server"],
"env": {
"BOOKSTACK_BASE_URL": "http://localhost:8080/api",
"BOOKSTACK_API_TOKEN": "your-api-token-here"
}
}'- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%/Claude/claude_desktop_config.json - Linux:
~/.config/claude/claude_desktop_config.json
Create config.json for complex setups:
{
"bookstack": {
"baseUrl": "https://docs.company.com/api",
"apiToken": "${BOOKSTACK_API_TOKEN}",
"timeout": 45000,
"retryAttempts": 3,
"retryDelay": 1000
},
"server": {
"name": "company-bookstack-mcp",
"version": "1.0.0",
"port": 3000
},
"rateLimit": {
"requestsPerMinute": 120,
"burstLimit": 20
},
"logging": {
"level": "info",
"format": "json",
"logFile": "/var/log/bookstack-mcp.log"
},
"features": {
"enableMetrics": true,
"enableHealthCheck": true,
"enableDocumentation": true
}
}For production deployments:
# Production Environment Variables
NODE_ENV=production
DEBUG=false
LOG_LEVEL=warn
LOG_FORMAT=json
# Security
CORS_ORIGIN=https://yourapp.com
HELMET_ENABLED=true
# Performance
RATE_LIMIT_REQUESTS_PER_MINUTE=180
RATE_LIMIT_BURST_LIMIT=30
# Monitoring
ENABLE_METRICS=true
METRICS_PORT=9090
HEALTH_CHECK_PORT=9091For multiple BookStack instances:
{
"instances": [
{
"name": "production",
"baseUrl": "https://docs.company.com/api",
"apiToken": "${PROD_API_TOKEN}",
"priority": 1
},
{
"name": "staging",
"baseUrl": "https://staging-docs.company.com/api",
"apiToken": "${STAGING_API_TOKEN}",
"priority": 2
}
]
}# Clone repository
git clone https://github.com/pnocera/bookstack-mcp-server.git
cd bookstack-mcp-server
# Install dependencies
npm install
# Copy environment template
cp .env.example .env
# Edit configuration
nano .env
# Start development server
npm run dev# Development server with hot reload
npm run dev
# Build TypeScript
npm run build
# Run tests
npm test
# Run tests with coverage
npm run test:coverage
# Lint code
npm run lint
# Format code
npm run format
# Clean build directory
npm run clean# Run specific test file
npm test -- books.test.ts
# Run tests in watch mode
npm run test:watch
# Debug tests
npm run test:debugCreate /etc/systemd/system/bookstack-mcp.service:
[Unit]
Description=BookStack MCP Server
After=network.target
[Service]
Type=simple
User=bookstack-mcp
WorkingDirectory=/opt/bookstack-mcp
ExecStart=/usr/bin/node /opt/bookstack-mcp/dist/server.js
Restart=always
RestartSec=10
Environment=NODE_ENV=production
EnvironmentFile=/opt/bookstack-mcp/.env
[Install]
WantedBy=multi-user.targetEnable and start:
sudo systemctl enable bookstack-mcp
sudo systemctl start bookstack-mcp
sudo systemctl status bookstack-mcpCreate Dockerfile:
FROM node:18-alpine
# Create app directory
WORKDIR /app
# Copy package files
COPY package*.json ./
# Install dependencies
RUN npm ci --only=production
# Copy source code
COPY dist ./dist
COPY .env.example .env
# Expose port
EXPOSE 3000
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD node -e "require('http').get('http://localhost:3000/health', (res) => process.exit(res.statusCode === 200 ? 0 : 1))"
# Start server
CMD ["node", "dist/server.js"]Build and run:
# Build image
docker build -t bookstack-mcp-server .
# Run container
docker run -d \
--name bookstack-mcp \
-p 3000:3000 \
-e BOOKSTACK_BASE_URL=http://bookstack:8080/api \
-e BOOKSTACK_API_TOKEN=your-token \
bookstack-mcp-serverError: ECONNREFUSED connecting to BookStack
Solutions:
- Verify BookStack is running and accessible
- Check
BOOKSTACK_BASE_URLis correct - Ensure
/apisuffix is included in URL - Test API access:
curl -H "Authorization: Token YOUR_TOKEN" http://localhost:8080/api/docs
Error: 401 Unauthorized or 403 Forbidden
Solutions:
- Verify API token is correct and not expired
- Check user permissions in BookStack
- Ensure token has required scopes
- Test token:
curl -H "Authorization: Token YOUR_TOKEN" http://localhost:8080/api/users
Error: 429 Too Many Requests
Solutions:
- Reduce
RATE_LIMIT_REQUESTS_PER_MINUTE - Increase
RATE_LIMIT_BURST_LIMIT - Check BookStack rate limits
- Implement request queuing
Error: Configuration validation failed
Solutions:
- Check all required environment variables are set
- Verify URL format (must include protocol)
- Ensure numeric values are valid
- Review configuration schema
Error: JavaScript heap out of memory
Solutions:
- Increase Node.js memory:
node --max-old-space-size=4096 dist/server.js - Reduce concurrent connections
- Enable response streaming
- Check for memory leaks
Enable debug logging:
# Set debug environment
export DEBUG=true
export LOG_LEVEL=debug
# Run with debug output
npm run devMonitor server health:
# Check server status
curl http://localhost:3000/health
# Expected response
{
"status": "healthy",
"checks": [
{"name": "bookstack_connection", "healthy": true},
{"name": "tools_loaded", "healthy": true, "message": "47 tools loaded"},
{"name": "resources_loaded", "healthy": true, "message": "12 resources loaded"}
]
}Check logs for issues:
# View recent logs
tail -f /var/log/bookstack-mcp.log
# Search for errors
grep -i error /var/log/bookstack-mcp.log
# Filter by timestamp
grep "2024-01-01" /var/log/bookstack-mcp.logMonitor performance metrics:
# Check memory usage
ps aux | grep bookstack-mcp
# Monitor network connections
netstat -an | grep :3000
# Check file descriptors
lsof -p $(pgrep -f bookstack-mcp)A: Yes, if your BookStack SaaS provider supports API access. Contact your provider for API endpoint and token generation.
A: Currently, one instance per server. For multiple instances, run multiple MCP servers with different configurations.
A: Tools are active functions (create, update, delete). Resources are passive data access (read-only content).
A: Back up your .env file and any custom configuration files. Store API tokens securely.
A: Yes, you can disable specific tools by modifying the source code or using feature flags.
A:
- Backup current configuration
- Update to new version
- Compare configuration schemas
- Test all integrations
- Update Claude integration if needed
A: Currently no GUI is available. Configuration is done through environment variables and config files.
A:
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
A: Minimal. The server uses connection pooling and efficient caching. Typical memory usage is 50-100MB.
A: Yes, it's designed for production use. Follow the production configuration guidelines and implement proper monitoring.
- Documentation: GitHub Repository
- Issues: GitHub Issues
- Discussions: GitHub Discussions
This project is licensed under the MIT License. See the LICENSE file for details.
Built with ❤️ for the BookStack community