Skip to main content
Glama
lightrag-docs-rag-mcp

lightrag-docs-rag-mcp

lightrag-docs-rag-mcp

An MCP server that exposes a LightRAG instance as three tools, so any MCP-capable agent can ground its answers in your indexed docs instead of relying on recall.

LightRAG ships a REST server but no MCP server of its own, and the community package uses different tool names. This one is a thin, auditable wrapper over four LightRAG HTTP routes, with tool names chosen to match how tool-calling corpora actually name them.

Tool

Purpose

docs_query

Ask the knowledge graph a question; returns a grounded answer and the source files that grounded it

docs_ingest

Add documents to the index

docs_stats

Document counts by pipeline stage, whether indexing is running, and the model endpoints in use

Why these names

Registered under a server named docs_rag, the tools surface as mcp__docs_rag__docs_query, mcp__docs_rag__docs_ingest, mcp__docs_rag__docs_stats. That matches the naming used by existing agent tool-calling datasets, so a corpus generated against this server validates without a rename layer.

Related MCP server: Cognify MCP Server

Install

uv tool install lightrag-docs-rag-mcp
# or, from a checkout:
uv tool install .

Requires a running LightRAG server (lightrag-server). Python 3.10+.

Configure

Hermes Agent

hermes mcp add docs_rag --command lightrag-docs-rag-mcp

or in ~/.hermes/config.yaml:

mcp_servers:
  docs_rag:
    command: "lightrag-docs-rag-mcp"
    env:
      LIGHTRAG_BASE_URL: "http://127.0.0.1:9621"
    timeout: 900

Claude Desktop / other MCP clients

{
  "mcpServers": {
    "docs_rag": {
      "command": "lightrag-docs-rag-mcp",
      "env": { "LIGHTRAG_BASE_URL": "http://127.0.0.1:9621" }
    }
  }
}

Environment

Variable

Default

Meaning

LIGHTRAG_BASE_URL

http://127.0.0.1:9621

LightRAG server root

LIGHTRAG_API_KEY

(unset)

Sent as X-API-Key when the server requires one

LIGHTRAG_TIMEOUT

900

Per-request timeout, seconds

DOCS_RAG_DEBUG

(unset)

Verbose logging to stderr

Operational notes

These are the things that will actually bite you.

Queries are slow, and that is the server's model choice, not this wrapper. A hybrid query over a ~20-chunk context measured ~212 s on a local 9B. Context size dominates. If you need faster answers, cap the server's MAX_TOTAL_TOKENS / MAX_ENTITY_TOKENS / MAX_RELATION_TOKENS and raise LLM_TIMEOUT. The default timeout here is 900 s so a slow-but-correct answer does not become an error.

The LightRAG LLM must have thinking disabled. With a thinking model, the query's final answer call returns empty content with finish_reason=length, which surfaces as OpenAI API Timeout Error — while retrieval looks perfectly healthy. That is an LLM-tier bug that reads like a retrieval bug. For llama.cpp-served models, serve a dedicated entry:

llama-server ... --n-predict 4096 --chat-template-kwargs '{"enable_thinking":false}'

An empty answer is not an empty index. llm_generated: false with no references means the LLM or embedding tier is unreachable, not that retrieval found nothing. Check docs_stats first — and note that ingestion completeness (processed: N) says nothing about queryability.

Indexing is graph extraction, not a vector write. Budget roughly a minute per chunk on a local model; a corpus stays queryable-but-partial while extraction runs.

Development

uv venv && uv pip install -e '.[dev]'
ruff check .
pytest

License

MIT

Available Tools

3 tools
docs_ingestAdd documents to the knowledge graphA

Insert text documents into the LightRAG index. Indexing is a graph-extraction pass, not a cheap vector write: budget roughly a minute per chunk on a local model, and expect the corpus to stay queryable-but-partial while it runs. Identical content is de-duplicated by hash, so re-submitting an unchanged document is a no-op rather than a duplicate.

Inputs: texts (required), file_sources. Returns: result

docs_queryQuery the docs knowledge graphA

Search the indexed documentation knowledge graph and return a grounded answer. Use this for questions about the libraries and tools in the corpus (for example an engine's class API or a text editor's scripting API) instead of relying on recall. The answer is generated from retrieved graph context and comes with the source files that grounded it, so prefer it over an ungrounded answer and cite the returned file paths. Expect this call to take up to several minutes on a local model; it is not a fast lookup.

Inputs: query (required), mode, top_k. Returns: result

docs_statsKnowledge graph statusA

Report the state of the LightRAG instance: document counts by pipeline stage, whether an indexing job is currently running, and which model and embedding endpoints it is configured to use. Check this before a large ingest, and to distinguish 'the corpus is still indexing' from 'the corpus is empty' when a query returns nothing.

Inputs: no named parameters. Returns: result

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.4/5.0

    Scored across 3 tools

    Disambiguation5/5

    Each tool targets a distinct operation: querying the graph, ingesting documents, and inspecting instance state. No two tools could be confused for one another.

    Naming Consistency5/5

    All tool names follow a consistent docs_ prefix with a clear verb suffix (query, ingest, stats). The pattern is uniform and predictable.

    Tool Count5/5

    Three tools cover the core RAG lifecycle (ingest, query, monitor) without redundancy. This is a well-scoped set for a focused documentation assistant.

    Completeness4/5

    The essential operations are present: adding documents, retrieving answers, and checking status. A delete or clear operation is the only notable gap, but it is not critical for the stated purpose.

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables document ingestion and typed knowledge graph queries through Claude MCP tools, allowing agents to extract, store, and retrieve typed entities and relations from documents.
      2
      MIT
    • F
      license
      Not graded
      quality
      D
      maintenance
      MCP server that bridges LightRAG API with MCP-compatible clients, enabling retrieval-augmented generation, document management, and knowledge graph operations.
      127
      -
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables AI agents to query and manage a document knowledge base via MCP, with RAG-powered search and grounded answers with citations.
      MIT