Logo Daniel LightRAG MCP Server

Daniel LightRAG MCP Server

Cộng đồng
desimpkins

A comprehensive MCP server for LightRAG integration with 22 tools for document management, querying, knowledge graph operations, and system management

Nhà phát hànhdesimpkins
Kho mãdaniel-lightrag-mcp
Ngôn ngữPython
Bản fork
16
Sao
37
Công cụ có sẵn
0
Phương thức truyền tảistdio
Danh mục
Giấy phépMIT
Liên kết
  • Kết nối công cụ với quy trình làm việc AI

    Daniel LightRAG MCP Server cung cấp các khả năng MCP mà ứng dụng khách và tác nhân AI tương thích có thể sử dụng.

  • 0 công cụ có sẵn

    Xem các thao tác có thể gọi bên dưới, kèm tên và mô tả nếu máy chủ cung cấp.

  • Cấu hình sẵn để sao chép

    Dùng các đoạn cấu hình cài đặt mẫu để thiết lập máy chủ này trong ứng dụng khách MCP bạn muốn dùng.

  • Chỉ số quan tâm đến mã nguồn mở

    37 sao và 16 bản fork từ kho mã được liên kết.

Daniel LightRAG MCP Server

A comprehensive MCP (Model Context Protocol) server that provides 100% functional integration with LightRAG API, offering 22 fully working tools across 4 categories for complete document management, querying, knowledge graph operations, and system management.

🎉 Status: 100% Functional

All 22 tools are working perfectly after comprehensive testing and optimization:

  • ✅ Document Management: 6/6 tools working (100%)
  • ✅ Query Operations: 2/2 tools working (100%)
  • ✅ Knowledge Graph: 6/6 tools working (100%)
  • ✅ System Management: 4/4 tools working (100%)
  • ✅ Health Check: 1/1 tools working (100%)

Features

  • Document Management: 6 tools for inserting, uploading, scanning, retrieving, and managing documents
  • Query Operations: 2 tools for text queries with regular and streaming responses
  • Knowledge Graph: 6 tools for accessing, checking, updating, and managing entities and relations
  • System Management: 4 tools for health checks, status monitoring, and cache management
  • Comprehensive Error Handling: Robust error handling with detailed error messages
  • Full API Coverage: Complete integration with LightRAG API 0.1.96+

