zotero-mcp-claude-code
CLAUDE.md41 starsChanged 6 months agoMITView on GitHub
Zotero MCP is a Zotero plugin that provides Model Context Protocol (MCP) integration, allowing AI clients (Claude Code, Claude Desktop, Cherry Studio, Cursor IDE) to interact with a user's local Zotero library. The plugin includes an integrated MCP server that uses Streamable HTTP protocol. Architecture: AI Client ↔ Streamable HTTP ↔ Zotero Plugin (integrated MCP server) Fork: This fork adds Claude Code compatibility. Contributed by lricher7329. To use with Claude Code, add this to your MCP configuration (~/.claude.json or .mcp.json):
- Installs packages
In this repositoryOne other file it gives its agents.
- zotero-mcp-plugin/CLAUDE.mdCLAUDE.md
The file
We split this CLAUDE.md into the rules it gives an agent
2 rules. About 0 are common, 1 is distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 30
All commands run from zotero-mcp-plugin/ directory:
- Distinctive: line 107
All source code comments and error messages are in English
≈ “Common” is an estimate: at least 1 in 5 of the 12,729 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Project Overview
Zotero MCP is a Zotero plugin that provides Model Context Protocol (MCP) integration, allowing AI clients (Claude Code, Claude Desktop, Cherry Studio, Cursor IDE) to interact with a user's local Zotero library. The plugin includes an integrated MCP server that uses Streamable HTTP protocol.
Architecture: AI Client ↔ Streamable HTTP ↔ Zotero Plugin (integrated MCP server)
Fork: This fork adds Claude Code compatibility. Contributed by lricher7329.
Claude Code Configuration
To use with Claude Code, add this to your MCP configuration (~/.claude.json or .mcp.json):
{
"mcpServers": {
"zotero-mcp": {
"type": "http",
"url": "http://127.0.0.1:23120/mcp"
}
}
}Build Commands
All commands run from zotero-mcp-plugin/ directory:
npm install # Install dependencies
npm run build # Build plugin and run TypeScript type checking
npm run start # Development mode with auto-reload
npm run lint:check # Check formatting and linting
npm run lint:fix # Fix formatting and linting issues
npm run test # Run tests via zotero-plugin-scaffoldCode Architecture
Entry Points
- src/index.ts - Plugin bootstrap
- src/addon.ts - Main Addon class, exposes API methods
- src/hooks.ts - Lifecycle hooks (startup, shutdown, prefs events), starts HTTP server
Core Modules (src/modules/)
- httpServer.ts - HTTP server using Mozilla nsIServerSocket, routes requests to MCP server or REST endpoints
- streamableMCPServer.ts - MCP protocol implementation, handles JSON-RPC 2.0 requests, defines all MCP tools
- searchEngine.ts - Advanced search with boolean operators, relevance scoring, field queries
- apiHandlers.ts - HTTP request handlers for search, items, collections, fulltext
Content Extraction
- unifiedContentExtractor.ts - Unified content extraction from PDFs, notes, attachments
- smartAnnotationExtractor.ts - Annotation extraction with relevance scoring
- pdfService.ts / pdfProcessor.ts - PDF text extraction
Configuration
- serverPreferences.ts - Server port and enabled state preferences
- mcpSettingsService.ts - MCP-specific settings (content modes, token limits)
- clientConfigGenerator.ts - Generates AI client configuration JSON
Utilities
- utils/prefs.ts - Preference getters/setters
- utils/ztoolkit.ts - ZToolkit factory for Zotero plugin utilities
MCP Tools Provided
The plugin exposes these tools via MCP protocol:
search_library- Library search with advanced filteringsearch_annotations- Search annotations/highlightsget_item_details- Get item metadataget_annotations- Get annotations for itemsget_content- Unified content extraction (PDF, notes, abstract)get_collections/search_collections/get_collection_details/get_collection_items/get_subcollections- Collection operationssearch_fulltext- Full-text search with contextget_item_abstract- Get item abstractimport_attachment_url- Import a file attachment from a URL. Accepts an optionalcontentTypeoverride; when omitted, the handler infersapplication/pdffor.pdf//pdf/URLs andapplication/epub+zipfor.epubURLs (seeinferContentTypeFromURLin writeHandlers.ts) so Zotero takes the binary-download path instead of the fragile SingleFile snapshot path. PMC/pdf/URLs are gated by a proof-of-work cookie (cloudpmc-viewer-pow) that server-side fetchers can't satisfy, so pmcURLResolver.ts reroutes them through the EuropePMC mirror (https://europepmc.org/articles/PMC###?pdf=render), which serves the same OA content without the gate. Non-OA articles fall through to the original URL. SupportsdryRun: trueto preview the action without writing, andifExists: "add" | "skip" | "replace"to dedup against existing same-content-type attachments on the parent (default"add"preserves backward-compat;"replace"requires thedeletewrite scope).
Key Technical Details
- Target: Zotero 7, 8, and 9 (manifest
strict_min_version: "6.999",strict_max_version: "9.*"); Firefox 115 (ESR) runtime - Protocol: MCP 2024-11-05 and 2025-03-26 with Streamable HTTP transport
- Default Port: 23120
- Endpoints:
/mcp(MCP requests),/ping(health check),/mcp/status,/capabilities - HTTP Methods: GET, POST, DELETE (for session termination)
Claude Code Compatibility Changes
This fork includes the following changes for Claude Code compatibility:
- Request body reading - Properly reads full POST body based on Content-Length (up to 64KB)
- Accept header validation - Validates client accepts application/json per MCP spec
- DELETE method support - Session termination per MCP spec
- Notification handling - Returns HTTP 202 for JSON-RPC notifications (requests without id)
- Batch request support - Handles JSON arrays of requests
- Protocol version support - Supports both 2024-11-05 and 2025-03-26 versions
Development Notes
- Uses
zotero-plugin-toolkitfor plugin utilities - Uses
zotero-plugin-scaffoldfor build tooling - HTTP server uses Mozilla's
nsIServerSocketcomponent - Preferences stored under
extensions.zotero.zotero-mcp-plugin.* - Logging uses
ztoolkit.log()with===MCP===prefix for easy filtering - All source code comments and error messages are in English
- Chinese locale files (
addon/locale/zh-CN/) are for UI translations only - Chinese stop word lists in NLP/annotation code are functional data and should remain
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

