GraphRAG MCP
A local-first MCP server that transforms crypto whitepapers into a knowledge graph and vector corpus, enabling entity-filtered RAG question answering with optional knowledge graph enrichment.
README
🧠 GraphRAG MCP
Entity-centric Retrieval-Augmented Generation for Crypto Whitepapers
Local-first • Private • FastMCP-ready

<!-- Badges -->
1️⃣ ✨ Overview
GraphRAG MCP is a modular, local-first system that turns crypto whitepapers into an entity-centric Knowledge Graph and a vector-searchable corpus, then answers questions with RAG + optional KG enrichment + LLM synthesis — all via standardized FastMCP tools.
Why this project?
- 🛡️ Privacy by default: runs entirely on your machine (Ollama, Chroma, GraphDB).
- ⚡ Fast & focused: entity-filtered retrieval narrows context to the right tokens/protocols.
- 🧩 Composable: exposes
rag.*andkg.*tools so an MCP Coordinator or Streamlit app can orchestrate multi-tool workflows. - 🧠 Explainable answers: returns citations with doc/chunk/entity IDs for every response.
🔁 Typical usage
- Ingest and label whitepapers → build embeddings and insert entities.
- Ask questions via
rag.qa(semantic + entity-filtered retrieval), optionally enrich with KG labels/aliases. - Get concise LLM answers with inline citations to source chunks.
2️⃣ Features
🧩 Knowledge Graph (KG)
- Entity-only architecture using RDF/OWL ontologies (
mcp-core.ttl,mcp-crypto.ttl). - Built on Ontotext GraphDB 11+ with SHACL validation and SPARQL/GraphQL endpoints.
- Stores canonical entities such as tokens, protocols, components, and organizations.
- Enables KG enrichment for RAG answers via aliases, labels, and relationships.
🔍 Vector Retrieval (RAG)
- ChromaDB acts as the persistent vector store for chunk embeddings.
- Embeddings generated using Ollama’s
nomic-embed-textmodel. - Supports semantic and entity-filtered retrieval modes for accurate context fetching.
- Each chunk contains structured metadata:
doc_id,chunk_id,entity_ids,section_type, andpage.
🧠 Local LLM Inference
- Uses Ollama for fully local inference — no external API keys required.
- Compatible with models like
llama3.1:latest,qwen2.5:14b-instruct, ormistral. - Performs labeling, summarization, and final QA synthesis.
- Includes deterministic mock mode for offline testing and CI.
⚙️ FastMCP Servers
- Two modular servers expose tools via FastMCP 2.x:
rag→rag.search,rag.embed_and_index,rag.reindex,rag.delete,rag.health,rag.qakg→sparql_query,sparql_update,push_labels,validate_labels,list_documents,kg.health
- Both run locally via stdio and are MCP-Coordinator compatible.
🔒 Privacy & Portability
- 100% offline operation — suitable for air-gapped or research environments.
- Reproducible local stack (GraphDB + Chroma + Ollama + FastMCP).
- Works seamlessly on Windows 11, macOS, or Linux.
🚀 Integration Ready
- Plug-and-play with MCP Coordinators or Streamlit apps for end-user Q&A.
- Can interoperate with other MCPs such as:
- Brave API MCP (web search)
- MongoDB MCP (strategy data)
- Telegram MCP (messaging)
- Gmail MCP (email retrieval)
- Returns clean JSON outputs for easy chaining into agentic workflows.
3️⃣ 🏗️ Architecture
The GraphRAG MCP architecture combines Knowledge Graph reasoning, Vector-based retrieval, and Local LLM synthesis — all under the MCP interoperability standard.
It’s designed for clarity, privacy, and modular scalability.
🧭 High-Level Overview
| Layer | Technology | Purpose | Example Components |
|---|---|---|---|
| 🗂 Ingestion Layer | Python + LangChain | Reads PDFs, splits into semantic chunks, labels with LLMs | pdf_reader.py, semantic_splitter.py, llm_chunk_tagger.py |
| 🧩 Knowledge Graph Layer (KG) | GraphDB (Ontotext) + RDFLib | Stores canonical entities (tokens, protocols, organizations) | graphdb_sink.py, namespaces.py, SHACL shapes |
| 💾 Vector Retrieval Layer (RAG) | ChromaDB + Ollama embeddings | Stores text chunks + metadata + embeddings for semantic retrieval | chroma_store.py, .chroma/ |
| ⚙️ MCP Layer | FastMCP 2.x | Exposes standardized MCP tools (rag.*, kg.*) |
rag_server.py, kg_server.py |
| 🧠 LLM Synthesis Layer | Ollama LLMs (llama3.1, qwen2.5) |
Answers questions with retrieved context + KG enrichment | rag.qa, llm_chunk_tagger |
| 💬 User Interface Layer | MCP Coordinator / Streamlit | Connects multiple MCPs for conversational Q&A | Coordinator UI or custom Streamlit dashboard |
🔹 Data Flow Diagram
┌────────────────────────────────────────┐
│ Whitepapers │
│ (PDFs, research papers, documentation) │
└───────────────────┬────────────────────┘
│
▼
┌─────────────────────────────────────────────┐
│ 📄 Ingestion & Labeling │
│ pdf_reader → semantic_splitter → │
│ llm_chunk_tagger → postprocess │
└───────────────────┬─────────────────────────┘
│
┌────────┴────────┐
│ │
▼ ▼
┌────────────────┐ ┌──────────────────────┐
│ 🧠 GraphDB KG │ │ 💾 Chroma RAG │
│ Entities & IRIs │ │ Chunks + Embeddings │
└────────┬────────┘ └────────┬────────────┘
│ │
▼ ▼
┌───────────────┐ ┌───────────────┐
│ ⚙️ kg_server │ │ ⚙️ rag_server │
│ (FastMCP) │ │ (FastMCP) │
└────────┬──────┘ └──────┬────────┘
│ │
└────────┬───────────┘
▼
┌────────────────────────────────┐
│ 💬 MCP Coordinator / Streamlit │
│ User-facing Q&A Interface │
└────────────────────────────────┘
🧠 How It Works (Step-by-Step)
| Step | Description | Input | Output |
|---|---|---|---|
| 1️⃣ | PDF Parsing | Whitepaper PDF | Raw text pages |
| 2️⃣ | Semantic Splitting | Raw text | Meaningful chunks (by section/topic) |
| 3️⃣ | LLM Labeling | Chunk text | Entities, relations, and section labels |
| 4️⃣ | Postprocessing | Labeled chunks | Cleaned JSONL with canonical entity IRIs |
| 5️⃣ | Indexing | JSONL labels | Chroma embeddings + KG triples |
| 6️⃣ | Retrieval (rag.search) | Query text / entities | Relevant chunks |
| 7️⃣ | Enrichment (optional) | Retrieved entities | KG aliases, definitions |
| 8️⃣ | Answer Synthesis (rag.qa) | Question + context | Concise answer with citations |
🌐 Data Modalities
| Data Type | Storage | Example |
|---|---|---|
| 🧱 Entity | GraphDB | <https://kg.mcp.ai/id/token/bitcoin> → rdf:type crypto:Token |
| 📜 Chunk | Chroma | “Bitcoin is a peer-to-peer electronic cash system…” |
| 🧩 Embedding | Chroma / Ollama | 768-dim nomic-embed-text vector |
| 🧮 Provenance | Metadata | doc_id, chunk_id, page, entity_ids[] |
| 💬 Answer | MCP JSON | { "answer": "...", "citations": [...] } |
🧱 Core MCP Tools
| Server | Tool | Description |
|---|---|---|
| 🧩 RAG | rag.search |
Semantic search over chunks |
rag.embed_and_index |
Add new labeled chunks to index | |
rag.reindex |
Rebuild from outputs directory | |
rag.delete |
Delete by IDs or filters | |
rag.qa |
Question answering with LLM synthesis | |
rag.health |
Diagnostics and store info | |
| 🧠 KG | sparql_query / sparql_update |
Execute SPARQL against GraphDB |
push_labels / validate_labels |
Add or validate KG entries | |
list_documents, get_chunk |
Retrieve document metadata | |
kg.health |
Check GraphDB repository status |
4️⃣ ⚙️ Installation & Setup
Set up your local GraphRAG MCP environment in just a few steps!
This stack runs fully offline and integrates seamlessly with Ollama, GraphDB, and Chroma.
🧾 Prerequisites
| Requirement | Description | Example |
|---|---|---|
| 🐍 Python | Version 3.11+ recommended | python --version → Python 3.11.8 |
| 🧠 Ollama | Local LLM runtime (for inference + embeddings) | ollama pull llama3.1:latest |
| 🧩 GraphDB Desktop 11+ | Local Knowledge Graph database | runs at http://localhost:7200 |
| 💾 ChromaDB | Vector store for embeddings | auto-initialized under .chroma/ |
| 🧰 FastMCP | Multi-Component Platform runtime (2.x) | installed via pip |
🧱 Folder Layout (simplified)
| Folder | Purpose | Example Contents |
|---|---|---|
src/ |
Core codebase | pipeline.py, mcp/, kg/, rag/ |
outputs/run_simple/ |
Generated outputs | labeled chunks, reports, embeddings |
.chroma/ |
Chroma persistent vector store | chroma.sqlite3, index/ |
.env |
Environment configuration | Ollama, GraphDB, Chroma settings |
tests/ |
Offline unit tests | test_rag_qa.py, test_kg_server.py |
🧰 Step-by-Step Setup
🪄 1️⃣ Clone & Create Virtual Environment
git clone https://github.com/Swissbit92/GraphDB_Desktop.git
⚡ 2️⃣ Activate Environment
| OS | Command |
|---|---|
| 🪟 Windows (PowerShell) | .venv\Scripts\activate |
| 🐧 Linux / macOS | source .venv/bin/activate |
📦 3️⃣ Install Dependencies
pip install -r requirements.txt
⚙️ 4️⃣ Verify Installation
python -m src.mcp.rag_server --list-tools
python -m src.mcp.kg_server --list-tools
✅ You should see tools like rag.qa, rag.search, and kg.health.
🧠 Optional: Preload Ollama Models
| Model | Purpose | Pull Command |
|---|---|---|
| 🦙 llama3.1:latest | Default reasoning + summarization model | ollama pull llama3.1:latest |
| 🧩 nomic-embed-text | Embedding model for RAG vectorization | ollama pull nomic-embed-text |
| 🤖 qwen2.5:14b-instruct | Larger model for complex QA tasks | ollama pull qwen2.5:14b-instruct |
🔍 Quick Sanity Check
Run a quick health diagnostic to ensure everything is configured correctly:
pytest -q
python -m src.mcp.rag_server --run-tool rag.health
python -m src.mcp.kg_server --run-tool kg.health
If both return ✅ OK, you’re ready to run the pipeline and start querying your Knowledge Graph + RAG system!
5️⃣ 🧪 How to Use & Test
📥 Ingest Whitepapers & Build the Index
# Place your PDFs under .\whitepapers\ then run:
python -m src.pipeline --input ".\whitepapers\*.pdf"
✅ Outputs:
- Labeled JSONL →
outputs\run_simple\labels\ - Chroma index →
.chroma\ - (If enabled) Entities pushed to GraphDB repository
mcp_kg
🖧 Start the MCP Servers (RAG + KG)
# Terminal A
python -m src.mcp.rag_server
# Terminal B
python -m src.mcp.kg_server
💡 Tip: In another PowerShell window, confirm the tools are available:
python -m src.mcp.rag_server --list-tools
python -m src.mcp.kg_server --list-tools
🔎 Quick Retrieval Check (RAG)
# Example: semantic search for "peer-to-peer electronic cash"
python -m src.mcp.rag_server --run-tool rag.search --input '{ "text": "peer-to-peer electronic cash", "k": 3 }'
You should see matching chunks with doc_id, chunk_id, and distances.
❓ Ask Questions with Citations (rag.qa)
# Fully offline (deterministic mock answer)
python -m src.mcp.rag_server --run-tool rag.qa --input '{ "question": "What problem does Bitcoin aim to solve?", "k": 5, "kg_enrich": true, "use_mock_llm": true }'
➡️ Returns:
answer: concise response (mock or LLM)citations:[ {doc_id, chunk_id, entity_ids, text} ]took_ms,model_used
Switch to real LLM synthesis by omitting use_mock_llm (requires Ollama running).
🧠 Optional: Entity-Filtered QA
python -m src.mcp.rag_server --run-tool rag.qa --input '{ "question": "How does proof-of-work secure the network?", "entity_ids": ["https://kg.mcp.ai/id/token/bitcoin"], "k": 5, "kg_enrich": true, "use_mock_llm": true }'
This restricts retrieval to chunks tagged with the specified KG entity(ies).
🧪 Run the Test Suite
pytest -q
Key tests (all offline):
tests\test_rag_qa.py: verifies retrieval normalization and mock LLM modetests\test_kg_server.py: checks KG connectivity (skips if GraphDB not running)
🩺 Health Checks
python -m src.mcp.rag_server --run-tool rag.health
python -m src.mcp.kg_server --run-tool kg.health
Expect collection info, document counts, and OK status.
🧩 MCP Coordinator / UI Hookup (Optional)
Ensure your mcp.json references the running servers:
{
"mcpServers": {
"rag": { "command": "python", "args": ["-m", "src.mcp.rag_server"] },
"kg": { "command": "python", "args": ["-m", "src.mcp.kg_server"] }
}
}
Then connect via your MCP Coordinator or Streamlit app to interactively call rag.qa and kg.* tools.
🙏 Closing Words
GraphRAG MCP is part of the broader Eeva AI ecosystem — an open, modular framework for intelligent crypto research and strategy generation.
This project wouldn’t exist without the incredible open-source community that continues to push the boundaries of local AI and knowledge engineering.
If you find this useful:
- ⭐ Star the repository to support ongoing development
- 🧩 Contribute improvements or new MCP modules
- 🧠 Explore integrations with other MCPs (Brave API, MongoDB, Telegram, etc.)
- 💬 Share feedback — every suggestion helps make the system smarter, faster, and more reliable
“Knowledge is only powerful when it’s connected.”
— Eeva AI Research
Thank you for being part of the open-source journey. 🚀
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。