Skip to main content
Glama
kronvex-ai-rag

kronvex-ai-rag

Official
by KRONVEX

Why This Template Exists

Most AI starter kits stop at a single chat box calling one LLM SDK with zero retrieval grounding, zero prompt-injection defense, bloated MCP tool schemas, and zero automated evaluation gates.

kronvex-template-ai ships a complete, clean-room production core that runs 100% locally at $0 cost out of the box and scales cleanly to PostgreSQL 16 + pgvector, Google Gemini, Anthropic Claude, OpenAI, or sovereign local Ollama:

  • Real Hybrid RAG (src/modules/rag/hybrid-engine.ts): Token-aware overlapping chunking + BM25 sparse retrieval + 64-dim vector cosine similarity fused via Reciprocal Rank Fusion (k=60), with live document ingestion (POST /v1/rag/ingest) and inline [1][2] source citations.

  • 4-Layer AI Security Firewall (src/modules/guardrails/firewall.ts):

    1. Direct & indirect prompt-injection, jailbreak, and tool-smuggling detection (INJ-01–INJ-04).

    2. Pre-LLM PII & cloud secret redaction (Stripe sk_live_, Anthropic sk-ant-, GitHub ghp_, AWS AKIA, credit cards, emails, phone numbers).

    3. Per-call random-UUID <untrusted-data-...> instruction-sandwich sandboxing.

    4. Faithfulness & grounding validation.

  • ZeroBurn 3-Band Multi-LLM Effort Router (src/modules/router/llm-router.ts): Classifies prompts into FAST, BALANCED, or DEEP across Gemini 2.5, Claude 3.7 / Opus 4, OpenAI GPT-4o / o3, and Ollama Local (\$0).

  • Stateful 4-Stage Multi-Agent DAG + Live SSE Streaming (src/modules/agents/orchestrator.ts & src/app.ts): Streams trace, citations, token, and done SSE events over POST /v1/chat/stream.

  • Zero-Dependency Code-Mode Stdio MCP Server (mcp/server.mjs): Collapses 50 classic tool schemas (~34,500 tokens/turn) into 2 Code-Mode tools (~620 tokens/turn — 98.2% savings) with pure stdout JSON-RPC 2.0 framing, readOnlyHint annotations, --read-only / --lockdown enforcement, and UUID untrusted boundaries.

  • Automated Golden Eval CI Gate (pnpm eval): Grades RAG Precision@2, Red-Team Block Rate, PII Redaction Accuracy, and Effort Routing; fails CI if pass rate drops below 100%.

  • Zero-Downtime PostgreSQL 16 + pgvector Migrations (sql/): SET lock_timeout = '2s', strict tenant Row-Level Security (app.current_tenant), and CREATE INDEX CONCURRENTLY GIN + HNSW vector indexes.


Related MCP server: Valstorm Hosted MCP Server

Architecture


Quick Start (< 60 Seconds, $0 API Cost)

pnpm install
pnpm dev

Open http://localhost:8788/ to launch the interactive KRONVEX AI & RAG Studio (Dark/Light optical themes + EN, العربية RTL, FR, ES, DE, ZH), or inspect http://localhost:8788/openapi.json.

Verification Commands

pnpm typecheck   # Strict TypeScript 5.8 check
pnpm test        # Unit, Hybrid RAG, Red-Team, Hono SSE & Live Stdio MCP integration tests
pnpm eval        # Automated Golden Eval CI Gate (exits 0 only at 100%)
pnpm build       # Production ESM build into dist/

Connect Code-Mode MCP Server (Antigravity / Claude / Cursor / VS Code)

{
  "mcpServers": {
    "kronvex-ai-rag": {
      "command": "node",
      "args": ["mcp/server.mjs", "--mode", "codemode", "--read-only"]
    }
  }
}

Use --mode classic to expose individual tools (rag_search, agent_execute, guardrail_scan, plus rag_ingest when --read-only is omitted).


Production Database & Container Deployment

  • Database: Apply sql/001_init_rag_pgvector.sql followed by sql/002_indexes_concurrently.sql (outside a transaction block).

  • Container: Multi-stage pinned node:22.15.0-alpine3.21 Dockerfile running as non-root USER node with HEALTHCHECK on /healthz.


License & Enterprise Engineering

Released under the Apache-2.0 License by KRONVEX.

Need custom Agentic RAG architectures, private sovereign LLM clusters, NexusMCP enterprise gateways, or Red-Team AI security audits? Contact kronvex.dev.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      B
      quality
      B
      maintenance
      Enables AI agents to query an air-gapped enterprise knowledge vault via seven MCP tools for deterministic and hybrid retrieval, entity graph traversal, context compression, archive inspection, onboarding scans, and node status.
      7
      -
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables autonomous agents to securely access and manage virtual file systems, records, schemas, SQL and Mongo queries, and RAG search through scoped MCP tools, while supporting binary transfers via presigned S3 recipes.
      PolyForm Noncommercial 1.0.0
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables agents to run hybrid retrieval, build token-budgeted attributed context packs, answer questions with citation and groundedness-gated release, explore temporal graph entities, evaluate claim support, and ingest screened, embedded documents through typed MCP tools.
      Apache 2.0