You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It serves every instance in writebook instance list, using your sign-ins.
list_instances lists the instances, and every other tool takes an instance argument (an alias or URL). Without it, a tool uses the default instance. Instances that aren't in the list are refused.
The tools that change books are listed only if at least one sign-in can change books. A read-only sign-in is refused before anything is sent.
--read-only serves only the tools that read.
With --serve
It serves one instance over HTTP at /mcp.
Every request must include a Writebook token as a Bearer header, and a request without one gets a 401.
The token is only sent to that instance, and the server never uses a stored login.
A rejected token fails the call with "did not accept your Writebook token".
It accepts any Host header. Host checks stop a web page from using a local server's stored login, and this server doesn't use one.
It serves plain HTTP, so it needs https in front unless it only listens on the machine itself.
Docker image
.github/workflows/publish-image.yml, based on Fizzy's, publishes ghcr.io/basecamp/writebook-cli for amd64 and arm64. The image is signed with cosign and has build provenance attestations.
Every push to main publishes :main and :sha-<commit>.
A release tag v1.2.3 publishes :1.2.3, :1.2, :1 and :latest. Until 1.0 there's no major-only tag such as :0.
A release candidate publishes only its own version, so it never becomes latest.
A release image is only built after the same checks as release.yml pass: the tag is on main, it matches Cargo.toml, and CI passes.
docker run -p 8080:8080 ghcr.io/basecamp/writebook-cli mcp --instance https://books.example.com --serve 0.0.0.0:8080
Logs
Both modes write structured logs to stderr, one JSON object per line:
at startup: the instance, the transport, the listening address, and whether it's read-only
for every HTTP request: the method, the status and how long it took
for every tool call: the tool, ok or error with a fixed reason (token_rejected, writebook_error with Writebook's status, or failed), and how long it took
They never include tokens, client IP addresses, tool arguments, book contents or error messages, since an error message can quote a title, a URL or a search. rmcp's own logs are filtered out because they can quote requests.
Tools
To read: list_books, book_contents, read_book, read_page, search, and list_instances on stdio
To change books: create_page, update_page, create_section
update_page needs the fingerprint that read_page returned. If the page changed since then, nothing is written and the tool says to read it again.
There are no tools yet for deleting or moving leaves, or for pictures.
Notes
It's built on rmcp, the official Rust MCP SDK, with tokio and axum. The release binary grows from 11.3 MB to 17.1 MB.
read.rs now exposes the functions that return its data, so the tools share them with book contents, search and read.
api::Client::with_token makes a client for a token someone handed over, which is never renewed from stored sign-ins.
Testing
tests/mcp.rs drives the server over stdio and HTTP against fake Writebooks, including picking an instance and keeping WRITEBOOK_TOKEN to its own host.
A live run against a local Writebook covered listing, creating, searching, a stale update, a good update, reading back, and a rejected token.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Unresolved issues allow write tools to report success with unusable IDs or fingerprints, MCP reads to fall back to anonymous access after sign-in is lost, and search results to exceed the advertised 50-match limit.
Extends the Writebook CLI so MCP clients can read and edit books on a configured instance, building on the security changes in #11.
Changes:
Adds stdio and HTTP MCP transports with stored sign-ins or per-request Bearer tokens.
Exposes reading, searching, creation, and fingerprint-guarded page updates through shared CLI logic.
Adds integration tests, setup documentation, and MCP runtime dependencies.
[!TIP]
If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.
File
Description
tests/mcp.rs
Tests transports, authentication, read-only tools, and guarded updates.
src/read.rs
Exposes shared read/search functions and typed token-rejection errors.
src/mcp/tools.rs
Defines MCP tool schemas and read/write operations.
src/mcp.rs
Implements MCP transports, credential handling, and request dispatch.
src/main.rs
Adds the mcp command and its options.
src/creds.rs
Exposes token and transport helpers; adds write-access detection.
src/api.rs
Adds nonrenewable supplied-token clients and typed rejection errors.
README.md
Documents local and HTTP MCP setup.
Cargo.toml
Adds rmcp, tokio, and axum dependencies.
Cargo.lock
Records the new dependencies and their transitive packages.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Unresolved MCP credential and capability-handling defects can break startup, misadvertise write access, and return anonymous results, while error logging and image-publication rules still lack required safeguards.
Suppress unsanitized stderr diagnostics in MCP mode
src/mcp.rs:161
When refreshing an expired stdio sign-in fails, this lookup prints the full server-provided error description via src/creds.rs:200, bypassing the sanitized logger. This breaks JSON-only logging and can expose sensitive error contents. Suppress direct stderr diagnostics in MCP mode and emit only fixed structured reasons; the legacy warning at src/read.rs:609 also needs this treatment.
Reject unauthenticated MCP HTML fallbacks
src/mcp/tools.rs:188
When the JSON endpoint is unavailable or redirects, this HTML fallback can return published-only books even after detecting that the supplied token was not accepted. Add an authenticated-only path for MCP that reports rejection instead of succeeding anonymously, while preserving the CLI fallback. Apply it to search at src/mcp/tools.rs:253 as well, including book-scoped searches where check_token currently accepts a missing manifest API.
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
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.
Adds
writebook mcp, an MCP server that lets agents read and edit books directly on all configured instances. To give Claude access to it, run:It can also be used as a server to give anyone's agent access to a Writebook instance using their own logins:
On stdio
writebook instance list, using your sign-ins.list_instanceslists the instances, and every other tool takes aninstanceargument (an alias or URL). Without it, a tool uses the default instance. Instances that aren't in the list are refused.--read-onlyserves only the tools that read.With
--serve/mcp.Hostheader. Host checks stop a web page from using a local server's stored login, and this server doesn't use one.Docker image
.github/workflows/publish-image.yml, based on Fizzy's, publishesghcr.io/basecamp/writebook-clifor amd64 and arm64. The image is signed with cosign and has build provenance attestations.:mainand:sha-<commit>.v1.2.3publishes:1.2.3,:1.2,:1and:latest. Until 1.0 there's no major-only tag such as:0.latest.release.ymlpass: the tag is on main, it matchesCargo.toml, and CI passes.Logs
Both modes write structured logs to stderr, one JSON object per line:
okorerrorwith a fixed reason (token_rejected,writebook_errorwith Writebook's status, orfailed), and how long it tookThey never include tokens, client IP addresses, tool arguments, book contents or error messages, since an error message can quote a title, a URL or a search. rmcp's own logs are filtered out because they can quote requests.
Tools
list_books,book_contents,read_book,read_page,search, andlist_instanceson stdiocreate_page,update_page,create_sectionupdate_pageneeds the fingerprint thatread_pagereturned. If the page changed since then, nothing is written and the tool says to read it again.There are no tools yet for deleting or moving leaves, or for pictures.
Notes
rmcp, the official Rust MCP SDK, with tokio and axum. The release binary grows from 11.3 MB to 17.1 MB.read.rsnow exposes the functions that return its data, so the tools share them withbook contents,searchandread.api::Client::with_tokenmakes a client for a token someone handed over, which is never renewed from stored sign-ins.Testing
tests/mcp.rsdrives the server over stdio and HTTP against fake Writebooks, including picking an instance and keepingWRITEBOOK_TOKENto its own host.