Knowledge Fabric

io.github.invarcore由 GitHub 帳號 invarcore 發布v0.1.1更新於 Nov 7, 2026

Multi-tenant hybrid RAG & evidence verification MCP server enforcing PostgreSQL RLS.

發布方自己的服務:Fabric

概覽

AI 產生的概覽

本機 MCP 伺服器,讓助理對存放在 PostgreSQL + pgvector 中的文件進行混合 RAG 檢索,並回傳附引用的證據包。

可以做什麼
  • 以混合 RRF、詞法或向量模式檢索證據,回傳引用、分數與各路檢索健康狀態
  • 依 ID 或來源 URI 取得被引用的片段或整份文件,並依租戶限定範圍
  • 解釋檢索診斷資訊,例如詞法排名、向量距離、各路延遲與融合分數
  • 檢視索引健康狀況、來源類型與文件數量,並稽核資料庫一致性
  • 執行資料庫連線與嵌入供應商健康檢查
適用情境
適合助理需要根據既有企業文件或程式碼庫語料給出可引用答案的情境,尤其是語料已存放在 PostgreSQL 中,且需要租戶隔離與稽核紀錄時。
執行需求
以本機程序方式透過 uvx 或 Docker 執行。需要可連線的 PostgreSQL 資料庫(含 pgvector 與本專案結構),透過 DATABASE_URL 與 KF_DEFAULT_TENANT 設定。需選定嵌入供應商:預設為本機 Ollama 或 sentence-transformers,或使用 OpenAI、Cohere 並設定 OPENAI_API_KEY、COHERE_API_KEY。文件需事先完成匯入。
安裝前請注意
它會讀取資料庫並把文件內容回傳給助理,因此租戶範圍設定很重要;預設隔離為應用層過濾,PostgreSQL RLS 為選用模式。啟用雲端供應商會把查詢文字與內容傳送給 OpenAI 或 Cohere,並產生 API 費用。README 中的基準數字已註明為示意值,並非依你的資料實測。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Knowledge Fabric,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

[Knowledge Fabric & Intent Fabric]

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

[CI Status] [Invarcore Website] [Coverage: 94%] [Release] [Open in GitHub Codespaces] [License] [MCP Native] [Docker Ready]


⚡ 30-Second Quickstart

1. Instant Cloud Sandbox (Zero Local Setup)

Click to launch a fully configured browser VS Code workspace with PostgreSQL + pgvector and Tika running automatically:

[Open in GitHub Codespaces]

2. Connect to Claude Desktop or Cursor (MCP)

Give Claude Desktop or Cursor private, local long-term memory over your enterprise codebase and documents. Add this to your claude_desktop_config.json:

json
{  "mcpServers": {    "knowledge-fabric": {      "command": "docker",      "args": [        "run", "-i", "--rm",        "-e", "DATABASE_URL=postgresql://knowledge_fabric:[email protected]:5432/knowledge_fabric",        "-e", "KF_DEFAULT_TENANT=default",        "ghcr.io/invarcore/knowledge-fabric:0.1.3",        "knowledge-fabric-mcp"      ]    }  }}

3. Run Locally with Docker Compose (60 Seconds)

bash
git clone https://github.com/invarcore/knowledge-fabric.git && cd knowledge-fabricdocker compose up -d
# Run the interactive hybrid RRF demonstrationpython examples/quickstart_interactive.py

Why Knowledge Fabric?

The $100k/Year Dedicated Vector DB Trap vs. The PostgreSQL Reality

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 StacksThe 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.

Industry Decision & Adoption Matrix

How actual CTOs deploy Knowledge Fabric across enterprise verticals:

VerticalPrimary Compliance & Architectural ConcernKnowledge Fabric SolutionImpact & ROI
Fintech & BankingStrict 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 & PharmaHIPAA 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 SaaSMulti-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 SREAutomated 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.

Architecture

mermaid
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

Quickstart & Deployment Options

Choose the consumption pathway that fits your architecture:

⚡ Pathway 1: Python Developers & MCP Users