Quick Start

  1. Install the server:

    bash
    pip install -e .
  2. Start LightRAG server (ensure it's running on http://localhost:9621)

  3. Configure your MCP client (e.g., Claude Desktop):

    json
    {
      "mcpServers": {
        "daniel-lightrag": {
          "command": "python",
          "args": ["-m", "daniel_lightrag_mcp"]
        }
      }
    }
  4. Test the connection: Use the get_health tool to verify everything is working.

Installation

bash
# Basic installation
pip install -e .

# With development dependencies
pip install -e ".[dev]"

Usage

Command Line

Start the MCP server:

bash
daniel-lightrag-mcp

Environment Variables

Configure the server with environment variables:

bash
export LIGHTRAG_BASE_URL="http://localhost:9621"
export LIGHTRAG_API_KEY="your-api-key"  # Optional
export LIGHTRAG_TIMEOUT="30"            # Optional
export LOG_LEVEL="INFO"                 # Optional

daniel-lightrag-mcp

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.

MCP Client Configuration

Add to your MCP client (e.g., Claude Desktop):

json
{
  "mcpServers": {
    "daniel-lightrag": {
      "command": "python",
      "args": ["-m", "daniel_lightrag_mcp"],
      "env": {
        "LIGHTRAG_BASE_URL": "http://localhost:9621",
        "LIGHTRAG_API_KEY": "lightragsecretkey"
      }
    }
  }
}

For detailed configuration options, see MCP_CONFIGURATION_GUIDE.md.

Implementation Details

This server has undergone comprehensive testing and optimization to achieve 100% functionality. Key improvements include:

  • HTTP Client Fixes: Proper DELETE request handling with JSON bodies
  • Request Parameter Validation: All request models aligned with LightRAG API
  • Response Model Alignment: All response models match actual server responses
  • File Source Implementation: Critical fix preventing database corruption
  • Knowledge Graph Access: Optimized label parameters for full graph access

For complete technical details, see IMPLEMENTATION_GUIDE.md.

Available Tools (22 Total - All Working ✅)

Document Management Tools (6 tools)

insert_text

Insert text content into LightRAG.

Parameters:

  • text (required): Text content to insert

Example:

json
{
  "text": "This is important information about machine learning algorithms and their applications in modern AI systems."
}

insert_texts

Insert multiple text documents into LightRAG.

Parameters:

  • texts (required): Array of text documents with optional title and metadata

Example:

json
{
  "texts": [
    {
      "title": "AI Overview",
      "content": "Artificial Intelligence is transforming industries...",
      "metadata": {"category": "technology", "author": "researcher"}
    },
    {
      "content": "Machine learning algorithms require large datasets..."
    }
  ]
}

upload_document

Upload a document file to LightRAG.

Parameters:

  • file_path (required): Path to the file to upload

Example:

json
{
  "file_path": "/path/to/document.pdf"
}

scan_documents

Scan for new documents in LightRAG.

Parameters: None

Example:

json
{}

get_documents

Retrieve all documents from LightRAG.

Parameters: None

Example:

json
{}

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:

json
{
  "page": 1,
  "page_size": 20
}

delete_document

Delete a specific document by ID.

Parameters:

  • document_id (required): ID of the document to delete

Example:

json
{
  "document_id": "doc_12345"
}

clear_documents

Clear all documents from LightRAG.

Parameters: None

Example:

json
{}

Query Tools (2 tools)

query_text

Query LightRAG with text.

Parameters:

  • query (required): Query text
  • mode (optional): Query mode - "naive", "local", "global", or "hybrid" (default: "hybrid")
  • only_need_context (optional): Whether to only return context without generation (default: false)

Example:

json
{
  "query": "What are the main concepts in machine learning?",
  "mode": "hybrid",
  "only_need_context": false
}

query_text_stream

Stream query results from LightRAG.

Parameters:

  • query (required): Query text
  • mode (optional): Query mode - "naive", "local", "global", or "hybrid" (default: "hybrid")
  • only_need_context (optional): Whether to only return context without generation (default: false)

Example:

json
{
  "query": "Explain the evolution of artificial intelligence",
  "mode": "global"
}

Knowledge Graph Tools (6 tools)

get_knowledge_graph

Retrieve the knowledge graph from LightRAG.

Parameters: None

Example:

json
{}

get_graph_labels

Get labels from the knowledge graph.

Parameters: None

Example:

json
{}

check_entity_exists

Check if an entity exists in the knowledge graph.

Parameters:

  • entity_name (required): Name of the entity to check

Example:

json
{
  "entity_name": "Machine Learning"
}

update_entity

Update an entity in the knowledge graph.

Parameters:

  • entity_id (required): ID of the entity to update
  • properties (required): Properties to update

Example:

json
{
  "entity_id": "entity_123",
  "properties": {
    "description": "Updated description for machine learning",
    "category": "AI Technology"
  }
}

update_relation

Update a relation in the knowledge graph.

Parameters:

  • relation_id (required): ID of the relation to update
  • properties (required): Properties to update

Example:

json
{
  "relation_id": "rel_456",
  "properties": {
    "strength": 0.9,
    "type": "implements"
  }
}

delete_entity

Delete an entity from the knowledge graph.

Parameters:

  • entity_id (required): ID of the entity to delete

Example:

json
{
  "entity_id": "entity_789"
}

delete_relation

Delete a relation from the knowledge graph.

Parameters:

  • relation_id (required): ID of the relation to delete

Example:

json
{
  "relation_id": "rel_101"
}

System Management Tools (4 tools)

get_pipeline_status

Get the pipeline status from LightRAG.

Parameters: None

Example:

json
{}

get_track_status

Get track status by ID.

Parameters:

  • track_id (required): ID of the track to get status for

Example:

json
{
  "track_id": "track_abc123"
}

get_document_status_counts

Get document status counts.

Parameters: None

Example:

json
{}

clear_cache

Clear LightRAG cache.

Parameters: None

Example:

json
{}

get_health

Check LightRAG server health.

Parameters: None

Example:

json
{}

Example Workflows

Complete Document Management Workflow

  1. Check server health:

    json
    {"tool": "get_health", "arguments": {}}
  2. Insert documents:

    json
    {
      "tool": "insert_texts",
      "arguments": {
        "texts": [
          {
            "title": "AI Research Paper",
            "content": "Recent advances in transformer architectures have shown remarkable improvements in natural language understanding tasks...",
            "metadata": {"category": "research", "year": 2024}
          }
        ]
      }
    }
  3. Query the knowledge base:

    json
    {
      "tool": "query_text",
      "arguments": {
        "query": "What are the recent advances in transformer architectures?",
        "mode": "hybrid"
      }
    }
  4. Explore the knowledge graph:

    json
    {"tool": "get_knowledge_graph", "arguments": {}}
  5. Check entity existence:

    json
    {
      "tool": "check_entity_exists",
      "arguments": {"entity_name": "transformer architectures"}
    }

Knowledge Graph Management Workflow

  1. Get current graph structure:

    json
    {"tool": "get_knowledge_graph", "arguments": {}}
  2. Get available labels:

    json
    {"tool": "get_graph_labels", "arguments": {}}
  3. Update entity properties:

    json
    {
      "tool": "update_entity",
      "arguments": {
        "entity_id": "transformer_arch_001",
        "properties": {
          "description": "Advanced neural network architecture for sequence processing",
          "applications": ["NLP", "computer vision", "speech recognition"],
          "year_introduced": 2017
        }
      }
    }
  4. Update relation properties:

    json
    {
      "tool": "update_relation",
      "arguments": {
        "relation_id": "rel_improves_002",
        "properties": {
          "improvement_factor": 2.5,
          "confidence": 0.92,
          "evidence": "Multiple benchmark studies"
        }
      }
    }

System Monitoring Workflow

  1. Check overall health:

    json
    {"tool": "get_health", "arguments": {}}
  2. Monitor pipeline status:

    json
    {"tool": "get_pipeline_status", "arguments": {}}
  3. Check document processing status:

    json
    {"tool": "get_document_status_counts", "arguments": {}}
  4. Track specific operations:

    json
    {
      "tool": "get_track_status",
      "arguments": {"track_id": "upload_batch_001"}
    }
  5. Clear cache when needed:

    json
    {"tool": "clear_cache", "arguments": {}}

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

json
{
  "tool": "insert_text",
  "error_type": "LightRAGConnectionError",
  "message": "Failed to connect to LightRAG server at http://localhost:9621",
  "timestamp": 1703123456.789,
  "status_code": null,
  "response_data": {}
}

Common Error Scenarios

Connection Errors

json
{
  "error_type": "LightRAGConnectionError",
  "message": "Connection refused to http://localhost:9621",
  "status_code": null
}

Validation Errors

json
{
  "error_type": "LightRAGValidationError", 
  "message": "Missing required arguments for query_text: ['query']",
  "validation_errors": [
    {
      "loc": ["query"],
      "msg": "field required",
      "type": "value_error.missing"
    }
  ]
}

API Errors

json
{
  "error_type": "LightRAGAPIError",
  "message": "Document not found",
  "status_code": 404,
  "response_data": {
    "detail": "Document with ID 'doc_123' does not exist"
  }
}

Troubleshooting

Quick Diagnostics

  1. Check LightRAG Server Status:

    bash
    curl http://localhost:9621/health
  2. Test MCP Server:

    bash
    python -m daniel_lightrag_mcp &
    sleep 2
    pkill -f daniel_lightrag_mcp
  3. Verify Installation:

    bash
    python -c "import daniel_lightrag_mcp; print('OK')"

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:

bash
export LOG_LEVEL=DEBUG
python -m daniel_lightrag_mcp

Getting Help

  1. Check server logs for detailed error messages
  2. Test individual tools with minimal examples
  3. Verify LightRAG server is responding correctly
  4. Review the Configuration Guide for setup details

Development

Install development dependencies:

bash
pip install -e ".[dev]"

Run tests:

bash
pytest

Run tests with coverage:

bash
pytest --cov=src/daniel_lightrag_mcp --cov-report=html

Format code:

bash
black src/ tests/
isort src/ tests/

License

MIT License

Cài đặt

TypingMind
Yêu cầu:

Node.js 18+

{
  "mcpServers": {
    "desimpkins-daniel-lightrag-mcp": {
      "command": "",
      "args": []
    }
  }
}

Dùng MCP Daniel LightRAG MCP Server với nhiều mô hình AI

TypingMind kết nối các công cụ MCP ở cấp không gian làm việc, nên sau khi kết nối Daniel LightRAG MCP Server, bạn có thể dùng với nhiều mô hình AI khác nhau trong TypingMind thay vì phải thiết lập riêng cho từng mô hình. MCP này chạy cục bộ thông qua trình kết nối MCP của TypingMind trên thiết bị của bạn.

Hướng dẫn thiết lập để dùng trình kết nối cục bộ

Dùng cách này khi máy chủ MCP cần truy cập các tệp, ứng dụng hoặc tài nguyên riêng tư trên máy tính của bạn.

1

Mở cài đặt MCP

Trong TypingMind, vào Cài đặt, Cài đặt nâng cao, rồi đến Giao thức ngữ cảnh mô hình và chọn Cài trình kết nối.

  1. Mở TypingMind trong trình duyệt của bạn.
  2. Nhấp vào biểu tượng Cài đặt.
  3. Vào Cài đặt nâng cao.
  4. Mở mục Giao thức ngữ cảnh mô hình.
  5. Nhấp vào Cài trình kết nối rồi chọn Thiết bị này.
Màn hình thiết lập trình kết nối MCP của TypingMind với tùy chọn Thiết bị này được chọn
2

Chạy lệnh trình kết nối

Chọn Thiết bị này, sao chép lệnh từ TypingMind và chạy trong Terminal. Giữ tiến trình chạy trong khi bạn dùng MCP.

  1. Sao chép lệnh thiết lập hiển thị trong TypingMind.
  2. Mở Terminal trên macOS hoặc Windows Terminal trên Windows.
  3. Dán và chạy lệnh.
  4. Xác nhận cài đặt gói nếu Terminal hỏi bạn có muốn tiếp tục không.
  5. Giữ tiến trình trong cửa sổ Terminal chạy trong khi dùng các công cụ MCP.
3

Thêm Daniel LightRAG MCP Server làm máy chủ

Khi trạng thái trình kết nối là Sẵn sàng, nhấp vào Sửa máy chủ và dán cấu hình máy chủ MCP.

  1. Đợi đến khi trạng thái trình kết nối hiển thị Sẵn sàng.
  2. Nhấp vào Sửa máy chủ.
  3. Dán cấu hình máy chủ MCP của Daniel LightRAG MCP Server.
  4. Lưu danh sách máy chủ.
  5. Làm mới nếu bạn muốn xác nhận trình kết nối vẫn sẵn sàng.
Cài đặt MCP của TypingMind hiển thị máy chủ đang hoạt động và nút Sửa máy chủ
{
  "mcpServers": {
    "desimpkins-daniel-lightrag-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "daniel-lightrag-mcp"
      ]
    }
  }
}
4

