bookstack-mcp 3.1.0 → 3.3.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 CHANGED
@@ -17,8 +17,9 @@ npx bookstack-mcp
17
17
 
18
18
  ## Features
19
19
 
20
- - 17 read-only tools + 10 write tools for complete BookStack API coverage
21
- - Books, chapters, pages, shelves, and attachments — full CRUD where it matters
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
@@ -50,8 +51,11 @@ BOOKSTACK_BASE_URL=https://your-bookstack.com # Required
50
51
  BOOKSTACK_TOKEN_ID=your-token-id # Required
51
52
  BOOKSTACK_TOKEN_SECRET=your-token-secret # Required
52
53
  BOOKSTACK_ENABLE_WRITE=false # Optional, default false
54
+ BOOKSTACK_INSECURE_SKIP_TLS_VERIFY=false # Optional, default false
53
55
  ```
54
56
 
57
+ > **Security warning:** `BOOKSTACK_INSECURE_SKIP_TLS_VERIFY=true` disables TLS certificate verification for outgoing requests to BookStack. Use only for self-signed certs on a trusted LAN — connections become vulnerable to MITM attacks. The server logs a `WARNING` line at startup whenever this is enabled.
58
+
55
59
  ## Client Configuration
56
60
 
57
61
  ### Claude Desktop
@@ -167,6 +171,8 @@ Both templates support `id` autocompletion: as you type, the server searches Boo
167
171
  | `get_chapters` / `get_chapter` | List or get chapter details |
168
172
  | `get_shelves` / `get_shelf` | List or get shelf details |
169
173
  | `get_attachments` / `get_attachment` | List or get attachment details |
174
+ | `get_comments` / `get_comment` | List or get page comments (BookStack v25.11+) |
175
+ | `get_recycle_bin` | List items in the recycle bin |
170
176
  | `export_page` | Export page as HTML, PDF, Markdown, plaintext, or ZIP |
171
177
  | `export_book` | Export entire book |
172
178
  | `export_chapter` | Export chapter |
@@ -176,12 +182,15 @@ Both templates support `id` autocompletion: as you type, the server searches Boo
176
182
 
177
183
  | Tool | Description |
178
184
  |------|-------------|
179
- | `create_book` | Create a new book |
180
- | `create_chapter` | Create a new chapter inside a book |
185
+ | `create_book` / `delete_book` | Create or delete a book |
186
+ | `create_chapter` / `delete_chapter` | Create or delete a chapter |
181
187
  | `create_page` | Create a new page (HTML or Markdown) |
182
- | `update_page` | Update page content, rename, or move it to a different book/chapter |
188
+ | `update_page` | Update content, rename, or move to a different book/chapter |
189
+ | `delete_page` | Delete a page (recoverable from recycle bin) |
183
190
  | `create_shelf` / `update_shelf` / `delete_shelf` | Manage shelves |
184
191
  | `create_attachment` / `update_attachment` / `delete_attachment` | Manage attachments |
192
+ | `create_comment` / `update_comment` / `delete_comment` | Manage page comments (v25.11+) |
193
+ | `restore_deleted` / `permanently_delete` | Restore or permanently destroy items in the recycle bin |
185
194
 
186
195
  ## BookStack API Setup
187
196
 
@@ -1,4 +1,5 @@
1
1
  import axios from 'axios';
2
+ import https from 'https';
2
3
  export class BookStackClient {
3
4
  client;
4
5
  enableWrite;
@@ -12,7 +13,10 @@ export class BookStackClient {
12
13
  headers: {
13
14
  'Authorization': `Token ${config.tokenId}:${config.tokenSecret}`,
14
15
  'Content-Type': 'application/json'
15
- }
16
+ },
17
+ httpsAgent: config.insecureSkipTlsVerify
18
+ ? new https.Agent({ rejectUnauthorized: false })
19
+ : undefined
16
20
  });
17
21
  }
18
22
  applyFilters(params, filter) {
@@ -332,6 +336,27 @@ export class BookStackClient {
332
336
  const response = await this.client.post('/pages', data);
333
337
  return await this.enhancePageResponse(response.data);
334
338
  }
339
+ async deleteBook(id) {
340
+ if (!this.enableWrite) {
341
+ throw new Error('Write operations are disabled. Set BOOKSTACK_ENABLE_WRITE=true to enable.');
342
+ }
343
+ const response = await this.client.delete(`/books/${id}`);
344
+ return response.data;
345
+ }
346
+ async deleteChapter(id) {
347
+ if (!this.enableWrite) {
348
+ throw new Error('Write operations are disabled. Set BOOKSTACK_ENABLE_WRITE=true to enable.');
349
+ }
350
+ const response = await this.client.delete(`/chapters/${id}`);
351
+ return response.data;
352
+ }
353
+ async deletePage(id) {
354
+ if (!this.enableWrite) {
355
+ throw new Error('Write operations are disabled. Set BOOKSTACK_ENABLE_WRITE=true to enable.');
356
+ }
357
+ const response = await this.client.delete(`/pages/${id}`);
358
+ return response.data;
359
+ }
335
360
  async updatePage(id, data) {
336
361
  if (!this.enableWrite) {
337
362
  throw new Error('Write operations are disabled. Set BOOKSTACK_ENABLE_WRITE=true to enable.');
@@ -625,4 +650,67 @@ export class BookStackClient {
625
650
  const response = await this.client.delete(`/attachments/${id}`);
626
651
  return response.data;
627
652
  }
653
+ // Comments (BookStack v25.11+)
654
+ async getComments(options) {
655
+ const params = {
656
+ offset: options?.offset || 0,
657
+ count: Math.min(options?.count || 50, 500)
658
+ };
659
+ if (options?.pageId)
660
+ params['filter[commentable_id]'] = options.pageId;
661
+ if (options?.sort)
662
+ params.sort = options.sort;
663
+ const response = await this.client.get('/comments', { params });
664
+ return response.data;
665
+ }
666
+ async getComment(id) {
667
+ const response = await this.client.get(`/comments/${id}`);
668
+ return response.data;
669
+ }
670
+ async createComment(data) {
671
+ if (!this.enableWrite) {
672
+ throw new Error('Write operations are disabled. Set BOOKSTACK_ENABLE_WRITE=true to enable.');
673
+ }
674
+ const response = await this.client.post('/comments', data);
675
+ return response.data;
676
+ }
677
+ async updateComment(id, data) {
678
+ if (!this.enableWrite) {
679
+ throw new Error('Write operations are disabled. Set BOOKSTACK_ENABLE_WRITE=true to enable.');
680
+ }
681
+ const response = await this.client.put(`/comments/${id}`, data);
682
+ return response.data;
683
+ }
684
+ async deleteComment(id) {
685
+ if (!this.enableWrite) {
686
+ throw new Error('Write operations are disabled. Set BOOKSTACK_ENABLE_WRITE=true to enable.');
687
+ }
688
+ const response = await this.client.delete(`/comments/${id}`);
689
+ return response.data;
690
+ }
691
+ // Recycle Bin
692
+ async getRecycleBin(options) {
693
+ const params = {
694
+ offset: options?.offset || 0,
695
+ count: Math.min(options?.count || 50, 500)
696
+ };
697
+ if (options?.sort)
698
+ params.sort = options.sort;
699
+ const response = await this.client.get('/recycle-bin', { params });
700
+ return response.data;
701
+ }
702
+ async restoreFromRecycleBin(deletionId) {
703
+ if (!this.enableWrite) {
704
+ throw new Error('Write operations are disabled. Set BOOKSTACK_ENABLE_WRITE=true to enable.');
705
+ }
706
+ const response = await this.client.put(`/recycle-bin/${deletionId}`);
707
+ return response.data;
708
+ }
709
+ async destroyFromRecycleBin(deletionId) {
710
+ if (!this.enableWrite) {
711
+ throw new Error('Write operations are disabled. Set BOOKSTACK_ENABLE_WRITE=true to enable.');
712
+ }
713
+ const response = await this.client.delete(`/recycle-bin/${deletionId}`);
714
+ return response.data;
715
+ }
628
716
  }
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) {
@@ -815,11 +974,15 @@ async function main() {
815
974
  baseUrl: getRequiredEnvVar('BOOKSTACK_BASE_URL'),
816
975
  tokenId: getRequiredEnvVar('BOOKSTACK_TOKEN_ID'),
817
976
  tokenSecret: getRequiredEnvVar('BOOKSTACK_TOKEN_SECRET'),
818
- enableWrite: process.env.BOOKSTACK_ENABLE_WRITE?.toLowerCase() === 'true'
977
+ enableWrite: process.env.BOOKSTACK_ENABLE_WRITE?.toLowerCase() === 'true',
978
+ insecureSkipTlsVerify: process.env.BOOKSTACK_INSECURE_SKIP_TLS_VERIFY?.toLowerCase() === 'true'
819
979
  };
820
980
  console.error('Initializing BookStack MCP Server...');
821
981
  console.error(`BookStack URL: ${config.baseUrl}`);
822
982
  console.error(`Write operations: ${config.enableWrite ? 'ENABLED' : 'DISABLED'}`);
983
+ if (config.insecureSkipTlsVerify) {
984
+ console.error('WARNING: TLS certificate verification is DISABLED (BOOKSTACK_INSECURE_SKIP_TLS_VERIFY=true). Connections to BookStack are vulnerable to MITM attacks. Use only with trusted self-signed certs on a trusted network.');
985
+ }
823
986
  const transportMode = (process.env.MCP_TRANSPORT ?? "stdio").toLowerCase();
824
987
  if (transportMode === "http" || transportMode === "sse") {
825
988
  await startHttp(config);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bookstack-mcp",
3
- "version": "3.1.0",
3
+ "version": "3.3.0",
4
4
  "description": "MCP server for BookStack wiki — search, read, create, and manage documentation via AI assistants",
5
5
  "type": "module",
6
6
  "bin": {