If you are importing the retrieval engine into Python code, custom agents, or running MCP:

bash
# Install core package from PyPIpip install knowledge-fabric
# Or install with neural rerankerspip install "knowledge-fabric[reranking]"
# Run the MCP server directly via uvx (zero-installation):uvx knowledge-fabric-mcp

🐳 Pathway 2: Turnkey Evaluation (Docker Compose)

Spin up the entire multi-tenant stack (PostgreSQL + pgvector, Apache Tika, and Admin UI) in seconds:

bash
# Clone or download docker-compose.prod.ymlcurl -sSL https://raw.githubusercontent.com/invarcore/knowledge-fabric/main/docker-compose.prod.yml -o docker-compose.yml
# Start full platform with pgvector and Tikadocker compose up -d
# Access Visual Admin Console at: http://localhost:8080

☸️ Pathway 3: Kubernetes Deployment (Planned)

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.

🛠️ Pathway 4: Local Contributor Setup

bash
git clone https://github.com/invarcore/knowledge-fabric.gitcd knowledge-fabricpython3 -m pip install -e ".[reranking,dev]"docker compose up -d postgres tikaEMBEDDING_PROVIDER=ollama knowledge-fabric-ingest --path ./docs --recursive --embed --tenant engineeringknowledge-fabric-mcp

Model Provider Strategy: Zero Lock-In

Configure your preferred embedding and reranking providers with environment variables or config/settings.yaml:

Embedding Providers

ProviderSetup / EnvironmentVector DimCost / Hardware
Ollama (Recommended)EMBEDDING_PROVIDER=ollama
ollama pull nomic-embed-text
768Free & Local (CPU or GPU)
OpenAIEMBEDDING_PROVIDER=openai
OPENAI_API_KEY=sk-...
1536Commercial API
CohereEMBEDDING_PROVIDER=cohere
COHERE_API_KEY=...
1024Commercial API
MockEMBEDDING_PROVIDER=mock1536Deterministic (Dev/CI only)

Reranking Providers

ProviderConfigurationCharacteristics
Passthrough (Default)RERANKER=passthroughFast zero-latency RRF ranking without neural reranking.
Cross-EncoderRERANKER=cross_encoderLocal neural model (ms-marco-MiniLM-L-6-v2) via sentence-transformers. Free & private.
CohereRERANKER=cohere
COHERE_API_KEY=...
Cloud reranking via Cohere Rerank API.

Dual-Mode Multi-Tenancy

Knowledge Fabric provides two isolation layers to accommodate both lightweight development and regulated enterprise environments:

Mode 1: Application-Level Filtering (Default)

Every query and ingestion specifies tenant_id:

python
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.

Mode 2: PostgreSQL Row-Level Security (RLS)

For HIPAA, SOC2, or government environments requiring database-enforced isolation:

sql
-- 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:

sql
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.


Model Context Protocol (MCP) Tools

Knowledge Fabric exposes standard MCP tools for LLMs, desktop assistants, and workflow runners:

Tool NameParametersDescription
retrieve_evidencequery_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_evidencechunk_id (int), tenant_id (str|null)Retrieves a specific cited chunk by its database ID with complete provenance and metadata.
get_documentdocument_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_retrievalquery_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_statustenant_id (str|null)Returns index health diagnostics: total documents, total chunks, and document counts per source type.
check_consistencytenant_id (str|null)Audits relational database invariants (orphaned chunks, empty docs, null tenants, missing embeddings).
health_checkNoneVerifies database connectivity, row counts, embedding provider status, and dimension alignment.
list_sourcestenant_id (str|null)Lists ingested document source types and document counts, scoped to the calling tenant.

Adding to Claude Desktop / Cursor

Add to your claude_desktop_config.json:

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"      }    }  }}

Retrieval Benchmark

Run the included benchmark evaluation suite to compare retrieval accuracy across strategies:

bash
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.

text
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     | baselineHybrid Fusion (RRF)        | 0.8924     | 0.8750     | 0.9500     | +10.4%Hybrid + Reranker          | 0.9416     | 0.9600     | 0.9800     | +16.5%----------------------------------------------------------------------------

