Daniel LightRAG MCP Server
A comprehensive MCP (Model Context Protocol) server that provides full integration with LightRAG API, offering 22 tools across 4 categories for complete document management, querying, knowledge graph operations, and system management.
Features
- Document Management: 8 tools for inserting, uploading, scanning, retrieving, and deleting documents
- Query Operations: 2 tools for text queries with regular and streaming responses
- Knowledge Graph: 7 tools for accessing, checking, updating, and deleting entities and relations
- System Management: 5 tools for health checks, status monitoring, and cache management
Quick Start
- Install the server:
- Start LightRAG server (ensure it's running on http://localhost:9621)
- Configure your MCP client (e.g., Claude Desktop):
- Test the connection:
Use the
get_health
tool to verify everything is working.
Installation
Usage
Command Line
Start the MCP server:
Environment Variables
Configure the server with environment variables:
Configuration
The server expects LightRAG to be running on http://localhost:9621
by default. Make sure your LightRAG server is started before running this MCP server.
For detailed configuration options, see CONFIGURATION_GUIDE.md.
Available Tools (22 Total)
Document Management Tools (8 tools)
insert_text
Insert text content into LightRAG.
Parameters:
text
(required): Text content to insert
Example:
insert_texts
Insert multiple text documents into LightRAG.
Parameters:
texts
(required): Array of text documents with optional title and metadata
Example:
upload_document
Upload a document file to LightRAG.
Parameters:
file_path
(required): Path to the file to upload
Example:
scan_documents
Scan for new documents in LightRAG.
Parameters: None
Example:
get_documents
Retrieve all documents from LightRAG.
Parameters: None
Example:
get_documents_paginated
Retrieve documents with pagination.
Parameters:
page
(required): Page number (1-based)page_size
(required): Number of documents per page (1-100)
Example:
delete_document
Delete a specific document by ID.
Parameters:
document_id
(required): ID of the document to delete
Example:
clear_documents
Clear all documents from LightRAG.
Parameters: None
Example:
Query Tools (2 tools)
query_text
Query LightRAG with text.
Parameters:
query
(required): Query textmode
(optional): Query mode - "naive", "local", "global", or "hybrid" (default: "hybrid")only_need_context
(optional): Whether to only return context without generation (default: false)
Example:
query_text_stream
Stream query results from LightRAG.
Parameters:
query
(required): Query textmode
(optional): Query mode - "naive", "local", "global", or "hybrid" (default: "hybrid")only_need_context
(optional): Whether to only return context without generation (default: false)
Example:
Knowledge Graph Tools (7 tools)
get_knowledge_graph
Retrieve the knowledge graph from LightRAG.
Parameters: None
Example:
get_graph_labels
Get labels from the knowledge graph.
Parameters: None
Example:
check_entity_exists
Check if an entity exists in the knowledge graph.
Parameters:
entity_name
(required): Name of the entity to check
Example:
update_entity
Update an entity in the knowledge graph.
Parameters:
entity_id
(required): ID of the entity to updateproperties
(required): Properties to update
Example:
update_relation
Update a relation in the knowledge graph.
Parameters:
relation_id
(required): ID of the relation to updateproperties
(required): Properties to update
Example:
delete_entity
Delete an entity from the knowledge graph.
Parameters:
entity_id
(required): ID of the entity to delete
Example:
delete_relation
Delete a relation from the knowledge graph.
Parameters:
relation_id
(required): ID of the relation to delete
Example:
System Management Tools (5 tools)
get_pipeline_status
Get the pipeline status from LightRAG.
Parameters: None
Example:
get_track_status
Get track status by ID.
Parameters:
track_id
(required): ID of the track to get status for
Example:
get_document_status_counts
Get document status counts.
Parameters: None
Example:
clear_cache
Clear LightRAG cache.
Parameters: None
Example:
get_health
Check LightRAG server health.
Parameters: None
Example:
Example Workflows
Complete Document Management Workflow
- Check server health:
- Insert documents:
- Query the knowledge base:
- Explore the knowledge graph:
- Check entity existence:
Knowledge Graph Management Workflow
- Get current graph structure:
- Get available labels:
- Update entity properties:
- Update relation properties:
System Monitoring Workflow
- Check overall health:
- Monitor pipeline status:
- Check document processing status:
- Track specific operations:
- Clear cache when needed:
Error Handling
The server provides comprehensive error handling with detailed error messages:
- Connection Errors: When LightRAG server is unreachable
- Authentication Errors: When API key is invalid or missing
- Validation Errors: When input parameters are invalid
- API Errors: When LightRAG API returns errors
- Timeout Errors: When requests exceed timeout limits
- Server Errors: When LightRAG server returns 5xx status codes
All errors include:
- Error type and message
- HTTP status code (when applicable)
- Timestamp
- Tool name that caused the error
- Additional context data when available
Error Response Format
Common Error Scenarios
Connection Errors
Validation Errors
API Errors
Troubleshooting
Quick Diagnostics
- Check LightRAG Server Status:
- Test MCP Server:
- Verify Installation:
Common Issues
Server Won't Start
- Check Python version: Requires Python 3.8+
- Verify dependencies: Run
pip install -e .
- Check port availability: Ensure no conflicts on stdio
Connection Refused
- LightRAG not running: Start LightRAG server first
- Wrong URL: Verify
LIGHTRAG_BASE_URL
environment variable - Firewall blocking: Check firewall settings for port 9621
Authentication Failed
- Missing API key: Set
LIGHTRAG_API_KEY
environment variable - Invalid key: Verify API key with LightRAG server
- Key format: Ensure key format matches LightRAG expectations
Timeout Errors
- Increase timeout: Set
LIGHTRAG_TIMEOUT=60
environment variable - Check server load: Verify LightRAG server performance
- Network latency: Test direct API calls with curl
Tool Not Found
- Restart MCP client: Reload server configuration
- Check tool name: Verify exact tool name spelling
- Server registration: Ensure all 22 tools are listed
Debug Mode
Enable detailed logging:
Getting Help
- Check server logs for detailed error messages
- Test individual tools with minimal examples
- Verify LightRAG server is responding correctly
- Review the Configuration Guide for setup details
Development
Install development dependencies:
Run tests:
Run tests with coverage:
Format code:
License
MIT License
This server cannot be installed
remote-capable server
The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.
A comprehensive MCP server that provides full integration with LightRAG API, offering 22 tools across document management, querying, knowledge graph operations, and system management.
Related MCP Servers
- AsecurityAlicenseAqualityMCP-compatible server that enables AI assistants to interact with Lightdash analytics data, providing tools to list and retrieve projects, spaces, charts, dashboards, and metrics through a standardized interface.Last updated -13217TypeScriptMIT License
- -securityFlicense-qualityAn MCP server that fetches real-time documentation for popular libraries like Langchain, Llama-Index, MCP, and OpenAI, allowing LLMs to access updated library information beyond their knowledge cut-off dates.Last updated -2Python
- -securityFlicense-qualityA customized MCP server that enables integration between LLM applications and documentation sources, providing AI-assisted access to LangGraph and Model Context Protocol documentation.Last updated -1Python
- -securityFlicense-qualityAn advanced MCP server providing RAG-enabled memory through a knowledge graph with vector search capabilities, enabling intelligent information storage, semantic retrieval, and document processing.Last updated -4116TypeScript