mcp-local-reference
# mcp-local-reference
An MCP server that gives Claude (or any MCP client) read access to your **Zotero** library. Search references, extract PDF text, crop figures, and format Harvard (Cite Them Right) citations — all from within your writing workflow.
## Features
| Tool | Description |
|------|-------------|
| `search_references` | Keyword or semantic search across your Zotero library |
| `get_reference` | Full metadata for a single reference |
| `list_collections` | Browse Zotero collections as a tree |
| `get_collection_items` | List references in a collection |
| `get_pdf_text` | Extract text from a reference's PDF |
| `list_figures` | Detect figures/images in a PDF |
| `crop_figure` | Crop a region from a PDF page and return as PNG |
| `format_citation` | Harvard Cite Them Right formatted citation |
| `index_library` | Build a vector index for semantic search |
## Prerequisites
- **Zotero** installed with a local library (the server reads `zotero.sqlite` directly)
- **Python 3.11+**
- **uv** (recommended) or pip
## Installation
```bash
# Clone the repository
git clone https://github.com/YOUR_USERNAME/mcp-local-reference.git
cd mcp-local-reference
# Install with uv
uv pip install -e .
# Or with pip
pip install -e .
```
## Claude Desktop Configuration
Add the server to your Claude Desktop config file:
**macOS:** `~/Library/Application Support/Claude/claude_desktop_config.json`
**Windows:** `%APPDATA%\Claude\claude_desktop_config.json`
### Using uv (recommended)
```json
{
"mcpServers": {
"local-reference": {
"command": "uv",
"args": ["run", "--directory", "/path/to/mcp-local-reference", "mcp-local-reference"]
}
}
}
```
### Using pip
```json
{
"mcpServers": {
"local-reference": {
"command": "mcp-local-reference"
}
}
}
```
### Using Docker
```json
{
"mcpServers": {
"local-reference": {
"command": "docker",
"args": [
"run", "-i", "--rm",
"-v", "~/Zotero:/zotero",
"-v", "mcp-local-ref-data:/data",
"mcp-local-reference"
]
}
}
}
```
## Configuration
All settings are via environment variables:
| Variable | Default | Description |
|----------|---------|-------------|
| `ZOTERO_DATA_DIR` | `~/Zotero` | Path to your Zotero data directory |
| `MCP_DATA_DIR` | `~/.mcp-local-reference` | Path for the vector index and other data |
| `FIGURE_DPI` | `300` | Resolution for cropped figures |
| `MIN_FIGURE_PIXELS` | `10000` | Minimum pixel area to count as a figure |
## Usage
Once connected to Claude Desktop, you can ask Claude things like:
- *"Search my Zotero library for papers about transformer architectures"*
- *"Get the abstract of reference TESTKEY1"*
- *"Extract the text from pages 5-10 of this paper"*
- *"List the figures in this PDF and crop figure 3"*
- *"Format a Harvard citation for this reference"*
- *"Index my library for semantic search"*
### Semantic search
Run `index_library` once to build a vector index. After that, `search_references` uses semantic similarity instead of keyword matching — so queries like *"papers about attention mechanisms in neural networks"* find relevant results even if those exact words aren't in the title.
## Development
```bash
# Install with dev dependencies
uv pip install -e ".[dev]"
# Run tests
pytest -v
# Lint
ruff check src/ tests/
# Format
ruff format src/ tests/
```
## License
MIT
TDQS
Scored across 28 tools
Most tools have clearly distinct purposes, and the parallel Zotero-vs-local PDF triples (get_pdf_text/read_local_pdf, list_figures/list_local_figures, crop_figure/crop_local_figure) are explicitly distinguished in their descriptions. Remaining ambiguities are mild: search_references vs search_passages (metadata vs full-text) and index_library vs index_pdfs require careful reading, though the descriptions resolve them.
Nearly all tools follow a verb_noun snake_case pattern (list_collections, create_collection, add_items_to_collection, delete_item) and related operations mirror each other cleanly, e.g. apply_tags/remove_tags and add_items_to_collection/remove_items_from_collection. Minor deviations exist where synonymous verbs are used for equivalent actions (get_pdf_text vs read_local_pdf) and the suggest_* family mixes context-gathering with action verbs.
At 28 tools this sits above the comfortable range and feels heavy, especially since six of them are near-duplicate PDF tools split only by storage location and three add_reference_by_* variants could arguably collapse into one resolver. The domain is genuinely broad (library search, collections, tags, PDFs, RAG, imports), so most tools do earn a place, but the surface is borderline bloated.
Coverage is strong: read/search items, three import paths, delete, full collection CRUD with membership management, tag add/remove with dry-run, citation formatting, PDF text/figure extraction, and passage-level RAG search. Notable gaps remain — there is no tool to update an item's metadata, add a manual (non-DOI/arXiv/ISBN) reference, manage notes/annotations, or read/manage attachments beyond PDF text.