# Configuration
How Zotero MCP connects to your library, and every setting that changes its behaviour. For first-time setup of a specific client, start with [Getting started](getting-started.md).
## Connection modes
- **Local read-only**: offline access to a running Zotero, no credentials at all (`ZOTERO_LOCAL=true`)
- **Local read-write** (Zotero 10+): add one authorization and writes stay local too. See [Local write support](#local-write-support)
- **Web API**: cloud library access from anywhere (`ZOTERO_API_KEY` + `ZOTERO_LIBRARY_ID`)
- **Hybrid**: read from local Zotero, write via the web API (`ZOTERO_LOCAL=true` plus web credentials), for anyone on an older Zotero
### Using the web API instead of the local API
For accessing your Zotero library via the web API (useful for remote setups):
```bash
zotero-mcp setup --no-local --api-key YOUR_API_KEY --library-id YOUR_LIBRARY_ID
```
Generate an API key at [zotero.org/settings/security](https://www.zotero.org/settings/security#applications). `ZOTERO_LIBRARY_ID` is your numeric **userID**, shown on that same page (for a group library, use the group's ID and also set `ZOTERO_LIBRARY_TYPE=group`).
If you sync your personal library's attachment files over WebDAV, setup also asks for its address and login, so that files you attach go to your WebDAV server instead of counting against your Zotero Storage quota. A re-run offers the stored settings as defaults.
## Local write support (Zotero 10+)
Zotero's local API was read-only for most of its life, which is why writes have always
gone through the Zotero web API. Zotero 10 added local write endpoints, so on that
version writes can stay entirely on your machine: no cloud account, no waiting for a
sync round-trip, and no Zotero Storage quota to run into when attaching PDFs.
Writes need a **local API key**. It has nothing to do with a zotero.org API key and
can't be created in advance — Zotero grants it through a dialog:
```bash
zotero-mcp authorize-local
```
Zotero shows a prompt with three buttons. **Always Allow** grants a reusable key that
is saved to `~/.config/zotero-mcp/config.json` (owner-only permissions) and picked up
automatically from then on — that's the one you want. **Allow** grants a key valid for
exactly one write; it is never saved to disk, since a consumed key sitting there would
take priority over working web credentials on every later run. **Deny** grants nothing.
If a key is ever rejected — consumed, revoked from Zotero's side, or belonging to a
Zotero database you no longer have — the server drops it and falls back to web
credentials if you have them, rather than failing against a key that cannot work again.
An MCP client can do the same thing without dropping to a shell: the
`zotero_authorize_local_writes` tool opens the same dialog, and
`zotero_write_capabilities` reports which write path is currently available. If a write
is refused, that second tool tells you whether the fix is authorizing or supplying web
credentials.
```bash
zotero-mcp authorize-local --status # what can write right now
zotero-mcp authorize-local --revoke # forget the stored key
zotero-mcp authorize-local --print # print it for ZOTERO_LOCAL_API_KEY instead
```
Nothing here is required. Without a local key the server behaves exactly as before:
hybrid mode if web credentials are set, and a message explaining both options if not.
Set `ZOTERO_LOCAL_WRITE=false` to keep writes on the web API even when a key exists.
**Revoking.** `--revoke` removes the copy this server stores. Zotero keeps its own
record of what it has authorized, cleared from **Settings → Advanced → Clear Write
Authorizations**.
**Requirements.** Zotero 10 or newer, with "Allow other applications on this computer
to communicate with Zotero" enabled in Settings → Advanced. Older versions have no
local write endpoints at all; `zotero-mcp authorize-local` detects this and says so
rather than opening a dialog that can't help.
## Environment variables
**Zotero connection:**
- `ZOTERO_LOCAL=true`: Use the local Zotero API (default: false)
- `ZOTERO_API_KEY`: Your Zotero API key (for web API)
- `ZOTERO_LIBRARY_ID`: Your Zotero library ID (for web API)
- `ZOTERO_LIBRARY_TYPE`: The type of library (user or group, default: user)
- `ZOTERO_API_URL`: Web API base URL, for a self-hosted server that speaks the Zotero Web
API (e.g. [altero](https://github.com/eseifert/altero)) instead of zotero.org — the same
value as Zotero desktop's `extensions.zotero.api.url` (default: `https://api.zotero.org`)
- `ZOTERO_LOCAL_API_KEY`: Local API key for writes (Zotero 10+). Normally set for you by
`zotero-mcp authorize-local`; use the variable for containers and CI, where the config
file isn't convenient
- `ZOTERO_LOCAL_SERVER_ID`: Pin the local Zotero database the key belongs to (optional —
discovered automatically)
- `ZOTERO_LOCAL_WRITE`: `auto` (default) or `false` to force writes onto the web API even
when a local key exists
- `ZOTERO_WEBDAV_URL`: Optional WebDAV folder that holds your Zotero files, as a full URL
including `https://`: the address in Zotero's File Syncing settings followed by `/zotero/`.
When set, attachments added to your personal library through the web API are written to it
directly rather than to Zotero Storage (group libraries always use Zotero Storage), and
attachments are downloaded from it in remote mode. `zotero-mcp setup --no-local` asks for
this and the two settings below
- `ZOTERO_WEBDAV_USERNAME`: Optional WebDAV username
- `ZOTERO_WEBDAV_PASSWORD`: Optional WebDAV password
Environment variables set in the shell you launch a client from (for example `claude`) override the values in its config file.
**HTTP authentication:**
- `ZOTERO_MCP_AUTH_TOKEN`: Shared bearer token required by the `streamable-http`
and `sse` transports when configured. It does not affect `stdio`. See
[HTTP authentication and network access](#http-authentication-and-network-access).
**Semantic search** (see [Semantic search](semantic-search.md)):
- `ZOTERO_EMBEDDING_MODEL`: Embedding model to use (default, openai, gemini, ollama)
- `OPENAI_API_KEY`: Your OpenAI API key (for OpenAI embeddings)
- `OPENAI_EMBEDDING_MODEL`: OpenAI model name (text-embedding-3-small, text-embedding-3-large)
- `OPENAI_BASE_URL`: Custom OpenAI endpoint URL (optional, for use with compatible APIs)
- OpenAI Batch API indexing is configured by `zotero-mcp setup` and can be overridden with
`zotero-mcp update-db --openai-batch` or `--no-openai-batch`
- `GEMINI_API_KEY`: Your Gemini API key (for Gemini embeddings)
- `GEMINI_EMBEDDING_MODEL`: Gemini model name (gemini-embedding-001)
- `GEMINI_BASE_URL`: Custom Gemini endpoint URL (optional, for use with compatible APIs)
- `OLLAMA_EMBEDDING_MODEL`: Ollama embedding model name (qwen3-embedding by default)
- `OLLAMA_BASE_URL`: Ollama server URL (default: http://localhost:11434)
- `ZOTERO_ONNX_THREADS`: Thread count for the default model's ONNX Runtime (optional).
Where zotero-mcp may run on only some CPUs (a container's cpuset, a Slurm job, taskset),
set it to that number of CPUs to stop the `pthread_setaffinity_np failed` errors
- `ZOTERO_DB_PATH`: Custom `zotero.sqlite` path (optional). When unset, the
database is located automatically: a data directory configured in Zotero's
preferences (read from the profile's `prefs.js`) is tried first, then the
default `~/Zotero` location.
**Read backend:**
In local mode (`ZOTERO_LOCAL=true`) read tools answer straight from `zotero.sqlite`
instead of paging the Zotero API. Measured on a 44,105-item library:
| operation | SQLite | API |
|---|---|---|
| one item | 0.4 ms | 43.5 ms |
| children of 25 items | 1.8 ms | 2,476 ms |
| all tags | 110 ms | 103.9 s |
Anything SQLite cannot express (a wildcard tag filter, a boolean `itemType`
expression) is answered through the API for that call, so the results are never
narrower than the API's. Writes always go through Zotero.
- `ZOTERO_BACKEND=api`: read through the Zotero API even in local mode, as before
0.12.1. `ZOTERO_BACKEND=sqlite` forces SQLite; `ZOTERO_SEARCH_BACKEND` is
accepted as an older name for the same setting. Outside local mode the API is
always used.
- `ZOTERO_STRICT_SQLITE=1`: a developer check. A read that would reach the Zotero
API (a GET on `/users/...` or `/groups/...`, any Better BibTeX request, a query
SQLite declines, or no readable `zotero.sqlite`) fails with an error naming the
code that made it, instead of falling back. Writes, the reads a write makes
through its own client, and citation rendering are still allowed. Off unless set.
- `ZOTERO_MCP_DB_SNAPSHOT_MIN_INTERVAL`: Zotero keeps recent changes in a WAL file
next to `zotero.sqlite`, so reads use a private copy of the database plus that
file. The copy is refreshed when Zotero writes, at most once per this many
seconds (default `5`). The first read after zotero-mcp itself writes always
takes a fresh copy, so it sees that write, and the limit then applies again.
`ZOTERO_MCP_DB_SNAPSHOT=0` reads the database in place instead, which never
copies but misses changes until Zotero checkpoints.
**Global search across libraries:**
With the SQLite backend (the default in local mode), `zotero_search_items`, `zotero_advanced_search`
and `zotero_semantic_search` accept `search_all_libraries=True` (`--all-libraries`
on the CLI). One query then covers your personal library and every group library
at once, and each result is labelled with the library it came from:
```
**Library:** AI in entrepreneurship (groupID=6015547)
```
This is deliberately limited to the SQLite backend. The Zotero API can
only search one library per request, so without direct SQL the best anyone could
do is replay a single-library search against each library in turn — a different
and far slower operation. Rather than emulate global search badly, the tools
refuse and say so.
Two limits follow from how Zotero stores things. **Collections are per-library**
(`collections.libraryID` is NOT NULL), so `collection_key` and `collection`
conditions cannot be combined with a global search. **Tags are not** — Zotero
keeps one database-wide `tags` table shared by every library — so tag filters and
`tag` conditions work globally and are the recommended way to slice a global
search.
Duplicates across libraries are returned as-is: the same paper filed in two
libraries is two items, and collapsing them would hide where each copy lives.
**Tool surface:**
- `ZOTERO_MCP_TOOLSETS`: Which optional tool groups to expose. Every tool the
server registers is sent to the model on *every* request, so the tool list is
a fixed cost on your context window. Groups that need an external service,
serve maintenance rather than research, or apply only to some users are off
by default. See [Tool groups](tools.md#tool-groups).
**Item schema:**
- `ZOTERO_MCP_SCHEMA_REFRESH=0`: Disable the weekly background refresh of
Zotero's item-type schema from `api.zotero.org`. The schema is what routes a
generic `title=` update to the field a type actually stores it under (a
statute's `nameOfAct`, a case's `caseName`). A copy ships with the package, so
disabling the refresh only means new item types added by Zotero after this
release won't be picked up until you upgrade. `zotero-mcp schema-refresh`
still refreshes on demand.
- `ZOTERO_MCP_SCHEMA_CACHE`: Custom path for the refreshed schema cache
(default: `~/.cache/zotero-mcp/schema.json`).
## HTTP authentication and network access
These settings apply to `serve --transport streamable-http` and `sse`; `stdio`
is not affected. With `ZOTERO_MCP_AUTH_TOKEN` set, every HTTP request must carry
`Authorization: Bearer ` or gets `401`. The token is a shared secret
(compared in constant time, never logged) that gives the holder every enabled
tool, writes included; it is separate from the Zotero API key.
Generate one and give the same value to the server and each client:
```bash
export ZOTERO_MCP_AUTH_TOKEN="$(python -c 'import secrets; print(secrets.token_urlsafe(32))')"
zotero-mcp serve --transport streamable-http --host 127.0.0.1 --port 8000
```
(PowerShell: `$env:ZOTERO_MCP_AUTH_TOKEN = python -c "import secrets; print(secrets.token_urlsafe(32))"`.)
To keep it, put it in `client_env` in `~/.config/zotero-mcp/config.json`; the
process environment and `.env` win over the config file, and re-running
`zotero-mcp setup` keeps it. There is deliberately no `--token` flag, which
would show the secret in the process list. An empty or malformed value (spaces,
`null`, a number) stops the server at startup rather than being used.
| Bind | No token | Token set |
|---|---|---|
| Loopback (`localhost`, `127.0.0.1`, `::1`) | Starts, with a warning; local clients unchanged | Bearer required |
| Anything else (`0.0.0.0`, a LAN address) | Refuses to start unless `--allow-unauthenticated` | Bearer required |
On a loopback bind the server also checks the `Host` and `Origin` headers, so a
web page cannot reach it through DNS rebinding; behind a tunnel or reverse proxy,
see [Troubleshooting](troubleshooting.md). A tunnel can expose even a loopback
server, so set a token before opening one. An auth provider configured through
FastMCP's own settings is kept when no token is set.
Use HTTPS outside the local machine (the token is not encryption), never put the
token in a URL, and note that an MCP session ID or SSE `session_id` is not a
credential. Client examples: [authenticated HTTP clients](getting-started.md#authenticated-http-clients);
ChatGPT: [Secure MCP Tunnel](getting-started.md#integrating-with-openais-chatgpt).
## Text extraction settings
PDFs are parsed with [pdf-inspector](https://github.com/firecrawl/pdf-inspector), which produces Markdown with the document's heading structure intact. These keys live under `semantic_search.extraction` in `~/.config/zotero-mcp/config.json`:
```json
{
"semantic_search": {
"extraction": {
"pdf_max_pages": 50,
"fulltext_display_max_pages": 10,
"attachment_priority": ["markdown", "pdf", "html", "other"]
}
}
}
```
| Key | Default | What it does |
|---|---|---|
| `pdf_max_pages` | `50` | Pages extracted per PDF when indexing. Raising it does not widen what search sees on its own — that is bounded by the embedding model's token limit or `chunking.max_chunks_per_item`. |
| `fulltext_display_max_pages` | `10` | Pages returned by `zotero_get_item_fulltext`. Separate from the above because reading a paper is bounded by your assistant's context, not by recall. |
| `attachment_priority` | `["pdf", "html", "other"]` | Order in which attachment kinds are tried when an item has several readable files. |
**`attachment_priority`** exists for the case where you have converted a paper to clean Markdown yourself and attached it next to the original PDF. By default the PDF still wins; listing `"markdown"` first makes your converted copy the one that gets read and indexed. Valid entries are `pdf`, `html`, `markdown`, `text` and `other`. `other` is a catch-all matching every kind not named elsewhere in the list, so the default sweeps Markdown and plain text into one bucket where the larger file wins. Omitting `other` means anything unlisted is never chosen.
Changing this setting marks affected items for re-extraction, so a following `zotero-mcp update-db` refreshes text that came from a now-deprioritized attachment rather than leaving stale embeddings behind.
To read one specific attachment regardless of priority, pass that attachment's own key to `zotero_get_item_fulltext` (find it with `zotero_get_item_children`) — an attachment key bypasses the priority order and reads exactly that file.
Extracted text is reliable for prose and unreliable for math and tables. `zotero_read_pdf_pages` flags the pages where that happens and can return those pages as images (`format='image'`).
## Passage chunking
By default each item is indexed as one vector: title, authors, abstract and any full text joined and cut at the embedding model's input limit. The default model, all-MiniLM-L6-v2, reads 256 tokens (about 1,000 characters), so with `update-db --fulltext` the body of a PDF is extracted but never embedded and only the start of each item is searchable. `zotero-mcp update-db --fulltext` and `zotero-mcp db-status` say so when this applies.
Passage chunking also indexes each item as several overlapping passages, in a separate ChromaDB collection (not a Zotero collection), so search can match anywhere in a paper and return the matching passage with its page. The one-vector article record stays: articles suit finding works on a topic, and passages suit finding where something is done or stated. It is off by default. These keys live under `semantic_search.chunking`:
```json
{
"semantic_search": {
"chunking": {
"enabled": true,
"chunk_size": 1500,
"overlap": 200,
"max_chunks_per_item": 100
}
}
}
```
| Key | Default | What it does |
|---|---|---|
| `enabled` | `false` | Index passages as well as one vector per item. Semantic search uses passages by default when this is on and articles when it is off. |
| `chunk_size` | `1500` | Target passage length in characters. |
| `overlap` | `200` | Characters shared between neighbouring passages. |
| `max_chunks_per_item` | `20` | Passages kept per item. Text past the last passage is not indexed. |
After turning it on, run `zotero-mcp update-db --fulltext` once in local mode (`ZOTERO_LOCAL=true`). With the web API, where `--fulltext` is not available, run `zotero-mcp update-db`, which uses the text Zotero has already extracted. It adds the passages and keeps the article vectors you already have, with no `--force-rebuild` and no re-embedding of articles. It works the same on the realtime and Batch API paths.
An update writes every article record before any passage, so article search covers a long run's items early. A changed item has no passages from the moment its new article record is written until its new passages are, and passage search misses it meanwhile; on the Batch API path, where passage files can land days after the article files, that can last until the whole run is imported. A run stopped in between leaves the rest to the next update.
`zotero_semantic_search` takes `level="articles"` or `level="passages"` to choose per search, and `zotero-cli search --mode semantic` takes `--level`.
While passages are being built, a default search covers only the items that have them so far. If passages don't exist at all yet, it searches articles instead. When the other level holds more items, the results say so, with the counts for the whole index, for example `Searched passages (12,000 items in the index). The article level has 48,750 items, so level="articles" may find more.`
Passages and articles live in two ChromaDB collections in the same index directory, `zotero_library_passages` and `zotero_library`, so an article search never loads passage vectors into memory. With chunking off, an item that changes loses its passages, and they are added back when chunking is next on.
An index built with chunking on by an earlier version holds its passages in `zotero_library`, the article-level ChromaDB collection: passages only, or passages beside article records left from before chunking was turned on (a mixed index). Search keeps working that way until you migrate, and the status commands (`zotero-mcp db-status`, `zotero-cli db status`, the `zotero_get_search_database_status` tool) say so, with the steps and an estimate of what the last one costs. To migrate:
1. Stop any running server, and upgrade any other copy of zotero-mcp using the same index; an older version would go back to writing passages in `zotero_library`.
2. `zotero-mcp migrate-index --dry-run` reports what would change.
3. `zotero-mcp migrate-index` renames the collection to `zotero_library_passages`, keeping every vector, and moves any article records into a new `zotero_library`. It embeds nothing and takes seconds however large the index is. The server can start again after it.
4. `zotero-mcp update-db --fulltext`, with the options you usually use, embeds one article vector for each item that has passages but no article record. In local mode, without `--fulltext`, items indexed with their full text wait for it and get no article vector; status leaves the flag out only when no such item was indexed with full text. With the web API, `--fulltext` is not available: run `zotero-mcp update-db`, which uses the text Zotero has already extracted (unless `include_fulltext` is `false`), and status gives it that way. This is the only step that embeds anything, and with a paid embedding API it is billed: status gives the number of items and an estimated token total, from the length of each item's indexed text, cut to the model's input limit. An interrupted run carries on where it stopped.
A passage longer than the model can read would lose its tail, so `chunk_size` is lowered to fit: about 85% of the model's token limit, at 4 characters per token (3 for OpenAI). For the default model that is roughly 870 characters per passage whatever `chunk_size` says. Models with a larger limit keep your `chunk_size`, and the change is logged once at info level.
With the default model, 20 passages cover about 13,000 characters, a few pages. To index whole papers, raise `max_chunks_per_item`: 100 covers roughly 20 pages, and longer papers need more. Each passage is one vector, so the database grows with it.
## Semantic search memory
ChromaDB loads the whole vector index into memory the first time a search runs, and keeps it there until the process holding it exits. Each vector takes its dimension × 4 bytes: a million passages with OpenAI's `text-embedding-3-small` (1,536 dimensions) need about 6 GB. To get that memory back, set `idle_unload_minutes`: the MCP server then runs ChromaDB in a separate worker process. The worker starts at the first semantic search and exits after a set time with no semantic calls, which returns that memory to the system. The next search starts a new worker and loads the index again, which takes a few seconds for a small index and can take half a minute for a large one.
Passages and articles load separately, and the passage ChromaDB collection is much the larger. Once a worker has loaded passages, only passage activity keeps it running: a passage search, or an update that writes or deletes passages. Article searches alone let it exit after the wait, and the next one starts a new worker that loads articles only. On an index whose passages are still in the article collection (not yet migrated with `migrate-index`), every call keeps the worker. The worker never exits while an index update runs in the server.
The article reload is quick: on an Apple M1 Max, a new worker answered its first article search in under a second for 50,000 articles, while the first passage search over 1.2 million passages took 6 to 7 s and about 15 GB. When the first passage search in a new worker takes 5 s or more, its result says so. To set the wait:
```json
{
"semantic_search": {
"idle_unload_minutes": 10
}
}
```
| Setting | Default | What it does |
|---|---|---|
| `idle_unload_minutes` | `0` (off) | Minutes without a semantic search or index update before the worker exits. Once the worker has loaded passages from their own ChromaDB collection, only passage searches and updates that write or delete passages count. It never exits during an index update in the server. `0` runs ChromaDB inside the server, where the index stays loaded until the server exits. |
The status tool (`zotero_get_search_database_status`) reads its counts from the database file and never loads the index. Command-line tools such as `update-db` run ChromaDB in their own process, which frees the index when the command finishes.
## Command-line options
```bash
# Run the server directly
zotero-mcp serve
# Specify transport method
zotero-mcp serve --transport stdio|streamable-http|sse
# HTTP network listener (set ZOTERO_MCP_AUTH_TOKEN first)
zotero-mcp serve --transport streamable-http --host 0.0.0.0 --port 8000
# Explicitly allow a network listener without a token (see access controls above)
zotero-mcp serve --transport streamable-http --host 0.0.0.0 --allow-unauthenticated
# Setup and configuration
zotero-mcp setup --help # Get help on setup options
zotero-mcp setup --semantic-config-only # Configure only semantic search
zotero-mcp setup-info # Show installation path and config info for MCP clients
zotero-mcp authorize-local # Grant local writes (Zotero 10+)
zotero-mcp install-skill # Install the zotero-cli agent skill
# Updates and maintenance
zotero-mcp update # Update to latest version
zotero-mcp update --check-only # Check for updates without installing
zotero-mcp update --force # Force update even if up to date
# Semantic search database management
zotero-mcp update-db # Update semantic search database (fast, metadata-only)
zotero-mcp update-db --openai-batch # Submit OpenAI embeddings through Batch API
zotero-mcp update-db --no-openai-batch # Force realtime OpenAI embeddings for this run
zotero-mcp openai-batch-status # Check latest OpenAI embedding batch status
zotero-mcp openai-batch-import # Import completed OpenAI batch embeddings
zotero-mcp update-db --fulltext # Update with full-text extraction (comprehensive but slower)
zotero-mcp update-db --force-rebuild # Force complete database rebuild
zotero-mcp update-db --fulltext --force-rebuild # Rebuild with full-text extraction
zotero-mcp update-db --fulltext --db-path "your_path_to/zotero.sqlite" # Customize your zotero database path
zotero-mcp db-status # Show database status and info
# General
zotero-mcp version # Show current version
```