Dùng kết nối với nhiều mô hình

Lưu danh sách máy chủ, mở Plugin, bật các công cụ MCP của Daniel LightRAG MCP Server, sau đó chọn bất kỳ mô hình AI nào được hỗ trợ trong TypingMind và dùng các công cụ trong cuộc trò chuyện hoặc gán chúng cho một tác nhân AI.

  1. Mở trang Plugin trong TypingMind.
  2. Bật các công cụ MCP của Daniel LightRAG MCP Server.
  3. Bắt đầu cuộc trò chuyện và chọn mô hình AI bạn muốn dùng.
  4. Dùng các công cụ MCP trong cuộc trò chuyện hoặc gán chúng cho một tác nhân AI.
  5. Chuyển sang mô hình AI khác bất cứ khi nào cần mà không phải kết nối lại MCP.
Cuộc trò chuyện TypingMind dùng các công cụ MCP đã bật với một mô hình AI được chọn
Bạn có thể dùng Daniel LightRAG MCP Server giúp tôi làm việc này không?
Daniel LightRAG MCP Server
Được. Tôi đã đọc.
Đây là kết quả tôi tìm được bằng Daniel LightRAG MCP Server.

Câu hỏi thường gặp

Máy chủ MCP Daniel LightRAG MCP Server dùng để làm gì?

