LightRAG MCP Server
MCP server for integrating LightRAG with AI tools. Provides a unified interface for interacting with LightRAG API through the MCP protocol.
Description
LightRAG MCP Server is a bridge between LightRAG API and MCP-compatible clients. It allows using LightRAG (Retrieval-Augmented Generation) capabilities in various AI tools that support the MCP protocol.
Key Features
- Information Retrieval: Execute semantic and keyword queries to documents
- Document Management: Upload, index, and track document status
- Knowledge Graph Operations: Manage entities and relationships in the knowledge graph
- Monitoring: Check LightRAG API status and document processing
Installation
This server is designed to be used as an MCP server and should be installed in a virtual environment using uv, not as a system-wide package.
Development Installation
# Create a virtual environment
uv venv --python 3.11
# Install the package in development mode
uv pip install -e .
Requirements
- Python 3.11+
- Running LightRAG API server
Usage
LightRAG MCP server supports two MCP transport modes:
- stdio (default): run through an MCP client configuration file (
mcp-config.json) - streamable-http: run as a standalone HTTP server for remote MCP clients
Command Line Options
LightRAG API connection:
--host: LightRAG API host (default: localhost)--port: LightRAG API port (default: 9621)--api-key: LightRAG API key (optional)
MCP transport:
--mcp-transport: MCP transport (stdioorstreamable-http, default: stdio)--mcp-host: MCP HTTP host (default: 127.0.0.1)--mcp-port: MCP HTTP port (default: 8000)--mcp-streamable-http-path: Streamable HTTP endpoint path (default: /mcp)--mcp-stateless-http: Enable stateless Streamable HTTP mode (new session per request)--mcp-json-response: Return JSON responses instead of SSE for Streamable HTTP
Integration with LightRAG API
The MCP server requires a running LightRAG API server. Start it as follows:
# Create virtual environment
uv venv --python 3.11
# Install dependencies
uv pip install -r LightRAG/lightrag/api/requirements.txt
# Start LightRAG API
uv run LightRAG/lightrag/api/lightrag_server.py --host localhost --port 9621 --working-dir ./rag_storage --input-dir ./input --llm-binding openai --embedding-binding openai --log-level DEBUG
Setting up as MCP server (stdio)
To set up LightRAG MCP as an MCP server, add the following configuration to your MCP client configuration file (e.g., mcp-config.json):
Using uvenv (uvx):
{
"mcpServers": {
"lightrag-mcp": {
"command": "uvx",
"args": [
"lightrag_mcp",
"--host",
"localhost",
"--port",
"9621",
"--api-key",
"your_api_key"
]
}
}
}
Development
{
"mcpServers": {
"lightrag-mcp": {
"command": "uv",
"args": [
"--directory",
"/path/to/lightrag_mcp",
"run",
"src/lightrag_mcp/main.py",
"--host",
"localhost",
"--port",
"9621",
"--api-key",
"your_api_key"
]
}
}
}
Replace /path/to/lightrag_mcp with the actual path to your lightrag-mcp directory.
Running over Streamable HTTP (standalone server)
Use this when you need remote access or want to host the MCP server behind HTTP infrastructure:
uv run src/lightrag_mcp/main.py \
--mcp-transport streamable-http \
--mcp-host 0.0.0.0 \
--mcp-port 8000 \
--mcp-streamable-http-path /mcp \
--host localhost \
--port 9621 \
--api-key your_api_key
MCP clients should connect to: http://localhost:8000/mcp
Available MCP Tools
Document Queries
query_document: Execute a query to documents through LightRAG API
Document Management
insert_document: Add text directly to LightRAG storageupload_document: Upload document from file to the /input directoryinsert_file: Add document from file directly to storageinsert_batch: Add batch of documents from directoryscan_for_new_documents: Start scanning the /input directory for new documentsget_documents: Get list of all uploaded documentsget_pipeline_status: Get status of document processing in pipeline
Knowledge Graph Operations
get_graph_labels: Get labels (node and relationship types) from knowledge graphcreate_entities: Create multiple entities in knowledge graphedit_entities: Edit multiple existing entities in knowledge graphdelete_by_entities: Delete multiple entities from knowledge graph by namedelete_by_doc_ids: Delete all entities and relationships associated with multiple documentscreate_relations: Create multiple relationships between entities in knowledge graphedit_relations: Edit multiple relationships between entities in knowledge graphmerge_entities: Merge multiple entities into one with relationship migration
Monitoring
check_lightrag_health: Check LightRAG API status
Development
Installing development dependencies
uv pip install -e ".[dev]"
Running linters
ruff check src/
mypy src/
License
MIT
Metadata
Release files for lightrag-mcp 0.1.1
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 | |
|---|---|---|---|---|
| lightrag_mcp-0.1.1.tar.gz | 53.0 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| lightrag_mcp-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 153.0 kB
Release files / lightrag_mcp-0.1.1.tar.gz
| Download URL | lightrag_mcp-0.1.1.tar.gz |
|---|---|
| Size | 53.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1ab40dfefa15628a4567855bb103338b62bd75be83f8c6c3cfa70d416285249d
|
|
BLAKE2b-256 checksum How to use checksums |
26964a8a18ec648d7b9aa4f175bb53cd08799bc687d4c1f3bf8e9972b213042a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Feb 28, 2026.
Transparency logRelease files / lightrag_mcp-0.1.1-py3-none-any.whl
| Download URL | lightrag_mcp-0.1.1-py3-none-any.whl |
|---|---|
| Size | 100.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a6fad8bd2b938fa6081ca2925b604b3b021cf98f7845c282ed08139e6f8fabae
|
|
BLAKE2b-256 checksum How to use checksums |
1ca143b11af90c38ef811ea4b4ca6025cfbf5cdd15798352dbd5935dded87307
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Feb 28, 2026.
Transparency logSecurity for lightrag-mcp 0.1.1
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.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for lightrag_mcp-0.1.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Feb 28, 2026.
Transparency logA 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.