MCP server providing comprehensive access to BookStack knowledge management system
npm install bookstack-mcp-serverA comprehensive Model Context Protocol (MCP) server providing full access to BookStack's knowledge management capabilities. This server exposes all 47 BookStack API endpoints as MCP tools, enabling seamless integration with Claude and other MCP-compatible AI assistants.
1. Clone and Install
``bash`
git clone
cd bookstack-mcp-server
npm install
2. Configure Environment
`bash`
cp .env.example .env
# Edit .env with your BookStack details
3. Build and Start
`bash`
npm run build
npm start
Create a .env file with your BookStack configuration:
`envBookStack API Configuration
BOOKSTACK_BASE_URL=http://localhost:8080/api
BOOKSTACK_API_TOKEN=your-api-token-here
BOOKSTACK_TIMEOUT=30000
๐ ๏ธ Available Tools
$3
- bookstack_books_list - List all books with filtering
- bookstack_books_create - Create new books
- bookstack_books_read - Get book details with contents
- bookstack_books_update - Update book information
- bookstack_books_delete - Delete books (to recycle bin)
- bookstack_books_export - Export books in multiple formats$3
- bookstack_pages_list - List all pages with filtering
- bookstack_pages_create - Create new pages with HTML/Markdown
- bookstack_pages_read - Get page details with content
- bookstack_pages_update - Update page content and metadata
- bookstack_pages_delete - Delete pages (to recycle bin)
- bookstack_pages_export - Export pages in multiple formats$3
- bookstack_chapters_list - List all chapters
- bookstack_chapters_create - Create new chapters
- bookstack_chapters_read - Get chapter details with pages
- bookstack_chapters_update - Update chapter information
- bookstack_chapters_delete - Delete chapters
- bookstack_chapters_export - Export chapters$3
- Search - Advanced search across all content
- Users & Roles - Complete user management
- Attachments & Images - File management
- Permissions - Content access control
- System Info - Instance information and health
- Recycle Bin - Deleted item recovery๐ Claude Code Integration
Add to your Claude Code MCP configuration:
`json
{
"mcpServers": {
"bookstack": {
"command": "npx",
"args": ["bookstack-mcp-server"],
"env": {
"BOOKSTACK_BASE_URL": "http://localhost:8080/api",
"BOOKSTACK_API_TOKEN": "your-token"
}
}
}
}
`๐ Usage Examples
$3
`javascript
// Use the bookstack_books_list tool
{
"count": 10,
"sort": "updated_at",
"filter": {
"name": "documentation"
}
}
`$3
`javascript
// Use the bookstack_pages_create tool
{
"name": "API Documentation",
"book_id": 1,
"html": "API Guide
Complete API documentation...
",
"tags": [
{"name": "category", "value": "documentation"},
{"name": "status", "value": "draft"}
]
}
`$3
`javascript
// Use the bookstack_search tool
{
"query": "API documentation [page] tag:category=api",
"count": 20
}
`๐งช Development
$3
`bash
npm run dev # Start development server with hot reload
npm run build # Build TypeScript to JavaScript
npm run test # Run test suite
npm run test:watch # Run tests in watch mode
npm run lint # Lint TypeScript code
npm run format # Format code with Prettier
`$3
`
src/
โโโ server.ts # Main MCP server
โโโ api/
โ โโโ client.ts # BookStack API client
โโโ tools/ # MCP tool implementations
โ โโโ books.ts
โ โโโ pages.ts
โ โโโ ...
โโโ resources/ # MCP resource handlers
โโโ utils/ # Utilities (logging, errors, rate limiting)
โโโ validation/ # Zod schemas and validation
โโโ config/ # Configuration management
โโโ context7/ # Context7 integration
`$3
`bash
Run all tests
npm testRun specific test file
npm test books.test.tsRun with coverage
npm run test:coverage
`๐ณ Docker Deployment
$3
`bash
docker build -t bookstack-mcp-server .
`$3
`bash
docker run -p 3000:3000 \
-e BOOKSTACK_BASE_URL=http://bookstack:8080/api \
-e BOOKSTACK_API_TOKEN=your-token \
bookstack-mcp-server
`$3
`yaml
version: '3.8'
services:
bookstack-mcp:
build: .
ports:
- "3000:3000"
environment:
BOOKSTACK_BASE_URL: http://bookstack:8080/api
BOOKSTACK_API_TOKEN: your-token
depends_on:
- bookstack
`๐ Monitoring & Health Checks
$3
The server provides health check functionality:`bash
curl http://localhost:3000/health
`Response:
`json
{
"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"}
]
}
`$3
- Request/response times
- Error rates
- Rate limit status
- Memory usage
- Tool usage statistics๐ก๏ธ Security
$3
- Secure token storage in environment variables
- Token validation on startup
- Automatic token rotation support (when available)$3
- Configurable request limits (default: 60/minute)
- Burst protection (default: 10 concurrent)
- Automatic backoff on rate limit hits$3
- Comprehensive Zod schema validation
- SQL injection prevention
- XSS protection for HTML content
- File upload validation๐ค Contributing
1. Fork the repository
2. Create a feature branch (
git checkout -b feature/amazing-feature)
3. Commit your changes (git commit -m 'Add amazing feature')
4. Push to the branch (git push origin feature/amazing-feature`)This project is licensed under the MIT License - see the LICENSE file for details.
- Documentation: Implementation Guide
- Issues: GitHub Issues
- Examples: Example Usage
---
Built with โค๏ธ for the BookStack community
For more information about BookStack, visit bookstackapp.com