An ASP.NET Core 9 Model Context Protocol (MCP) server that provides tools for interacting with BookStack wiki software via its API.
This MCP server implements tools for all major BookStack API endpoints:
Note: Write operations (create/delete) are disabled by default. Set BookStack:EnableWrite
to true
to enable them.
list_books
- List all books with paginationget_book
- Get detailed information about a specific bookcreate_book
- Create a new book (requiresEnableWrite: true
)delete_book
- Delete a book (requiresEnableWrite: true
)
list_chapters
- List all chapters with paginationget_chapter
- Get detailed information about a specific chaptercreate_chapter
- Create a new chapter in a book (requiresEnableWrite: true
)delete_chapter
- Delete a chapter (requiresEnableWrite: true
)
list_pages
- List all pages with paginationget_page
- Get detailed information about a specific pagecreate_page
- Create a new page in a book or chapter (requiresEnableWrite: true
)delete_page
- Delete a page (requiresEnableWrite: true
)
list_shelves
- List all shelves with paginationget_shelf
- Get detailed information about a specific shelfcreate_shelf
- Create a new shelf (requiresEnableWrite: true
)delete_shelf
- Delete a shelf (requiresEnableWrite: true
)
list_users
- List all users with paginationget_user
- Get detailed information about a specific user
search_all
- Search across all BookStack content (books, chapters, pages)search_books
- Search for books by name or descriptionsearch_chapters
- Search for chapters by name or descriptionsearch_pages
- Search for pages by name or contentsearch_shelves
- Search for shelves by name or descriptionsearch_users
- Search for users by name or emailadvanced_search
- Advanced search with custom filters and operators
- .NET 9 SDK
- BookStack instance with API access enabled
- BookStack API token credentials
- Clone the repository:
git clone https://github.com/jeroenmaes/dotnet-bookstack-mcp-server.git
cd dotnet-bookstack-mcp-server
- Configure your BookStack connection in
BookStackMcpServer/appsettings.json
:
{
"BookStack": {
"BaseUrl": "https://your-bookstack-instance.com",
"TokenId": "your-token-id",
"TokenSecret": "your-token-secret"
}
}
- Run the application:
cd BookStackMcpServer
dotnet run
The application includes Docker support for easy deployment:
- Copy the environment template:
cp .env.example .env
- Edit
.env
file with your BookStack configuration:
BOOKSTACK_BASE_URL=https://your-bookstack-instance.com
BOOKSTACK_TOKEN_ID=your-token-id
BOOKSTACK_TOKEN_SECRET=your-token-secret
- Build and run with Docker Compose:
docker-compose up -d
- Build the Docker image:
docker build -t bookstack-mcp-server .
- Run the container:
docker run -d \
-p 8080:8080 \
-e BookStack__BaseUrl=https://your-bookstack-instance.com \
-e BookStack__TokenId=your-token-id \
-e BookStack__TokenSecret=your-token-secret \
--name bookstack-mcp-server \
bookstack-mcp-server
Pre-built images are available from GitHub Container Registry:
# Pull the latest image
docker pull ghcr.io/jeroenmaes/dotnet-bookstack-mcp-server:latest
# Pull a specific build number
docker pull ghcr.io/jeroenmaes/dotnet-bookstack-mcp-server:build-123
# Pull a specific version tag
docker pull ghcr.io/jeroenmaes/dotnet-bookstack-mcp-server:v1.0.0
The server implements the Model Context Protocol using the official C# SDK. It exposes an MCP endpoint that can be used by MCP-compatible clients to interact with BookStack.
By default, the server operates in read-only mode for safety. Write operations (create_*
and delete_*
tools) are disabled unless explicitly enabled.
To enable write operations:
In appsettings.json
:
{
"BookStack": {
"BaseUrl": "https://your-bookstack-instance.com",
"TokenId": "your-token-id",
"TokenSecret": "your-token-secret",
"EnableWrite": true
}
}
Or via environment variables:
BookStack__EnableWrite=true
Docker example with write enabled:
docker run -d \
-p 8080:8080 \
-e BookStack__BaseUrl=https://your-bookstack-instance.com \
-e BookStack__TokenId=your-token-id \
-e BookStack__TokenSecret=your-token-secret \
-e BookStack__EnableWrite=true \
--name bookstack-mcp-server \
bookstack-mcp-server
Notes:
- When
EnableWrite
isfalse
(default), only read operations (list, get, search) are available - When
EnableWrite
istrue
, create and delete operations become available - This provides an extra layer of protection against accidental modifications to your BookStack content
The server supports optional HTTP header-based authentication for the MCP endpoints. When configured, all requests to the MCP endpoint must include the specified authentication header with the correct value.
Configuration:
In appsettings.json
:
{
"Security": {
"AuthHeaderName": "X-MCP-Auth",
"AuthHeaderValue": "your-secret-token"
}
}
Or via environment variables:
Security__AuthHeaderName=X-MCP-Auth
Security__AuthHeaderValue=your-secret-token
Docker example:
docker run -d \
-p 8080:8080 \
-e BookStack__BaseUrl=https://your-bookstack-instance.com \
-e BookStack__TokenId=your-token-id \
-e BookStack__TokenSecret=your-token-secret \
-e Security__AuthHeaderName=X-MCP-Auth \
-e Security__AuthHeaderValue=your-secret-token \
--name bookstack-mcp-server \
bookstack-mcp-server
Notes:
- If
AuthHeaderName
orAuthHeaderValue
is not configured, security is disabled and all requests are allowed - Health check endpoints (
/health
,/health/live
,/health/ready
) are not protected by this security mechanism - When enabled, clients must send the configured header with every MCP request
The server includes built-in HTTP rate limiting to protect against abuse and excessive requests. Rate limiting is applied per IP address using a fixed window algorithm.
Configuration:
In appsettings.json
:
{
"Throttling": {
"Enabled": true,
"PermitLimit": 100,
"WindowSeconds": 60,
"QueueLimit": 0
}
}
Or via environment variables:
Throttling__Enabled=true
Throttling__PermitLimit=100
Throttling__WindowSeconds=60
Throttling__QueueLimit=0
Docker example:
docker run -d \
-p 8080:8080 \
-e BookStack__BaseUrl=https://your-bookstack-instance.com \
-e BookStack__TokenId=your-token-id \
-e BookStack__TokenSecret=your-token-secret \
-e Throttling__Enabled=true \
-e Throttling__PermitLimit=100 \
-e Throttling__WindowSeconds=60 \
--name bookstack-mcp-server \
bookstack-mcp-server
Configuration Options:
Enabled
- Enable or disable rate limiting (default:true
)PermitLimit
- Maximum number of requests allowed per time window (default:100
)WindowSeconds
- Time window in seconds for rate limiting (default:60
)QueueLimit
- Number of requests to queue when limit is reached (default:0
- no queuing)
Notes:
- Rate limiting is applied per IP address
- Health check endpoints (
/health
,/health/live
,/health/ready
) are not rate limited - When the limit is exceeded, the server returns a
429 Too Many Requests
response - Set
Enabled
tofalse
to disable throttling entirely
The server includes built-in in-memory caching for BookStack API responses to improve performance and reduce load on the BookStack server. Caching is applied to all read operations (list, get, search).
Configuration:
In appsettings.json
:
{
"Caching": {
"Enabled": true,
"AbsoluteExpirationMinutes": 5,
"SlidingExpirationMinutes": 2
}
}
Or via environment variables:
Caching__Enabled=true
Caching__AbsoluteExpirationMinutes=5
Caching__SlidingExpirationMinutes=2
Docker example:
docker run -d \
-p 8080:8080 \
-e BookStack__BaseUrl=https://your-bookstack-instance.com \
-e BookStack__TokenId=your-token-id \
-e BookStack__TokenSecret=your-token-secret \
-e Caching__Enabled=true \
-e Caching__AbsoluteExpirationMinutes=5 \
-e Caching__SlidingExpirationMinutes=2 \
--name bookstack-mcp-server \
bookstack-mcp-server
Configuration Options:
Enabled
- Enable or disable caching (default:true
)AbsoluteExpirationMinutes
- Maximum time an item stays in cache regardless of access (default:5
minutes)SlidingExpirationMinutes
- Time window of inactivity before an item expires (default:2
minutes)
Notes:
- Caching significantly improves response times for repeated requests
- Each unique request (different parameters) is cached separately
- Absolute expiration ensures data freshness by forcing cache refresh after a maximum time
- Sliding expiration keeps frequently accessed items in cache longer
- Set
Enabled
tofalse
to disable caching entirely - Write operations are not cached and automatically invalidate relevant cache entries
The server provides ASP.NET Core health check endpoints for monitoring:
GET /health
- Comprehensive health check with detailed status informationGET /health/ready
- Readiness check (includes BookStack API dependency check)GET /health/live
- Liveness check (returns 200 if the application is running)
Check application health:
# Liveness check (app is running)
curl http://localhost:8080/health/live
# Readiness check (app is ready to serve requests, including BookStack API)
curl http://localhost:8080/health/ready
# Detailed health information
curl http://localhost:8080/health
- In your BookStack instance, go to Settings → Users → API Tokens
- Create a new API token with the required permissions
- Use the Token ID and Token Secret in your configuration
- ASP.NET Core 9 - Web framework
- ModelContextProtocol.AspNetCore (0.4.0-preview.1) - MCP server implementation
- BookStackApiClient (25.7.0-lib.2) - BookStack API client library
- Microsoft.Extensions.Diagnostics.HealthChecks (9.0.9) - Health checks support
MIT License - see LICENSE file for details.