Skip to content

fix: real BookStack search syntax for recent-changes + book-scoped search (v5.2.2) - #15

Merged
ttpears merged 1 commit into
mainfrom
fix/recent-changes-filter
Jul 20, 2026
Merged

fix: real BookStack search syntax for recent-changes + book-scoped search (v5.2.2)#15
ttpears merged 1 commit into
mainfrom
fix/recent-changes-filter

Conversation

@ttpears

@ttpears ttpears commented Jul 20, 2026

Copy link
Copy Markdown
Owner

Why

Two MCP tools passed BookStack search-filter tokens that don't exist. BookStack silently drops unknown {...} filters, so both tools returned unfiltered, wrong data (same class as the recent OOM/stall work — a bug surfaced by a real "what changed last week?" query returning the entire wiki).

Fixes (src/bookstack-client.ts)

  1. getRecentChanges used {updated_at:>=DATE} — no such token; BookStack returned the whole wiki (~2681 items) mislabeled as "recent". Live check: {updated_at:>=2026-07-13} → 2681 vs correct {updated_after:2026-07-13} → 15.
    • Now {updated_after:DATE}; dropped the dead sort query param (/search ignores it) and sort newest-first client-side; report the true match total + a returned count.
  2. searchPages injected {book_id:X} to scope to a book — also ignored, so scoped searches leaked other books' pages (live: {book_id:1}, {book_id:999999}, and no filter all returned 1937). BookStack search has no book-scoping token, so over-fetch and filter client-side on book_id (best-effort past the 500-result ceiling, but every returned result truly belongs to the book).

Verification

  • npm run type-check + npm run build clean.
  • Three one-off tests pass (mock BookStack): recent-changes emits {updated_after:} with no dead sort and newest-first order; search-pages emits no {book_id:} token and returns only the requested book; slug-cache cross-session sharing still holds.

Found but NOT fixed here (needs a decision)

The Comments API (get_comments etc.) returns HTTP 404 on bookstack.teamgleim.com — it requires BookStack v25.11+ and the instance predates it. Environmental, not a syntax bug: either upgrade BookStack or gate/hide those tools. Flagged separately.

…d page search

Two tools passed BookStack search-filter tokens that do not exist, which
BookStack silently ignores — so both returned unfiltered, wrong data:

- getRecentChanges used {updated_at:>=DATE} (no such token; returned the entire
  wiki, ~2681 items, mislabeled as recent). Now {updated_after:DATE}. Also dropped
  the dead sort= query param (/search ignores it) and sort results newest-first
  client-side; report the true match total plus a returned count.
- searchPages injected {book_id:X} to scope a search to a book, but that token is
  ignored too, so scoped searches leaked every book's pages. BookStack search has
  no book-scoping token, so over-fetch and filter client-side on book_id.

Bumps version to 5.2.2.
@ttpears
ttpears merged commit d6b865c into main Jul 20, 2026
3 checks passed
@ttpears
ttpears deleted the fix/recent-changes-filter branch July 20, 2026 20:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant