kassist
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
kassist: Agentic Engineering-Knowledge Assistant (MCP + RAG + Eval Harness)
An MCP server that answers questions over a corpus of internal engineering documents (runbooks, configs, ADRs, postmortems, ownership pages). It uses multi-query hybrid retrieval, reranking, an answer-grounding check that abstains instead of guessing, a fallback retrieval route, and ships with an automated evaluation-dataset pipeline, an ablation benchmark, fault injection, CI gates and Cloud Run deployment assets.
Components and runtime requirements
Component | Needs |
Core pipeline, MCP protocol core, stdio transport, eval harness, fault injection, benchmark | Python ≥ 3.10, |
HTTP server ( |
|
Vector engine |
|
Graph runtime | built-in |
Gemini / Vertex embeddings ( |
|
Query log ( |
|
Container / Cloud Run | Docker, |
Dashboards / alerts | Prometheus-compatible scraping of |
Latency in the benchmark tables = measured compute + modelled model-call time (kassist/llm.py::SIM_MEDIAN_MS); with KA_BACKEND=gemini
the same scripts record measured end-to-end latency.
Related MCP server: mcp-rag-bridge
Quickstart
pip install numpy scipy # core + benchmark need only these
python scripts/build_corpus.py # 3,000 docs + dev/test eval sets (deterministic)
python scripts/benchmark.py # ablation R0..R8, thresholds tuned on dev, scored on test
python scripts/fault_injection.py && python scripts/render_results.py
python -m unittest discover -s tests -q # or: pip install pytest && pytest
python -m kassist.mcp_stdio # MCP over stdio (Claude Desktop / any MCP client)
python scripts/dev_http.py # dev HTTP server on :8080 (no FastAPI needed)
pip install -r requirements.txt && uvicorn kassist.server:app --port 8080 # production serverClaude Desktop / MCP client config (stdio):
{"mcpServers": {"eng-docs": {"command": "python", "args": ["-m", "kassist.mcp_stdio"], "cwd": "/path/to/kassist-mcp"}}}Architecture
flowchart LR
C[MCP client<br/>Claude / IDE agent] -- "JSON-RPC: tools/call" --> S[Cloud Run: FastAPI /mcp<br/>McpServer core]
S --> G
subgraph G[Agentic RAG graph - LangGraph-compatible nodes]
A[analyze<br/>entity grounding] -->|unknown service| AB[abstain]
A --> EX[expand<br/>multi-query]
EX --> R[retrieve<br/>dense + BM25 + RRF]
R --> RR[rerank]
RR --> GR{grade<br/>confidence + grounding}
GR -->|ok| AN[answer + citation]
GR -->|low| FB[fallback<br/>entity-scoped sweep]
FB -->|ok| AN
FB -->|fail| AB
end
R <--> V[(Vector index<br/>FAISS / numpy)]
R <--> B[(BM25 sparse)]
EX -. Gemini .-> L[Vertex AI]
RR -. Gemini .-> L
AN -. Gemini .-> L
S -- query log --> F[(Firestore)]
S -- /metrics + JSON logs --> O[Prometheus / Grafana / Cloud Logging]Adaptive path. A cheap single-query first pass runs; only low-confidence queries escalate to multi-query + rerank (confidence-gated early exit). R8 additionally routes low-confidence queries about a known service straight to the deterministic entity-scoped sweep (no extra model calls), which requires clean entity metadata.
Offline / online parity. Every model-dependent stage has a deterministic offline implementation (hashing embedder, rule expander, lexical reranker, extractive generator) and a Gemini implementation behind the same interface, so the whole pipeline is testable and benchmarkable without credentials. Results from offline components do not predict absolute Gemini numbers; they measure the pipeline design (routing, grading, fallback, resilience).
MCP surface
Tool | Purpose |
| Cited answer or abstention, with confidence and route taken |
| Multi-query hybrid + rerank, no generation |
| Full document |
| Index size / engine |
Stateless (no session id), JSON responses over POST /mcp, optional X-MCP-Token and Origin allow-list; Cloud Run IAM recommended.
Results
Corpus: 3,000 docs / 485,872 words / 15,000 chunks (sha256 cb2a5d219bc9). Test set: 900 queries (held out; thresholds tuned on a disjoint 300-query dev split: tau=0.4, tau_hi=0.9).
Ablation (each row adds one capability)
Config | Success | 95% CI | Acc. (answerable) | Hallucination (unanswerable) | hit@5 | p50 ms | p95 ms | tokens/q |
R0 baseline (naive RAG) | 33.1% | 30.0%–36.1% | 39.7% | 100.0% | 46.4% | 850 | 1474 | 399 |
R1 +structure chunks w/ context prefix | 43.9% | 40.7%–47.1% | 52.7% | 100.0% | 60.1% | 852 | 1475 | 285 |
R2 +hybrid BM25 (RRF) | 50.4% | 47.1%–53.7% | 60.5% | 100.0% | 69.2% | 852 | 1475 | 296 |
R3 +multi-query | 48.3% | 45.1%–51.6% | 58.0% | 100.0% | 66.7% | 1243 | 1876 | 321 |
R4 +rerank | 65.3% | 62.0%–68.4% | 78.4% | 100.0% | 86.4% | 2028 | 2796 | 1249 |
R5 +grounding/abstain | 81.7% | 79.0%–84.2% | 78.0% | 0.0% | 86.4% | 1766 | 2716 | 1055 |
R6 +fallback route | 82.8% | 80.2%–85.2% | 79.3% | 0.0% | 85.1% | 1774 | 2717 | 1058 |
R7 +adaptive early-exit (full) | 82.8% | 80.2%–85.2% | 79.3% | 0.0% | 85.1% | 1620 | 2677 | 924 |
R8 +entity-routed fallback (needs metadata) | 81.9% | 79.3%–84.4% | 78.3% | 0.0% | 83.9% | 702 | 1438 | 187 |
Success = correct+cited answer (answerable) or abstention (unanswerable). Latency = measured compute + simulated model-call time.
Success by question category
Config | direct | gloss | hard | unans_fake | unans_missing |
R0 baseline (naive RAG) | 48.0% | 48.0% | 6.7% | 0.0% | 0.0% |
R1 +structure chunks w/ context prefix | 78.7% | 52.0% | 2.0% | 0.0% | 0.0% |
R2 +hybrid BM25 (RRF) | 90.0% | 60.0% | 2.7% | 0.0% | 0.0% |
R3 +multi-query | 81.3% | 62.7% | 2.0% | 0.0% | 0.0% |
R4 +rerank | 99.3% | 95.7% | 2.0% | 0.0% | 0.0% |
R5 +grounding/abstain | 99.3% | 95.7% | 0.0% | 100.0% | 100.0% |
R6 +fallback route | 99.7% | 98.7% | 0.0% | 100.0% | 100.0% |
R7 +adaptive early-exit (full) | 99.7% | 98.7% | 0.0% | 100.0% | 100.0% |
R8 +entity-routed fallback (needs metadata) | 100.0% | 95.7% | 0.0% | 100.0% | 100.0% |
Early-exit Pareto (test split; reported, not used for selection)
Variant | tau_hi | Success | mean ms | p50 ms | p95 ms | escalation |
R7 | 0.6 | 80.4% | 1099 | 1023 | 2238 | 38.9% |
R8 | 0.6 | 80.2% | 630 | 700 | 1435 | 0.0% |
R7 | 0.7 | 80.4% | 1099 | 1022 | 2242 | 38.9% |
R8 | 0.7 | 80.2% | 631 | 700 | 1437 | 0.0% |
R7 | 0.8 | 82.4% | 1296 | 1174 | 2521 | 54.8% |
R8 | 0.8 | 82.2% | 631 | 701 | 1435 | 0.0% |
R7 | 0.9 | 82.8% | 1566 | 1624 | 2679 | 77.7% |
R8 | 0.9 | 81.9% | 631 | 701 | 1437 | 0.0% |
R7 | 1.1 | 82.8% | 1725 | 1820 | 2764 | 91.7% |
R8 | 1.1 | 81.9% | 632 | 703 | 1438 | 0.0% |
Fault injection (embedder, expander and reranker each fail with probability p)
p(fail) | Pipeline | Success | Errors (HTTP-500 equivalent) | Degraded | p95 ms | Embedder calls |
0.0 | naive baseline (R0) | 33.1% | 0.0% | 0.0% | 1474 | 900 |
0.0 | full resilient (R7) | 82.8% | 0.0% | 0.0% | 2674 | 1524 |
0.1 | naive baseline (R0) | 30.2% | 9.9% | 0.0% | 1456 | 900 |
0.1 | full resilient (R7) | 82.7% | 0.0% | 26.1% | 2661 | 1524 |
0.3 | naive baseline (R0) | 24.3% | 28.1% | 0.0% | 1414 | 900 |
0.3 | full resilient (R7) | 81.0% | 0.0% | 77.4% | 2286 | 690 |
0.5 | naive baseline (R0) | 18.8% | 47.0% | 0.0% | 1294 | 900 |
0.5 | full resilient (R7) | 80.8% | 0.0% | 91.4% | 1954 | 28 |
1.0 | naive baseline (R0) | 0.0% | 100.0% | 0.0% | 106 | 900 |
1.0 | full resilient (R7) | 80.1% | 0.0% | 91.7% | 1343 | 5 |
Headline
Failure rate 66.9% → 17.2% (74.3% relative reduction); paired-bootstrap success gain 49.7% (95% CI 46.2%–53.0%).
Accuracy on answerable queries 39.7% → 79.3%; hallucination on unanswerable 100.0% → 0.0%.
p95 (modelled): baseline 1474 ms, always-on agentic 2717 ms, R7 2677 ms, R8 1438 ms (47.1% below always-on).
How to read this.
The corpus is synthetic with exact ground truth; absolute numbers are not claims about real corpora.
The
hardcategory (150 of 900 queries) are paraphrases outside the glossary that a lexical system cannot resolve. It caps achievable success at 83.3%; R7 reaches 82.8%. These are the cases an LLM generator/expander (the Gemini path) exists for. Baseline rows answer them wrongly; R5+ abstain, which counts as a failure for answerable questions but is the safe behaviour.R4→R5 gains partly reflect abstention on the 150 unanswerable queries, which naive RAG fails by construction. The "Acc. (answerable)" column separates retrieval gains (39.7% → 79.3%) from abstention gains.
Multi-query alone (R3) slightly hurts (50.4% → 48.3%): fusing rewritten queries dilutes the ranking until a reranker (R4) can use them. R3 and R4 should be read as one unit.
Early-exit (R7) barely moves p95 (−1.5% vs always-on) because the tail is the escalating queries; it lowers mean/p50 modestly. The big latency lever is R8's entity routing (p95 −47%, mean −62% vs always-on) at −0.9 pt success, but it relies on metadata that a real corpus may lack.
Thresholds (
tau,tau_hi) are tuned on the dev split only; the test split is touched once per row. CIs are bootstrap over queries.
Design decisions (and rejected alternatives)
Decision | Why | Rejected alternative |
Hand-rolled JSON-RPC MCP core over a transport-agnostic class | Testable without any dependency; identical logic for stdio + HTTP; stateless for Cloud Run scale-out | Official |
Stateless Streamable-HTTP-style ( | No sticky sessions; any instance serves any request | SSE/session transport: needed only for server-initiated messages, which this server does not send |
Hybrid dense + BM25 with Reciprocal Rank Fusion | Identifiers ( | Weighted score sum (needs calibration per corpus); dense-only (R0/R1 show the cost) |
Structure-aware chunks with | Fact sentences often say "it"; the entity lives in the title (+10.8 pt, R0→R1) | Fixed windows; LLM chunking everywhere (cost; kept as |
Graph of pure nodes ( | Same nodes run on my 40-line engine and on LangGraph; routers with side effects silently break on LangGraph | Direct LangGraph dependency in core: heavier tests, version churn |
Fail-closed entity grounding → abstain | Wrong confident answers about the wrong service are worse than "I don't know" | Always answer (baseline hallucinates on 100% of unanswerable); LLM self-assessed confidence only (not auditable, costs a call) |
Deterministic fallback = entity-scoped sweep (metadata filter) | Survives embedding misses; no model call; bounded cost | Fallback = "retry with bigger k" (same failure mode); web search (wrong domain) |
Stage guards + per-stage circuit breakers | Measured: total outage of all 3 dependencies → 0% errors, ~80% success | Retries with backoff in-request (amplifies load during incidents); fail-fast 500s |
Thresholds tuned on dev, reported on test, bootstrap CIs, paired difference | Avoids tuning-on-test; quantifies noise | Single-split point estimates |
Rule judge as ground truth + LLM judge with kappa agreement | Deterministic CI gate; LLM judge only where free-text answers need it | LLM-only judging (non-deterministic, costly, self-preference bias) |
Synthetic corpus with exact ground truth | Real internal docs can't be published; scale and labels are free | Public docs (no team-specific facts; no ground truth for abstention) |
In-process LRU cache | Zero infra | Redis/Memorystore: worthwhile at multi-instance scale, premature here |
Failure modes (known, observed or designed-against)
Failure | Behaviour | Mitigation / status |
Query names a service not in the corpus | Abstain ( | Fail-closed grounding with a regression test (a fake name sharing one word with the lexicon abstains). Residual: names sharing no tokens with the lexicon and not hyphenated are not recognised as entities |
Boilerplate sentence mimics a fact's concept (e.g. "accepted" in ADR boilerplate) | ~4% of confident first-pass answers are wrong | Documented; reranker/fallback reduce it; real fix is sentence-level cross-encoder or LLM verification |
Paraphrase outside the glossary | Lexical system abstains (R5+) / answers wrongly (R0–R4) | Gemini expander/generator path; reported separately as |
Embedding/Vertex outage | Degrades to BM25 + entity sweep | Fault-injected; breaker sheds load (900 → 5 embedder calls at p=1) |
LLM chunker returns garbage/drops text | Coverage check → deterministic structure chunker | Unit-tested |
Stale or conflicting docs (v1 vs v2) | Both versions are retrievable; the grader picks the best-supported sentence | Extension point: |
Prompt injection via document text | Extractive path is immune; Gemini path delimits passages as untrusted data ( | Output validation can be tightened per corpus trust level |
Entity metadata missing (R8 relies on it) | Use R7 ( | Config flag |
Firestore sink down | Logged, serving unaffected | Tested |
Question text in logs | Stored in Firestore by design | Set |
Production signals
Structured logging: JSON to stderr with
severity,request_id, routepath,outcome,total_ms, degraded stages (Cloud Logging format).Metrics (
/metrics, Prometheus text):ka_queries_total{outcome},ka_query_latency_mshistogram,ka_stage_failures_total{stage},ka_stage_skipped_total(breaker),ka_fallback_total{outcome},ka_cache_total,ka_mcp_requests_total,ka_mcp_latency_ms.Dashboard:
deploy/grafana/dashboard.json(8 panels). Alerts:deploy/alerts.yml(7 rules, each linked to a runbook section).Tests: 74 (unit, MCP conformance, stdio subprocess round-trip, fault tolerance, regression guard). CI: lint, tests on 3.11/3.12, benchmark regression gate (
scripts/check_regression.py), docker build + container smoke test. CD: tag-triggered deploy via Workload Identity Federation, rollback step.Runbook:
docs/runbook.md.
Configuration reference
All options are environment variables (full annotated list in .env.example; typed accessors in kassist/config.py::Settings).
Group | Variables (defaults) |
Backend |
|
Corpus/cache |
|
GCP |
|
Security |
|
Thresholds |
|
Time budgets (s) |
|
Retries / breakers |
|
Reporting |
|
Credentials needed for the Vertex-backed path (KA_BACKEND=gemini): a GCP project with the Vertex AI API enabled, Application Default
Credentials (gcloud auth application-default login locally; the attached service account on Cloud Run with roles/aiplatform.user),
GOOGLE_CLOUD_PROJECT, and for KA_SINK=firestore a Firestore (Native mode) database and roles/datastore.user. No code changes are required;
the same pipeline, tests-of-record and benchmark run against these components via kassist/factory.py.
Deploying to Cloud Run
export PROJECT=my-gcp-project REGION=us-central1
# once: service account with roles/aiplatform.user + roles/datastore.user named kassist-sa
./deploy/deploy.sh # private (IAM). Add --public for a demo URL
python scripts/loadtest.py "$URL" --n 500 --concurrency 16 # REAL latency under load
KA_BACKEND=gemini GOOGLE_CLOUD_PROJECT=$PROJECT python scripts/benchmark.py # real-model ablation, measured latency
KA_BACKEND=gemini GOOGLE_CLOUD_PROJECT=$PROJECT python scripts/judge_agreement.py # LLM-judge vs rule-judge kappaThen record the real numbers in results/ and replace the simulated-latency caveat. A screen recording of gcloud run deploy + smoke_test.py is an acceptable demo if the service must stay private.
Repo map
kassist/ core library (pipeline, kb, chunking, index, mcp_core, server, evals/) · scripts/ build/benchmark/fault/smoke/load ·
tests/ · deploy/ (deploy.sh, Grafana, alerts) · docs/ (runbook, write-up, dataset card, design notes) · data/eval/ released eval sets · results/ generated tables.
Roadmap checklist (spec items → where)
1 baseline & reproducible benchmark → scripts/benchmark.py, R0 row · 2 deploy → Dockerfile, deploy/deploy.sh, .github/workflows/deploy.yml ·
3 production signals → above · 4 scale → 3,000 docs / 15,000 chunks / 900+300 queries · 5 docs → this file ·
6 fault injection → scripts/fault_injection.py (the spec's Kafka/Paxos/routing wording is adapted to this system's dependencies: embedder, expander, reranker) ·
7 research artifacts → data/eval/, docs/DATASET_CARD.md, docs/writeup.md, ablation table · 8 iteration history → git log, tags, CHANGELOG.md, docs/ISSUES.md ·
9 collaboration → CONTRIBUTING.md, PR template, docs/COLLABORATION.md (review log) · 10 summary → below.
References
Cormack, Clarke & Büttcher, Reciprocal Rank Fusion outperforms Condorcet and individual rank learning methods, SIGIR 2009 · Robertson & Zaragoza, The Probabilistic Relevance Framework: BM25 and Beyond, FnTIR 2009 · Lewis et al., Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks, NeurIPS 2020 · Asai et al., Self-RAG, ICLR 2024 · Yan et al., Corrective Retrieval Augmented Generation (CRAG), 2024 · Liu et al., Lost in the Middle, TACL 2024 · Zheng et al., Judging LLM-as-a-Judge with MT-Bench and Chatbot Arena, NeurIPS 2023 · Es et al., RAGAS, 2023 · Johnson, Douze & Jégou, Billion-scale similarity search with GPUs (FAISS), 2019 · Anthropic, Introducing Contextual Retrieval, 2024 (context-prefix chunking) · Model Context Protocol specification (modelcontextprotocol.io) · Nygard, Release It! (circuit breaker). Verify citation details before publishing.
Results summary
Problem. Engineers lose time finding team-specific facts (ports, SLOs, on-call rotations, rollback tags, root causes) scattered over thousands of near-identical internal documents, and naive RAG over such corpora answers confidently from the wrong service.
Approach. An MCP server over an agentic RAG graph: entity-grounding check, multi-query hybrid retrieval (dense + BM25, RRF), reranking, a confidence gate that abstains, a deterministic entity-scoped fallback route, confidence-gated early exit, and stage-level circuit breakers. An automated dataset pipeline (5 question categories, dev/test split, rule + LLM judges) and an 8-step ablation quantify each piece.
Architecture. MCP client → Cloud Run (FastAPI /mcp, stateless) → LangGraph-compatible node graph → FAISS/numpy + BM25 → Gemini on Vertex AI (optional backend);
Firestore query log; Prometheus metrics, JSON logs, Grafana dashboard, alerts, runbook, GitHub Actions CI/CD.
Headline metric (3,000 docs / 15,000 chunks, 900 held-out queries, offline components, simulated model latency): query failure rate 66.9% → 17.2% (−74% relative; +49.7 pt success, paired-bootstrap 95% CI +46.2 to +53.0); accuracy on answerable questions 39.7% → 79.3%; hallucination on unanswerable questions 100% → 0%; with all three model dependencies down, the resilient pipeline still succeeds on 80.1% of queries with 0% errors (naive baseline: 0%). Modelled p95 latency: the always-on agentic pipeline costs +84% over baseline; entity-routed adaptive execution (R8) brings p95 to 1,435 ms (−47% vs always-on, −2.6% vs baseline) at −0.9 pt success. The residual 17% of failures is the held-out paraphrase category that needs an LLM.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Versioned documentation registry and semantic search for AI tools and coding assistants.
Governed, auditable knowledge your team curates for its AI assistants, self-hostable
Your company's brain for AI agents. Cited, permission-aware knowledge across every system.
Shared knowledge for teams and AI agents: search, brief, and record decisions with provenance.
Related MCP Servers
- FlicenseAqualityNot gradedmaintenanceExposes an internal engineering knowledge base to AI assistants, allowing users to search and retrieve standards, runbooks, and architecture decisions. It supports RAG-enhanced search, document scraping, and specialized prompts for incident investigation and code reviews.5-
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to query and manage a document knowledge base via MCP, with RAG-powered search and grounded answers with citations.MIT
- FlicenseNot gradedqualityDmaintenanceEnables natural-language retrieval from a self-hosted documentation index, returning cited answers with deep links, and supports private corpora inaccessible on the public internet.-
- FlicenseNot gradedqualityDmaintenanceEnables traceable, version-aware question answering over product documentation, combining vector and graph retrieval to return cited evidence and support agentic workflows.-