# daniel-lightrag-mcp
## 基本信息
- Slug: `desimpkins-daniel-lightrag-mcp`
- Source: modelscope
- Publisher: @desimpkins/daniel-lightrag-mcp
- Categories: rag-systems / knowledge-and-memory / documentation-access
- Hosted: No
- License: MIT License
- Source URL: https://www.modelscope.cn/mcp/servers/@desimpkins/daniel-lightrag-mcp
## 简介
暂无描述。
## 安装提示

```bash
pip install -e .
```

## MCP Server 详情

# 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](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](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 onl…

