Skip to main content

Minimal, honest RAG-over-a-corpus MCP retrieval tool: search_knowledge(query, k) -> cited chunks. Local embeddings + embedded vector store. Auth-scoped, fail-soft, version-pinned.

Project description


title: rag-mcp type: project-readme tags: [rag, retrieval, embeddings, mcp]

rag-mcp

CI

A minimal, honest RAG-over-a-corpus MCP retrieval tool. One tool, search_knowledge(query, k), that embeds a query, vector-searches a local corpus, and returns passages with citations (source + heading + chunk index) so answers are traceable.

Built to slot into the mcp-factory manifest model. Fully local + $0 (no paid embedding API).

Why it's safe to put in front of a real corpus

  • Cited - every hit carries source + heading + chunk_index.
  • Auth-scoped - results are confined to the configured corpus root; sources that escape it (absolute paths, .. traversal) are refused.
  • Fail-soft - a down or empty store returns a structured error, never an exception that crashes the calling agent.
  • Bounded - k is clamped to [1, 20]; empty queries are rejected.
  • Version-pinned deps (requirements.txt).

Stack

Layer Choice
Embeddings local ONNX all-MiniLM-L6-v2 (384-dim, CPU, $0) -- default. bge-large-en-v1.5 (1024-dim, 512-token context) available opt-in via RAG_MCP_EMBEDDER=bge; see CUTOVER.md.
Vector store ChromaDB embedded PersistentClient (zero-infra)
Server mcp Python SDK, stdio transport

Quick start

python -m venv .venv && .venv/Scripts/python -m pip install -r requirements.txt

# Ingest a corpus (markdown)
python -m rag_mcp.cli ingest path/to/docs --db ./store.chroma

# One-off query (corpus root = the auth scope)
python -m rag_mcp.cli query "your question" --db ./store.chroma --corpus path/to/docs -k 5

# Run as an MCP server (stdio); configure via env first
#   RAG_MCP_CORPUS_ROOT, RAG_MCP_DB_PATH, RAG_MCP_COLLECTION, RAG_MCP_EMBEDDER
python run_server.py        # operational entrypoint (referenced by mcp.yaml)
python -m rag_mcp           # same server, via the packaged console entry point
rag-mcp                     # after `pip install jaimenbell-rag-mcp` -- console script

As an MCP server

Register via mcp.yaml (validated against mcp-factory's Manifest loader). The tool is search_knowledge(query, k); it reads the store configured by the RAG_MCP_* env vars.

Tests

python -m pytest        # 68 passed

Layout

rag_mcp/
  chunking.py   heading-scoped, overlapping markdown chunks
  store.py      VectorStore (Chroma) + Embedder protocol (MiniLM default + BgeEmbedder opt-in + offline HashEmbedder)
  ingest.py     idempotent ingest pipeline with source/heading/chunk-index metadata
  search.py     search_knowledge: cited, auth-scoped, fail-soft, bounded
  server.py     MCP stdio server exposing search_knowledge
  config.py     env-driven Config
  cli.py        ingest + query CLI
  __main__.py   console entrypoint (`python -m rag_mcp` / `rag-mcp` script); fails loud on missing config
run_server.py   operational MCP entrypoint (referenced by mcp.yaml)
mcp.yaml        manifest (mcp-factory model)

mcp-name: io.github.jaimenbell/rag-mcp

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jaimenbell_rag_mcp-0.1.0.tar.gz (29.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jaimenbell_rag_mcp-0.1.0-py3-none-any.whl (22.0 kB view details)

Uploaded Python 3

File details

Details for the file jaimenbell_rag_mcp-0.1.0.tar.gz.

File metadata

  • Download URL: jaimenbell_rag_mcp-0.1.0.tar.gz
  • Upload date:
  • Size: 29.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for jaimenbell_rag_mcp-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6e51259925e5668d323f3eb7eaa2e4d773e4666321f73993dff5168e88462d9f
MD5 3d5c0bc9881c4d1bb98f771758e7fbdc
BLAKE2b-256 948c3f2b25955486c5ef5951e3078fe37b24079dc428ebae1079a607f6eedd9d

See more details on using hashes here.

File details

Details for the file jaimenbell_rag_mcp-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for jaimenbell_rag_mcp-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 38ec8f66150e728d710264c79a7a986e04c6d454b6cabc4779fbd30536edd292
MD5 e5d11ff0315462b1097336456dc16b60
BLAKE2b-256 abea803488dd38aaa7a2f5e4958a603bbc8b7f8de2e3398ac54ed785e8b91f9b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page