bookstack-mcp 3.4.0 → 3.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -1
- package/dist/bookstack-client.js +27 -0
- package/dist/index.js +37 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -60,7 +60,15 @@ BOOKSTACK_INSECURE_SKIP_TLS_VERIFY=false # Optional, default false
|
|
|
60
60
|
|
|
61
61
|
### Claude Desktop
|
|
62
62
|
|
|
63
|
-
|
|
63
|
+
The easiest install is the prebuilt MCPB bundle attached to each [GitHub release](https://github.com/ttpears/bookstack-mcp/releases/latest):
|
|
64
|
+
|
|
65
|
+
1. Download `bookstack-mcp-<version>.mcpb` from the latest release.
|
|
66
|
+
2. Open Claude Desktop → **Settings → Extensions** and drag the `.mcpb` file in (or click *Install Extension*).
|
|
67
|
+
3. Fill in **BookStack URL**, **API Token ID**, and **API Token Secret**. Tokens are stored in your OS keychain. Leave **Enable Write Operations** as `false` for read-only access; set to `true` to enable create/update/delete tools.
|
|
68
|
+
|
|
69
|
+
#### Manual install (JSON config)
|
|
70
|
+
|
|
71
|
+
If you'd rather edit the config file directly:
|
|
64
72
|
|
|
65
73
|
```json
|
|
66
74
|
{
|
|
@@ -221,6 +229,7 @@ Both templates support `id` autocompletion: as you type, the server searches Boo
|
|
|
221
229
|
| `get_shelves` / `get_shelf` | List or get shelf details |
|
|
222
230
|
| `get_attachments` / `get_attachment` | List or get attachment details |
|
|
223
231
|
| `get_comments` / `get_comment` | List or get page comments (BookStack v25.11+) |
|
|
232
|
+
| `find_users` | Look up BookStack users by name, email, or slug to resolve numeric user IDs for search filters |
|
|
224
233
|
| `get_recycle_bin` | List items in the recycle bin |
|
|
225
234
|
| `export_page` | Export page as HTML, PDF, Markdown, plaintext, or ZIP |
|
|
226
235
|
| `export_book` | Export entire book |
|
package/dist/bookstack-client.js
CHANGED
|
@@ -12,6 +12,19 @@ function parseRetryAfter(value) {
|
|
|
12
12
|
return Math.max(0, dateMs - Date.now());
|
|
13
13
|
return null;
|
|
14
14
|
}
|
|
15
|
+
// BookStack's advanced search silently ignores {created_by:X}/{updated_by:X}/{owned_by:X}
|
|
16
|
+
// when X isn't a numeric user ID — the query falls back to unfiltered results, which is
|
|
17
|
+
// a confusing footgun. Reject the bad form up front and point the caller at find_users.
|
|
18
|
+
function validateUserIdFilters(query) {
|
|
19
|
+
const re = /\{(created_by|updated_by|owned_by):([^}\s]+)\}/g;
|
|
20
|
+
for (const match of query.matchAll(re)) {
|
|
21
|
+
const [, field, value] = match;
|
|
22
|
+
if (!/^\d+$/.test(value)) {
|
|
23
|
+
throw new Error(`Search filter {${field}:${value}} requires a numeric user ID, not "${value}". ` +
|
|
24
|
+
`Use the find_users tool to look up a user's ID by name, email, or slug.`);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
15
28
|
export class BookStackClient {
|
|
16
29
|
client;
|
|
17
30
|
enableWrite;
|
|
@@ -219,6 +232,7 @@ export class BookStackClient {
|
|
|
219
232
|
}
|
|
220
233
|
}
|
|
221
234
|
async searchContent(query, options) {
|
|
235
|
+
validateUserIdFilters(query);
|
|
222
236
|
let searchQuery = query;
|
|
223
237
|
// Use advanced search syntax for type filtering
|
|
224
238
|
if (options?.type) {
|
|
@@ -234,6 +248,7 @@ export class BookStackClient {
|
|
|
234
248
|
return await this.enhanceSearchResults(results, query);
|
|
235
249
|
}
|
|
236
250
|
async searchPages(query, options) {
|
|
251
|
+
validateUserIdFilters(query);
|
|
237
252
|
let searchQuery = `{type:page} ${query}`.trim();
|
|
238
253
|
// Add book filtering if specified
|
|
239
254
|
if (options?.bookId) {
|
|
@@ -742,4 +757,16 @@ export class BookStackClient {
|
|
|
742
757
|
const response = await this.client.delete(`/recycle-bin/${deletionId}`);
|
|
743
758
|
return response.data;
|
|
744
759
|
}
|
|
760
|
+
// Users
|
|
761
|
+
async getUsers(options) {
|
|
762
|
+
const params = {
|
|
763
|
+
offset: options?.offset || 0,
|
|
764
|
+
count: Math.min(options?.count || 50, 500)
|
|
765
|
+
};
|
|
766
|
+
if (options?.sort)
|
|
767
|
+
params.sort = options.sort;
|
|
768
|
+
this.applyFilters(params, options?.filter);
|
|
769
|
+
const response = await this.client.get('/users', { params });
|
|
770
|
+
return response.data;
|
|
771
|
+
}
|
|
745
772
|
}
|
package/dist/index.js
CHANGED
|
@@ -168,9 +168,11 @@ function registerTools(server, client, config) {
|
|
|
168
168
|
});
|
|
169
169
|
readTool("search_content", {
|
|
170
170
|
title: "Search BookStack Content",
|
|
171
|
-
description: "Search across BookStack content with contextual previews and location info",
|
|
171
|
+
description: "Search across BookStack content with contextual previews and location info. Supports BookStack's advanced search syntax — see the query parameter for caveats.",
|
|
172
172
|
inputSchema: {
|
|
173
|
-
query: z.string().describe("Search query.
|
|
173
|
+
query: z.string().describe("Search query. Supports BookStack advanced search syntax like {type:page} or {book_id:5}. " +
|
|
174
|
+
"Caveat: {created_by:X}, {updated_by:X}, and {owned_by:X} require a numeric user ID — pass a name and BookStack silently ignores the filter, returning the unfiltered query. " +
|
|
175
|
+
"Use the find_users tool to resolve names to IDs."),
|
|
174
176
|
type: z.enum(["book", "page", "chapter", "bookshelf"]).optional().describe("Filter by content type"),
|
|
175
177
|
count: z.coerce.number().max(500).optional().describe("Number of results to return (max 500)"),
|
|
176
178
|
offset: z.coerce.number().optional().describe("Number of results to skip for pagination")
|
|
@@ -187,9 +189,11 @@ function registerTools(server, client, config) {
|
|
|
187
189
|
});
|
|
188
190
|
readTool("search_pages", {
|
|
189
191
|
title: "Search Pages",
|
|
190
|
-
description: "Search specifically for pages with optional book filtering",
|
|
192
|
+
description: "Search specifically for pages with optional book filtering. Same advanced-search caveats as search_content — see the query parameter.",
|
|
191
193
|
inputSchema: {
|
|
192
|
-
query: z.string().describe("Search query for pages"
|
|
194
|
+
query: z.string().describe("Search query for pages. Supports BookStack advanced search syntax. " +
|
|
195
|
+
"Caveat: {created_by:X}, {updated_by:X}, and {owned_by:X} require a numeric user ID — pass a name and BookStack silently ignores the filter. " +
|
|
196
|
+
"Use the find_users tool to resolve names to IDs."),
|
|
193
197
|
book_id: z.coerce.number().optional().describe("Filter results to pages within a specific book"),
|
|
194
198
|
count: z.coerce.number().max(500).optional().describe("Number of results to return"),
|
|
195
199
|
offset: z.coerce.number().optional().describe("Pagination offset")
|
|
@@ -504,6 +508,35 @@ function registerTools(server, client, config) {
|
|
|
504
508
|
content: [{ type: "text", text: JSON.stringify(comment, null, 2) }]
|
|
505
509
|
};
|
|
506
510
|
});
|
|
511
|
+
readTool("find_users", {
|
|
512
|
+
title: "Find Users",
|
|
513
|
+
description: "List BookStack users with optional filtering by name, email, or slug. Use this to resolve a person's name into the numeric user ID needed for {created_by:X}/{updated_by:X}/{owned_by:X} search filters and for the filter parameter on get_pages, get_books, etc. Requires admin permissions on the API token.",
|
|
514
|
+
inputSchema: {
|
|
515
|
+
name: z.string().optional().describe("Filter by user display name (partial match)"),
|
|
516
|
+
email: z.string().optional().describe("Filter by email address (partial match)"),
|
|
517
|
+
slug: z.string().optional().describe("Filter by URL slug (e.g. \"jane-doe\")"),
|
|
518
|
+
offset: z.coerce.number().default(0).describe("Pagination offset"),
|
|
519
|
+
count: z.coerce.number().max(500).default(50).describe("Number of results to return"),
|
|
520
|
+
sort: z.string().optional().describe("Sort field (e.g. 'name', '-created_at')")
|
|
521
|
+
}
|
|
522
|
+
}, async (args) => {
|
|
523
|
+
const filter = {};
|
|
524
|
+
if (args.name)
|
|
525
|
+
filter.name = args.name;
|
|
526
|
+
if (args.email)
|
|
527
|
+
filter.email = args.email;
|
|
528
|
+
if (args.slug)
|
|
529
|
+
filter.slug = args.slug;
|
|
530
|
+
const users = await client.getUsers({
|
|
531
|
+
offset: args.offset,
|
|
532
|
+
count: args.count,
|
|
533
|
+
sort: args.sort,
|
|
534
|
+
filter: Object.keys(filter).length ? filter : undefined
|
|
535
|
+
});
|
|
536
|
+
return {
|
|
537
|
+
content: [{ type: "text", text: JSON.stringify(users, null, 2) }]
|
|
538
|
+
};
|
|
539
|
+
});
|
|
507
540
|
readTool("get_recycle_bin", {
|
|
508
541
|
title: "List Recycle Bin",
|
|
509
542
|
description: "List items in the recycle bin (deleted books, chapters, pages, shelves). Requires admin permissions on the API token.",
|