Local Research Library MCP
让 AI Agent 安全地访问你的本地科研资料库。
A Model Context Protocol (MCP) server that gives AI agents read-only access to your local research library. Search papers, fetch metadata, and find specific passages — all without leaving your machine.
Features
- 4 Tools:
list_collections,search_papers,get_paper,search_in_paper - 2 Resources:
research://library(overview),research://papers/{paper_id}(metadata) - 6 File Formats: PDF, Markdown, BibTeX, RIS, EndNote, XML
- Auto-Index: Detects new/changed files automatically (every 30s)
- Smart Scoring: Title > Keywords > Abstract > Author > Body relevance ranking
- SQLite + FTS5: Fast full-text search with graceful LIKE fallback
- Read-Only: Never modifies your files
- Path-Safe: Paper IDs validated, all reads stay inside library root
Installation
From PyPI
pip install local-research-library-mcp
From Source
git clone https://github.com/luhongyuan/local-research-library-mcp.git
cd local-research-library-mcp
pip install -e .
Quick Start
1. Configure MCP Client
Add to your MCP client configuration (e.g., Cursor, Claude Desktop, Trae):
{
"mcpServers": {
"research-library": {
"command": "local-research-library-mcp",
"args": ["serve"],
"env": {
"RESEARCH_LIBRARY_ROOT": "/path/to/your/papers",
"RESEARCH_LIBRARY_DB": "/path/to/your/papers/.index/library.db"
}
}
}
}
Or if installed from source:
{
"mcpServers": {
"research-library": {
"command": "python",
"args": ["-m", "local_research_library_mcp", "serve"],
"env": {
"RESEARCH_LIBRARY_ROOT": "/path/to/your/papers",
"RESEARCH_LIBRARY_DB": "/path/to/your/papers/.index/library.db"
}
}
}
}
2. Start Using
The server auto-indexes on startup and checks for changes every 30 seconds. Just ask your AI agent:
- "Find papers about graph neural networks"
- "What collections do I have?"
- "Search for 'attention mechanism' in paper X"
Configuration
| Environment Variable | Default | Description |
|---|---|---|
RESEARCH_LIBRARY_ROOT |
./research-library |
Root directory of your paper library |
RESEARCH_LIBRARY_DB |
./research-library/.index/library.db |
SQLite index location |
RESEARCH_LIBRARY_LOG_LEVEL |
INFO |
Log level (DEBUG, INFO, WARNING, ERROR) |
CLI Commands
# Start the MCP server (default)
local-research-library-mcp serve
# Manually index the library
local-research-library-mcp index
# Force re-index all files (after parser upgrades)
local-research-library-mcp index --force
# Show library status
local-research-library-mcp status
local-research-library-mcp status --json
Search Scoring
When you search, results are ranked by relevance:
| Match Location | Score |
|---|---|
| Title (exact) | +100 |
| Title (contains) | +80 |
| Title (token) | +50 |
| Keywords | +35~45 |
| Abstract | +30~40 |
| Author | +20~30 |
| Collection name | +20 |
| Body (FTS) | +10~40 |
Supported Formats
| Format | Extensions | Extractable Metadata |
|---|---|---|
.pdf |
title, authors, year, keywords, abstract | |
| Markdown | .md, .markdown |
title (first heading), body |
| BibTeX | .bib |
title, authors, year, DOI, journal, abstract |
| RIS | .ris |
title, authors, year, journal, DOI, abstract |
| EndNote | .enw |
title, authors, year, journal, DOI, abstract |
| XML | .xml |
title, authors, year, DOI, abstract |
Architecture
MCP Client (Agent)
│ stdio
▼
MCP Server
│
├── Service Layer (search, fetch, collections)
│ │
│ ▼
├── Storage (SQLite + FTS5)
│ │
│ ▼
└── Indexer / Parsers
│
▼
Local File System
Development
# Clone and install dev dependencies
git clone https://github.com/luhongyuan/local-research-library-mcp.git
cd local-research-library-mcp
pip install -e ".[dev]"
# Run tests
pytest
# Run with coverage
pytest --cov=local_research_library_mcp
Publishing to PyPI
# Build
python -m build
# Upload
python -m twine upload dist/*
License
MIT License - see LICENSE for details.
Contributing
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
Acknowledgments
Built with:
Metadata
Release files for local-research-library-mcp 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| local_research_library_mcp-0.2.0.tar.gz | 30.2 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| local_research_library_mcp-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 72.8 kB
Release files / local_research_library_mcp-0.2.0.tar.gz
| Download URL | local_research_library_mcp-0.2.0.tar.gz |
|---|---|
| Size | 30.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2e5a077c0c9ba11b88eaaf8ff960ba317c756734d55daed44a371103e67f9a0d
|
|
BLAKE2b-256 checksum How to use checksums |
5c25bdd6272c8c06af69b273307bc5bb351edfcd38a10d2a64e75a63778ccc54
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.7
|
Release files / local_research_library_mcp-0.2.0-py3-none-any.whl
| Download URL | local_research_library_mcp-0.2.0-py3-none-any.whl |
|---|---|
| Size | 42.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e4f8416f4459f2cd1bee5faafa83a61c182ae3e7872f2690d24cf9eb98af2a17
|
|
BLAKE2b-256 checksum How to use checksums |
7cae43b4b3e5601644895ef263b1b6c5b1e22c8dcee660bc5d97261f7470a4f6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.7
|
Security for local-research-library-mcp 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.