Repository navigation
feat(books): MCP tools and slashdocs books CLI (4/7) - #271
Open
nehalkumarsingh wants to merge 13 commits into
Open
nehalkumarsingh wants to merge 13 commits into
nehalkumarsingh wants to merge 13 commits into
Conversation
nehalkumarsingh
requested review from
anuragrao04 and
razvi-razorpay
as code owners
November 4, 2026 08:19
This was referenced Nov 4, 2026
nehalkumarsingh
force-pushed
the
nehal/book-mode-3-api
branch
from
November 5, 2026 10:48
431010e to
035177d
Compare
nehalkumarsingh
force-pushed
the
nehal/book-mode-4-agents
branch
from
November 5, 2026 10:48
5b3eb74 to
2674ed4
Compare
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
books status fell through to the generic compact row and printed a Go map dump. It now lists each outline entry with its number (or front or back), title, document ID and current version, marks placeholders, and lists the documents not in the outline and the removed chapters. --json still prints the raw payload. The test uses the server's real bookStatusResponse shape. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
POST /v1/folders/{id}/book on a folder that is already a book now puts
the book's id in error.details.book_id. Only folder editors get this far,
and they can already read it from GET /v1/folders/{id}/book, so an agent
that tries to create a book can carry on with the one that exists.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
books create printed only the new book id, so the documents the seeded outline left out were visible only with --json. It now says how many documents were placed and lists the ones not in the outline. When the folder already is a book, the error names that book (from the new book_exists details) and how to show it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every book tool but create_book needs a book_id, and no MCP tool
returned one for an existing book, so an agent told to edit a folder's
book had no way to find it. get_folder_book calls GET
/v1/folders/{id}/book (folder viewers) and returns the book_id.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The CLI had no way to get the book id of an existing book, which every
books command but create needs. books show --folder <folder_id> looks
the book up with GET /v1/folders/{id}/book and shows it, and books show
now prints the book id in its header (--json keeps metadata.identifier).
Front and back matter are labelled by kind instead of a dash.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With SLASHDOCS_BOOKS_ENABLED off (the default), tools/list still offered seven book tools that could only answer feature_disabled, so agents paid context for them and tried them. The tools are now registered only when book mode is on; the flag is read once at startup, the same value the REST handlers check. The tools/list test runs with book mode on, and a new test checks that with it off the book tools are not listed and calling one is an unknown tool. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- delete_book said it deleted reading state and did not say it was permanent. It now says it permanently deletes the book and every outline version, that readers' saved places go too, and that the folder, documents and chapter progress stay. - The outline argument now says that doc is a document ID from the book's folder and planned is a placeholder title, lists subtitle, and says to send only the outline field from get_book_outline. - create_book, get_book_outline, update_book_outline, get_book_status and delete_book say they need editor access; get_book says it is the reader tool. update_book_outline names current_version_id and problems in its errors, and create_book names book_id in book_exists. - The four book_id-only tools share one handler helper. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Pushing the same pulled file twice conflicted with the first push, because the file still names the version it was pulled at, and the CLI said someone else had changed the outline. If the agent then pulled into the same file, it lost its edits. push now remembers the version it saved for each book (as docs push does). On a 409 it reads current_version_id: if that is its own push, it says so and suggests --base-version <that version> or pulling into a new file; otherwise it names the base and current versions. explainOutlineError now updates the APIError message in place. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- outline pull into a file now confirms like docs pull (check mark, version number and id, honours --quiet), and indents the server's JSON with json.Indent so the file keeps the server's key order. - A file that is valid JSON but not an object (an array, or null) is now a usage error saying the file must be a JSON object, instead of a message with Go types or, for null, a request with an empty outline. - A table test covers invalid JSON, an array, null and a missing file. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The MCP book test covered only the stale-base conflict. It now also pushes from the current version and checks the version number goes up. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Build the books outline and summary tables in a strings.Builder and flush them through one checked tabwriter call, and annotate the test file read. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…k, list placeholders - books outline push: after a successful push from a pulled file, rewrite the file's version_id and number to the new version, and drop the "which you pushed" conflict branch, which trusted a per-machine record and could talk a second agent into overwriting the first one's outline. Every conflict now gets the generic "pull and re-apply" message. - MCP get_book runs the same bookReadLimit instance as GET /v1/books/:id, so both share one per-principal budget. - books show renders from the toc, so placeholders are listed (as "planned") and the header count matches the rows. - books delete help and the README say the delete is permanent and removes every outline version and readers' saved places. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
nehalkumarsingh
force-pushed
the
nehal/book-mode-3-api
branch
from
November 5, 2026 12:13
035177d to
d77d67a
Compare
nehalkumarsingh
force-pushed
the
nehal/book-mode-4-agents
branch
from
November 5, 2026 12:13
2674ed4 to
339beca
Compare
Contributor
Author
End-to-end test evidence (stack tip
|
| Check | Result |
|---|---|
| Walkthrough: 12 flows, each asserted through the API and the screen | 12/12 pass |
frontend/e2e on the same server |
26/28. book-mode.spec.ts passes 4/4. The 2 failures need Dex: the public-view sign-in and the @mention picker. The stack changes none of that code. |
| Frontend unit tests | 289/289 |
| Go suite (Postgres-backed, 0 skipped) | pass |
| golangci-lint v2.14.0 | 0 issues |
| Flag off | every book route 404, no book buttons, chapters still open as documents |
What this PR's code did in the run:
- The CLI commands
books show,books statusandbooks outline pullwork against the server. - MCP
tools/listshows the 7 book tools. - As the owner,
get_bookreturns all 4 chapters. - As the partial reader,
get_bookreturns 2 chapters with no hidden titles, andget_book_outlinereturns not_found.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stack: 4/7. Based on #270 (API), then #269 (storage) and #268 (proposal). Review this PR after #270.
What and why
These are the agent surfaces for Book mode. Agents can create a book, read its outline, and push a new outline with the same conflict and validation rules people get.
MCP tools:
create_book,get_book(the per-reader manifest),get_book_outline,get_book_status.update_book_outline, which takes the outline as an object. It reportsoutline_conflictwithcurrent_version_idon a stale base, and returns every validation problem.delete_book, marked destructive.The tools call the REST handlers in-process, so the feature flag, auth and validation are shared.
CLI:
slashdocs books create | show | status | delete, plus:slashdocs books outline pull <book> [file], which writes pretty JSON (to stdout when no file is given or the file is-).slashdocs books outline push <book> <file> [--base-version <id>] [--note "…"]. The file can be a pulled JSON (the base version defaults to itsversion_id) or a bare outline. A conflict exits 5 with a "pull again" message. Invalid outlines print each problem aspath: message.cli/README.mdis updated.How it was tested
go test ./api/... ./internal/... ./cli/... -count=1passes with 0 skipped DB tests.outline_conflictandcurrent_version_id, andexpectedMCPToolslists the six new tools.gofmtandgo vetare clean.go.mod/go.sumare unchanged.Checklist
cli/README.md)🤖 Generated with Claude Code