papers-mcp
by jmajerus
README.md
# papers-mcp
An [MCP](https://modelcontextprotocol.io/) server that lets an AI agent search, read, and cite the
scholarly papers in a Zotero library (journal articles, conference papers, reports, preprints, theses,
book chapters) by the text of their PDFs, and cite them with the Zotero record and the page numbers the
paper prints.
It is part of an authoring suite with
[corpus-mcp](https://github.com/jmajerus/corpus-mcp) (books in Calibre),
[holdings-mcp](https://github.com/jmajerus/holdings-mcp) (what is held, in
what form), and [quote-mcp](https://github.com/jmajerus/quote-mcp) (quotes).
Zotero stays the catalogue and stores the files; papers-mcp keeps a full-text
index it can rebuild from them.
The papers are other people's, mostly freely available copies that are still under copyright.
papers-mcp never publishes a paper's text or files: it answers on the LAN and through Cloudflare Access only,
and its tests use made-up PDFs. See [PLAN.md](PLAN.md) for the plan and its stages.
## Tools
| Tool | |
|---|---|
| `search_papers` | Full-text search with author, venue, type, and year filters; ranked passages with the printed page |
| `get_paper_outline` | Zotero metadata, the PDF's sections, and where its page labels come from |
| `read_paper` | Text by page range, printed page, or section |
| `render_page` | A page as a PNG, for figures and tables and to check a printed number |
| `cite_passage` | CSL JSON from the Zotero record (through holdings-mcp) and a locator with the printed pages |
| `pin_page_labels` | Record a PDF's printed numbering when the labels are wrong |
| `status` | Papers, PDFs, what couldn't be read and why, and the last sync and index |
## Page labels
A journal article's first page is often printed 347, so the file position is rarely the page to cite.
Each PDF's labels come from, in order: a pinned numbering; the PDF's own labels (unless they are only
1, 2, 3…); the numbering printed in its running heads and folios
([@jmajerus/pdf-text](https://github.com/jmajerus/corpus-mcp/tree/main/packages/pdf-text));
Zotero's page range when it spans exactly the file's pages; else the file positions, which the tools flag.
When the folios disagree with Zotero's range, the file is often another version than the record (a
preprint, an author manuscript, a translation), and `cite_passage` says so.
## Sources
- **Zotero items** through holdings-mcp's read-only mirror of the Zotero Web API on the LAN
(`PAPERS_ZOTERO_API`), only what changed since the last library version.
- **Files** from Zotero's WebDAV store with a read-only login ([docs/zotero-webdav.md](docs/zotero-webdav.md)),
only those whose md5 changed, kept for `render_page`.
Settings are listed in [src/config.ts](src/config.ts).
## Running
```bash
npm install
npm run index # sync and index once, into data/
npm run serve # MCP at http://localhost:8000/mcp, refreshing every 10 minutes
npm test
```
## Deploying
On its own LXC (`papers-mcp.localdomain`, port 8000), on holdings-mcp's pattern:
```bash
npm run deploy -- --provision # once: Node 22, the papers user, directories, default settings
npm run deploy -- --env # copy PAPERS_WEBDAV_PASSWORD and the other settings from .env
npm run deploy # build, test, install a release, health-check, roll back on failure
```
On the server, log in as `authoring` and run `papers-mcp status`, `papers-mcp index`, or
`papers-mcp reindex`. A nightly timer backs up `data.db` (the pinned labels; everything else rebuilds).
On the LAN, `GET /api/holdings/papers` is holdings-mcp's feed of papers with text (with an ETag), and
`POST /api/refresh` syncs and indexes now. After the first deploy, add a Cloudflare Access application for
the host and add it to the Authoring MCP portal.
## License
[PolyForm Noncommercial 1.0.0](LICENSE.md)
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues