mcp-lightrag
Enables AI assistants to interact with LightRAG knowledge graphs, supporting smart upsert for Obsidian vaults, semantic queries, and document/graph management.
README
LightRAG MCP Server
A Model Context Protocol (MCP) server that enables AI assistants to interact with LightRAG knowledge graphs. Query documents, manage entities, and build semantic relationships through a standardized tool interface. Optimized for Obsidian Vaults: The built-in smart upsert and document tracking capabilities make it perfect for agents that need to sync and reason over evolving Obsidian knowledge bases.
Features
- Smart Updates: Intelligent
upsertlogic that detects changes in documents, skipping redundant uploads and re-indexing only when necessary - Knowledge Graph Queries: Perform semantic, keyword, or hybrid searches across your indexed documents
- Document Ingestion: Add text, files, or entire directories to your knowledge base
- Entity Management: Create, update, merge, and delete entities in the graph
- Relationship Handling: Define and modify connections between entities
- Robust Connectivity: Automatic retry with exponential backoff for reliable API communication
- Flexible Configuration: Set options via environment variables or command-line arguments
Installation
# Clone the repository
git clone https://github.com/enriquecatala/mcp-lightrag.git
cd mcp-lightrag
# Install dependencies
uv sync
Quick Start
-
Start your LightRAG server (must be running before the MCP server)
-
Launch the MCP server:
uv run mcp-lightrag --host localhost --port 9621 -
Connect your AI assistant via the MCP protocol (stdio transport)
Configuration
| Option | Environment Variable | Default | Description |
|---|---|---|---|
--host |
LIGHTRAG_HOST |
localhost |
LightRAG API host |
--port |
LIGHTRAG_PORT |
9621 |
LightRAG API port |
--api-key |
LIGHTRAG_API_KEY |
(none) | Optional API key |
--log-level |
— | INFO |
Logging verbosity |
Setting up as MCP Server
To integrate this server with an MCP client (such as Claude Desktop), add the following configuration to your mcp-server-config.json key in your settings file. This configuration uses uv to run the server from the source directory.
{
"mcpServers": {
"mcp-lightrag": {
"command": "uv",
"args": [
"--directory",
"/absolute/path/to/mcp-lightrag",
"run",
"mcp-lightrag",
"--host",
"localhost",
"--port",
"9621"
],
"env": {
"LIGHTRAG_API_KEY": "optional_api_key"
}
}
}
}
Note: Replace
/absolute/path/to/mcp-lightragwith the actual full path to where you cloned this repository.
Smart Document Handling
This server distinguishes itself with an intelligent Upsert Mechanism ideal for keeping in sync with Obsidian Vaults or other local knowledge bases:
- New File → Uploads and indexes immediately.
- Unchanged File → Detects identical content and skips (saving time and resources).
- Modified File → Automatically removes the old version and indexes the new one. This allows agents to efficiently "watch" a folder and keep the RAG knowledge graph up-to-date without redundant processing.
Available Tools
Search & Query
query_knowledge_graph— Execute specialized RAG queries (mix, semantic, keyword, etc.) to answer questions based on your data.
Document Management
ingest_text— Index raw text content directly into the graph.ingest_file— Index a specific local file (absolute path required).upload_and_index— Upload a file to the server for indexing (handles transfer).ingest_batch— Recursively scan and index directories with pattern filtering.upsert_document— Smart document upload: creates new, skips identical, or updates modified documents.find_document— Search for a document by filename to check status and details.get_latest_documents— Retrieve a paginated list of recently updated documents.list_all_docs— List all documents in the system (warning: can be slow for large datasets).check_indexing_status— Check if the background indexing pipeline is idle or busy.
Graph Operations
create_entities— Manually insert new entities.modify_entities— Update attributes of existing entities.remove_entities— Delete specific entities.unify_entities— Merge multiple entities into a single canonical entity.connect_entities— Create or update relationships between entities.purge_by_document— Delete a document and remove all its associated data from the graph.get_graph_metadata— Explore the graph schema (available node labels and relationship types).
System
verify_server_health— Check if the LightRAG API is reachable and healthy.
Development
# Install dev dependencies
uv sync --all-extras
# Run tests
uv run python -m pytest
# Lint code
uv run ruff check src/
Publishing
To publish a new version to PyPI:
- Update the version in
pyproject.toml. - Build the package:
uv run python -m build - Upload to PyPI (requires PyPI API token):
uv run twine upload dist/*
Updating the Client
If the LightRAG API evolves, you can regenerate the client using openapi-python-client. Ensure your LightRAG server is running (e.g., at http://localhost:9621), then run:
uv tool run openapi-python-client generate \
--url http://localhost:9621/openapi.json \
--output-path src/mcp_lightrag/client/light_rag_server_api_client \
--meta none \
--overwrite
This will update the client code in src/mcp_lightrag/client/light_rag_server_api_client based on the latest OpenAPI specification.
License
MIT
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。