loading…
Search for a command to run...
loading…
Enables AI assistants to manage documents, query knowledge graphs, and perform retrieval-augmented generation using LightRAG with 30 tools and multiple query mo
Enables AI assistants to manage documents, query knowledge graphs, and perform retrieval-augmented generation using LightRAG with 30 tools and multiple query modes.
A comprehensive Model Context Protocol (MCP) server for LightRAG - Simple and Fast Retrieval-Augmented Generation. This server enables AI assistants to interact with LightRAG's powerful knowledge graph and RAG capabilities.
LightRAG MCP Server provides complete integration with LightRAG's API, offering 30 fully working tools for document management, knowledge graph operations, querying, and system management. Build sophisticated RAG applications with knowledge graph capabilities through a simple MCP interface.
npx @g99/lightrag-mcp-server
npm install -g @g99/lightrag-mcp-server
git clone https://github.com/lalitsuryan/lightragmcp.git
cd lightragmcp
npm install
You need a running LightRAG server instance. Install and start LightRAG:
# Install LightRAG
pip install "lightrag-hku[api]"
# Create .env file with your LLM and embedding configurations
cp env.example .env
# Start LightRAG server (default: http://localhost:9621)
lightrag-server
For detailed LightRAG server setup, visit LightRAG GitHub.
Create a .env file or set the following environment variables:
# Required: Your LightRAG server URL
LIGHTRAG_SERVER_URL=http://localhost:9621
# Optional: Authentication token if your LightRAG server requires it
LIGHTRAG_API_KEY=your_api_key_here
# Optional: Custom workspace name for data isolation
LIGHTRAG_WORKSPACE=default
If your LightRAG server has authentication enabled:
.env file for LIGHTRAG_API_KEYAdd to your claude_desktop_config.json:
{
"mcpServers": {
"lightrag": {
"command": "npx",
"args": ["@g99/lightrag-mcp-server"],
"env": {
"LIGHTRAG_SERVER_URL": "http://localhost:9621",
"LIGHTRAG_API_KEY": "your_api_key_here"
}
}
}
}
Add to your MCP settings:
{
"mcpServers": {
"lightrag": {
"command": "npx",
"args": ["@g99/lightrag-mcp-server"],
"env": {
"LIGHTRAG_SERVER_URL": "http://localhost:9621",
"LIGHTRAG_API_KEY": "your_api_key_here"
}
}
}
}
Insert a single text document into LightRAG.
Parameters:
text (required): Text content to insertdescription (optional): Description of the textExample:
{
"text": "LightRAG is a powerful retrieval-augmented generation system that uses knowledge graphs.",
"description": "Introduction to LightRAG"
}
Insert multiple text documents into LightRAG in batch.
Parameters:
texts (required): Array of text documents with optional metadataExample:
{
"texts": [
{
"content": "LightRAG uses knowledge graphs for enhanced retrieval.",
"title": "LightRAG Overview",
"metadata": {"category": "documentation"}
},
{
"content": "Knowledge graphs connect entities and relationships.",
"title": "Knowledge Graphs"
}
]
}
Upload a document file to LightRAG.
Parameters:
file_path (required): Path to the file to uploadchunk_size (optional): Custom chunk size for document splittingchunk_overlap (optional): Overlap size between chunksExample:
{
"file_path": "/path/to/document.pdf",
"chunk_size": 1200,
"chunk_overlap": 100
}
Upload multiple documents in batch.
Parameters:
file_paths (required): Array of file paths to uploadExample:
{
"file_paths": [
"/path/to/doc1.pdf",
"/path/to/doc2.txt",
"/path/to/doc3.docx"
]
}
Scan for new documents in the configured input directory.
Parameters: None
Example:
{}
Retrieve all documents from LightRAG.
Parameters: None
Example:
{}
Retrieve documents with pagination support.
Parameters:
page (required): Page number (1-based)page_size (required): Number of documents per page (1-100)Example:
{
"page": 1,
"page_size": 20
}
Delete a specific document by ID.
Parameters:
document_id (required): ID of the document to deleteExample:
{
"document_id": "doc_12345"
}
Clear all documents from LightRAG.
Parameters: None
Example:
{}
Get processing status for documents.
Parameters:
document_id (optional): Specific document ID to checkExample:
{
"document_id": "doc_12345"
}
Query LightRAG with text using various retrieval modes.
Parameters:
query (required): Query textmode (optional): Query mode - "naive", "local", "global", "hybrid", or "mix" (default: "hybrid")only_need_context (optional): Return only context without generation (default: false)top_k (optional): Number of top results to retrieve (default: 60)max_tokens (optional): Maximum tokens in responseExample:
{
"query": "What are the main concepts in machine learning?",
"mode": "hybrid",
"top_k": 20
}
Stream query results from LightRAG in real-time.
Parameters:
query (required): Query textmode (optional): Query mode (default: "hybrid")only_need_context (optional): Return only context (default: false)Example:
{
"query": "Explain the evolution of artificial intelligence",
"mode": "global"
}
Query LightRAG and get results with source citations.
Parameters:
query (required): Query textmode (optional): Query mode (default: "hybrid")Example:
{
"query": "What is retrieval-augmented generation?",
"mode": "hybrid"
}
Retrieve the complete knowledge graph from LightRAG.
Parameters: None
Example:
{}
Get the structure and statistics of the knowledge graph.
Parameters: None
Example:
{}
Retrieve all entities from the knowledge graph.
Parameters:
limit (optional): Maximum number of entities to retrieveExample:
{
"limit": 100
}
Retrieve all relationships from the knowledge graph.
Parameters:
limit (optional): Maximum number of relations to retrieveExample:
{
"limit": 100
}
Check if an entity exists in the knowledge graph.
Parameters:
entity_name (required): Name of the entity to checkExample:
{
"entity_name": "Machine Learning"
}
Update properties of an entity in the knowledge graph.
Parameters:
entity_id (required): ID of the entity to updateproperties (required): Properties to updateExample:
{
"entity_id": "entity_123",
"properties": {
"description": "Updated description",
"category": "AI Technology"
}
}
Delete an entity from the knowledge graph.
Parameters:
entity_id (required): ID of the entity to deleteExample:
{
"entity_id": "entity_789"
}
Delete a relationship from the knowledge graph.
Parameters:
relation_id (required): ID of the relation to deleteExample:
{
"relation_id": "rel_456"
}
Check LightRAG server health and status.
Parameters: None
Example:
{}
Get detailed system status and statistics.
Parameters: None
Example:
{}
Clear LightRAG's internal cache.
Parameters:
cache_type (optional): Type of cache to clear (default: "all")Example:
{
"cache_type": "llm"
}
Get current LightRAG server configuration.
Parameters: None
Example:
{}
Get information about the current workspace.
Parameters: None
Example:
{}
// Insert documents
await use_mcp_tool("lightrag", "insert_texts", {
texts: [
{
content: "LightRAG is an advanced RAG system with knowledge graph capabilities.",
title: "LightRAG Introduction"
},
{
content: "Knowledge graphs enhance retrieval by capturing entity relationships.",
title: "Knowledge Graphs"
}
]
});
// Query the indexed content
await use_mcp_tool("lightrag", "query_text", {
query: "How does LightRAG use knowledge graphs?",
mode: "hybrid"
});
// Upload a PDF document
await use_mcp_tool("lightrag", "upload_document", {
file_path: "/path/to/research-paper.pdf"
});
// Check document status
await use_mcp_tool("lightrag", "document_status", {
document_id: "doc_12345"
});
// Query the document
await use_mcp_tool("lightrag", "query_text", {
query: "What are the key findings in the research?",
mode: "local"
});
// Get knowledge graph structure
await use_mcp_tool("lightrag", "get_graph_structure", {});
// Check if entity exists
await use_mcp_tool("lightrag", "check_entity_exists", {
entity_name: "Artificial Intelligence"
});
// Get all entities
await use_mcp_tool("lightrag", "get_entities", {
limit: 50
});
// Update an entity
await use_mcp_tool("lightrag", "update_entity", {
entity_id: "entity_123",
properties: {
description: "A comprehensive field of computer science",
category: "Technology"
}
});
// Query with source citations
await use_mcp_tool("lightrag", "query_with_citation", {
query: "Explain the benefits of RAG systems",
mode: "hybrid"
});
LightRAG supports multiple query modes for different use cases:
# Clone the repository
git clone https://github.com/lalitsuryan/lightragmcp.git
cd lightragmcp
# For Python development
pip install -e ".[dev]"
# For TypeScript development
npm install
npm run build
# Python tests
pytest tests/
# TypeScript tests
npm test
This MCP server implements the LightRAG API. For detailed API documentation, visit:
The LightRAG MCP Server is built with:
Verify that:
lightrag-server)http://localhost:9621)Verify that:
Ensure you're using the correct tool name. All available tools are listed in the documentation above.
Check that:
Contributions are welcome! Please follow these steps:
git checkout -b feature/amazing-feature)git commit -m 'Add amazing feature')git push origin feature/amazing-feature)This project is licensed under the MIT License - see the LICENSE file for details.
Major Update - All Tools Verified Working
Made with ❤️ by Lalit Suryan for the LightRAG and MCP communities
Run in your terminal:
claude mcp add lightrag-mcp-server -- npx Security
Low riskAutomated heuristic from public metadata — not a security guarantee.