bookstack-mcp 3.1.0 → 3.2.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 +11 -5
- package/dist/bookstack-client.js +84 -0
- package/dist/index.js +159 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -17,8 +17,9 @@ npx bookstack-mcp
|
|
|
17
17
|
|
|
18
18
|
## Features
|
|
19
19
|
|
|
20
|
-
-
|
|
21
|
-
- Books, chapters, pages, shelves, and
|
|
20
|
+
- 20 read-only tools + 18 write tools for complete BookStack API coverage
|
|
21
|
+
- Books, chapters, pages, shelves, attachments, and comments — full CRUD
|
|
22
|
+
- Recycle bin support — restore or permanently delete soft-deleted content
|
|
22
23
|
- Type-safe input validation with Zod (auto-coerces string/number params for broad client compatibility)
|
|
23
24
|
- Embedded URLs and content previews in all responses
|
|
24
25
|
- Markdown export fallback for HTML-authored pages, so AI clients always get usable content
|
|
@@ -167,6 +168,8 @@ Both templates support `id` autocompletion: as you type, the server searches Boo
|
|
|
167
168
|
| `get_chapters` / `get_chapter` | List or get chapter details |
|
|
168
169
|
| `get_shelves` / `get_shelf` | List or get shelf details |
|
|
169
170
|
| `get_attachments` / `get_attachment` | List or get attachment details |
|
|
171
|
+
| `get_comments` / `get_comment` | List or get page comments (BookStack v25.11+) |
|
|
172
|
+
| `get_recycle_bin` | List items in the recycle bin |
|
|
170
173
|
| `export_page` | Export page as HTML, PDF, Markdown, plaintext, or ZIP |
|
|
171
174
|
| `export_book` | Export entire book |
|
|
172
175
|
| `export_chapter` | Export chapter |
|
|
@@ -176,12 +179,15 @@ Both templates support `id` autocompletion: as you type, the server searches Boo
|
|
|
176
179
|
|
|
177
180
|
| Tool | Description |
|
|
178
181
|
|------|-------------|
|
|
179
|
-
| `create_book` | Create a
|
|
180
|
-
| `create_chapter` | Create
|
|
182
|
+
| `create_book` / `delete_book` | Create or delete a book |
|
|
183
|
+
| `create_chapter` / `delete_chapter` | Create or delete a chapter |
|
|
181
184
|
| `create_page` | Create a new page (HTML or Markdown) |
|
|
182
|
-
| `update_page` | Update
|
|
185
|
+
| `update_page` | Update content, rename, or move to a different book/chapter |
|
|
186
|
+
| `delete_page` | Delete a page (recoverable from recycle bin) |
|
|
183
187
|
| `create_shelf` / `update_shelf` / `delete_shelf` | Manage shelves |
|
|
184
188
|
| `create_attachment` / `update_attachment` / `delete_attachment` | Manage attachments |
|
|
189
|
+
| `create_comment` / `update_comment` / `delete_comment` | Manage page comments (v25.11+) |
|
|
190
|
+
| `restore_deleted` / `permanently_delete` | Restore or permanently destroy items in the recycle bin |
|
|
185
191
|
|
|
186
192
|
## BookStack API Setup
|
|
187
193
|
|
package/dist/bookstack-client.js
CHANGED
|
@@ -332,6 +332,27 @@ export class BookStackClient {
|
|
|
332
332
|
const response = await this.client.post('/pages', data);
|
|
333
333
|
return await this.enhancePageResponse(response.data);
|
|
334
334
|
}
|
|
335
|
+
async deleteBook(id) {
|
|
336
|
+
if (!this.enableWrite) {
|
|
337
|
+
throw new Error('Write operations are disabled. Set BOOKSTACK_ENABLE_WRITE=true to enable.');
|
|
338
|
+
}
|
|
339
|
+
const response = await this.client.delete(`/books/${id}`);
|
|
340
|
+
return response.data;
|
|
341
|
+
}
|
|
342
|
+
async deleteChapter(id) {
|
|
343
|
+
if (!this.enableWrite) {
|
|
344
|
+
throw new Error('Write operations are disabled. Set BOOKSTACK_ENABLE_WRITE=true to enable.');
|
|
345
|
+
}
|
|
346
|
+
const response = await this.client.delete(`/chapters/${id}`);
|
|
347
|
+
return response.data;
|
|
348
|
+
}
|
|
349
|
+
async deletePage(id) {
|
|
350
|
+
if (!this.enableWrite) {
|
|
351
|
+
throw new Error('Write operations are disabled. Set BOOKSTACK_ENABLE_WRITE=true to enable.');
|
|
352
|
+
}
|
|
353
|
+
const response = await this.client.delete(`/pages/${id}`);
|
|
354
|
+
return response.data;
|
|
355
|
+
}
|
|
335
356
|
async updatePage(id, data) {
|
|
336
357
|
if (!this.enableWrite) {
|
|
337
358
|
throw new Error('Write operations are disabled. Set BOOKSTACK_ENABLE_WRITE=true to enable.');
|
|
@@ -625,4 +646,67 @@ export class BookStackClient {
|
|
|
625
646
|
const response = await this.client.delete(`/attachments/${id}`);
|
|
626
647
|
return response.data;
|
|
627
648
|
}
|
|
649
|
+
// Comments (BookStack v25.11+)
|
|
650
|
+
async getComments(options) {
|
|
651
|
+
const params = {
|
|
652
|
+
offset: options?.offset || 0,
|
|
653
|
+
count: Math.min(options?.count || 50, 500)
|
|
654
|
+
};
|
|
655
|
+
if (options?.pageId)
|
|
656
|
+
params['filter[commentable_id]'] = options.pageId;
|
|
657
|
+
if (options?.sort)
|
|
658
|
+
params.sort = options.sort;
|
|
659
|
+
const response = await this.client.get('/comments', { params });
|
|
660
|
+
return response.data;
|
|
661
|
+
}
|
|
662
|
+
async getComment(id) {
|
|
663
|
+
const response = await this.client.get(`/comments/${id}`);
|
|
664
|
+
return response.data;
|
|
665
|
+
}
|
|
666
|
+
async createComment(data) {
|
|
667
|
+
if (!this.enableWrite) {
|
|
668
|
+
throw new Error('Write operations are disabled. Set BOOKSTACK_ENABLE_WRITE=true to enable.');
|
|
669
|
+
}
|
|
670
|
+
const response = await this.client.post('/comments', data);
|
|
671
|
+
return response.data;
|
|
672
|
+
}
|
|
673
|
+
async updateComment(id, data) {
|
|
674
|
+
if (!this.enableWrite) {
|
|
675
|
+
throw new Error('Write operations are disabled. Set BOOKSTACK_ENABLE_WRITE=true to enable.');
|
|
676
|
+
}
|
|
677
|
+
const response = await this.client.put(`/comments/${id}`, data);
|
|
678
|
+
return response.data;
|
|
679
|
+
}
|
|
680
|
+
async deleteComment(id) {
|
|
681
|
+
if (!this.enableWrite) {
|
|
682
|
+
throw new Error('Write operations are disabled. Set BOOKSTACK_ENABLE_WRITE=true to enable.');
|
|
683
|
+
}
|
|
684
|
+
const response = await this.client.delete(`/comments/${id}`);
|
|
685
|
+
return response.data;
|
|
686
|
+
}
|
|
687
|
+
// Recycle Bin
|
|
688
|
+
async getRecycleBin(options) {
|
|
689
|
+
const params = {
|
|
690
|
+
offset: options?.offset || 0,
|
|
691
|
+
count: Math.min(options?.count || 50, 500)
|
|
692
|
+
};
|
|
693
|
+
if (options?.sort)
|
|
694
|
+
params.sort = options.sort;
|
|
695
|
+
const response = await this.client.get('/recycle-bin', { params });
|
|
696
|
+
return response.data;
|
|
697
|
+
}
|
|
698
|
+
async restoreFromRecycleBin(deletionId) {
|
|
699
|
+
if (!this.enableWrite) {
|
|
700
|
+
throw new Error('Write operations are disabled. Set BOOKSTACK_ENABLE_WRITE=true to enable.');
|
|
701
|
+
}
|
|
702
|
+
const response = await this.client.put(`/recycle-bin/${deletionId}`);
|
|
703
|
+
return response.data;
|
|
704
|
+
}
|
|
705
|
+
async destroyFromRecycleBin(deletionId) {
|
|
706
|
+
if (!this.enableWrite) {
|
|
707
|
+
throw new Error('Write operations are disabled. Set BOOKSTACK_ENABLE_WRITE=true to enable.');
|
|
708
|
+
}
|
|
709
|
+
const response = await this.client.delete(`/recycle-bin/${deletionId}`);
|
|
710
|
+
return response.data;
|
|
711
|
+
}
|
|
628
712
|
}
|
package/dist/index.js
CHANGED
|
@@ -472,6 +472,56 @@ function registerTools(server, client, config) {
|
|
|
472
472
|
content: [{ type: "text", text: JSON.stringify(attachment, null, 2) }]
|
|
473
473
|
};
|
|
474
474
|
});
|
|
475
|
+
readTool("get_comments", {
|
|
476
|
+
title: "List Comments",
|
|
477
|
+
description: "List comments, optionally filtered to a single page. Requires BookStack v25.11+.",
|
|
478
|
+
inputSchema: {
|
|
479
|
+
page_id: z.coerce.number().optional().describe("Filter to comments on this page"),
|
|
480
|
+
offset: z.coerce.number().default(0).describe("Pagination offset"),
|
|
481
|
+
count: z.coerce.number().max(500).default(50).describe("Number of results to return"),
|
|
482
|
+
sort: z.string().optional().describe("Sort field")
|
|
483
|
+
}
|
|
484
|
+
}, async (args) => {
|
|
485
|
+
const comments = await client.getComments({
|
|
486
|
+
pageId: args.page_id,
|
|
487
|
+
offset: args.offset,
|
|
488
|
+
count: args.count,
|
|
489
|
+
sort: args.sort
|
|
490
|
+
});
|
|
491
|
+
return {
|
|
492
|
+
content: [{ type: "text", text: JSON.stringify(comments, null, 2) }]
|
|
493
|
+
};
|
|
494
|
+
});
|
|
495
|
+
readTool("get_comment", {
|
|
496
|
+
title: "Get Comment",
|
|
497
|
+
description: "Get a single comment by ID. Requires BookStack v25.11+.",
|
|
498
|
+
inputSchema: {
|
|
499
|
+
id: z.coerce.number().min(1).describe("Comment ID")
|
|
500
|
+
}
|
|
501
|
+
}, async (args) => {
|
|
502
|
+
const comment = await client.getComment(args.id);
|
|
503
|
+
return {
|
|
504
|
+
content: [{ type: "text", text: JSON.stringify(comment, null, 2) }]
|
|
505
|
+
};
|
|
506
|
+
});
|
|
507
|
+
readTool("get_recycle_bin", {
|
|
508
|
+
title: "List Recycle Bin",
|
|
509
|
+
description: "List items in the recycle bin (deleted books, chapters, pages, shelves). Requires admin permissions on the API token.",
|
|
510
|
+
inputSchema: {
|
|
511
|
+
offset: z.coerce.number().default(0).describe("Pagination offset"),
|
|
512
|
+
count: z.coerce.number().max(500).default(50).describe("Number of results to return"),
|
|
513
|
+
sort: z.string().optional().describe("Sort field")
|
|
514
|
+
}
|
|
515
|
+
}, async (args) => {
|
|
516
|
+
const items = await client.getRecycleBin({
|
|
517
|
+
offset: args.offset,
|
|
518
|
+
count: args.count,
|
|
519
|
+
sort: args.sort
|
|
520
|
+
});
|
|
521
|
+
return {
|
|
522
|
+
content: [{ type: "text", text: JSON.stringify(items, null, 2) }]
|
|
523
|
+
};
|
|
524
|
+
});
|
|
475
525
|
// Register write tools if enabled
|
|
476
526
|
if (config.enableWrite) {
|
|
477
527
|
writeTool("create_book", {
|
|
@@ -671,6 +721,115 @@ function registerTools(server, client, config) {
|
|
|
671
721
|
content: [{ type: "text", text: JSON.stringify(result, null, 2) }]
|
|
672
722
|
};
|
|
673
723
|
});
|
|
724
|
+
writeTool("delete_book", {
|
|
725
|
+
title: "Delete Book",
|
|
726
|
+
description: "Delete a book. Goes to the recycle bin and can be restored from there.",
|
|
727
|
+
inputSchema: {
|
|
728
|
+
id: z.coerce.number().min(1).describe("Book ID")
|
|
729
|
+
}
|
|
730
|
+
}, async (args) => {
|
|
731
|
+
const result = await client.deleteBook(args.id);
|
|
732
|
+
return {
|
|
733
|
+
content: [{ type: "text", text: JSON.stringify(result, null, 2) }]
|
|
734
|
+
};
|
|
735
|
+
});
|
|
736
|
+
writeTool("delete_chapter", {
|
|
737
|
+
title: "Delete Chapter",
|
|
738
|
+
description: "Delete a chapter. Goes to the recycle bin and can be restored from there.",
|
|
739
|
+
inputSchema: {
|
|
740
|
+
id: z.coerce.number().min(1).describe("Chapter ID")
|
|
741
|
+
}
|
|
742
|
+
}, async (args) => {
|
|
743
|
+
const result = await client.deleteChapter(args.id);
|
|
744
|
+
return {
|
|
745
|
+
content: [{ type: "text", text: JSON.stringify(result, null, 2) }]
|
|
746
|
+
};
|
|
747
|
+
});
|
|
748
|
+
writeTool("delete_page", {
|
|
749
|
+
title: "Delete Page",
|
|
750
|
+
description: "Delete a page. Goes to the recycle bin and can be restored from there.",
|
|
751
|
+
inputSchema: {
|
|
752
|
+
id: z.coerce.number().min(1).describe("Page ID")
|
|
753
|
+
}
|
|
754
|
+
}, async (args) => {
|
|
755
|
+
const result = await client.deletePage(args.id);
|
|
756
|
+
return {
|
|
757
|
+
content: [{ type: "text", text: JSON.stringify(result, null, 2) }]
|
|
758
|
+
};
|
|
759
|
+
});
|
|
760
|
+
writeTool("create_comment", {
|
|
761
|
+
title: "Create Comment",
|
|
762
|
+
description: "Add a comment to a page. Pass parent_id to reply to an existing comment. Requires BookStack v25.11+.",
|
|
763
|
+
inputSchema: {
|
|
764
|
+
page_id: z.coerce.number().min(1).describe("Page ID to comment on"),
|
|
765
|
+
html: z.string().describe("Comment HTML body"),
|
|
766
|
+
parent_id: z.coerce.number().optional().describe("Optional: parent comment ID for threaded replies"),
|
|
767
|
+
content_ref: z.string().optional().describe("Optional: anchor/selection reference within the page")
|
|
768
|
+
}
|
|
769
|
+
}, async (args) => {
|
|
770
|
+
const comment = await client.createComment({
|
|
771
|
+
page_id: args.page_id,
|
|
772
|
+
html: args.html,
|
|
773
|
+
parent_id: args.parent_id,
|
|
774
|
+
content_ref: args.content_ref
|
|
775
|
+
});
|
|
776
|
+
return {
|
|
777
|
+
content: [{ type: "text", text: JSON.stringify(comment, null, 2) }]
|
|
778
|
+
};
|
|
779
|
+
});
|
|
780
|
+
writeTool("update_comment", {
|
|
781
|
+
title: "Update Comment",
|
|
782
|
+
description: "Edit a comment's body or archive/unarchive it. Requires BookStack v25.11+.",
|
|
783
|
+
inputSchema: {
|
|
784
|
+
id: z.coerce.number().min(1).describe("Comment ID"),
|
|
785
|
+
html: z.string().optional().describe("Optional: new HTML body"),
|
|
786
|
+
archived: z.boolean().optional().describe("Optional: archive (true) or unarchive (false) the comment")
|
|
787
|
+
}
|
|
788
|
+
}, async (args) => {
|
|
789
|
+
const comment = await client.updateComment(args.id, {
|
|
790
|
+
html: args.html,
|
|
791
|
+
archived: args.archived
|
|
792
|
+
});
|
|
793
|
+
return {
|
|
794
|
+
content: [{ type: "text", text: JSON.stringify(comment, null, 2) }]
|
|
795
|
+
};
|
|
796
|
+
});
|
|
797
|
+
writeTool("delete_comment", {
|
|
798
|
+
title: "Delete Comment",
|
|
799
|
+
description: "Delete a comment. Requires BookStack v25.11+.",
|
|
800
|
+
inputSchema: {
|
|
801
|
+
id: z.coerce.number().min(1).describe("Comment ID")
|
|
802
|
+
}
|
|
803
|
+
}, async (args) => {
|
|
804
|
+
const result = await client.deleteComment(args.id);
|
|
805
|
+
return {
|
|
806
|
+
content: [{ type: "text", text: JSON.stringify(result, null, 2) }]
|
|
807
|
+
};
|
|
808
|
+
});
|
|
809
|
+
writeTool("restore_deleted", {
|
|
810
|
+
title: "Restore from Recycle Bin",
|
|
811
|
+
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.",
|
|
812
|
+
inputSchema: {
|
|
813
|
+
deletion_id: z.coerce.number().min(1).describe("Deletion ID (from get_recycle_bin)")
|
|
814
|
+
}
|
|
815
|
+
}, async (args) => {
|
|
816
|
+
const result = await client.restoreFromRecycleBin(args.deletion_id);
|
|
817
|
+
return {
|
|
818
|
+
content: [{ type: "text", text: JSON.stringify(result, null, 2) }]
|
|
819
|
+
};
|
|
820
|
+
});
|
|
821
|
+
writeTool("permanently_delete", {
|
|
822
|
+
title: "Permanently Delete from Recycle Bin",
|
|
823
|
+
description: "PERMANENTLY destroys a deleted item — this cannot be undone. Use the deletion ID from get_recycle_bin. Requires admin permissions.",
|
|
824
|
+
inputSchema: {
|
|
825
|
+
deletion_id: z.coerce.number().min(1).describe("Deletion ID (from get_recycle_bin)")
|
|
826
|
+
}
|
|
827
|
+
}, async (args) => {
|
|
828
|
+
const result = await client.destroyFromRecycleBin(args.deletion_id);
|
|
829
|
+
return {
|
|
830
|
+
content: [{ type: "text", text: JSON.stringify(result, null, 2) }]
|
|
831
|
+
};
|
|
832
|
+
});
|
|
674
833
|
}
|
|
675
834
|
}
|
|
676
835
|
async function startStdio(config) {
|