Provenance-Aware Retrieval MCP Server

Provenance-Aware Retrieval MCP Server

Exposes a provenance-aware knowledge graph to AI agents over MCP, providing tools like get_fact and search_documents that return precise answers with source citations.

Category
访问服务器

README

Provenance-aware retrieval for enterprise AI agents

A small, self-contained study comparing two ways of giving an AI agent access to enterprise knowledge, and showing how they behave as the knowledge base grows.

Scope, stated honestly: this is a self-directed proof of concept built to understand a trade-off, not a benchmark or a finished research system. See Limitations below.

The question

When an agent retrieves knowledge to answer a question, does a provenance-aware knowledge graph give more traceable, auditable answers than plain vector retrieval, and how does that hold up as the knowledge base scales?

Two retrieval methods run over the same corpus:

  1. Knowledge graph (RDF + SPARQL) where every fact carries provenance (source document, retrieval date, license).
  2. Vector retrieval (TF-IDF) over the same documents.

The knowledge base spans two domains that grew additively: semantic-web standards (RDF, SPARQL, OWL, knowledge graphs, linked data, DBpedia) and the Solar System (the Sun and eight planets, with moons and orbits). Every fact is derived from a cited Wikipedia article (data/LICENSE-DATA.md). There is no LLM in the pipeline; both methods are deterministic and run locally with no API keys.

The same graph is also exposed to AI agents over MCP and can be explored as an interactive, provenance-coloured graph.

Findings

Evaluated on 15 questions across both domains (12 answerable, 3 unanswerable):

Metric Knowledge graph Vector (TF-IDF)
Answer correct 15/15 11/15
Correct source cited 12/12 8/12
Abstained on unanswerable 3/3 2/3

The graph returns a typed, exact answer with the exact source document, its URL, and retrieval date. Vector retrieval returns a passage that must still be read to extract the answer, and it showed two weaknesses that got worse as the knowledge base grew:

  • Vocabulary collisions at scale. Once a second domain was added, common words ("moon", "Sun", "planet") appear across many documents, so TF-IDF ranks the wrong source first, and it misses on simple form mismatches (query "moon" vs text "moons"), because it matches words, not meaning.
  • Weaker abstention. For a question whose topic is in the corpus but whose answer is not ("How many people live on Mars?"), the vector method fails to abstain, while the graph cleanly returns nothing.

So the graph's advantage is in precision and traceability, and it widens as the knowledge base scales, which is the property that matters for a governed enterprise knowledge base.

How it fits together

One provenance-aware core, with several faces:

  • Core: the corpus, curated facts, and src/build_graph.py, which builds an RDF dataset where each document's facts live in a named graph tied to its provenance.
  • Research face: src/evaluate.py compares graph vs vector and writes the results.
  • Human face: src/visualize.py renders the graph as an interactive network, coloured by source, hover any edge for its provenance.
  • Agent face: src/mcp_server.py serves the knowledge to agents over MCP, so an agent gets answers with provenance attached.

Screenshots

Interactive knowledge graph (edges coloured by source document; hover for provenance):

Knowledge graph visualiser

Live MCP call in the MCP Inspector: an agent-style client calls get_fact and receives a sourced, machine-readable answer:

MCP Inspector call MCP Inspector call

Running it

Tested on Windows 10/11 with Python 3.10. From the project folder:

# 1. install dependencies
pip install -r requirements.txt

# 2. grow the knowledge base with the solar-system domain (run once)
python scripts/add_solar_system.py

# 3. build the graph and run a traceable SPARQL query
python src/build_graph.py

# 4. run the vector-retrieval demo
python src/build_vectors.py

# 5. compare both methods across all questions -> writes results/
python src/evaluate.py

# 6. build the interactive graph -> open results/graph.html in a browser
python src/visualize.py

Serving it to an agent over MCP

# start the MCP server (Ctrl+C to stop); it waits for a client to connect
python src/mcp_server.py

To watch a client call it live in the MCP Inspector (needs Node.js):

# one-time: allow local scripts for your user (Windows PowerShell)
Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned

# launch the Inspector pointed at the server with plain python
npx.cmd @modelcontextprotocol/inspector python src/mcp_server.py

Open the http://localhost:6274?... link it prints, connect, open Tools, and call get_fact (e.g. subject Jupiter, predicate hasMoon) or search_documents.

Windows notes (things that tripped me up):

  • After installing Node.js, open a new terminal so node/npx are on PATH.
  • If npx reports "running scripts is disabled", run the Set-ExecutionPolicy line above, or call npx.cmd instead of npx.
  • If the Inspector's auto-command fails with "'uv' is not recognized", use the explicit npx.cmd @modelcontextprotocol/inspector python src/mcp_server.py form above (it uses plain python).

Layout

data/       corpus documents + provenance.json + data license
facts/      curated triples (facts.json) + evaluation questions (questions.json)
scripts/    add_solar_system.py (additive domain growth)
src/        build_graph.py, build_vectors.py, evaluate.py, visualize.py, mcp_server.py
docs/       images used in this README
results/    generated artifacts (graph.trig, comparison.csv, summary.md, graph.html)

Limitations / future work

  • TF-IDF is lexical (word overlap), not semantic embeddings; embeddings would recover some of the vector misses. A sentence-transformer backend is a natural next step.
  • The corpus is small; results are illustrative, not benchmarked.
  • The vector "answer found" check is a generous substring proxy, disclosed here.
  • The MCP tools were verified live in the Inspector; wiring into a full LLM host (e.g. an agent that autonomously decides to call them) is future work.

Data & license

Facts are concise summaries derived from the cited Wikipedia articles under CC BY-SA 4.0. See data/LICENSE-DATA.md and data/provenance.json.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选