Summary
get_page returns word_count: 0 for WYSIWYG-authored pages even when content is successfully returned (e.g. content_total_chars: 6393). This can mislead consumers into treating populated pages as empty stubs.
Steps to Reproduce
- Create a page using BookStack's WYSIWYG editor
- Ensure the API token's role has "Export Content" so the markdown fallback works
- Call
get_page with default format (markdown)
Expected: word_count reflects actual content
Actual: word_count: 0 despite content_total_chars: 6393 and full content in the response
Root Cause
In enhancePageResponse (bookstack-client.js line 136):
word_count: page.text ? page.text.split(' ').length : 0
word_count is derived from page.text, but for WYSIWYG pages BookStack's API returns page.text as empty. The markdown fallback at line 287-291 populates pageData.markdown via the export endpoint, but never backfills page.text. So word_count stays 0.
Requesting format: "text" directly also returns empty content for WYSIWYG pages, confirming page.text is not populated by BookStack for these pages.
Suggested Fix
Derive word_count from whichever content was actually resolved:
word_count: page.text
? page.text.split(' ').length
: fullContent
? fullContent.split(/\s+/).filter(Boolean).length
: 0
Side note: Export Content permission
Separately, the WYSIWYG→markdown fallback requires the "Export Content" role permission, which isn't included in the default Viewer role. When missing, the fallback silently fails (caught error, logged to stderr) and returns empty content. This isn't a code bug — it's the correct BookStack permission model — but it might be worth documenting in the README since it's a common setup for read-only API tokens.
Environment
- bookstack-mcp v5.1.0
- BookStack hosted on PikaPod, WYSIWYG editor
Summary
get_pagereturnsword_count: 0for WYSIWYG-authored pages even when content is successfully returned (e.g.content_total_chars: 6393). This can mislead consumers into treating populated pages as empty stubs.Steps to Reproduce
get_pagewith default format (markdown)Expected:
word_countreflects actual contentActual:
word_count: 0despitecontent_total_chars: 6393and full content in the responseRoot Cause
In
enhancePageResponse(bookstack-client.js line 136):word_countis derived frompage.text, but for WYSIWYG pages BookStack's API returnspage.textas empty. The markdown fallback at line 287-291 populatespageData.markdownvia the export endpoint, but never backfillspage.text. Soword_countstays 0.Requesting
format: "text"directly also returns empty content for WYSIWYG pages, confirmingpage.textis not populated by BookStack for these pages.Suggested Fix
Derive
word_countfrom whichever content was actually resolved:Side note: Export Content permission
Separately, the WYSIWYG→markdown fallback requires the "Export Content" role permission, which isn't included in the default Viewer role. When missing, the fallback silently fails (caught error, logged to stderr) and returns empty content. This isn't a code bug — it's the correct BookStack permission model — but it might be worth documenting in the README since it's a common setup for read-only API tokens.
Environment