Skip to main content

MCP Server for LightRAG

Project description

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

Important: LightRAG MCP server should only be run as an MCP server through an MCP client configuration file (mcp-config.json).

Command Line Options

The following arguments are available when configuring the server in mcp-config.json:

  • --host: LightRAG API host (default: localhost)
  • --port: LightRAG API port (default: 9621)
  • --api-key: LightRAG API key (optional)

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

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.

Available MCP Tools

Document Queries

  • query_document: Execute a query to documents through LightRAG API

Document Management

  • insert_document: Add text directly to LightRAG storage
  • upload_document: Upload document from file to the /input directory
  • insert_file: Add document from file directly to storage
  • insert_batch: Add batch of documents from directory
  • scan_for_new_documents: Start scanning the /input directory for new documents
  • get_documents: Get list of all uploaded documents
  • get_pipeline_status: Get status of document processing in pipeline

Knowledge Graph Operations

  • get_graph_labels: Get labels (node and relationship types) from knowledge graph
  • create_entities: Create multiple entities in knowledge graph
  • edit_entities: Edit multiple existing entities in knowledge graph
  • delete_by_entities: Delete multiple entities from knowledge graph by name
  • delete_by_doc_ids: Delete all entities and relationships associated with multiple documents
  • create_relations: Create multiple relationships between entities in knowledge graph
  • edit_relations: Edit multiple relationships between entities in knowledge graph
  • merge_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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lightrag_mcp-0.1.0.tar.gz (51.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lightrag_mcp-0.1.0-py3-none-any.whl (98.7 kB view details)

Uploaded Python 3

File details

Details for the file lightrag_mcp-0.1.0.tar.gz.

File metadata

  • Download URL: lightrag_mcp-0.1.0.tar.gz
  • Upload date:
  • Size: 51.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for lightrag_mcp-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1a583a8917ccea00ac33ddd201b7dd6271521a85bb0245e3c8c6b6f389811e07
MD5 4adf14308574af51878979215a101679
BLAKE2b-256 6aef74f08b08e40624818e726dcfc16a18da2822e6fddff1b670bdcd839b08a0

See more details on using hashes here.

Provenance

The following attestation bundles were made for lightrag_mcp-0.1.0.tar.gz:

Publisher: publish.yml on shemhamforash23/lightrag-mcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lightrag_mcp-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: lightrag_mcp-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 98.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for lightrag_mcp-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 281b576f150a03b73d7a5fcd045194467b704289d7a59d535b8009fa637ea6b7
MD5 c4e9c35cffe916410ba4b1884184afad
BLAKE2b-256 ec4aa22f3596968843d8d22bf747f27799046b8c6d62398e6a0a31def29df1ff

See more details on using hashes here.

Provenance

The following attestation bundles were made for lightrag_mcp-0.1.0-py3-none-any.whl:

Publisher: publish.yml on shemhamforash23/lightrag-mcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page