Listed from the MCP registry; nobody on Odel publishes it.
Multi-tenant hybrid RAG & evidence verification MCP server enforcing PostgreSQL RLS.
Runs on your machine from its package; the steps are below.

At most: only reads or looks up information.
Odel charges nothing per call. The publisher may charge for its own service.
Runs locally over stdio
This server isn't hosted — your MCP client launches it from a package registry. Use one of the commands below, or drop the config into your client (e.g. Claude Desktop).
Run
uvx knowledge-fabric
MCP client config
{
"mcpServers": {
"knowledge-fabric": {
"command": "uvx",
"args": [
"knowledge-fabric"
]
}
}
}
Vendor-neutral, governance-first evidence retrieval for AI systems.
Native PostgreSQL + pgvector • Hybrid RRF Fusion • Cross-Encoder Reranking • Dual-Mode Multi-Tenancy • MCP-Native
Click to launch a fully configured browser VS Code workspace with PostgreSQL + pgvector and Tika running automatically:
Give Claude Desktop or Cursor private, local long-term memory over your enterprise codebase and documents. Add this to your claude_desktop_config.json:
{
"mcpServers": {
"knowledge-fabric": {
"command": "docker",
"args": [
"run", "-i", "--rm",
"-e", "DATABASE_URL=postgresql://knowledge_fabric:knowledge_fabric@host.docker.internal:5432/knowledge_fabric",
"-e", "KF_DEFAULT_TENANT=default",
"ghcr.io/invarcore/knowledge-fabric:0.1.4",
"knowledge-fabric-mcp"
]
}
}
}
git clone https://github.com/invarcore/knowledge-fabric.git && cd knowledge-fabric
docker compose up -d
# Run the interactive hybrid RRF demonstration
python examples/quickstart_interactive.py
Most enterprise AI initiatives stall not because of model capability, but because of operational sprawl, data leakage, and ungrounded retrieval. Traditional architectures force engineering teams to introduce dedicated vector databases (Pinecone, Qdrant, Weaviate), creating a second source of truth, new vendor contracts, complex VPC peering, and $50k–$100k/year in recurring cloud spend.
Knowledge Fabric eliminates this entire infrastructure tier by running directly on your existing PostgreSQL database with pgvector HNSW indexes and native full-text search (tsvector), combined with Reciprocal Rank Fusion (RRF):
| Challenge with Traditional Stacks | The Knowledge Fabric Enterprise Architecture |
|---|---|
| Forced Database Sprawl: Introducing specialized vector databases requires separate VPC peering, backup regimes, and $2,000–$10,000/mo in dedicated infrastructure. | Runs on your existing PostgreSQL: Combines pgvector HNSW with PostgreSQL full-text search (tsvector) in a single ACID database. Zero new infrastructure to operate. |
| Naive Cosine Search Misses Exact Terms: Pure vector search frequently misses critical error codes, IDs, SKUs, drug names, and legal terms. | Hybrid RRF + Neural Reranking: Reciprocal Rank Fusion (k=60) merges BM25 lexical precision with dense vector semantics, refined by local cross-encoders. |
| Cross-Tenant Data Contamination: Naive vector stores expose all chunks globally, risking cross-tenant data leakage in multi-tenant SaaS. | Dual-Mode Multi-Tenancy: Application-level tenant isolation by default, plus opt-in PostgreSQL Row-Level Security (RLS) for HIPAA and SOC 2 compliance. |
| Vendor API Lock-In & Recurring Cost: Cloud frameworks default to proprietary embedding APIs, risking breaking changes and per-token fees. | 100% Local & Open by Default: Ollama & sentence-transformers run offline and free on CPU/GPU. OpenRouter, OpenAI, and Cohere are drop-in alternatives. |
| Framework Monoliths: LlamaIndex and LangChain force you into proprietary prompt abstraction libraries. | Clean FastMCP Boundary: Exposes retrieval as a standard Model Context Protocol (MCP) server that any agent or framework can consume. |
How actual CTOs deploy Knowledge Fabric across enterprise verticals:
| Vertical | Primary Compliance & Architectural Concern | Knowledge Fabric Solution | Impact & ROI |
|---|---|---|---|
| Fintech & Banking | Strict SEC/FINRA audit trails, zero public cloud data leakage, exact compliance code matching. | Hybrid RRF (BM25 + pgvector) on private AWS RDS Aurora; local offline embeddings with Ollama. | Eliminates dedicated vector DB SaaS spend; 100% compliance audit trail via built-in AuditLogger. |
| Healthcare & Pharma | HIPAA compliance, patient PII containment, medical terminology precision. | Dual-mode PostgreSQL Row-Level Security (RLS) guarantees data is physically unqueryable across departments. | Zero cross-tenant leakage risk; passes strict clinical HIPAA review. |
| Enterprise B2B SaaS | Multi-tenancy at scale (50M+ chunks), sub-10ms query latency, fast self-hosting. | HNSW indexing with declarative PostgreSQL tenant table partitioning. | HNSW enables low-latency retrieval across millions of documents with partition pruning. |
| DevOps & Cloud SRE | Automated incident triage, runbook citation, turnkey Kubernetes deployment. | Multi-arch Docker containers, Docker Compose stack, and FastMCP server. | Rapid local deployment; grounded runbook retrieval for on-call agents. |
flowchart TB
subgraph Ingestion ["1. INGESTION PIPELINE"]
Sources["Enterprise Docs\n(MD, PDF, DOCX, HTML)"] --> Tika["Apache Tika\n(Text Extraction)"]
Tika --> Chunker["Document Chunker\n(Sliding Window)"]
Chunker --> Embedder["Embedding Provider\n(Ollama / OpenRouter / OpenAI / Cohere)"]
end
subgraph Storage ["2. POSTGRESQL + PGVECTOR"]
Embedder --> Chunks[("chunks table\n• Full-text tsvector (BM25)\n• pgvector embedding\n• tenant_id & metadata")]
end
subgraph Retrieval ["3. RETRIEVAL & FUSION ENGINE"]
Query["User / Agent Query\n(with tenant_id)"] --> Lexical["Lexical Search\n(tsvector English)"]
Query --> Vector["Dense Vector Search\n(Cosine Distance)"]
Chunks -.-> Lexical
Chunks -.-> Vector
Lexical --> RRF["Hybrid Fusion\n(RRF k=60)"]
Vector --> RRF
RRF --> Reranker["Cross-Encoder Reranker\n(sentence-transformers / Cohere)"]
end
subgraph Interface ["4. AUDITABLE EVIDENCE CONSUMPTION"]
Reranker --> EvidencePkg["Structured Evidence Package\n• Ranked snippets with citations\n• Provenance trace & scores\n• Audit event log"]
EvidencePkg --> MCPServer["MCP Server\n(retrieve_evidence)"]
MCPServer --> Downstream["Intent Fabric / AI Agent / Claude / Cursor"]
end
Choose the consumption pathway that fits your architecture:
If you are importing the retrieval engine into Python code, custom agents, or running MCP:
# Install core package from PyPI
pip install knowledge-fabric
# Or install with neural rerankers
pip install "knowledge-fabric[reranking]"
# Run the MCP server directly via uvx (zero-installation):
uvx knowledge-fabric-mcp
Spin up the entire multi-tenant stack (PostgreSQL + pgvector, Apache Tika, and Admin UI) in seconds:
# Clone or download docker-compose.prod.yml
curl -sSL https://raw.githubusercontent.com/invarcore/knowledge-fabric/main/docker-compose.prod.yml -o docker-compose.yml
# Start full platform with pgvector and Tika
docker compose up -d
# Access Visual Admin Console at: http://localhost:8080
Helm chart packaging is planned. For now, deploy the Docker image directly to your cluster using standard Kubernetes Deployment + Service manifests, pointing to your external RDS / Cloud SQL instance.
Note
The helm install oci://ghcr.io/invarcore/charts/knowledge-fabric command shown in earlier versions targets a Helm OCI registry that has not yet been published. Watch the releases page for the first official Helm chart release.
git clone https://github.com/invarcore/knowledge-fabric.git
cd knowledge-fabric
python3 -m pip install -e ".[reranking,dev]"
docker compose up -d postgres tika
EMBEDDING_PROVIDER=ollama knowledge-fabric-ingest --path ./docs --recursive --embed --tenant engineering
knowledge-fabric-mcp
Configure your preferred embedding and reranking providers with environment variables or config/settings.yaml:
| Provider | Setup / Environment | Vector Dim | Cost / Hardware |
|---|---|---|---|
| Ollama (Recommended) | EMBEDDING_PROVIDER=ollamaollama pull nomic-embed-text | 768 | Free & Local (CPU or GPU) |
| OpenAI | EMBEDDING_PROVIDER=openaiOPENAI_API_KEY=sk-... | 1536 | Commercial API |
| Cohere | EMBEDDING_PROVIDER=cohereCOHERE_API_KEY=... | 1024 | Commercial API |
| Mock | EMBEDDING_PROVIDER=mock | 1536 | Deterministic (Dev/CI only) |
| Provider | Configuration | Characteristics |
|---|---|---|
| Passthrough (Default) | RERANKER=passthrough | Fast zero-latency RRF ranking without neural reranking. |
| CASE-Guard | RERANKER=case_guard | Safeguard-boosted & insecure-exemplar quarantined code reranker (AST + polyglot security checks). |
| Cross-Encoder | RERANKER=cross_encoder | Local neural model (ms-marco-MiniLM-L-6-v2) via sentence-transformers. Free & private. |
| Cohere | RERANKER=cohereCOHERE_API_KEY=... | Cloud reranking via Cohere Rerank API. |
Knowledge Fabric provides two isolation layers to accommodate both lightweight development and regulated enterprise environments:
Every query and ingestion specifies tenant_id:
pipeline.retrieve_evidence(
query_text="emergency access procedures",
tenant_id="healthcare-corp-a",
top_k=5,
)
SQL queries automatically include WHERE d.tenant_id = %s. Requires no special database privileges.
For HIPAA, SOC2, or government environments requiring database-enforced isolation:
-- Enable RLS across all tables with one command:
SELECT enable_tenant_rls();
PostgreSQL kernel rejects any access that does not set session variable app.tenant_id:
SELECT set_config('app.tenant_id', 'healthcare-corp-a', true);
Even if application code contains a bug or omission, cross-tenant data leakage is physically impossible.
Standard connection pools (e.g. naive pooling) are dangerous in multi-tenant RLS environments: if an application checks in a connection with an active app.tenant_id session setting or uncommitted transaction, subsequent queries from a different tenant can bleed or inherit privileges. Furthermore, re-querying SHOW is_superuser on every checkout imposes a severe 3x TCP handshake latency penalty.
Knowledge Fabric's RLSSafeConnectionPool eliminates both issues:
SHOW is_superuser exactly once upon physical connection startup, caching the boolean across checkouts.conn.rollback() and SELECT set_config('app.tenant_id', '', false) to guarantee zero tenant context residue.max_active = 16 socket bound to prevent database socket starvation under high agent load.from knowledge_fabric.database.connection_pool import RLSSafeConnectionPool
# Initialize pool with max active socket limits
pool = RLSSafeConnectionPool(
dsn="postgresql://knowledge_fabric@localhost:5432/knowledge_fabric",
min_size=2,
max_size=16,
)
# Use safe context manager - automatically sets tenant_id and cleans up on exit
with pool.connection(tenant_id="healthcare-corp-a") as conn:
with conn.cursor() as cur:
cur.execute("SELECT chunk_id, content FROM chunks WHERE source_type = 'ehr'")
results = cur.fetchall()
# Upon block exit, conn is rolled back, app.tenant_id is cleared, and connection returns to pool
To prevent code-generation RAG pipelines from retrieving insecure exemplars or missing repository security safeguards (CASE-Bench), Knowledge Fabric annotates code chunks at ingestion/chunking time and filters retrieval candidates at rerank time:
DocumentIngestionService and DocumentChunkingService classify Python (via AST slicing) as well as JavaScript, TypeScript, Go, and Rust (SourceFormat.JAVASCRIPT, TYPESCRIPT, GO, RUST), populating is_security_safeguard and has_insecure_exemplar chunk metadata.classify_code_chunk_security): Recognizes parameterized auth/validation decorators (@require_auth(...), @login_required, etc.) and flags unsafe patterns including command execution, SQL string interpolation, yaml.unsafe_load_all, marshal.load, weak hashes (hashlib.md5/sha1 unless usedforsecurity=False), and polyglot sinks (new Function, innerHTML =, child_process.execSync).RERANKER=case_guard): CaseGuardReranker promotes genuine safeguard chunks while quarantining insecure exemplars (quarantine_insecure=True by default).Knowledge Fabric exposes standard MCP tools for LLMs, desktop assistants, and workflow runners:
| Tool Name | Parameters | Description |
|---|---|---|
retrieve_evidence | query_text (str), tenant_id (str|null), top_k (int), source_type (str|null), trace_id (str|null), mode (str: hybrid|lexical|vector), format (str: json|compact|markdown) | Executes retrieval (hybrid RRF, lexical full-text, or semantic vector) and returns structured evidence package with citations, per-leg health, and relevance scores. Supports format='markdown' for token-efficient citations and format='compact' to omit wire duplication. |
get_evidence | chunk_id (int), tenant_id (str|null) | Retrieves a specific cited chunk by its database ID with complete provenance and metadata. |
get_document | document_id (int|null), source_uri (str|null), tenant_id (str|null) | Retrieves the full content and metadata for a specific document, scoped to tenant. |
explain_retrieval | query_text (str), top_k (int), source_type (str|null), tenant_id (str|null), mode (str) | Returns detailed diagnostics: lexical ranks, vector distances, per-leg latencies, and RRF fusion scores. |
get_index_status | tenant_id (str|null) | Returns index health diagnostics: total documents, total chunks, and document counts per source type. |
check_consistency | tenant_id (str|null) | Audits relational database invariants (orphaned chunks, empty docs, null tenants, missing embeddings). |
health_check | None | Verifies database connectivity, row counts, embedding provider status, and dimension alignment. |
list_sources | tenant_id (str|null) | Lists ingested document source types and document counts, scoped to the calling tenant. |
Add to your claude_desktop_config.json:
{
"mcpServers": {
"knowledge-fabric": {
"command": "python",
"args": ["-m", "knowledge_fabric.mcp.server"],
"env": {
"DATABASE_URL": "postgresql://knowledge_fabric@localhost:5432/knowledge_fabric",
"EMBEDDING_PROVIDER": "ollama",
"RERANKER": "cross_encoder",
"KF_DEFAULT_TENANT": "default"
}
}
}
}
Run the included benchmark evaluation suite to compare retrieval accuracy across strategies:
python benchmarks/evaluate_retrieval.py
Note
The numbers below are illustrative — generated by running python benchmarks/evaluate_retrieval.py on a small synthetic operational corpus. Run the command yourself on your own corpus to produce numbers that reflect your data and query distribution. Results will differ by domain, chunk size, and embedding model.
Retrieval Strategy | NDCG@10 | MRR@10 | Recall@10 | vs Vector
----------------------------------------------------------------------------
Lexical Only (BM25) | 0.7240 | 0.6850 | 0.8200 | -10.4%
Vector Only (Cosine) | 0.8082 | 0.7600 | 0.8800 | baseline
Hybrid Fusion (RRF) | 0.8924 | 0.8750 | 0.9500 | +10.4%
Hybrid + Reranker | 0.9416 | 0.9600 | 0.9800 | +16.5%
----------------------------------------------------------------------------
Ingest content directly from enterprise platforms with the unified knowledge-fabric-sync CLI:
# Ingest Confluence spaces into tenant 'engineering'
knowledge-fabric-sync --connector confluence --url "https://mycorp.atlassian.net/wiki" --space ENG,PROD --tenant engineering --embed
# Ingest Notion databases
knowledge-fabric-sync --connector notion --token "$NOTION_API_KEY" --database-id "<id>" --tenant product --embed
# Ingest Google Drive folder / Google Docs
knowledge-fabric-sync --connector gdrive --token "$GOOGLE_ACCESS_TOKEN" --folder-id "<id>" --tenant legal --embed
# Ingest Jira resolved incidents & ADRs
knowledge-fabric-sync --connector jira --url "https://mycorp.atlassian.net" --jql "project = SEC AND status = Done" --tenant security-ops --embed
Knowledge Fabric is built to grow with your infrastructure from early prototyping to 100M+ vectors:
SELECT upgrade_to_hnsw_index(m_val => 16, ef_val => 64);
chunks table by tenant_id. Queries for a specific tenant scan only that tenant's dedicated partition index, enabling PostgreSQL to support tens of millions of vectors with partition pruning.export RETRIEVAL_STORE_BACKEND=qdrant
export QDRANT_URL=http://qdrant-cluster:6333
Knowledge Fabric includes a visual management console with zero Node/NPM dependencies:
knowledge-fabric-ui --port 8080
# Open http://localhost:8080/ in your browser
Features:
See examples/04-end-to-end-with-intent:
A complete demonstration ingesting enterprise policy documents, querying hybrid evidence with multi-tenant partitioning, planning safe actions with Intent Fabric, evaluating YAML policy rules, and emitting an audit-ready approval package.
python examples/04-end-to-end-with-intent/run.py
Knowledge Fabric includes a zero-dependency, standard-library-only cryptographic verifier in knowledge_fabric.evidence_contract:
from knowledge_fabric.evidence_contract import (
sign_evidence_contract_rfc8785,
verify_evidence_contract_rfc8785,
)
# Sign an evidence payload using RFC 8785 Canonical JSON (JCS) and HMAC-SHA256
signature = sign_evidence_contract_rfc8785(payload, secret_key="corp-hmac-key")
# Verify contract signature, temporal freshness, and chunk-level SHA-256 provenance fail-closed
is_valid = verify_evidence_contract_rfc8785(
payload,
signature=signature,
secret_key="corp-hmac-key",
max_age_seconds=300.0,
)
hmac.compare_digest), TTL-based freshness validation, and chunk content hash verification.Knowledge Fabric enforces rigorous test coverage ($\ge 90%$), strict multi-tenant isolation, and a zero-live-HTTP CI architecture:
tests/fixtures/corpora/ for deterministic, offline, sub-second CI validation.benchmarks/live_retrieval_smoke_test.py --openrouter).# Execute unit & integration test suite (enforces >= 90% coverage)
uv run pytest tests/ -v --tb=short --cov=knowledge_fabric --cov-report=term-missing --cov-fail-under=90
Run the zero-cost hermetic verification pipeline covering chunking, in-memory multi-tenant storage, hybrid RRF retrieval, cryptographic provenance (chunk hashes, package digest, HMAC-SHA256 signature), and MCP tools:
# Local hermetic mode (runs in ~1ms, zero API keys required)
python benchmarks/live_retrieval_smoke_test.py
# Live cloud mode with OpenRouter free tier
python benchmarks/live_retrieval_smoke_test.py --openrouter --model openrouter/free
Run the entire test suite and smoke test inside an isolated container:
docker compose -f docker-compose.test.yml up --build --abort-on-container-exit
We welcome community contributions! Please see CONTRIBUTING.md for development setup, how to add new embedding/reranking providers, and coding standards.
Please report security issues responsibly. See SECURITY.md for our vulnerability disclosure policy.
This engine is part of the Invarcore enterprise verification fabric. Invarcore develops mathematical invariants, cryptographic policy contracts, and execution runtimes for autonomous AI systems.
Licensed under the Apache License, Version 2.0.