Zotero Reader Bridge
by kltng
README.md
# Zotero Reader Bridge
Connect an MCP client to a live Zotero 10.0.x reading session on the same Mac. Capture a selection in a PDF, EPUB, or HTML snapshot, explain it in context, and take the reader back to the same passage.
## Tools
| Tool | Use |
|---|---|
| `reader_list_tabs` | List reader tabs and separate windows, their attachment identities, and readiness. |
| `reader_get_context` | Capture the active pane’s location and live selection. Save `selection.locator` when it is present. |
| `reader_read` | Pass the saved locator as `at` with `mode:"passage"`. Also reads zero-based PDF page ranges and individual EPUB sections. Supply the returned cursor to continue a range. |
| `reader_navigate` | Pass the saved locator as `to`. Navigation also accepts a PDF page or label, or an annotation’s stored position. `focus:false` keeps the current tab. |
| `reader_search` | Find literal, non-overlapping matches within blocks of a loaded document. Pass a result’s locator to `reader_navigate`. Check `complete`, `stopReason`, and `failedUnits` before claiming the document contains no matches. |
| `reader_get_annotations` | List stored annotations for an attachment, including an unopened document. Filter by type or inclusive PDF page range. Read-only. |
When there are duplicate reader tabs (verified live), use the original tab and reader instance from the capture as the target. The locator identifies the document and passage. A coarse locator identifies only a block, section, or page. Search numbers repeated hits that share a coarse location.
## Install and upgrade
Download `zotero-reader-bridge.xpi` from [GitHub Releases](https://github.com/kltng/zotero-reader-plugin/releases). In Zotero, choose **Tools → Plugins → Install Plugin From File** and select the downloaded XPI. Starting with 0.3.3, Zotero checks GitHub Releases for plugin updates automatically.
To build the plugin and MCP server from source, use Node ≥ 22.13.0 and pnpm 11.15.0.
```sh
pnpm install --frozen-lockfile
pnpm build
pnpm typecheck
pnpm lint
pnpm test
```
To install a local build, use the same menu and select `plugin/build/zotero-reader-bridge.xpi`. For each upgrade, always bump the plugin version in its package and manifest before building and reinstalling. Reinstalling the same version failed in the owner’s profile. Never run `zotero-plugin-scaffold serve` against a daily profile.
Add the stdio server to your MCP client configuration. Substitute the absolute path to your checkout and, if necessary, the absolute path to Node. Restart the MCP client after upgrading the server.
```json
{
"mcpServers": {
"zotero-reader-bridge": {
"command": "node",
"args": ["/absolute/path/to/zotero-reader-plugin/server/dist/index.js"]
}
}
}
```
The server reads `~/Library/Application Support/zotero-reader-bridge/token` before every call. `ZOTERO_READER_BRIDGE_TOKEN_FILE` overrides the client’s path. `ZOTERO_BASE_URL` defaults to `http://127.0.0.1:23119`; allowed hosts are `127.0.0.1`, `localhost`, and `[::1]`, with an optional port. Use HTTP with no path. To rotate the token, open Zotero’s Run JavaScript window, tick **Run as async function**, and run `await Zotero.ReaderBridge.rotateToken()`. Plain HTTP clients can use the [agent skill](SKILL.md).
## Security and native effects
The bridge trusts the owner’s OS processes, installed Zotero plugins, and the program listening on the configured loopback port. A different local process that takes that port can receive the token. The plugin creates a 32-byte random token in a private directory (0700) and file (0600), rejects unsafe paths, and authenticates every operation, including discovery. Requests use POST. Host and port checks defend against DNS rebinding, and browser-origin requests are rejected. The service caps request bodies at 256 KiB, responses at 1 MiB, and locators at 16 KiB.
Always send **`Content-Type: application/x-zotero-reader-bridge+json`**. Put the token in the JSON body’s `auth` field. Zotero can log request headers, and it can debug-log the entire body of a plain JSON or form-urlencoded request **before** rejecting it. The MCP server supplies the exact media type and rejects redirects. The bridge disables response caching and redacts its own logs (verified live with Zotero debug output on: no token, query or reading text is logged). Zotero’s reader can log document titles or navigation locations independently.
The plugin reads library data and manages its private token. The owner opted into Zotero’s ordinary navigation effects. Any navigation can save the reading position. Selecting a PDF tab can reimport external annotations if the file changed, deleting and recreating those imported annotations. Loading a new reader can migrate annotation colours and build Zotero’s text cache. Use `focus:false` for an already loaded tab when a tab switch or document load is unwanted. Navigating to an annotation uses its stored position and never selects the annotation.
## Reading limits
- The bridge is pinned to Zotero 10.0.x. A 10.1 upgrade requires a compatible build. It does not request Zotero’s structured-text cache. Text extraction requires a loaded reader, while stored annotations are available directly from the database.
- Reading Mode limits context and disables live selection and navigation. Separate reader windows can be listed, read and searched (verified live). Navigation requires a main-window reader tab.
- Search stays within a block. Queries containing a CJK character ignore Unicode whitespace by default. Set `ignoreWhitespace` explicitly to override this. Case-insensitive matching uses lowercase mappings that preserve UTF-16 length. Variant characters such as 爲 and 為 remain distinct. Vertical-text reading order is not guaranteed.
- Search matches composed and decomposed kana such as で and て + U+3099. Each hit points to the original text.
- PDF running heads and footers appear as blocks. Image-only pages have no searchable text layer. Search reports empty pages separately from extraction failures and returns partial coverage at the result limit or 40-second deadline. A hidden tab can receive a navigation whose arrival cannot be visually verified.
- Search stops before its serialized response exceeds 512 KiB. A `size-budget` stop returns `complete:false` and the hits that fit. `foundAtLeast` counts those hits. Use a more specific query to narrow the search.
## License
MIT — see LICENSE.
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues