Context Catalog MCP

Context Catalog MCP

Exposes schema, lineage, and data-quality trust signals from a SQLite-backed catalog as MCP tools, enabling AI agents to answer grounded questions about datasets without hallucinating.

Category
访问服务器

README

ShopSense — AI Shopping Assistant (RAG + MCP Agent)

A grounded shopping assistant: hybrid (RAG-style) product search, stock-aware recommendations, and honest reviews/pricing — exposed as an MCP server so any agent can use it without guessing.

Why this project exists

I wanted a project in a domain I actually care about (e-commerce), built with the same rigor real AI infrastructure needs: retrieval, grounding, and honest refusal when the data doesn't support an answer.

A shopping agent that confidently recommends an out-of-stock product, states a stale price as current, or invents a star rating is worse than useless — it actively misleads a buyer. This project treats "can I trust this recommendation" as a first-class concern, not an afterthought:

  • Hybrid retrieval — BM25 + Vector Search + HNSW — every search runs two independent retrieval signals: BM25 (lexical/keyword ranking) and a TF-IDF vector looked up via an HNSW approximate-nearest-neighbour index (the same indexing approach real vector databases use), then combines and normalizes both into one ranked result. Not a single keyword match — a genuine hybrid RAG retrieval pipeline.
  • Structured tracing (Query → Retrieval → Ranking → Response) — every search is logged as a 4-stage trace, Langfuse-style: what was asked, every candidate considered with its BM25/vector scores, how they were ranked, and what was finally returned. Viewable live in the dashboard's Transaction Log.
  • Product lineage — "why was this recommended" — a dedicated explainability tool that traces a result back to the actual signals that surfaced it: matched keywords, stock status, and price freshness. Never a generic justification — grounded in the same data the search itself used.
  • Stock-aware grounding — every recommendation path checks real stock; an out-of-stock product is flagged, never silently recommended.
  • Price freshness — every product tracks when its price was last updated; stale prices (>30 days) are explicitly flagged, not presented as current.
  • Honest reviews — ratings are computed only from real review data. Zero reviews means zero reviews, never a fabricated rating.
  • Refuses to hallucinate — unknown product ids, empty search results, and missing data all return an explicit "not found" instead of an invented answer. Tested directly in the eval harness.

Why each layer exists (and what breaks without it)

Layer Why it exists What breaks without it
BM25 + Vector/HNSW hybrid search Catches both exact keywords and semantically-similar phrasing Keyword-only search misses loosely-worded queries; vector-only search misses precise matches
Structured tracing Makes every ranking decision auditable stage by stage No way to tell whether a bad result came from retrieval or ranking
Lineage / explainability Lets an agent justify why it recommended something A recommendation becomes an unexplainable black box
Stock check Separates "relevant" from "actually buyable right now" Agent recommends something the buyer can't actually purchase
Price freshness Tells the agent whether a price is safe to quote A 4-month-old price looks identical to today's price
Review grounding Prevents inventing social proof A fabricated "4.5 stars" is worse than saying "no reviews yet"
Eval harness Proves the refusal/grounding behavior actually works "Looks fine in the demo" with no evidence it holds up

How to run it

Requires Python 3.10+.

pip install -r requirements.txt
./run_demo.sh

This seeds the catalog, runs the eval harness (prints a pass/fail report), and runs the demo client showing 5 realistic shopping questions answered from real catalog data.

Run the web dashboard

python3 app.py

Then open http://localhost:5001 — a live "trust receipt" UI where you can search the catalog and see each result stamped in real time (VERIFIED · IN STOCK / VOID · OUT OF STOCK), click any product for its full trust breakdown (price freshness, honest reviews, and a "Why this result?" lineage explanation), plus "Run Eval Harness" and "View Recent Tool Calls" buttons that execute the real eval suite and structured trace log live in the browser. This is the same catalog_core logic underneath — the UI is just a window into it, nothing is reimplemented or faked.

Run the real MCP server

python3 catalog_server.py

Connect it to Claude Desktop by adding to your MCP config:

{
  "mcpServers": {
    "shopsense": {
      "command": "python3",
      "args": ["/absolute/path/to/catalog_server.py"]
    }
  }
}

Try the live LLM agent (optional)

export ANTHROPIC_API_KEY=sk-ant-...
python3 agent_demo.py "recommend a lightweight gaming laptop under 50000"

Eval results

12/12 passed  (100.0% accuracy)   — eval_harness.py (live demo harness)
17/17 passed                       — pytest tests/ (isolated CI-style suite)

Covers correct search ranking and price filtering, AND explicit refusal behavior: unknown products, out-of-stock recommendations, stale prices, missing descriptions, and zero-review products are all handled honestly instead of guessed. tests/ uses pytest fixtures with a fresh isolated database per test — no shared state between tests, unlike the flat demo-harness script.

Honest trade-offs

This project makes deliberate simplifications (TF-IDF instead of neural embeddings, HNSW at a tiny catalog scale, custom tracing instead of a real observability vendor) to stay fully offline and reviewable in minutes. Every one of those trade-offs, and what a production version would do differently, is written up in DESIGN_DECISIONS.md.

Tech stack

Python, SQLite, rank-bm25 + scikit-learn (TF-IDF) + hnswlib (hybrid retrieval), Flask (web dashboard), the official mcp SDK, Anthropic API (optional, for the live agent demo). Runs fully offline except for the optional agent demo and web fonts.

推荐服务器

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 模型以安全和受控的方式获取实时的网络信息。

官方
精选