Daniel LightRAG MCP Server là máy chủ MCP cho phép các ứng dụng AI tương thích kết nối với công cụ và ngữ cảnh bên ngoài. Trong TypingMind, bạn chỉ cần thêm máy chủ MCP này một lần để các công cụ của nó có sẵn trong không gian làm việc AI của bạn.

Bạn có thể dùng MCP Daniel LightRAG MCP Server với nhiều mô hình AI trong TypingMind không?

Có. TypingMind kết nối các công cụ MCP ở cấp không gian làm việc, nên bạn có thể dùng Daniel LightRAG MCP Server với nhiều mô hình AI như Claude, ChatGPT, Gemini hoặc các mô hình khác đã cấu hình trong TypingMind mà không cần thiết lập máy chủ MCP riêng cho từng mô hình.

Vì sao nên dùng MCP Daniel LightRAG MCP Server với TypingMind?

TypingMind là một trong những giao diện trò chuyện với LLM tốt nhất vì tập hợp nhiều mô hình AI, prompt, plugin, tác nhân AI, khóa API và công cụ MCP vào một không gian làm việc. Khi kết nối Daniel LightRAG MCP Server, bạn có thể dùng các công cụ MCP của dịch vụ này với những mô hình ưa thích, đồng thời giữ quy trình trò chuyện gọn gàng trong TypingMind.

Làm cách nào để kết nối MCP Daniel LightRAG MCP Server với TypingMind?

Daniel LightRAG MCP Server hoạt động thông qua trình kết nối MCP cục bộ của TypingMind. Đây là lựa chọn phù hợp nhất khi máy chủ MCP cần truy cập tệp cục bộ, ứng dụng máy tính, công cụ dòng lệnh hoặc tài nguyên riêng trên máy tính của bạn.

MCP Daniel LightRAG MCP Server cung cấp những công cụ nào trong TypingMind?

Daniel LightRAG MCP Server cung cấp các chức năng MCP mà bạn có thể bật từ trang Plugin của TypingMind để dùng trong trò chuyện hoặc gán cho tác nhân AI.

Bạn có cần chia sẻ khóa API với TypingMind để dùng MCP Daniel LightRAG MCP Server không?

Không. TypingMind ưu tiên xử lý cục bộ và cho phép bạn kiểm soát nhà cung cấp mô hình, khóa API, prompt và cấu hình MCP. Nếu Daniel LightRAG MCP Server yêu cầu xác thực, hãy thêm các header, cài đặt OAuth hoặc cấu hình cục bộ cần thiết cho máy chủ MCP đó khi tạo kết nối.

Máy chủ MCP liên quan

Xem tất cả

Tạo ngay không gian làm việc AI riêng

Đăng ký bản tin của chúng tôi để nhận thông báo về tính năng mới và các đợt tặng quà sắp tới 👇