BookStack MCP Server
Enables AI assistants to manage BookStack knowledge bases with tools for creating, reading, updating, and deleting pages, books, and shelves, as well as searching content.
README
📚 BookStack MCP Server
A professional-grade Model Context Protocol (MCP) server that seamlessly bridges AI assistants with BookStack knowledge management systems. Transform your documentation workflows with intelligent automation.
Created by Derron Knox | Showcasing enterprise-level software architecture and best practices
🚀 Overview
This TypeScript-based MCP server provides a robust, production-ready interface for AI assistants to interact with BookStack instances. Designed with enterprise scalability, security, and maintainability in mind, it demonstrates advanced software engineering principles and modern development practices.
✨ Key Features
- 🛡️ Enterprise Security: Token-based authentication with secure credential management
- 🏗️ Modular Architecture: Clean separation of concerns with TypeScript interfaces
- 🔄 Comprehensive CRUD Operations: Full lifecycle management of BookStack content
- 🐳 Container-Ready: Production-optimized Docker setup with multi-stage builds
- ⚡ High Performance: Optimized API calls with proper error handling and timeouts
- 📋 Type Safety: Full TypeScript implementation with strict type checking
- 🔍 Smart Search: Advanced content discovery and filtering capabilities
- 📖 Intelligent Resolution: Name-to-ID resolution for user-friendly operations
🛠️ Available Tools
Page Management
create_page- Create new pages with HTML/Markdown contentget_page_content- Retrieve page content by ID or nameupdate_page- Modify existing pages (content, location, metadata)delete_page- Remove pages from BookStack
Content Discovery
search_items- Search across shelves, books, chapters, and pageslist_books- Enumerate books with filtering and paginationlist_shelves- Browse shelf collections with advanced options
Book Management
read_book- Get details of a specific book by ID or namecreate_book- Create a new bookupdate_book- Modify existing books (content, metadata)delete_book- Remove books from BookStack
Advanced Features
- Flexible Targeting: Use either IDs or names for all operations
- Context-Aware Resolution: Automatic name-to-ID conversion
- Hierarchical Navigation: Support for book/chapter/page relationships
- Metadata Management: Tags, priorities, and organizational features
🏃♂️ Quick Start
Prerequisites
- Node.js 20+
- Docker & Docker Compose (for containerized deployment)
- BookStack instance with API access
- BookStack API tokens (Token ID & Secret)
1. Environment Setup
# Clone and configure
git clone <repository-url>
cd bookstack/
cp .env.example .env
# Configure your BookStack credentials
cat > .env << EOF
BOOKSTACK_URL="https://your-bookstack-instance.com"
BOOKSTACK_API_TOKEN_ID="your_token_id_here"
BOOKSTACK_API_TOKEN_SECRET="your_token_secret_here"
EOF
2. Installation Options
Option A: Docker Deployment (Recommended)
# Production-ready containerized deployment
docker-compose up --build -d
# Monitor logs
docker-compose logs -f bookstack-mcp-server
Option B: Local Development
# Install dependencies
npm install
# Development with hot reload
npm run watch
# Production build
npm run build
npm start
3. Integration with Claude Desktop
Add to your Claude Desktop configuration (~/Library/Application Support/Claude/claude_desktop_config.json):
{
"mcpServers": {
"bookstack-mcp-server": {
"command": "node",
"args": ["/path/to/bookstack/build/index.js"],
"env": {
"BOOKSTACK_URL": "https://your-bookstack-instance.com",
"BOOKSTACK_API_TOKEN_ID": "your_token_id",
"BOOKSTACK_API_TOKEN_SECRET": "your_token_secret"
}
}
}
}
🏗️ Architecture & Best Practices
Project Structure
bookstack/
├── src/
│ ├── types.ts # TypeScript interface definitions
│ ├── utils/
│ │ ├── validation.ts # Input validation & sanitization
│ │ └── api.ts # API utilities & helper functions
│ ├── tools/
│ │ ├── definitions.ts # Tool schema definitions
│ │ └── handlers.ts # Business logic implementations
│ └── index.ts # Main server & orchestration
├── build/ # Compiled JavaScript output
├── Dockerfile # Multi-stage container build
├── docker-compose.yml # Production deployment config
└── package.json # Dependencies & scripts
Engineering Principles Demonstrated
🎯 Clean Architecture
- Separation of Concerns: Distinct layers for validation, business logic, and API interaction
- Dependency Injection: Modular design with clear interfaces
- Single Responsibility: Each module has one well-defined purpose
🔒 Security First
- Environment Variable Management: Secure credential handling
- Input Validation: Comprehensive argument sanitization
- Error Boundaries: Proper exception handling without information leakage
🚀 Production Readiness
- Container Optimization: Multi-stage Docker builds for minimal image size
- Health Checks: Built-in container health monitoring
- Graceful Shutdown: Proper signal handling for clean termination
- Comprehensive Logging: Structured error reporting and debugging
📊 Code Quality
- TypeScript Strict Mode: Full type safety with comprehensive interfaces
- Modular Design: Reusable components with clear APIs
- Error Handling: Robust exception management with user-friendly messages
🔧 Configuration Options
Environment Variables
| Variable | Description | Required | Example |
|---|---|---|---|
BOOKSTACK_URL |
BookStack instance URL | ✅ | https://wiki.company.com |
BOOKSTACK_API_TOKEN_ID |
API Token ID from BookStack | ✅ | abc123def456 |
BOOKSTACK_API_TOKEN_SECRET |
API Token Secret from BookStack | ✅ | xyz789uvw012 |
Docker Configuration
- Health Checks: 30-second intervals with 3 retry attempts
- Log Rotation: 10MB max file size, 5 file retention
- Security: Non-root user execution
- Resource Optimization: Multi-stage builds for production efficiency
🔍 Usage Examples
Creating Content
// Create a page in a specific book
await createPage({
name: "API Documentation",
markdown: "# API Guide\n\nComprehensive API documentation...",
book_name: "Development Guides",
tags: [
{ name: "category", value: "api" },
{ name: "priority", value: "high" }
]
});
Content Discovery
// Search across all content types
await searchItems({
query: "kubernetes deployment",
count: 20
});
// Find pages by context
await getPageContent({
page_name: "Deployment Guide",
book_name: "Infrastructure Documentation"
});
Content Management
// Update page with new content
await updatePage({
page_name: "Getting Started",
book_name: "User Manual",
markdown: "# Updated Getting Started Guide\n...",
tags: [{ name: "status", value: "updated" }]
});
🚀 Deployment Options
Production Deployment
Docker Swarm
# Scale across multiple nodes
docker stack deploy -c docker-compose.yml bookstack-mcp
Kubernetes
apiVersion: apps/v1
kind: Deployment
metadata:
name: bookstack-mcp-server
spec:
replicas: 3
selector:
matchLabels:
app: bookstack-mcp-server
template:
metadata:
labels:
app: bookstack-mcp-server
spec:
containers:
- name: bookstack-mcp-server
image: bookstack-mcp-server:latest
env:
- name: BOOKSTACK_URL
valueFrom:
secretKeyRef:
name: bookstack-credentials
key: url
Development Workflow
# Development with auto-reload
npm run watch
# Type checking
npx tsc --noEmit
# Debug with MCP Inspector
npm run inspector
🐛 Debugging & Troubleshooting
MCP Inspector
# Launch debugging interface
npm run inspector
# Access via browser at provided URL
Common Issues
Connection Problems
# Verify BookStack accessibility
curl -H "Authorization: Token $BOOKSTACK_API_TOKEN_ID:$BOOKSTACK_API_TOKEN_SECRET" \
"$BOOKSTACK_URL/api/books"
Container Issues
# Check container health
docker-compose ps
docker-compose logs bookstack-mcp-server
# Restart with fresh build
docker-compose down && docker-compose up --build
📋 Dependencies
Production Dependencies
- @modelcontextprotocol/sdk: ^0.6.0 - MCP protocol implementation
- axios: ^1.9.0 - HTTP client for BookStack API
Development Dependencies
- typescript: ^5.3.3 - Type-safe JavaScript development
- @types/node: ^20.11.24 - Node.js type definitions
System Requirements
- Node.js: 20+ (LTS recommended)
- Memory: 256MB minimum, 512MB recommended
- Storage: 100MB for application, additional for logs
🎯 Professional Showcase
This project demonstrates expertise in:
Backend Development
- RESTful API integration and design
- Microservices architecture patterns
- Error handling and resilience patterns
DevOps & Infrastructure
- Containerization with Docker
- Production deployment strategies
- Configuration management
- Health monitoring and observability
Software Engineering
- Clean code principles
- Design patterns (Strategy, Factory, Dependency Injection)
- Test-driven development mindset
- Documentation and maintainability
Modern JavaScript/TypeScript
- Advanced TypeScript features
- Async/await patterns
- ES2022+ modern syntax
- Node.js best practices
🤝 Contributing
This project welcomes contributions! Areas for enhancement:
- Unit test coverage expansion
- Additional BookStack API endpoints
- Performance optimizations
- Enhanced error recovery
📞 Contact
Derron Knox - Software Engineer & Solutions Architect
This project exemplifies enterprise-grade software development practices, demonstrating proficiency in modern web technologies, cloud-native development, and scalable system architecture.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。