LightRAG MCP Server
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@LightRAG MCP Serversearch knowledge graph for quantum computing"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
LightRAG MCP Server
Model Context Protocol (MCP) server for the LightRAG API — 30 tools covering queries, document management, knowledge graph operations, and server utilities.
Table of Contents
Related MCP server: LightRAG MCP Server
Overview
This MCP server acts as a bridge between any MCP-compatible AI client (n8n, Claude Desktop, Zed, Cursor, etc.) and a running LightRAG server.
AI Client (n8n / Claude Desktop / Zed)
│
│ MCP protocol (SSE or stdio)
▼
┌─────────────────────────┐
│ LightRAG MCP Server │ ← this project
│ (Node.js + TypeScript) │
└─────────────────────────┘
│
│ HTTP REST
▼
┌────────────────────────┐
│ LightRAG API │
│ http://localhost:9621 │
└────────────────────────┘Key features:
30 tools covering all major LightRAG API endpoints
Two transports: HTTP+SSE for n8n / remote clients, stdio for local desktop clients
Workspace support: all tools accept an optional
workspaceparameter to target specific knowledge basesDocker daemon: runs as a background service, survives Ctrl+C and host reboots
Graceful shutdown: handles SIGTERM/SIGINT properly so Docker can stop it cleanly
Prerequisites
Requirement | Version | Notes |
Node.js | ≥ 18 | LTS recommended |
npm | ≥ 9 | Comes with Node.js |
LightRAG server | any | Must be running on |
Docker (optional) | ≥ 24 | For daemon mode |
LightRAG must already be running before you start the MCP server. If it's currently running from PowerShell on port 9621, that's perfect — no changes needed.
Quick Start
1. Install dependencies
# From the devstral-mcp directory
npm install2. Build TypeScript
npm run build3. Configure (optional)
# Copy the example config and edit if needed
Copy-Item .env.example .env
# Edit .env — most defaults work out of the box for a local LightRAG installThe only value you typically need to change is LIGHTRAG_BASE_URL if LightRAG is not on localhost:9621.
4. Start the server
# HTTP+SSE mode (for n8n) — default
npm run start:http
# stdio mode (for Claude Desktop / Zed)
npm run start:stdioYou should see:
┌──────────────────────────────────────────────────────┐
│ LightRAG MCP Server — Configuration │
├──────────────────────────────────────────────────────┤
│ LightRAG URL : http://localhost:9621 │
│ Transport : http │
│ Listen : 0.0.0.0:3000 │
│ SSE endpoint : http://localhost:3000/sse │
└──────────────────────────────────────────────────────┘5. Test connectivity
# Check the MCP server itself
Invoke-RestMethod http://localhost:3000/health
# Verify it can reach LightRAG
Invoke-RestMethod http://localhost:3000/Configuration
All settings can be set in .env or as environment variables. Environment variables always take priority over .env.
Variable | Default | Description |
|
| LightRAG server URL (no trailing slash) |
| (empty) | API key for LightRAG. Leave empty if auth is disabled (default for local installs) |
|
| HTTP request timeout in milliseconds |
| (empty) | Default workspace. Empty = server default |
|
| Transport mode: |
|
| Bind host for HTTP transport |
|
| Port for HTTP+SSE transport |
|
| Log verbosity: |
The transport can also be set via CLI flag, which takes highest priority:
node dist/index.js --transport http
node dist/index.js --transport stdioAll 30 Tools
Query Tools (1–3)
# | Tool name | Description |
1 |
| Query the knowledge base and get an LLM-generated answer. Supports all retrieval modes. |
2 |
| Same as above but uses the |
3 |
| Returns raw retrieval data (entities, relationships, chunks) without LLM generation. |
Query modes (all query tools accept a mode parameter):
Mode | Description |
| ⭐ Recommended — combines knowledge graph with vector search |
| Focuses on specific entities and their direct relationships |
| Analyses broad relationship patterns across the whole graph |
| Combines local + global strategies |
| Plain vector similarity search, no knowledge graph |
| Direct LLM call, no retrieval at all |
Document Management Tools (4–18)
# | Tool name | Description |
4 |
| Insert a single text string into the knowledge base |
5 |
| Insert multiple texts in one request (batch) |
6 |
| Trigger a scan of the server's input directory for new files |
7 |
| List all documents grouped by status (up to 1000) |
8 |
| Paginated document list with filtering and sorting |
9 |
| Quick count summary: PROCESSED / PENDING / FAILED / etc. |
10 |
| Check indexing progress using a track_id |
11 |
| Delete documents by ID (async, with optional file/cache deletion) |
12 |
| Remove an entity node from the knowledge graph |
13 |
| Remove a relationship edge from the knowledge graph |
14 |
| ⚠️ Wipe everything — all documents, entities, vectors |
15 |
| Monitor the document processing pipeline (busy/idle, progress) |
16 |
| Request graceful cancellation of the running pipeline |
17 |
| Retry documents stuck in FAILED or PENDING state |
18 |
| Clear LLM response cache (forces fresh extraction on next insert) |
Typical insert workflow:
lightrag_insert_text → returns track_id
lightrag_get_track_status(track_id) → poll until PROCESSED
lightrag_query → ask questionsGraph / Entity / Relation Tools (19–28)
# | Tool name | Description |
19 |
| List all entity names in the knowledge graph |
20 |
| Get the most-connected entities (sorted by degree) |
21 |
| Fuzzy search for entity names |
22 |
| Get a subgraph around a specific entity (nodes + edges) |
23 |
| Check if an entity with a given name exists |
24 |
| Manually create a new entity node |
25 |
| Update entity properties, rename, or merge with another entity |
26 |
| Create a relationship between two existing entities |
27 |
| Update relationship properties |
28 |
| Consolidate duplicate entities, transferring all relationships |
Utility Tools (29–30)
# | Tool name | Description |
29 |
| Full server health: version, LLM config, storage backends, pipeline state |
30 |
| Authentication configuration status |
Transport Modes
HTTP + SSE (recommended for n8n)
The default mode. Starts an Express server with two endpoints:
Endpoint | Method | Purpose |
| GET | MCP client connects here to open an SSE session |
| POST | MCP client sends tool call requests |
| GET | Liveness check (no auth required) |
| GET | Server info |
npm run start:http
# or
npm start # same thingstdio (for Claude Desktop, Zed, Cursor)
Used when the MCP client spawns this process as a child and communicates via stdin/stdout.
npm run start:stdion8n Integration
Step 1: Start the MCP server
npm run start:http
# MCP server now listening at http://localhost:3000/sseOr via Docker (see Docker Daemon section).
Step 2: Create MCP Client credential in n8n
Open n8n → Settings → Credentials → New Credential
Search for MCP Client API
Set SSE URL to:
Local:
http://localhost:3000/sseDocker (same compose network):
http://lightrag-mcp:3000/sseDocker (host machine):
http://host.docker.internal:3000/sse
Save the credential
Step 3: Import the workflow template
In n8n, go to Workflows → Import from file
Select
n8n/lightrag-workflow.jsonfrom this projectOpen the imported workflow
Update the OpenAI GPT-4o-mini node with your OpenAI credential
Update the LightRAG MCP Tools node with the MCP credential you just created
Click Save and Activate
Step 4: Test
Open the chat in n8n and try:
"Is LightRAG running?" → triggers
lightrag_health_check"What documents do you know about?" → triggers
lightrag_get_document_status_counts"Tell me about [topic]" → triggers
lightrag_query
Network configuration
Scenario |
| n8n MCP SSE URL |
Everything on host machine |
|
|
MCP in Docker, LightRAG on host |
|
|
Everything in Docker (same network) |
|
|
Docker Daemon
Running the MCP server in Docker keeps it alive even after closing the terminal window. It will restart automatically after crashes or host reboots.
Build and start
# From the devstral-mcp directory
docker compose -f docker/docker-compose.yml up -d --buildCommon commands
# Check status
docker compose -f docker/docker-compose.yml ps
# Follow logs
docker compose -f docker/docker-compose.yml logs -f
# Stop the daemon (Ctrl+C does NOT stop it — this does)
docker compose -f docker/docker-compose.yml down
# Restart without rebuilding
docker compose -f docker/docker-compose.yml restart
# Rebuild after code changes
docker compose -f docker/docker-compose.yml up -d --buildWhy it survives Ctrl+C
restart: unless-stopped— Docker automatically restarts the container if it exits for any reasoninit: true— Uses tini as PID 1 so Node.js receives SIGTERM properlystop_grace_period: 15s— Docker waits 15 seconds for graceful shutdown before force-killingThe Node.js process handles SIGTERM/SIGINT gracefully, closing SSE sessions and the HTTP server
Environment variables for Docker
Create a .env file next to docker/docker-compose.yml (or in the project root):
# If LightRAG runs on the host machine (not in Docker)
LIGHTRAG_BASE_URL=http://host.docker.internal:9621
# If LightRAG runs in Docker on the same network
# LIGHTRAG_BASE_URL=http://lightrag:9621
MCP_PORT=3000
LOG_LEVEL=infoWorkspace Support
LightRAG supports multiple isolated knowledge bases called workspaces. All 30 tools accept an optional workspace parameter.
How it works:
When
workspaceis provided in a tool call, the MCP server sends it as theLIGHTRAG-WORKSPACEHTTP header to LightRAGLightRAG routes the request to the workspace-specific storage
Workspace names must contain only letters, digits, and underscores (
[a-zA-Z0-9_]+)
Example use cases:
workspace: "python_books"— knowledge base with Python programming booksworkspace: "company_docs"— internal company documentationworkspace: "research_papers"— academic papers collection
Set a default workspace so you don't have to pass it every time:
# .env
LIGHTRAG_DEFAULT_WORKSPACE=python_booksIndividual tool calls can still override the default by passing a different workspace value.
Claude Desktop / Zed
To use this MCP server with Claude Desktop or Zed, use stdio transport.
Claude Desktop
Add to %APPDATA%\Claude\claude_desktop_config.json:
{
"mcpServers": {
"lightrag": {
"command": "node",
"args": ["C:/path/to/devstral-mcp/dist/index.js", "--transport", "stdio"],
"env": {
"LIGHTRAG_BASE_URL": "http://localhost:9621",
"LIGHTRAG_DEFAULT_WORKSPACE": ""
}
}
}
}Zed
Add to Zed settings.json:
{
"context_servers": {
"lightrag-mcp": {
"command": {
"path": "node",
"args": ["C:/path/to/devstral-mcp/dist/index.js", "--transport", "stdio"],
"env": {
"LIGHTRAG_BASE_URL": "http://localhost:9621"
}
}
}
}
}Replace C:/path/to/devstral-mcp with the actual absolute path to this project.
Development
# Install dependencies
npm install
# Run in development mode with hot reload (HTTP transport)
npm run dev:http
# Run in development mode (stdio transport)
npm run dev:stdio
# Type-check without building
npm run typecheck
# Build for production
npm run build
# Clean build output
npm run cleanProject structure
devstral-mcp/
├── src/
│ ├── index.ts # Entry point — transport selection and startup
│ ├── server.ts # McpServer factory — registers all 30 tools
│ ├── config.ts # Typed environment configuration + logger
│ ├── client.ts # Axios HTTP client for LightRAG API
│ └── tools/
│ ├── query.ts # Tools 1–3: query, query_stream, query_data
│ ├── documents.ts # Tools 4–18: insert, scan, list, delete, pipeline
│ └── graph.ts # Tools 19–30: entities, relations, labels, health
├── docker/
│ ├── Dockerfile # Multi-stage production build
│ └── docker-compose.yml # Daemon with restart:unless-stopped
├── n8n/
│ └── lightrag-workflow.json # n8n AI Agent workflow template
├── .env.example # All configurable environment variables
├── package.json
├── tsconfig.json
└── README.mdTroubleshooting
"Cannot connect to LightRAG at http://localhost:9621"
The LightRAG server is not reachable. Check:
# Is LightRAG running?
Invoke-RestMethod http://localhost:9621/health
# Is the URL correct in .env?
Get-Content .env | Select-String LIGHTRAG_BASE_URLIf LightRAG is running in Docker and the MCP server is on the host:
LIGHTRAG_BASE_URL=http://localhost:9621 # ✅ correct (Docker maps the port)If both are in Docker containers on different compose files:
LIGHTRAG_BASE_URL=http://host.docker.internal:9621 # ✅ correctn8n cannot connect to the MCP server
Verify the MCP server is running:
Invoke-RestMethod http://localhost:3000/healthCheck the SSE URL in your n8n MCP credential
If n8n is in Docker and MCP server is on the host, use
http://host.docker.internal:3000/sseIf both are in Docker on the same network, use
http://lightrag-mcp:3000/sse
Tools return "Request timed out"
LightRAG operations (especially document insertion with LLM extraction) can take several minutes.
# .env — increase timeout to 5 minutes
LIGHTRAG_TIMEOUT=300000Documents stuck in PENDING or PROCESSING
# Use lightrag_get_pipeline_status to see what's happening
# Then try lightrag_reprocess_failed to retry stuck documents"Session not found" on POST /messages
The SSE session expired. The MCP client needs to reconnect to /sse first. This is handled automatically by most MCP clients.
TypeScript build errors
# Clean and rebuild
npm run clean
npm run build
# Check for type errors
npm run typecheckLicense
MIT
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/nailmailster/lightrag-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server