Skip to main content
Glama
zotero-local-api-mcp

zotero-local-api-mcp

by Matcraft94
README.md
# zotero-local-api-mcp

**An MCP server for your local Zotero desktop library: read *and* write,
entirely offline, with zero configuration.**

Servidor MCP para la biblioteca Zotero local del escritorio: lectura y
escritura, 100% offline, sin cuentas ni claves de zotero.org.

## Why another Zotero MCP?

Zotero 10 added **write support to its built-in local HTTP API**
(`127.0.0.1:23119`), including a proper local-authorization handshake.
This server uses it directly:

- No zotero.org account, no web API key, no cloud round trip
- No Zotero plugin to install
- Reads are instant (~10 ms, loopback)
- Writes go through Zotero's own consent dialog — you approve each
  application once, inside Zotero
- Pure Python, stdlib HTTP client (only runtime dependency: the `mcp` SDK)
- BibTeX export of any search, straight from the local API

## Requirements

- Zotero 10 or newer, running, with
  *Settings → Advanced → "Allow other applications on this computer to
  communicate with Zotero"* enabled
- Python 3.10+ (or just `uvx`)

## Install & run

From the repo (no clone needed):

```jsonc
// e.g. Claude Desktop / any MCP client config
{
  "mcpServers": {
    "zotero": {
      "command": "uvx",
      "args": ["--from", "git+https://github.com/Matcraft94/zotero-local-api-mcp",
               "zotero-local-api-mcp"]
    }
  }
}
```

Hermes Agent:

```yaml
mcp_servers:
  zotero:
    command: "uvx"
    args: ["--from", "git+https://github.com/Matcraft94/zotero-local-api-mcp",
           "zotero-local-api-mcp"]
```

### Enabling writes

By default the server is **read-only**. To allow creating/deleting items,
start it with `ZOTERO_MCP_WRITES=1`. The first write then triggers a
dialog **inside Zotero** asking to authorize the app:

- **Allow** → one-time key, valid for that single request
- **Always Allow** → persistent key, cached in
  `~/.cache/zotero-local-api-mcp/key.txt` (0600); no more prompts

```jsonc
{
  "mcpServers": {
    "zotero": {
      "command": "uvx",
      "args": ["--from", "git+https://github.com/Matcraft94/zotero-local-api-mcp",
               "zotero-local-api-mcp"],
      "env": { "ZOTERO_MCP_WRITES": "1" }
    }
  }
}
```

## Tools

| Tool | Kind | Description |
|---|---|---|
| `ping` | read | Local API reachability + Zotero version |
| `search_items` | read | Search by text, tag, item type, collection |
| `get_item` | read | Full metadata of one item |
| `get_item_children` | read | Notes and attachments of an item |
| `list_collections` | read | All collections |
| `list_collection_items` | read | Items in a collection |
| `list_tags` | read | Tags used in the library |
| `export_bibtex` | read | BibTeX export, optionally filtered by query |
| `create_items` | write | Create items from JSON (accepts full Zotero item schema) |
| `create_collection` | write | Create a (nested) collection |
| `delete_item` | write | Move an item to trash |
| `delete_collection` | write | Delete a collection |

## The Zotero 10 write handshake (for implementers)

Documented here because most guides predate it:

1. Every response carries a `Zotero-Server-ID` header (stable per
   database). All write requests must echo it back — missing → `428`,
   mismatched → `412`.
2. `POST /api/local/authorize` with `{"appName": "..."}` and the
   Server-ID header opens a consent dialog in Zotero and returns
   `{"key": "...", "remember": bool}`.
3. Writes send `Zotero-Server-ID` + `Zotero-API-Key`
   (+ `X-Zotero-Write-Token` on POST/PUT). `DELETE`/`PUT` additionally
   require `If-Unmodified-Since-Version: <current item version>`.
4. Authorization prompts are rate-limited to 5/minute (HTTP `429`).

## Development

```bash
uv venv && uv pip install -e ".[test]"
pytest            # live tests against your running Zotero (self-cleaning)
python -m zotero_local_api_mcp.server   # run the server over stdio
```

## License

MIT — see [LICENSE](LICENSE).

TDQS

B3.4/5.0

Scored across 12 tools

Disambiguation4/5

Each tool targets a clear resource+action pair, so an agent can easily pick between get_item, get_item_children, list_collections, and list_collection_items. The only mild overlap is between search_items (which accepts a collection filter) and list_collection_items, since both can enumerate items in a collection.

Naming Consistency5/5

All tools use a consistent snake_case verb_noun pattern (search_items, get_item, list_collections, create_items, delete_item, delete_collection). The sole exception is the conventional health-check name 'ping', which is idiomatic rather than inconsistent.

Tool Count5/5

Twelve tools is well within the ideal range and each one maps to a distinct library operation (search, read, list, export, create, delete). There is no obvious filler or redundant tool in the set.

Completeness3/5

The surface covers discovery, reading, creation, and deletion, but there is no update/edit tool for items or collections, and no way to create notes or manage tags/attachments directly. These gaps force agents to delete-and-recreate instead of editing metadata in place.

Maintenance

ActivityMaintained
ResponsivenessNo recent community issues