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 MCPSearch for technical documentation on how the TMS module works"
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 tool — README
Summary
Tool name:
query_knowledge_base(registered asquery_knowledge_baseinlightrag_mcp.py)If you prefer the tool be named
lightrag_query, change the decorator to@mcp.tool("lightrag_query")inlightrag_mcp.py.
Description: Query the internal LightRAG knowledge base for technical documentation. Returns raw text or HTML from the LightRAG server.
Input schema: QueryInput { query: str, mode: str = 'hybrid' }
Output schema: QueryOutput { result: str }
Quick start (local)
Create and activate a virtualenv, then install dependencies:
(Or install packages individually: pip install modelcontextprotocol httpx pydantic python-dotenv)
Configure environment variables:
Copy the example env file and edit as needed:
Set a system prompt file (optional):
Run the MCP server:
Notes:
Default FastMCP port is 8000. To change the port, set it in code before
mcp.run():
FastMCP exposes streamable HTTP at
/mcp(default) and may expose SSE endpoints depending on transport.
Example: call the tool from Python (local test)
The call returns a QueryOutput-like structure; depending on transport the response may be a JSON string or an object containing response/result fields.
Test connectivity to LightRAG server (direct)
If you need to verify the upstream LightRAG service the MCP calls, you can test it directly (example):
This helps verify the configured LIGHTRAG_URL is reachable and responding.
Configuration and environment variables
The server looks for these values in order:
LIGHTRAG_SYSTEM_PROMPT— inline prompt (env var)LIGHTRAG_SYSTEM_PROMPT_FILE— path to a file containing the promptprompts/light_rag_system.txt— project default
Recommended .env entries (see .env.example):
Security note: Avoid committing sensitive prompts to the repository. Use a secrets manager for production.
Transport security and allowed hosts example
If the client (e.g., remote Claude) will connect to your MCP server, restrict allowed hosts in FastMCP settings. Example (add in lightrag_mcp.py before mcp.run()):
Adjust based on your deployment and transport configuration.
Registering the tool with clients
Claude Code (VSCode extension / local development)
Ensure the MCP server is running locally (e.g.,
http://localhost:8000).In the Claude Code extension (or your local client), add or point to the server origin and streamable path (usually
/mcp).The extension should detect registered tools; verify
query_knowledge_baseappears inmcp.list_tools().
Remote Claude clients (claude.ai)
Expose your local server using a secure tunnel (for testing) or deploy it to a publicly reachable HTTPS endpoint.
Example (temporary):
ngrok http 8000→ use the provided HTTPS URL
Configure transport settings and allowed hosts on the MCP server (see transport security example).
Provide the server URL to claude.ai or the remote client in its external tools configuration and confirm the transport type (streamable HTTP vs SSE).
Troubleshooting
Tool not visible in client:
Confirm the MCP server is running and reachable.
Verify
query_knowledge_baseappears inmcp.list_tools().Ensure client and server use the same transport (streamable HTTP or SSE).
Validation errors:
Client must send payload matching Pydantic input schema. When calling via the SDK or
mcp.call_tool, wrap the payload underinput.
Port already in use:
Set
mcp.settings.portto a free port before callingmcp.run().
Development notes
lightrag_mcp.pyregisters the tool asquery_knowledge_base. To rename the tool tolightrag_query, either:Change the decorator to
@mcp.tool("lightrag_query"), orUpdate README to reference
query_knowledge_base(current state).
A
requirements.txtfile is included with the minimal runtime dependencies. Pin versions if you need reproducible installs.
Contributing
PRs are welcome. Please avoid committing secrets or sensitive prompts. For changes that alter tool names or schemas, update README and tests accordingly.
License
MIT (or replace with your preferred license)