Skip to main content

Local Research Library MCP

PyPI version License: MIT Python 3.11+

让 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 .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:

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

local_research_library_mcp-0.2.0.tar.gz (30.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

local_research_library_mcp-0.2.0-py3-none-any.whl (42.6 kB view details)

Uploaded Python 3

File details

Details for the file local_research_library_mcp-0.2.0.tar.gz.

File metadata

File hashes

Hashes for local_research_library_mcp-0.2.0.tar.gz
Algorithm Hash digest
SHA256 2e5a077c0c9ba11b88eaaf8ff960ba317c756734d55daed44a371103e67f9a0d
MD5 c7b506d74195693bf7108fd1ace6eb11
BLAKE2b-256 5c25bdd6272c8c06af69b273307bc5bb351edfcd38a10d2a64e75a63778ccc54

See more details on using hashes here.

File details

Details for the file local_research_library_mcp-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for local_research_library_mcp-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e4f8416f4459f2cd1bee5faafa83a61c182ae3e7872f2690d24cf9eb98af2a17
MD5 63c20c7c77c1af34e0c2dfed030984c6
BLAKE2b-256 7cae43b4b3e5601644895ef263b1b6c5b1e22c8dcee660bc5d97261f7470a4f6

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page