Lightrag Mcp — independently scanned and version-tracked by SaferSkills.
SaferSkills independently audited Lightrag Mcp (Agent Skill) and scored it 100/100 (green). The audit ran 55 deterministic rules across Security, Supply Chain, Maintenance, Transparency, and Community; it found 0 high-severity and 0 lower-severity findings. The full rule-by-rule trace and per-finding evidence are below. Free, methodology-open.
Findings & checks · 0 flagged
Every scanned point with the score it earned and what moved between them.
First recorded scan — no prior version to compare against.
The primary manifest — the file an agent reads to learn what this artifact does.
Model Context Protocol (MCP) server for the LightRAG API — 30 tools covering queries, document management, knowledge graph operations, and server utilities.
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:
workspace parameter to target specific knowledge bases| Requirement | Version | Notes |
|---|---|---|
| Node.js | ≥ 18 | LTS recommended |
| npm | ≥ 9 | Comes with Node.js |
| LightRAG server | any | Must be running on localhost:9621 (or configured URL) |
| 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.
# From the devstral-mcp directory
npm installnpm run build# 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.
# 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 │
└──────────────────────────────────────────────────────┘# Check the MCP server itself
Invoke-RestMethod http://localhost:3000/health
# Verify it can reach LightRAG
Invoke-RestMethod http://localhost:3000/All settings can be set in .env or as environment variables. Environment variables always take priority over .env.
| Variable | Default | Description |
|---|---|---|
LIGHTRAG_BASE_URL | http://localhost:9621 | LightRAG server URL (no trailing slash) |
LIGHTRAG_API_KEY | (empty) | API key for LightRAG. Leave empty if auth is disabled (default for local installs) |
LIGHTRAG_TIMEOUT | 30000 | HTTP request timeout in milliseconds |
LIGHTRAG_DEFAULT_WORKSPACE | (empty) | Default workspace. Empty = server default |
MCP_TRANSPORT | http | Transport mode: http or stdio |
MCP_HOST | 0.0.0.0 | Bind host for HTTP transport |
MCP_PORT | 3000 | Port for HTTP+SSE transport |
LOG_LEVEL | info | Log verbosity: error, warn, info, debug |
The transport can also be set via CLI flag, which takes highest priority:
node dist/index.js --transport http
node dist/index.js --transport stdio| # | Tool name | Description |
|---|---|---|
| 1 | lightrag_query | Query the knowledge base and get an LLM-generated answer. Supports all retrieval modes. |
| 2 | lightrag_query_stream | Same as above but uses the /query/stream endpoint (different server code path). |
| 3 | lightrag_query_data | Returns raw retrieval data (entities, relationships, chunks) without LLM generation. |
Query modes (all query tools accept a mode parameter):
| Mode | Description |
|---|---|
mix | ⭐ Recommended — combines knowledge graph with vector search |
local | Focuses on specific entities and their direct relationships |
global | Analyses broad relationship patterns across the whole graph |
hybrid | Combines local + global strategies |
naive | Plain vector similarity search, no knowledge graph |
bypass | Direct LLM call, no retrieval at all |
| # | Tool name | Description |
|---|---|---|
| 4 | lightrag_insert_text | Insert a single text string into the knowledge base |
| 5 | lightrag_insert_texts | Insert multiple texts in one request (batch) |
| 6 | lightrag_scan_documents | Trigger a scan of the server's input directory for new files |
| 7 | lightrag_list_documents | List all documents grouped by status (up to 1000) |
| 8 | lightrag_get_documents_paginated | Paginated document list with filtering and sorting |
| 9 | lightrag_get_document_status_counts | Quick count summary: PROCESSED / PENDING / FAILED / etc. |
| 10 | lightrag_get_track_status | Check indexing progress using a track_id |
| 11 | lightrag_delete_documents | Delete documents by ID (async, with optional file/cache deletion) |
| 12 | lightrag_delete_entity | Remove an entity node from the knowledge graph |
| 13 | lightrag_delete_relation | Remove a relationship edge from the knowledge graph |
| 14 | lightrag_clear_all_documents | ⚠️ Wipe everything — all documents, entities, vectors |
| 15 | lightrag_get_pipeline_status | Monitor the document processing pipeline (busy/idle, progress) |
| 16 | lightrag_cancel_pipeline | Request graceful cancellation of the running pipeline |
| 17 | lightrag_reprocess_failed | Retry documents stuck in FAILED or PENDING state |
| 18 | lightrag_clear_cache | 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 questions| # | Tool name | Description |
|---|---|---|
| 19 | lightrag_get_graph_labels | List all entity names in the knowledge graph |
| 20 | lightrag_get_popular_labels | Get the most-connected entities (sorted by degree) |
| 21 | lightrag_search_labels | Fuzzy search for entity names |
| 22 | lightrag_get_knowledge_graph | Get a subgraph around a specific entity (nodes + edges) |
| 23 | lightrag_check_entity_exists | Check if an entity with a given name exists |
| 24 | lightrag_create_entity | Manually create a new entity node |
| 25 | lightrag_edit_entity | Update entity properties, rename, or merge with another entity |
| 26 | lightrag_create_relation | Create a relationship between two existing entities |
| 27 | lightrag_edit_relation | Update relationship properties |
| 28 | lightrag_merge_entities | Consolidate duplicate entities, transferring all relationships |
| # | Tool name | Description |
|---|---|---|
| 29 | lightrag_health_check | Full server health: version, LLM config, storage backends, pipeline state |
| 30 | lightrag_get_auth_status | Authentication configuration status |
The default mode. Starts an Express server with two endpoints:
| Endpoint | Method | Purpose |
|---|---|---|
/sse | GET | MCP client connects here to open an SSE session |
/messages | POST | MCP client sends tool call requests |
/health | GET | Liveness check (no auth required) |
/ | GET | Server info |
npm run start:http
# or
npm start # same thingUsed when the MCP client spawns this process as a child and communicates via stdin/stdout.
npm run start:stdionpm run start:http
# MCP server now listening at http://localhost:3000/sseOr via Docker (see Docker Daemon section).
http://localhost:3000/ssehttp://lightrag-mcp:3000/ssehttp://host.docker.internal:3000/ssen8n/lightrag-workflow.json from this projectOpen the chat in n8n and try:
lightrag_health_checklightrag_get_document_status_countslightrag_query| Scenario | LIGHTRAG_BASE_URL | n8n MCP SSE URL |
|---|---|---|
| Everything on host machine | http://localhost:9621 | http://localhost:3000/sse |
| MCP in Docker, LightRAG on host | http://host.docker.internal:9621 | http://localhost:3000/sse |
| Everything in Docker (same network) | http://lightrag:9621 | http://lightrag-mcp:3000/sse |
Running the MCP server in Docker keeps it alive even after closing the terminal window. It will restart automatically after crashes or host reboots.
# From the devstral-mcp directory
docker compose -f docker/docker-compose.yml up -d --build# 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 --buildrestart: 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-killingCreate 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=infoLightRAG supports multiple isolated knowledge bases called workspaces. All 30 tools accept an optional workspace parameter.
How it works:
workspace is provided in a tool call, the MCP server sends it as the LIGHTRAG-WORKSPACE HTTP header to LightRAG[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 collectionSet 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.
To use this MCP server with Claude Desktop or Zed, use stdio transport.
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": ""
}
}
}
}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.
# 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 cleandevstral-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.mdThe 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 # ✅ correctInvoke-RestMethod http://localhost:3000/healthhttp://host.docker.internal:3000/ssehttp://lightrag-mcp:3000/sseLightRAG operations (especially document insertion with LLM extraction) can take several minutes.
# .env — increase timeout to 5 minutes
LIGHTRAG_TIMEOUT=300000# Use lightrag_get_pipeline_status to see what's happening
# Then try lightrag_reprocess_failed to retry stuck documentsThe SSE session expired. The MCP client needs to reconnect to /sse first. This is handled automatically by most MCP clients.
# Clean and rebuild
npm run clean
npm run build
# Check for type errors
npm run typecheckMIT
~30 seconds. Free. No account. Every finding cites a rule and a line of evidence.