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
Visit Server

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.

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured