bookstack-mcp 3.5.0 → 4.0.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 +3 -1
- package/dist/bookstack-client.js +32 -136
- package/dist/index.js +139 -237
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -23,6 +23,7 @@ npx bookstack-mcp
|
|
|
23
23
|
- Type-safe input validation with Zod (auto-coerces string/number params for broad client compatibility)
|
|
24
24
|
- Embedded URLs and content previews in all responses
|
|
25
25
|
- Markdown export fallback for HTML-authored pages, so AI clients always get usable content
|
|
26
|
+
- Token-efficient responses: compact JSON, no redundant fields, no N+1 fetches — ~30–55% smaller payloads than 3.x
|
|
26
27
|
- Write operations disabled by default for safety
|
|
27
28
|
- Works with Claude Desktop, Claude Code, LibreChat, and any MCP-compatible client
|
|
28
29
|
- Stdio and Streamable HTTP transports
|
|
@@ -214,13 +215,14 @@ Books and pages are also exposed as MCP resources, so clients that browse resour
|
|
|
214
215
|
|
|
215
216
|
Both templates support `id` autocompletion: as you type, the server searches BookStack and returns matching IDs so you don't have to remember numeric IDs by hand.
|
|
216
217
|
|
|
218
|
+
> **4.0.0 breaking changes:** tool responses were trimmed for token efficiency. Removed fields: `direct_link`, `*_friendly` date strings, `content_info`, `contextual_info`, `change_summary`, `pagination_hint`, `location`, `summary`/`tags_summary`/`book_count` on shelves, and the buggy `page_url` on attachments. Use `url`, the ISO date fields, and `download_url` instead. The `get_capabilities` tool was removed — clients should use `tools/list` (built into MCP). Responses are now compact JSON (no pretty-printing) and `get_recent_changes` no longer issues per-result fetches.
|
|
219
|
+
|
|
217
220
|
## Available Tools
|
|
218
221
|
|
|
219
222
|
### Read Operations (always available)
|
|
220
223
|
|
|
221
224
|
| Tool | Description |
|
|
222
225
|
|------|-------------|
|
|
223
|
-
| `get_capabilities` | Server capabilities and configuration |
|
|
224
226
|
| `search_content` | Search across all content with filtering |
|
|
225
227
|
| `search_pages` | Search pages with optional book filtering |
|
|
226
228
|
| `get_books` / `get_book` | List or get details of books |
|
package/dist/bookstack-client.js
CHANGED
|
@@ -102,23 +102,17 @@ export class BookStackClient {
|
|
|
102
102
|
const encodedQuery = encodeURIComponent(query);
|
|
103
103
|
return `${this.baseUrl}/search?term=${encodedQuery}`;
|
|
104
104
|
}
|
|
105
|
-
// Enhanced response helpers
|
|
105
|
+
// Enhanced response helpers. Each one adds only `url` on top of the raw
|
|
106
|
+
// BookStack record — narrated/duplicate fields (direct_link, *_friendly,
|
|
107
|
+
// content_info, summary, location, etc.) were removed to shrink the MCP
|
|
108
|
+
// payload; the LLM can derive them from the raw fields when needed.
|
|
106
109
|
enhanceBookResponse(book) {
|
|
107
|
-
const lastUpdated = this.formatDate(book.updated_at);
|
|
108
|
-
const created = this.formatDate(book.created_at);
|
|
109
110
|
return {
|
|
110
111
|
...book,
|
|
111
|
-
url: this.generateBookUrl(book)
|
|
112
|
-
direct_link: `[${book.name}](${this.generateBookUrl(book)})`,
|
|
113
|
-
last_updated_friendly: lastUpdated,
|
|
114
|
-
created_friendly: created,
|
|
115
|
-
summary: book.description ? `${book.description.substring(0, 100)}${book.description.length > 100 ? '...' : ''}` : 'No description available',
|
|
116
|
-
content_info: `Book created ${created}, last updated ${lastUpdated}`
|
|
112
|
+
url: this.generateBookUrl(book)
|
|
117
113
|
};
|
|
118
114
|
}
|
|
119
115
|
async enhancePageResponse(page, options) {
|
|
120
|
-
const lastUpdated = this.formatDate(page.updated_at);
|
|
121
|
-
const created = this.formatDate(page.created_at);
|
|
122
116
|
const url = await this.generatePageUrl(page);
|
|
123
117
|
// Pick a single content format to return to avoid 3x duplication (html + markdown + text)
|
|
124
118
|
const format = options?.format ?? 'markdown';
|
|
@@ -139,72 +133,41 @@ export class BookStackClient {
|
|
|
139
133
|
return {
|
|
140
134
|
...pageMeta,
|
|
141
135
|
url,
|
|
142
|
-
direct_link: `[${page.name}](${url})`,
|
|
143
|
-
last_updated_friendly: lastUpdated,
|
|
144
|
-
created_friendly: created,
|
|
145
|
-
content_info: `Page created ${created}, last updated ${lastUpdated}`,
|
|
146
136
|
word_count: page.text ? page.text.split(' ').length : 0,
|
|
147
|
-
location: `Book ID ${page.book_id}${page.chapter_id ? `, Chapter ID ${page.chapter_id}` : ''}`,
|
|
148
137
|
content_format: format,
|
|
149
138
|
content_total_chars: totalChars,
|
|
150
139
|
content_offset: offset,
|
|
151
140
|
content_returned_chars: slice.length,
|
|
152
141
|
content_truncated: truncated,
|
|
153
142
|
content_next_offset: truncated ? nextOffset : null,
|
|
154
|
-
pagination_hint: truncated
|
|
155
|
-
? `Only ${nextOffset}/${totalChars} characters returned. Call get_page again with offset=${nextOffset} to continue, or pass a larger limit.`
|
|
156
|
-
: undefined,
|
|
157
143
|
content: slice
|
|
158
144
|
};
|
|
159
145
|
}
|
|
160
146
|
async enhanceChapterResponse(chapter) {
|
|
161
|
-
const lastUpdated = this.formatDate(chapter.updated_at);
|
|
162
|
-
const created = this.formatDate(chapter.created_at);
|
|
163
147
|
const url = await this.generateChapterUrl(chapter);
|
|
164
|
-
return {
|
|
165
|
-
...chapter,
|
|
166
|
-
url,
|
|
167
|
-
direct_link: `[${chapter.name}](${url})`,
|
|
168
|
-
last_updated_friendly: lastUpdated,
|
|
169
|
-
created_friendly: created,
|
|
170
|
-
summary: chapter.description ? `${chapter.description.substring(0, 100)}${chapter.description.length > 100 ? '...' : ''}` : 'No description available',
|
|
171
|
-
content_info: `Chapter created ${created}, last updated ${lastUpdated}`,
|
|
172
|
-
location: `In Book ID ${chapter.book_id}`
|
|
173
|
-
};
|
|
148
|
+
return { ...chapter, url };
|
|
174
149
|
}
|
|
175
150
|
enhanceShelfResponse(shelf) {
|
|
176
|
-
const lastUpdated = this.formatDate(shelf.updated_at);
|
|
177
|
-
const created = this.formatDate(shelf.created_at);
|
|
178
|
-
const bookCount = shelf.books?.length || 0;
|
|
179
151
|
return {
|
|
180
152
|
...shelf,
|
|
181
153
|
url: this.generateShelfUrl(shelf),
|
|
182
|
-
|
|
183
|
-
last_updated_friendly: lastUpdated,
|
|
184
|
-
created_friendly: created,
|
|
185
|
-
summary: shelf.description ? `${shelf.description.substring(0, 100)}${shelf.description.length > 100 ? '...' : ''}` : 'No description available',
|
|
186
|
-
content_info: `Shelf with ${bookCount} book${bookCount !== 1 ? 's' : ''}, created ${created}, last updated ${lastUpdated}`,
|
|
187
|
-
book_count: bookCount,
|
|
188
|
-
books: shelf.books?.map(book => this.enhanceBookResponse(book)),
|
|
189
|
-
tags_summary: shelf.tags?.length ? `Tagged with: ${shelf.tags.map(t => `${t.name}${t.value ? `=${t.value}` : ''}`).join(', ')}` : 'No tags'
|
|
154
|
+
books: shelf.books?.map(book => this.enhanceBookResponse(book))
|
|
190
155
|
};
|
|
191
156
|
}
|
|
192
157
|
async enhanceSearchResults(results, originalQuery) {
|
|
193
158
|
const enhancedResults = await Promise.all(results.map(async (result) => {
|
|
194
159
|
const url = await this.generateContentUrl(result);
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
location_info: result.book_id ? `In book ID ${result.book_id}${result.chapter_id ? `, chapter ID ${result.chapter_id}` : ''}` : 'Location unknown'
|
|
202
|
-
};
|
|
160
|
+
const preview = result.preview_content?.content;
|
|
161
|
+
const out = { ...result, url };
|
|
162
|
+
if (preview) {
|
|
163
|
+
out.content_preview = preview.length > 150 ? `${preview.substring(0, 150)}...` : preview;
|
|
164
|
+
}
|
|
165
|
+
return out;
|
|
203
166
|
}));
|
|
204
167
|
return {
|
|
205
168
|
search_query: originalQuery,
|
|
206
169
|
search_url: this.generateSearchUrl(originalQuery),
|
|
207
|
-
|
|
170
|
+
total: results.length,
|
|
208
171
|
results: enhancedResults
|
|
209
172
|
};
|
|
210
173
|
}
|
|
@@ -303,25 +266,15 @@ export class BookStackClient {
|
|
|
303
266
|
};
|
|
304
267
|
}
|
|
305
268
|
async enhancePageListItem(page) {
|
|
306
|
-
const lastUpdated = this.formatDate(page.updated_at);
|
|
307
|
-
const created = this.formatDate(page.created_at);
|
|
308
269
|
const url = await this.generatePageUrl(page);
|
|
309
|
-
const preview = page.text
|
|
310
|
-
? `${page.text.substring(0, 200)}${page.text.length > 200 ? '...' : ''}`
|
|
311
|
-
: 'No content preview available';
|
|
312
270
|
// List responses from BookStack don't include html/markdown/text/raw_html, but strip
|
|
313
271
|
// defensively and never embed full content here — use get_page for that.
|
|
314
272
|
const { html: _h, markdown: _m, text: _t, raw_html: _r, ...pageMeta } = page;
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
created_friendly: created,
|
|
321
|
-
content_preview: preview,
|
|
322
|
-
content_info: `Page created ${created}, last updated ${lastUpdated}`,
|
|
323
|
-
location: `Book ID ${page.book_id}${page.chapter_id ? `, Chapter ID ${page.chapter_id}` : ''}`
|
|
324
|
-
};
|
|
273
|
+
const out = { ...pageMeta, url };
|
|
274
|
+
if (page.text) {
|
|
275
|
+
out.content_preview = page.text.length > 200 ? `${page.text.substring(0, 200)}...` : page.text;
|
|
276
|
+
}
|
|
277
|
+
return out;
|
|
325
278
|
}
|
|
326
279
|
async getPage(id, options) {
|
|
327
280
|
const response = await this.client.get(`/pages/${id}`);
|
|
@@ -522,76 +475,24 @@ export class BookStackClient {
|
|
|
522
475
|
};
|
|
523
476
|
const response = await this.client.get('/search', { params });
|
|
524
477
|
const results = response.data.data || response.data;
|
|
525
|
-
//
|
|
478
|
+
// Use the search response data as-is — no per-item BookStack fetch (was N+1).
|
|
479
|
+
// Callers can fetch full details via get_page/get_book/get_chapter if needed.
|
|
526
480
|
const enhancedResults = await Promise.all(results.map(async (result) => {
|
|
527
|
-
let contextualInfo = '';
|
|
528
|
-
let contentPreview = result.preview_content?.content || '';
|
|
529
|
-
try {
|
|
530
|
-
// Get additional context based on content type
|
|
531
|
-
if (result.type === 'page' && result.id) {
|
|
532
|
-
const fullPage = await this.client.get(`/pages/${result.id}`);
|
|
533
|
-
const pageData = fullPage.data;
|
|
534
|
-
contentPreview = pageData.text?.substring(0, 200) || contentPreview;
|
|
535
|
-
contextualInfo = `Updated in book: ${pageData.book?.name || 'Unknown Book'}`;
|
|
536
|
-
if (pageData.chapter) {
|
|
537
|
-
contextualInfo += `, chapter: ${pageData.chapter.name}`;
|
|
538
|
-
}
|
|
539
|
-
}
|
|
540
|
-
else if (result.type === 'book' && result.id) {
|
|
541
|
-
const fullBook = await this.client.get(`/books/${result.id}`);
|
|
542
|
-
const bookData = fullBook.data;
|
|
543
|
-
contentPreview = bookData.description?.substring(0, 200) || 'No description available';
|
|
544
|
-
contextualInfo = `Book with ${bookData.page_count || 0} pages`;
|
|
545
|
-
}
|
|
546
|
-
else if (result.type === 'chapter' && result.id) {
|
|
547
|
-
const fullChapter = await this.client.get(`/chapters/${result.id}`);
|
|
548
|
-
const chapterData = fullChapter.data;
|
|
549
|
-
contentPreview = chapterData.description?.substring(0, 200) || 'No description available';
|
|
550
|
-
contextualInfo = `Chapter in book: ${chapterData.book?.name || 'Unknown Book'}`;
|
|
551
|
-
}
|
|
552
|
-
}
|
|
553
|
-
catch (error) {
|
|
554
|
-
// If we can't get additional context, use what we have
|
|
555
|
-
contextualInfo = `${result.type.charAt(0).toUpperCase() + result.type.slice(1)} content`;
|
|
556
|
-
}
|
|
557
481
|
const url = await this.generateContentUrl(result);
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
last_updated: this.formatDate(result.updated_at || result.created_at || ''),
|
|
565
|
-
change_summary: `${result.type === 'page' ? 'Page' : result.type === 'book' ? 'Book' : 'Chapter'} "${result.name}" was updated`
|
|
566
|
-
};
|
|
482
|
+
const preview = result.preview_content?.content;
|
|
483
|
+
const out = { ...result, url };
|
|
484
|
+
if (preview) {
|
|
485
|
+
out.content_preview = preview.length > 200 ? `${preview.substring(0, 200)}...` : preview;
|
|
486
|
+
}
|
|
487
|
+
return out;
|
|
567
488
|
}));
|
|
568
489
|
return {
|
|
569
|
-
search_query: `Recent changes in the last ${days} days (${type})`,
|
|
570
490
|
date_threshold: dateFilter,
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
summary: `Found ${results.length} items updated in the last ${days} days${type !== 'all' ? ` (${type}s only)` : ''}`,
|
|
491
|
+
type,
|
|
492
|
+
total: results.length,
|
|
574
493
|
results: enhancedResults
|
|
575
494
|
};
|
|
576
495
|
}
|
|
577
|
-
formatDate(dateString) {
|
|
578
|
-
if (!dateString)
|
|
579
|
-
return 'Unknown date';
|
|
580
|
-
const date = new Date(dateString);
|
|
581
|
-
const now = new Date();
|
|
582
|
-
const diffInHours = Math.floor((now.getTime() - date.getTime()) / (1000 * 60 * 60));
|
|
583
|
-
if (diffInHours < 1)
|
|
584
|
-
return 'Less than an hour ago';
|
|
585
|
-
if (diffInHours < 24)
|
|
586
|
-
return `${diffInHours} hours ago`;
|
|
587
|
-
const diffInDays = Math.floor(diffInHours / 24);
|
|
588
|
-
if (diffInDays < 7)
|
|
589
|
-
return `${diffInDays} days ago`;
|
|
590
|
-
const diffInWeeks = Math.floor(diffInDays / 7);
|
|
591
|
-
if (diffInWeeks < 4)
|
|
592
|
-
return `${diffInWeeks} weeks ago`;
|
|
593
|
-
return date.toLocaleDateString();
|
|
594
|
-
}
|
|
595
496
|
// Shelves (Book Collections) Management
|
|
596
497
|
async getShelves(options) {
|
|
597
498
|
const params = {
|
|
@@ -648,8 +549,7 @@ export class BookStackClient {
|
|
|
648
549
|
...data,
|
|
649
550
|
data: data.data.map((attachment) => ({
|
|
650
551
|
...attachment,
|
|
651
|
-
|
|
652
|
-
direct_link: `[${attachment.name}](${this.baseUrl}/attachments/${attachment.id})`
|
|
552
|
+
download_url: `${this.baseUrl}/attachments/${attachment.id}`
|
|
653
553
|
}))
|
|
654
554
|
};
|
|
655
555
|
}
|
|
@@ -658,8 +558,6 @@ export class BookStackClient {
|
|
|
658
558
|
const attachment = response.data;
|
|
659
559
|
return {
|
|
660
560
|
...attachment,
|
|
661
|
-
page_url: `${this.baseUrl}/books/${Math.floor(attachment.uploaded_to / 1000)}/page/${attachment.uploaded_to}`,
|
|
662
|
-
direct_link: `[${attachment.name}](${this.baseUrl}/attachments/${attachment.id})`,
|
|
663
561
|
download_url: `${this.baseUrl}/attachments/${attachment.id}`
|
|
664
562
|
};
|
|
665
563
|
}
|
|
@@ -671,8 +569,7 @@ export class BookStackClient {
|
|
|
671
569
|
const attachment = response.data;
|
|
672
570
|
return {
|
|
673
571
|
...attachment,
|
|
674
|
-
|
|
675
|
-
direct_link: `[${attachment.name}](${this.baseUrl}/attachments/${attachment.id})`
|
|
572
|
+
download_url: `${this.baseUrl}/attachments/${attachment.id}`
|
|
676
573
|
};
|
|
677
574
|
}
|
|
678
575
|
async updateAttachment(id, data) {
|
|
@@ -683,8 +580,7 @@ export class BookStackClient {
|
|
|
683
580
|
const attachment = response.data;
|
|
684
581
|
return {
|
|
685
582
|
...attachment,
|
|
686
|
-
|
|
687
|
-
direct_link: `[${attachment.name}](${this.baseUrl}/attachments/${attachment.id})`
|
|
583
|
+
download_url: `${this.baseUrl}/attachments/${attachment.id}`
|
|
688
584
|
};
|
|
689
585
|
}
|
|
690
586
|
async deleteAttachment(id) {
|
package/dist/index.js
CHANGED
|
@@ -56,7 +56,7 @@ function registerResources(server, client) {
|
|
|
56
56
|
resources: (books.data ?? []).map((b) => ({
|
|
57
57
|
uri: `bookstack://book/${b.id}`,
|
|
58
58
|
name: b.name,
|
|
59
|
-
description: b.
|
|
59
|
+
description: b.description ?? undefined,
|
|
60
60
|
mimeType: "application/json"
|
|
61
61
|
}))
|
|
62
62
|
};
|
|
@@ -70,7 +70,6 @@ function registerResources(server, client) {
|
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
}), {
|
|
73
|
-
title: "BookStack Book",
|
|
74
73
|
description: "A BookStack book exposed as an MCP resource",
|
|
75
74
|
mimeType: "application/json"
|
|
76
75
|
}, async (uri, variables) => {
|
|
@@ -83,7 +82,7 @@ function registerResources(server, client) {
|
|
|
83
82
|
contents: [{
|
|
84
83
|
uri: uri.href,
|
|
85
84
|
mimeType: "application/json",
|
|
86
|
-
text: JSON.stringify(book
|
|
85
|
+
text: JSON.stringify(book)
|
|
87
86
|
}]
|
|
88
87
|
};
|
|
89
88
|
});
|
|
@@ -95,7 +94,7 @@ function registerResources(server, client) {
|
|
|
95
94
|
resources: (pages.data ?? []).map((p) => ({
|
|
96
95
|
uri: `bookstack://page/${p.id}`,
|
|
97
96
|
name: p.name,
|
|
98
|
-
description: p.content_preview ??
|
|
97
|
+
description: p.content_preview ?? undefined,
|
|
99
98
|
mimeType: "text/markdown"
|
|
100
99
|
}))
|
|
101
100
|
};
|
|
@@ -109,7 +108,6 @@ function registerResources(server, client) {
|
|
|
109
108
|
}
|
|
110
109
|
}
|
|
111
110
|
}), {
|
|
112
|
-
title: "BookStack Page",
|
|
113
111
|
description: "A BookStack page exposed as an MCP resource (markdown content)",
|
|
114
112
|
mimeType: "text/markdown"
|
|
115
113
|
}, async (uri, variables) => {
|
|
@@ -133,10 +131,10 @@ function registerResources(server, client) {
|
|
|
133
131
|
chapter_id: page.chapter_id,
|
|
134
132
|
url: page.url,
|
|
135
133
|
word_count: page.word_count,
|
|
136
|
-
|
|
134
|
+
updated_at: page.updated_at,
|
|
137
135
|
content_truncated: page.content_truncated,
|
|
138
136
|
content_total_chars: page.content_total_chars
|
|
139
|
-
}
|
|
137
|
+
})
|
|
140
138
|
}]
|
|
141
139
|
};
|
|
142
140
|
});
|
|
@@ -147,35 +145,16 @@ function registerTools(server, client, config) {
|
|
|
147
145
|
// to the SDK's generic overloads at the call sites.
|
|
148
146
|
const readTool = ((name, cfg, handler) => server.registerTool(name, { ...cfg, annotations: { ...READ_ONLY_ANNOTATIONS, ...(cfg.annotations ?? {}) } }, handler));
|
|
149
147
|
const writeTool = ((name, cfg, handler) => server.registerTool(name, { ...cfg, annotations: { ...WRITE_ANNOTATIONS, ...(cfg.annotations ?? {}) } }, handler));
|
|
150
|
-
// Register read-only tools
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
description: "Get information about available BookStack MCP capabilities and current configuration",
|
|
154
|
-
inputSchema: {}
|
|
155
|
-
}, async () => {
|
|
156
|
-
const capabilities = {
|
|
157
|
-
server_name: "BookStack MCP Server",
|
|
158
|
-
version: PKG_VERSION,
|
|
159
|
-
write_operations_enabled: config.enableWrite,
|
|
160
|
-
available_tools: config.enableWrite ? "All tools enabled" : "Read-only tools only",
|
|
161
|
-
security_note: config.enableWrite
|
|
162
|
-
? "⚠️ Write operations are ENABLED - AI can create and modify BookStack content"
|
|
163
|
-
: "🛡️ Read-only mode - Safe for production use"
|
|
164
|
-
};
|
|
165
|
-
return {
|
|
166
|
-
content: [{ type: "text", text: JSON.stringify(capabilities, null, 2) }]
|
|
167
|
-
};
|
|
168
|
-
});
|
|
148
|
+
// Register read-only tools.
|
|
149
|
+
// Common params (offset/count/sort/filter/id) are self-describing and intentionally
|
|
150
|
+
// bare so tool definitions stay compact in the MCP tools/list payload.
|
|
169
151
|
readTool("search_content", {
|
|
170
|
-
|
|
171
|
-
description: "Search across BookStack content with contextual previews and location info. Supports BookStack's advanced search syntax — see the query parameter for caveats.",
|
|
152
|
+
description: "Search BookStack content. Supports advanced syntax like {type:page} or {book_id:5}. {created_by:X}/{updated_by:X}/{owned_by:X} need a numeric user ID — use find_users to resolve names.",
|
|
172
153
|
inputSchema: {
|
|
173
|
-
query: z.string()
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
count: z.coerce.number().max(500).optional().describe("Number of results to return (max 500)"),
|
|
178
|
-
offset: z.coerce.number().optional().describe("Number of results to skip for pagination")
|
|
154
|
+
query: z.string(),
|
|
155
|
+
type: z.enum(["book", "page", "chapter", "bookshelf"]).optional(),
|
|
156
|
+
count: z.coerce.number().max(500).optional(),
|
|
157
|
+
offset: z.coerce.number().optional()
|
|
179
158
|
}
|
|
180
159
|
}, async (args) => {
|
|
181
160
|
const results = await client.searchContent(args.query, {
|
|
@@ -183,20 +162,15 @@ function registerTools(server, client, config) {
|
|
|
183
162
|
count: args.count,
|
|
184
163
|
offset: args.offset
|
|
185
164
|
});
|
|
186
|
-
return {
|
|
187
|
-
content: [{ type: "text", text: JSON.stringify(results, null, 2) }]
|
|
188
|
-
};
|
|
165
|
+
return { content: [{ type: "text", text: JSON.stringify(results) }] };
|
|
189
166
|
});
|
|
190
167
|
readTool("search_pages", {
|
|
191
|
-
|
|
192
|
-
description: "Search specifically for pages with optional book filtering. Same advanced-search caveats as search_content — see the query parameter.",
|
|
168
|
+
description: "Search BookStack pages, optionally within a book. Same user-ID caveat as search_content.",
|
|
193
169
|
inputSchema: {
|
|
194
|
-
query: z.string()
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
count: z.coerce.number().max(500).optional().describe("Number of results to return"),
|
|
199
|
-
offset: z.coerce.number().optional().describe("Pagination offset")
|
|
170
|
+
query: z.string(),
|
|
171
|
+
book_id: z.coerce.number().optional(),
|
|
172
|
+
count: z.coerce.number().max(500).optional(),
|
|
173
|
+
offset: z.coerce.number().optional()
|
|
200
174
|
}
|
|
201
175
|
}, async (args) => {
|
|
202
176
|
const results = await client.searchPages(args.query, {
|
|
@@ -204,18 +178,15 @@ function registerTools(server, client, config) {
|
|
|
204
178
|
count: args.count,
|
|
205
179
|
offset: args.offset
|
|
206
180
|
});
|
|
207
|
-
return {
|
|
208
|
-
content: [{ type: "text", text: JSON.stringify(results, null, 2) }]
|
|
209
|
-
};
|
|
181
|
+
return { content: [{ type: "text", text: JSON.stringify(results) }] };
|
|
210
182
|
});
|
|
211
183
|
readTool("get_books", {
|
|
212
|
-
|
|
213
|
-
description: "List available books with advanced filtering and sorting",
|
|
184
|
+
description: "List books with optional filter/sort.",
|
|
214
185
|
inputSchema: {
|
|
215
|
-
offset: z.coerce.number().default(0)
|
|
216
|
-
count: z.coerce.number().max(500).default(50)
|
|
217
|
-
sort: z.string().optional()
|
|
218
|
-
filter: z.record(z.any()).optional()
|
|
186
|
+
offset: z.coerce.number().default(0),
|
|
187
|
+
count: z.coerce.number().max(500).default(50),
|
|
188
|
+
sort: z.string().optional(),
|
|
189
|
+
filter: z.record(z.any()).optional()
|
|
219
190
|
}
|
|
220
191
|
}, async (args) => {
|
|
221
192
|
const books = await client.getBooks({
|
|
@@ -225,31 +196,29 @@ function registerTools(server, client, config) {
|
|
|
225
196
|
filter: args.filter
|
|
226
197
|
});
|
|
227
198
|
return {
|
|
228
|
-
content: [{ type: "text", text: JSON.stringify(books
|
|
199
|
+
content: [{ type: "text", text: JSON.stringify(books) }]
|
|
229
200
|
};
|
|
230
201
|
});
|
|
231
202
|
readTool("get_book", {
|
|
232
|
-
|
|
233
|
-
description: "Get detailed information about a specific book",
|
|
203
|
+
description: "Get a book.",
|
|
234
204
|
inputSchema: {
|
|
235
|
-
id: z.coerce.number().min(1)
|
|
205
|
+
id: z.coerce.number().min(1)
|
|
236
206
|
}
|
|
237
207
|
}, async (args) => {
|
|
238
208
|
const book = await client.getBook(args.id);
|
|
239
209
|
return {
|
|
240
|
-
content: [{ type: "text", text: JSON.stringify(book
|
|
210
|
+
content: [{ type: "text", text: JSON.stringify(book) }]
|
|
241
211
|
};
|
|
242
212
|
});
|
|
243
213
|
readTool("get_pages", {
|
|
244
|
-
|
|
245
|
-
description: "List pages with content previews, word counts, and contextual information",
|
|
214
|
+
description: "List pages with previews.",
|
|
246
215
|
inputSchema: {
|
|
247
|
-
book_id: z.coerce.number().optional()
|
|
248
|
-
chapter_id: z.coerce.number().optional()
|
|
249
|
-
offset: z.coerce.number().default(0)
|
|
250
|
-
count: z.coerce.number().max(500).default(50)
|
|
251
|
-
sort: z.string().optional()
|
|
252
|
-
filter: z.record(z.any()).optional()
|
|
216
|
+
book_id: z.coerce.number().optional(),
|
|
217
|
+
chapter_id: z.coerce.number().optional(),
|
|
218
|
+
offset: z.coerce.number().default(0),
|
|
219
|
+
count: z.coerce.number().max(500).default(50),
|
|
220
|
+
sort: z.string().optional(),
|
|
221
|
+
filter: z.record(z.any()).optional()
|
|
253
222
|
}
|
|
254
223
|
}, async (args) => {
|
|
255
224
|
const pages = await client.getPages({
|
|
@@ -261,14 +230,13 @@ function registerTools(server, client, config) {
|
|
|
261
230
|
filter: args.filter
|
|
262
231
|
});
|
|
263
232
|
return {
|
|
264
|
-
content: [{ type: "text", text: JSON.stringify(pages
|
|
233
|
+
content: [{ type: "text", text: JSON.stringify(pages) }]
|
|
265
234
|
};
|
|
266
235
|
});
|
|
267
236
|
readTool("get_page", {
|
|
268
|
-
|
|
269
|
-
description: "Get content of a specific page. Returns one content format (default markdown) and supports character-range pagination so large pages don't blow the context window. Use offset/limit or the returned content_next_offset to page through long content.",
|
|
237
|
+
description: "Get a page. Returns one format (default markdown); use offset/limit + content_next_offset to paginate large pages.",
|
|
270
238
|
inputSchema: {
|
|
271
|
-
id: z.coerce.number().min(1)
|
|
239
|
+
id: z.coerce.number().min(1),
|
|
272
240
|
format: z.enum(["markdown", "html", "text"]).optional().describe("Which content format to return. Defaults to markdown."),
|
|
273
241
|
offset: z.coerce.number().min(0).optional().describe("Character offset into the content to start from (default 0)"),
|
|
274
242
|
limit: z.coerce.number().min(1).max(200000).optional().describe("Max characters of content to return (default 50000)")
|
|
@@ -280,127 +248,87 @@ function registerTools(server, client, config) {
|
|
|
280
248
|
limit: args.limit
|
|
281
249
|
});
|
|
282
250
|
return {
|
|
283
|
-
content: [{ type: "text", text: JSON.stringify(page
|
|
251
|
+
content: [{ type: "text", text: JSON.stringify(page) }]
|
|
284
252
|
};
|
|
285
253
|
});
|
|
286
254
|
readTool("get_chapters", {
|
|
287
|
-
|
|
288
|
-
description: "List chapters, optionally filtered by book",
|
|
255
|
+
description: "List chapters; optional book_id.",
|
|
289
256
|
inputSchema: {
|
|
290
|
-
book_id: z.coerce.number().optional()
|
|
291
|
-
offset: z.coerce.number().default(0)
|
|
292
|
-
count: z.coerce.number().default(50)
|
|
257
|
+
book_id: z.coerce.number().optional(),
|
|
258
|
+
offset: z.coerce.number().default(0),
|
|
259
|
+
count: z.coerce.number().default(50)
|
|
293
260
|
}
|
|
294
261
|
}, async (args) => {
|
|
295
262
|
const chapters = await client.getChapters(args.book_id, args.offset, args.count);
|
|
296
263
|
return {
|
|
297
|
-
content: [{ type: "text", text: JSON.stringify(chapters
|
|
264
|
+
content: [{ type: "text", text: JSON.stringify(chapters) }]
|
|
298
265
|
};
|
|
299
266
|
});
|
|
300
267
|
readTool("get_chapter", {
|
|
301
|
-
|
|
302
|
-
description: "Get details of a specific chapter",
|
|
268
|
+
description: "Get a chapter.",
|
|
303
269
|
inputSchema: {
|
|
304
|
-
id: z.coerce.number().min(1)
|
|
270
|
+
id: z.coerce.number().min(1)
|
|
305
271
|
}
|
|
306
272
|
}, async (args) => {
|
|
307
273
|
const chapter = await client.getChapter(args.id);
|
|
308
274
|
return {
|
|
309
|
-
content: [{ type: "text", text: JSON.stringify(chapter
|
|
275
|
+
content: [{ type: "text", text: JSON.stringify(chapter) }]
|
|
310
276
|
};
|
|
311
277
|
});
|
|
312
278
|
readTool("export_page", {
|
|
313
|
-
|
|
314
|
-
description: "Export a page in various formats (PDF/ZIP provide direct BookStack download URLs)",
|
|
279
|
+
description: "Export a page (PDF/ZIP return download URL).",
|
|
315
280
|
inputSchema: {
|
|
316
|
-
id: z.coerce.number().min(1)
|
|
317
|
-
format: z.enum(["html", "pdf", "markdown", "plaintext", "zip"])
|
|
281
|
+
id: z.coerce.number().min(1),
|
|
282
|
+
format: z.enum(["html", "pdf", "markdown", "plaintext", "zip"])
|
|
318
283
|
}
|
|
319
284
|
}, async (args) => {
|
|
320
285
|
const content = await client.exportPage(args.id, args.format);
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
const format = args.format.toUpperCase();
|
|
324
|
-
return {
|
|
325
|
-
content: [{
|
|
326
|
-
type: "text",
|
|
327
|
-
text: `✅ **${format} Export Ready**\n\n` +
|
|
328
|
-
`📄 **Page:** ${content.page_name}\n` +
|
|
329
|
-
`📚 **Book:** ${content.book_name}\n` +
|
|
330
|
-
`📁 **File:** ${content.filename}\n\n` +
|
|
331
|
-
`🚀 **Direct Download Link:**\n${content.download_url}\n\n` +
|
|
332
|
-
`ℹ️ **Note:** ${content.note}`
|
|
333
|
-
}]
|
|
334
|
-
};
|
|
286
|
+
if (typeof content === 'object' && content.download_url) {
|
|
287
|
+
return { content: [{ type: "text", text: JSON.stringify(content) }] };
|
|
335
288
|
}
|
|
336
|
-
|
|
337
|
-
const text = typeof content === 'string' ? content : JSON.stringify(content, null, 2);
|
|
289
|
+
const text = typeof content === 'string' ? content : JSON.stringify(content);
|
|
338
290
|
return {
|
|
339
291
|
content: [{ type: "text", text }]
|
|
340
292
|
};
|
|
341
293
|
});
|
|
342
294
|
readTool("export_book", {
|
|
343
|
-
|
|
344
|
-
description: "Export an entire book in various formats",
|
|
295
|
+
description: "Export a book.",
|
|
345
296
|
inputSchema: {
|
|
346
|
-
id: z.coerce.number().min(1)
|
|
347
|
-
format: z.enum(["html", "pdf", "markdown", "plaintext", "zip"])
|
|
297
|
+
id: z.coerce.number().min(1),
|
|
298
|
+
format: z.enum(["html", "pdf", "markdown", "plaintext", "zip"])
|
|
348
299
|
}
|
|
349
300
|
}, async (args) => {
|
|
350
301
|
const content = await client.exportBook(args.id, args.format);
|
|
351
302
|
if (typeof content === 'object' && content.download_url) {
|
|
352
|
-
|
|
353
|
-
return {
|
|
354
|
-
content: [{
|
|
355
|
-
type: "text",
|
|
356
|
-
text: `✅ **${format} Book Export Ready**\n\n` +
|
|
357
|
-
`📚 **Book:** ${content.book_name}\n` +
|
|
358
|
-
`📁 **File:** ${content.filename}\n\n` +
|
|
359
|
-
`🚀 **Direct Download Link:**\n${content.download_url}\n\n` +
|
|
360
|
-
`ℹ️ **Note:** ${content.note}`
|
|
361
|
-
}]
|
|
362
|
-
};
|
|
303
|
+
return { content: [{ type: "text", text: JSON.stringify(content) }] };
|
|
363
304
|
}
|
|
364
|
-
const text = typeof content === 'string' ? content : JSON.stringify(content
|
|
305
|
+
const text = typeof content === 'string' ? content : JSON.stringify(content);
|
|
365
306
|
return {
|
|
366
307
|
content: [{ type: "text", text }]
|
|
367
308
|
};
|
|
368
309
|
});
|
|
369
310
|
readTool("export_chapter", {
|
|
370
|
-
|
|
371
|
-
description: "Export a chapter in various formats",
|
|
311
|
+
description: "Export a chapter.",
|
|
372
312
|
inputSchema: {
|
|
373
|
-
id: z.coerce.number().min(1)
|
|
374
|
-
format: z.enum(["html", "pdf", "markdown", "plaintext", "zip"])
|
|
313
|
+
id: z.coerce.number().min(1),
|
|
314
|
+
format: z.enum(["html", "pdf", "markdown", "plaintext", "zip"])
|
|
375
315
|
}
|
|
376
316
|
}, async (args) => {
|
|
377
317
|
const content = await client.exportChapter(args.id, args.format);
|
|
378
318
|
if (typeof content === 'object' && content.download_url) {
|
|
379
|
-
|
|
380
|
-
return {
|
|
381
|
-
content: [{
|
|
382
|
-
type: "text",
|
|
383
|
-
text: `✅ **${format} Chapter Export Ready**\n\n` +
|
|
384
|
-
`📖 **Chapter:** ${content.chapter_name}\n` +
|
|
385
|
-
`📚 **Book:** ${content.book_name}\n` +
|
|
386
|
-
`📁 **File:** ${content.filename}\n\n` +
|
|
387
|
-
`🚀 **Direct Download Link:**\n${content.download_url}\n\n` +
|
|
388
|
-
`ℹ️ **Note:** ${content.note}`
|
|
389
|
-
}]
|
|
390
|
-
};
|
|
319
|
+
return { content: [{ type: "text", text: JSON.stringify(content) }] };
|
|
391
320
|
}
|
|
392
|
-
const text = typeof content === 'string' ? content : JSON.stringify(content
|
|
321
|
+
const text = typeof content === 'string' ? content : JSON.stringify(content);
|
|
393
322
|
return {
|
|
394
323
|
content: [{ type: "text", text }]
|
|
395
324
|
};
|
|
396
325
|
});
|
|
397
326
|
readTool("get_recent_changes", {
|
|
398
|
-
|
|
399
|
-
description: "Get recently updated content with contextual previews and change descriptions",
|
|
327
|
+
description: "List content updated in the last N days.",
|
|
400
328
|
inputSchema: {
|
|
401
|
-
type: z.enum(["all", "page", "book", "chapter"]).default("all")
|
|
402
|
-
limit: z.coerce.number().max(100).default(20)
|
|
403
|
-
days: z.coerce.number().default(30)
|
|
329
|
+
type: z.enum(["all", "page", "book", "chapter"]).default("all"),
|
|
330
|
+
limit: z.coerce.number().max(100).default(20),
|
|
331
|
+
days: z.coerce.number().default(30)
|
|
404
332
|
}
|
|
405
333
|
}, async (args) => {
|
|
406
334
|
const changes = await client.getRecentChanges({
|
|
@@ -409,17 +337,16 @@ function registerTools(server, client, config) {
|
|
|
409
337
|
days: args.days
|
|
410
338
|
});
|
|
411
339
|
return {
|
|
412
|
-
content: [{ type: "text", text: JSON.stringify(changes
|
|
340
|
+
content: [{ type: "text", text: JSON.stringify(changes) }]
|
|
413
341
|
};
|
|
414
342
|
});
|
|
415
343
|
readTool("get_shelves", {
|
|
416
|
-
|
|
417
|
-
description: "List available book shelves (collections) with filtering and sorting",
|
|
344
|
+
description: "List shelves (book collections).",
|
|
418
345
|
inputSchema: {
|
|
419
|
-
offset: z.coerce.number().default(0)
|
|
420
|
-
count: z.coerce.number().max(500).default(50)
|
|
421
|
-
sort: z.string().optional()
|
|
422
|
-
filter: z.record(z.any()).optional()
|
|
346
|
+
offset: z.coerce.number().default(0),
|
|
347
|
+
count: z.coerce.number().max(500).default(50),
|
|
348
|
+
sort: z.string().optional(),
|
|
349
|
+
filter: z.record(z.any()).optional()
|
|
423
350
|
}
|
|
424
351
|
}, async (args) => {
|
|
425
352
|
const shelves = await client.getShelves({
|
|
@@ -429,29 +356,27 @@ function registerTools(server, client, config) {
|
|
|
429
356
|
filter: args.filter
|
|
430
357
|
});
|
|
431
358
|
return {
|
|
432
|
-
content: [{ type: "text", text: JSON.stringify(shelves
|
|
359
|
+
content: [{ type: "text", text: JSON.stringify(shelves) }]
|
|
433
360
|
};
|
|
434
361
|
});
|
|
435
362
|
readTool("get_shelf", {
|
|
436
|
-
|
|
437
|
-
description: "Get details of a specific book shelf including all books",
|
|
363
|
+
description: "Get a shelf including its books.",
|
|
438
364
|
inputSchema: {
|
|
439
|
-
id: z.coerce.number().min(1)
|
|
365
|
+
id: z.coerce.number().min(1)
|
|
440
366
|
}
|
|
441
367
|
}, async (args) => {
|
|
442
368
|
const shelf = await client.getShelf(args.id);
|
|
443
369
|
return {
|
|
444
|
-
content: [{ type: "text", text: JSON.stringify(shelf
|
|
370
|
+
content: [{ type: "text", text: JSON.stringify(shelf) }]
|
|
445
371
|
};
|
|
446
372
|
});
|
|
447
373
|
readTool("get_attachments", {
|
|
448
|
-
|
|
449
|
-
description: "List attachments (files and links) with filtering and sorting",
|
|
374
|
+
description: "List attachments (files and links).",
|
|
450
375
|
inputSchema: {
|
|
451
|
-
offset: z.coerce.number().default(0)
|
|
452
|
-
count: z.coerce.number().max(500).default(50)
|
|
453
|
-
sort: z.string().optional()
|
|
454
|
-
filter: z.record(z.any()).optional()
|
|
376
|
+
offset: z.coerce.number().default(0),
|
|
377
|
+
count: z.coerce.number().max(500).default(50),
|
|
378
|
+
sort: z.string().optional(),
|
|
379
|
+
filter: z.record(z.any()).optional()
|
|
455
380
|
}
|
|
456
381
|
}, async (args) => {
|
|
457
382
|
const attachments = await client.getAttachments({
|
|
@@ -461,29 +386,27 @@ function registerTools(server, client, config) {
|
|
|
461
386
|
filter: args.filter
|
|
462
387
|
});
|
|
463
388
|
return {
|
|
464
|
-
content: [{ type: "text", text: JSON.stringify(attachments
|
|
389
|
+
content: [{ type: "text", text: JSON.stringify(attachments) }]
|
|
465
390
|
};
|
|
466
391
|
});
|
|
467
392
|
readTool("get_attachment", {
|
|
468
|
-
|
|
469
|
-
description: "Get details of a specific attachment including download links",
|
|
393
|
+
description: "Get an attachment with download_url.",
|
|
470
394
|
inputSchema: {
|
|
471
|
-
id: z.coerce.number().min(1)
|
|
395
|
+
id: z.coerce.number().min(1)
|
|
472
396
|
}
|
|
473
397
|
}, async (args) => {
|
|
474
398
|
const attachment = await client.getAttachment(args.id);
|
|
475
399
|
return {
|
|
476
|
-
content: [{ type: "text", text: JSON.stringify(attachment
|
|
400
|
+
content: [{ type: "text", text: JSON.stringify(attachment) }]
|
|
477
401
|
};
|
|
478
402
|
});
|
|
479
403
|
readTool("get_comments", {
|
|
480
|
-
|
|
481
|
-
description: "List comments, optionally filtered to a single page. Requires BookStack v25.11+.",
|
|
404
|
+
description: "List comments (optional page_id). BookStack v25.11+.",
|
|
482
405
|
inputSchema: {
|
|
483
|
-
page_id: z.coerce.number().optional()
|
|
484
|
-
offset: z.coerce.number().default(0)
|
|
485
|
-
count: z.coerce.number().max(500).default(50)
|
|
486
|
-
sort: z.string().optional()
|
|
406
|
+
page_id: z.coerce.number().optional(),
|
|
407
|
+
offset: z.coerce.number().default(0),
|
|
408
|
+
count: z.coerce.number().max(500).default(50),
|
|
409
|
+
sort: z.string().optional()
|
|
487
410
|
}
|
|
488
411
|
}, async (args) => {
|
|
489
412
|
const comments = await client.getComments({
|
|
@@ -493,31 +416,29 @@ function registerTools(server, client, config) {
|
|
|
493
416
|
sort: args.sort
|
|
494
417
|
});
|
|
495
418
|
return {
|
|
496
|
-
content: [{ type: "text", text: JSON.stringify(comments
|
|
419
|
+
content: [{ type: "text", text: JSON.stringify(comments) }]
|
|
497
420
|
};
|
|
498
421
|
});
|
|
499
422
|
readTool("get_comment", {
|
|
500
|
-
|
|
501
|
-
description: "Get a single comment by ID. Requires BookStack v25.11+.",
|
|
423
|
+
description: "Get a comment. BookStack v25.11+.",
|
|
502
424
|
inputSchema: {
|
|
503
|
-
id: z.coerce.number().min(1)
|
|
425
|
+
id: z.coerce.number().min(1)
|
|
504
426
|
}
|
|
505
427
|
}, async (args) => {
|
|
506
428
|
const comment = await client.getComment(args.id);
|
|
507
429
|
return {
|
|
508
|
-
content: [{ type: "text", text: JSON.stringify(comment
|
|
430
|
+
content: [{ type: "text", text: JSON.stringify(comment) }]
|
|
509
431
|
};
|
|
510
432
|
});
|
|
511
433
|
readTool("find_users", {
|
|
512
|
-
|
|
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.",
|
|
434
|
+
description: "List users; filter by name/email/slug (partial match). Resolves names to numeric user IDs for {created_by:X}/{updated_by:X}/{owned_by:X} search filters. Requires admin token.",
|
|
514
435
|
inputSchema: {
|
|
515
|
-
name: z.string().optional()
|
|
516
|
-
email: z.string().optional()
|
|
517
|
-
slug: z.string().optional()
|
|
518
|
-
offset: z.coerce.number().default(0)
|
|
519
|
-
count: z.coerce.number().max(500).default(50)
|
|
520
|
-
sort: z.string().optional()
|
|
436
|
+
name: z.string().optional(),
|
|
437
|
+
email: z.string().optional(),
|
|
438
|
+
slug: z.string().optional(),
|
|
439
|
+
offset: z.coerce.number().default(0),
|
|
440
|
+
count: z.coerce.number().max(500).default(50),
|
|
441
|
+
sort: z.string().optional()
|
|
521
442
|
}
|
|
522
443
|
}, async (args) => {
|
|
523
444
|
const filter = {};
|
|
@@ -534,16 +455,15 @@ function registerTools(server, client, config) {
|
|
|
534
455
|
filter: Object.keys(filter).length ? filter : undefined
|
|
535
456
|
});
|
|
536
457
|
return {
|
|
537
|
-
content: [{ type: "text", text: JSON.stringify(users
|
|
458
|
+
content: [{ type: "text", text: JSON.stringify(users) }]
|
|
538
459
|
};
|
|
539
460
|
});
|
|
540
461
|
readTool("get_recycle_bin", {
|
|
541
|
-
|
|
542
|
-
description: "List items in the recycle bin (deleted books, chapters, pages, shelves). Requires admin permissions on the API token.",
|
|
462
|
+
description: "List recycle-bin items. Admin token required.",
|
|
543
463
|
inputSchema: {
|
|
544
|
-
offset: z.coerce.number().default(0)
|
|
545
|
-
count: z.coerce.number().max(500).default(50)
|
|
546
|
-
sort: z.string().optional()
|
|
464
|
+
offset: z.coerce.number().default(0),
|
|
465
|
+
count: z.coerce.number().max(500).default(50),
|
|
466
|
+
sort: z.string().optional()
|
|
547
467
|
}
|
|
548
468
|
}, async (args) => {
|
|
549
469
|
const items = await client.getRecycleBin({
|
|
@@ -552,13 +472,12 @@ function registerTools(server, client, config) {
|
|
|
552
472
|
sort: args.sort
|
|
553
473
|
});
|
|
554
474
|
return {
|
|
555
|
-
content: [{ type: "text", text: JSON.stringify(items
|
|
475
|
+
content: [{ type: "text", text: JSON.stringify(items) }]
|
|
556
476
|
};
|
|
557
477
|
});
|
|
558
478
|
// Register write tools if enabled
|
|
559
479
|
if (config.enableWrite) {
|
|
560
480
|
writeTool("create_book", {
|
|
561
|
-
title: "Create Book",
|
|
562
481
|
description: "Create a new book in BookStack",
|
|
563
482
|
inputSchema: {
|
|
564
483
|
name: z.string().describe("Book name"),
|
|
@@ -575,11 +494,10 @@ function registerTools(server, client, config) {
|
|
|
575
494
|
tags: args.tags
|
|
576
495
|
});
|
|
577
496
|
return {
|
|
578
|
-
content: [{ type: "text", text: JSON.stringify(book
|
|
497
|
+
content: [{ type: "text", text: JSON.stringify(book) }]
|
|
579
498
|
};
|
|
580
499
|
});
|
|
581
500
|
writeTool("create_chapter", {
|
|
582
|
-
title: "Create Chapter",
|
|
583
501
|
description: "Create a new chapter within a book",
|
|
584
502
|
inputSchema: {
|
|
585
503
|
book_id: z.coerce.number().min(1).describe("Book ID where the chapter will be created"),
|
|
@@ -598,11 +516,10 @@ function registerTools(server, client, config) {
|
|
|
598
516
|
tags: args.tags
|
|
599
517
|
});
|
|
600
518
|
return {
|
|
601
|
-
content: [{ type: "text", text: JSON.stringify(chapter
|
|
519
|
+
content: [{ type: "text", text: JSON.stringify(chapter) }]
|
|
602
520
|
};
|
|
603
521
|
});
|
|
604
522
|
writeTool("create_page", {
|
|
605
|
-
title: "Create Page",
|
|
606
523
|
description: "Create a new page in BookStack",
|
|
607
524
|
inputSchema: {
|
|
608
525
|
name: z.string().describe("Page name"),
|
|
@@ -620,14 +537,13 @@ function registerTools(server, client, config) {
|
|
|
620
537
|
markdown: args.markdown
|
|
621
538
|
});
|
|
622
539
|
return {
|
|
623
|
-
content: [{ type: "text", text: JSON.stringify(page
|
|
540
|
+
content: [{ type: "text", text: JSON.stringify(page) }]
|
|
624
541
|
};
|
|
625
542
|
});
|
|
626
543
|
writeTool("update_page", {
|
|
627
|
-
title: "Update Page",
|
|
628
544
|
description: "Update an existing page. Pass book_id (and optionally chapter_id) to move the page to a different location.",
|
|
629
545
|
inputSchema: {
|
|
630
|
-
id: z.coerce.number().min(1)
|
|
546
|
+
id: z.coerce.number().min(1),
|
|
631
547
|
name: z.string().optional().describe("Optional: New page name"),
|
|
632
548
|
html: z.string().optional().describe("Optional: New HTML content"),
|
|
633
549
|
markdown: z.string().optional().describe("Optional: New Markdown content"),
|
|
@@ -643,11 +559,10 @@ function registerTools(server, client, config) {
|
|
|
643
559
|
chapter_id: args.chapter_id
|
|
644
560
|
});
|
|
645
561
|
return {
|
|
646
|
-
content: [{ type: "text", text: JSON.stringify(page
|
|
562
|
+
content: [{ type: "text", text: JSON.stringify(page) }]
|
|
647
563
|
};
|
|
648
564
|
});
|
|
649
565
|
writeTool("create_shelf", {
|
|
650
|
-
title: "Create Shelf",
|
|
651
566
|
description: "Create a new book shelf (collection)",
|
|
652
567
|
inputSchema: {
|
|
653
568
|
name: z.string().describe("Shelf name"),
|
|
@@ -666,14 +581,13 @@ function registerTools(server, client, config) {
|
|
|
666
581
|
tags: args.tags
|
|
667
582
|
});
|
|
668
583
|
return {
|
|
669
|
-
content: [{ type: "text", text: JSON.stringify(shelf
|
|
584
|
+
content: [{ type: "text", text: JSON.stringify(shelf) }]
|
|
670
585
|
};
|
|
671
586
|
});
|
|
672
587
|
writeTool("update_shelf", {
|
|
673
|
-
title: "Update Shelf",
|
|
674
588
|
description: "Update an existing book shelf",
|
|
675
589
|
inputSchema: {
|
|
676
|
-
id: z.coerce.number().min(1)
|
|
590
|
+
id: z.coerce.number().min(1),
|
|
677
591
|
name: z.string().optional().describe("New shelf name"),
|
|
678
592
|
description: z.string().optional().describe("New shelf description"),
|
|
679
593
|
books: z.array(z.coerce.number()).optional().describe("Array of book IDs"),
|
|
@@ -690,23 +604,21 @@ function registerTools(server, client, config) {
|
|
|
690
604
|
tags: args.tags
|
|
691
605
|
});
|
|
692
606
|
return {
|
|
693
|
-
content: [{ type: "text", text: JSON.stringify(shelf
|
|
607
|
+
content: [{ type: "text", text: JSON.stringify(shelf) }]
|
|
694
608
|
};
|
|
695
609
|
});
|
|
696
610
|
writeTool("delete_shelf", {
|
|
697
|
-
title: "Delete Shelf",
|
|
698
611
|
description: "Delete a book shelf (collection)",
|
|
699
612
|
inputSchema: {
|
|
700
|
-
id: z.coerce.number().min(1)
|
|
613
|
+
id: z.coerce.number().min(1)
|
|
701
614
|
}
|
|
702
615
|
}, async (args) => {
|
|
703
616
|
const result = await client.deleteShelf(args.id);
|
|
704
617
|
return {
|
|
705
|
-
content: [{ type: "text", text: JSON.stringify(result
|
|
618
|
+
content: [{ type: "text", text: JSON.stringify(result) }]
|
|
706
619
|
};
|
|
707
620
|
});
|
|
708
621
|
writeTool("create_attachment", {
|
|
709
|
-
title: "Create Attachment",
|
|
710
622
|
description: "Create a new link attachment to a page",
|
|
711
623
|
inputSchema: {
|
|
712
624
|
name: z.string().describe("Attachment name"),
|
|
@@ -720,14 +632,13 @@ function registerTools(server, client, config) {
|
|
|
720
632
|
link: args.link
|
|
721
633
|
});
|
|
722
634
|
return {
|
|
723
|
-
content: [{ type: "text", text: JSON.stringify(attachment
|
|
635
|
+
content: [{ type: "text", text: JSON.stringify(attachment) }]
|
|
724
636
|
};
|
|
725
637
|
});
|
|
726
638
|
writeTool("update_attachment", {
|
|
727
|
-
title: "Update Attachment",
|
|
728
639
|
description: "Update an existing attachment",
|
|
729
640
|
inputSchema: {
|
|
730
|
-
id: z.coerce.number().min(1)
|
|
641
|
+
id: z.coerce.number().min(1),
|
|
731
642
|
name: z.string().optional().describe("New attachment name"),
|
|
732
643
|
link: z.string().optional().describe("New URL for link attachment"),
|
|
733
644
|
uploaded_to: z.coerce.number().optional().describe("Move attachment to different page")
|
|
@@ -739,59 +650,54 @@ function registerTools(server, client, config) {
|
|
|
739
650
|
uploaded_to: args.uploaded_to
|
|
740
651
|
});
|
|
741
652
|
return {
|
|
742
|
-
content: [{ type: "text", text: JSON.stringify(attachment
|
|
653
|
+
content: [{ type: "text", text: JSON.stringify(attachment) }]
|
|
743
654
|
};
|
|
744
655
|
});
|
|
745
656
|
writeTool("delete_attachment", {
|
|
746
|
-
title: "Delete Attachment",
|
|
747
657
|
description: "Delete an attachment",
|
|
748
658
|
inputSchema: {
|
|
749
|
-
id: z.coerce.number().min(1)
|
|
659
|
+
id: z.coerce.number().min(1)
|
|
750
660
|
}
|
|
751
661
|
}, async (args) => {
|
|
752
662
|
const result = await client.deleteAttachment(args.id);
|
|
753
663
|
return {
|
|
754
|
-
content: [{ type: "text", text: JSON.stringify(result
|
|
664
|
+
content: [{ type: "text", text: JSON.stringify(result) }]
|
|
755
665
|
};
|
|
756
666
|
});
|
|
757
667
|
writeTool("delete_book", {
|
|
758
|
-
title: "Delete Book",
|
|
759
668
|
description: "Delete a book. Goes to the recycle bin and can be restored from there.",
|
|
760
669
|
inputSchema: {
|
|
761
|
-
id: z.coerce.number().min(1)
|
|
670
|
+
id: z.coerce.number().min(1)
|
|
762
671
|
}
|
|
763
672
|
}, async (args) => {
|
|
764
673
|
const result = await client.deleteBook(args.id);
|
|
765
674
|
return {
|
|
766
|
-
content: [{ type: "text", text: JSON.stringify(result
|
|
675
|
+
content: [{ type: "text", text: JSON.stringify(result) }]
|
|
767
676
|
};
|
|
768
677
|
});
|
|
769
678
|
writeTool("delete_chapter", {
|
|
770
|
-
title: "Delete Chapter",
|
|
771
679
|
description: "Delete a chapter. Goes to the recycle bin and can be restored from there.",
|
|
772
680
|
inputSchema: {
|
|
773
|
-
id: z.coerce.number().min(1)
|
|
681
|
+
id: z.coerce.number().min(1)
|
|
774
682
|
}
|
|
775
683
|
}, async (args) => {
|
|
776
684
|
const result = await client.deleteChapter(args.id);
|
|
777
685
|
return {
|
|
778
|
-
content: [{ type: "text", text: JSON.stringify(result
|
|
686
|
+
content: [{ type: "text", text: JSON.stringify(result) }]
|
|
779
687
|
};
|
|
780
688
|
});
|
|
781
689
|
writeTool("delete_page", {
|
|
782
|
-
title: "Delete Page",
|
|
783
690
|
description: "Delete a page. Goes to the recycle bin and can be restored from there.",
|
|
784
691
|
inputSchema: {
|
|
785
|
-
id: z.coerce.number().min(1)
|
|
692
|
+
id: z.coerce.number().min(1)
|
|
786
693
|
}
|
|
787
694
|
}, async (args) => {
|
|
788
695
|
const result = await client.deletePage(args.id);
|
|
789
696
|
return {
|
|
790
|
-
content: [{ type: "text", text: JSON.stringify(result
|
|
697
|
+
content: [{ type: "text", text: JSON.stringify(result) }]
|
|
791
698
|
};
|
|
792
699
|
});
|
|
793
700
|
writeTool("create_comment", {
|
|
794
|
-
title: "Create Comment",
|
|
795
701
|
description: "Add a comment to a page. Pass parent_id to reply to an existing comment. Requires BookStack v25.11+.",
|
|
796
702
|
inputSchema: {
|
|
797
703
|
page_id: z.coerce.number().min(1).describe("Page ID to comment on"),
|
|
@@ -807,14 +713,13 @@ function registerTools(server, client, config) {
|
|
|
807
713
|
content_ref: args.content_ref
|
|
808
714
|
});
|
|
809
715
|
return {
|
|
810
|
-
content: [{ type: "text", text: JSON.stringify(comment
|
|
716
|
+
content: [{ type: "text", text: JSON.stringify(comment) }]
|
|
811
717
|
};
|
|
812
718
|
});
|
|
813
719
|
writeTool("update_comment", {
|
|
814
|
-
title: "Update Comment",
|
|
815
720
|
description: "Edit a comment's body or archive/unarchive it. Requires BookStack v25.11+.",
|
|
816
721
|
inputSchema: {
|
|
817
|
-
id: z.coerce.number().min(1)
|
|
722
|
+
id: z.coerce.number().min(1),
|
|
818
723
|
html: z.string().optional().describe("Optional: new HTML body"),
|
|
819
724
|
archived: z.boolean().optional().describe("Optional: archive (true) or unarchive (false) the comment")
|
|
820
725
|
}
|
|
@@ -824,43 +729,40 @@ function registerTools(server, client, config) {
|
|
|
824
729
|
archived: args.archived
|
|
825
730
|
});
|
|
826
731
|
return {
|
|
827
|
-
content: [{ type: "text", text: JSON.stringify(comment
|
|
732
|
+
content: [{ type: "text", text: JSON.stringify(comment) }]
|
|
828
733
|
};
|
|
829
734
|
});
|
|
830
735
|
writeTool("delete_comment", {
|
|
831
|
-
title: "Delete Comment",
|
|
832
736
|
description: "Delete a comment. Requires BookStack v25.11+.",
|
|
833
737
|
inputSchema: {
|
|
834
|
-
id: z.coerce.number().min(1)
|
|
738
|
+
id: z.coerce.number().min(1)
|
|
835
739
|
}
|
|
836
740
|
}, async (args) => {
|
|
837
741
|
const result = await client.deleteComment(args.id);
|
|
838
742
|
return {
|
|
839
|
-
content: [{ type: "text", text: JSON.stringify(result
|
|
743
|
+
content: [{ type: "text", text: JSON.stringify(result) }]
|
|
840
744
|
};
|
|
841
745
|
});
|
|
842
746
|
writeTool("restore_deleted", {
|
|
843
|
-
title: "Restore from Recycle Bin",
|
|
844
747
|
description: "Restore a deleted item from the recycle bin. Use the deletion ID from get_recycle_bin (not the original entity ID). Requires admin permissions.",
|
|
845
748
|
inputSchema: {
|
|
846
|
-
deletion_id: z.coerce.number().min(1)
|
|
749
|
+
deletion_id: z.coerce.number().min(1)
|
|
847
750
|
}
|
|
848
751
|
}, async (args) => {
|
|
849
752
|
const result = await client.restoreFromRecycleBin(args.deletion_id);
|
|
850
753
|
return {
|
|
851
|
-
content: [{ type: "text", text: JSON.stringify(result
|
|
754
|
+
content: [{ type: "text", text: JSON.stringify(result) }]
|
|
852
755
|
};
|
|
853
756
|
});
|
|
854
757
|
writeTool("permanently_delete", {
|
|
855
|
-
title: "Permanently Delete from Recycle Bin",
|
|
856
758
|
description: "PERMANENTLY destroys a deleted item — this cannot be undone. Use the deletion ID from get_recycle_bin. Requires admin permissions.",
|
|
857
759
|
inputSchema: {
|
|
858
|
-
deletion_id: z.coerce.number().min(1)
|
|
760
|
+
deletion_id: z.coerce.number().min(1)
|
|
859
761
|
}
|
|
860
762
|
}, async (args) => {
|
|
861
763
|
const result = await client.destroyFromRecycleBin(args.deletion_id);
|
|
862
764
|
return {
|
|
863
|
-
content: [{ type: "text", text: JSON.stringify(result
|
|
765
|
+
content: [{ type: "text", text: JSON.stringify(result) }]
|
|
864
766
|
};
|
|
865
767
|
});
|
|
866
768
|
}
|