SaaS Source Connectors

Ingest content directly from enterprise platforms with the unified knowledge-fabric-sync CLI:

bash
# 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 databasesknowledge-fabric-sync --connector notion --token "$NOTION_API_KEY" --database-id "<id>" --tenant product --embed
# Ingest Google Drive folder / Google Docsknowledge-fabric-sync --connector gdrive --token "$GOOGLE_ACCESS_TOKEN" --folder-id "<id>" --tenant legal --embed
# Ingest Jira resolved incidents & ADRsknowledge-fabric-sync --connector jira --url "https://mycorp.atlassian.net" --jql "project = SEC AND status = Done" --tenant security-ops --embed

Large-Scale Vector Performance & Pluggable Backends

Knowledge Fabric is built to grow with your infrastructure from early prototyping to 100M+ vectors:

  1. HNSW Indexing (Migration 005): Upgrade from IVFFlat to HNSW for 10x higher QPS and sub-10ms latency:
    sql
    SELECT upgrade_to_hnsw_index(m_val => 16, ef_val => 64);
  2. Declarative Tenant Partitioning: Partition the 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.
  3. Pluggable Vector Store Protocol: For ultra-large enterprise clusters with existing dedicated vector infrastructure, plug in Qdrant with zero application changes:
    bash
    export RETRIEVAL_STORE_BACKEND=qdrantexport QDRANT_URL=http://qdrant-cluster:6333

Visual Admin & Governance UI

Knowledge Fabric includes a visual management console with zero Node/NPM dependencies:

bash
knowledge-fabric-ui --port 8080# Open http://localhost:8080/ in your browser

Features:

  • 🛡️ Human-in-the-Loop Approval Queue: Authorize or reject pending action plans with audit comments.
  • 🔍 Interactive Retrieval Playground: Inspect side-by-side BM25, Cosine, RRF, and Cross-Encoder score distributions and citations.
  • 📜 Live Audit Trail: Chronological event viewer tracking queries, latencies, and security events.
  • ⚙️ Policy Engine Sandbox: Test proposed agent action strings against active YAML rules with instant match highlighting.

End-to-End Enterprise Example

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.

bash
python examples/04-end-to-end-with-intent/run.py

🧪 Testing & Verification

Knowledge Fabric enforces rigorous test coverage ($\ge 90%$), strict multi-tenant isolation, and a zero-live-HTTP CI architecture:

  • Tier 1 (Golden Corpus Fixtures): NIST Special Publication 800-53 Rev 5 control catalog fixtures checked into tests/fixtures/corpora/ for deterministic, offline, sub-second CI validation.
  • Tier 2 (Opt-in Live Harness): Live cloud retrieval verification against OpenRouter (benchmarks/live_retrieval_smoke_test.py --openrouter).

1. Run Complete Test Suite with Coverage Gate

bash
# 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

2. End-to-End Live Verification Smoke Test

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:

bash
# Local hermetic mode (runs in ~1ms, zero API keys required)python benchmarks/live_retrieval_smoke_test.py
# Live cloud mode with OpenRouter free tierpython benchmarks/live_retrieval_smoke_test.py --openrouter --model openrouter/free

3. Containerized Verification with Docker Compose

Run the entire test suite and smoke test inside an isolated container:

bash
docker compose -f docker-compose.test.yml up --build --abort-on-container-exit

Contributing

We welcome community contributions! Please see CONTRIBUTING.md for development setup, how to add new embedding/reranking providers, and coding standards.

Security

Please report security issues responsibly. See SECURITY.md for our vulnerability disclosure policy.


🏛️ Invarcore Verification Fabric

This engine is part of the Invarcore enterprise verification fabric. Invarcore develops mathematical invariants, cryptographic policy contracts, and execution runtimes for autonomous AI systems.

License

Licensed under the Apache License, Version 2.0.

來源:README.md,提交 fdf5112

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

1
  1. v0.1.1最新Nov 7, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分

其他 Fabric 整合