Skip to main content
Glama

πŸ›οΈ ARCHON-KB

High-Performance Technical Knowledge Base & MCP Server

Deterministic Graph-RAG β€’ PostgreSQL 17 β€’ pgvector (HNSW) β€’ Reciprocal Rank Fusion β€’ Systems & Reverse Engineering

Python 3.10+ PostgreSQL 17 pgvector HNSW MCP Protocol License: MIT


⚑ Overview

Archon-KB is an industrial-grade, deterministic Technical Knowledge Base and Model Context Protocol (MCP) server engineered specifically for systems programming, kernel architecture, hardware specifications, and reverse engineering research.

Naive RAG pipelines fail in low-level engineering domains: they slice code blocks across arbitrary token counts, butcher SMBIOS structs, drop IOCTL codes, and hallucinate entity links. Archon-KB solves this at the database engine layer by combining:

  1. Hierarchy-Preserving AST Markdown Parser: Retains full heading ancestry, code blocks, tables, and exact line-level provenance with zero data loss.

  2. Domain-Specific Entity Graph Extractor: Automatically identifies IOCTLs, WMI classes, NT native APIs, SMBIOS table types, drivers, devices, and RVAs.

  3. 5-Stage Hybrid Retrieval Pipeline: Exact Match + GIN Full-Text Lexical Search + pgvector HNSW Cosine Similarity fused via Reciprocal Rank Fusion (RRF).

  4. Token-Dense FastMCP Server: Native MCP integration with AI agents (Claude Desktop, Antigravity, Cursor, Windsurf).


Related MCP server: Qurio MCP Server

πŸ”¬ Architecture & Retrieval Pipeline

flowchart TD
    Query["User / Agent Query (e.g. 'IOCTL 0x800021DC' or 'SMBIOS Type 17')"] --> Stage1["1. EXACT IDENTIFIER MATCH (+2.5 Boost)\nDirect match on Canonical Name, Aliases, IOCTL Hex, RVAs"]
    Query --> Stage2["2. LEXICAL FULL-TEXT SEARCH\nPostgreSQL GIN tsvector + ts_rank_cd"]
    Query --> Stage3["3. VECTOR COSINE SIMILARITY\npgvector <=> HNSW Index (384-dim Embeddings)"]
    
    Stage1 --> Fuse["4. RECIPROCAL RANK FUSION (RRF)\nRRF Score = 1.0 / (k + rank) + Boost"]
    Stage2 --> Fuse
    Stage3 --> Fuse
    
    Fuse --> Stage4["5. KNOWLEDGE GRAPH TRAVERSAL\nExtracts: CONTAINS, CALLS, USES, MAPS_TO_WMI, HAS_PROPERTY"]
    Stage4 --> Stage5["6. VERBATIM PROVENANCE INJECTION\nLine-accurate citations, heading paths, and code excerpts"]
    Stage5 --> Output["Token-Dense Entity Card + Context Chunks"]

🌟 Key Capabilities

1. Zero-Hallucination Technical Entity Extraction

Extracts and indexes domain entities out-of-the-box:

  • Kernel IOCTLs & FSCTLs: Standard codes and raw hex values (e.g. 0x2D1400, 0x800021DC).

  • Firmware & SMBIOS: Complete SMBIOS specification tables (Types 0 to 127: BIOS, BaseBoard, Processor, OEM Strings, Memory Serials).

  • WMI Classes & Namespaces: root\cimv2, root\wmi, properties, and PowerShell CIM invocation methods.

  • Native & Win32 APIs: Nt*, Zw*, Rtl*, Ob*, Io*, DeviceIoControl, GetSystemFirmwareTable.

  • Drivers & Device Objects: System drivers (.sys), kernel devices (\Device\...).

  • Disassembly RVAs: Relative virtual addresses for binary inspection.

2. Multi-Provider Embedding Engine

  • Local Deterministic Hasher: Built-in 384-dimensional unit vectorizer with zero external dependencies.

  • FastEmbed / Sentence-Transformers: Plug-and-play support for BAAI/bge-small-en-v1.5 or any HuggingFace model.

  • Configurable Vector Dimensions: Fully adjustable via EMBEDDING_DIM environment variable.

3. Strict Provenance (Line-Accurate Auditing)

Every entity and assertion links back to its exact document:

  • Source file path & SHA256 hash

  • Full heading breadcrumb path

  • Exact line numbers (start_line to end_line)

  • Verbatim source quote snippet


πŸš€ Quickstart

Prerequisites

  • Python 3.10+

  • PostgreSQL 17 (with pgvector extension recommended)

1. Start PostgreSQL with pgvector (Docker)

docker run -d \
  --name archon-postgres \
  -e POSTGRES_DB=technical_kb \
  -e POSTGRES_USER=postgres \
  -e POSTGRES_PASSWORD=postgres \
  -p 5432:5432 \
  pgvector/pgvector:pg17

2. Clone & Install

git clone https://github.com/DeFexNN/archon-kb.git
cd archon-kb
python -m venv .venv
# Windows:
.venv\Scripts\activate
# Linux/macOS:
# source .venv/bin/activate

pip install -r requirements.txt

3. Initialize Database Schema

# Using psql:
psql -h localhost -U postgres -d technical_kb -f migrations/init.sql

4. Ingest Technical Documents

# Ingest single markdown document:
python scripts/import_file.py examples/sample_hardware_kernel_doc.md

# Or ingest an entire directory recursively:
python scripts/import_directory.py path/to/your/research_notes/

5. Verify Database Integrity

python scripts/validate_integrity.py

πŸ”Œ MCP Client Configuration

Archon-KB implements the standard Model Context Protocol via FastMCP. Add it to your AI toolchain in seconds:

Claude Desktop

Add to %APPDATA%\Claude\claude_desktop_config.json:

{
  "mcpServers": {
    "archon-kb": {
      "command": "python",
      "args": [
        "C:\\Archon-KB\\src\\mcp_server.py"
      ],
      "env": {
        "PYTHONPATH": "C:\\Archon-KB",
        "PGHOST": "localhost",
        "PGPORT": "5432",
        "PGDATABASE": "technical_kb",
        "PGUSER": "postgres",
        "PGPASSWORD": "your_password"
      }
    }
  }
}

Google Antigravity / Cursor / Windsurf

Add to your IDE's MCP configuration (mcp_config.json):

{
  "mcpServers": {
    "archon-kb": {
      "command": "C:\\Users\\<USER>\\AppData\\Local\\Programs\\Python\\Python313\\python.exe",
      "args": [
        "C:\\Archon-KB\\src\\mcp_server.py"
      ],
      "env": {
        "PYTHONPATH": "C:\\Archon-KB"
      }
    }
  }
}

πŸ› οΈ MCP Tools Reference

When connected, AI agents gain access to the following native tools:

Tool

Parameters

Description

lookup_technical_entity

identifier: str

Fast direct lookup for exact identifiers (IOCTLs, WMI, APIs, RVAs). Returns complete entity card in 1 call.

search_technical_knowledge

query: str, limit: int

5-stage hybrid search combining lexical GIN + vector HNSW via RRF. Returns matched entities and code chunks.

get_kb_health_status

(none)

Returns real-time health status, document counts, chunk counts, and relationship metrics.


πŸ“Š Benchmarks & Health Check

Output from scripts/validate_integrity.py:

======================================================================
ARCHON-KB INTEGRITY & HEALTH AUDIT REPORT
======================================================================
Total Documents:                     47
Total Structural Chunks:          5,260
Total Extracted Entities:           898
Total Entity Properties:            430
Total Retrieval Methods:            210
Total Knowledge Relationships:      200
Total Evidence Citations:         4,120

Vector Embeddings Health:
  * Entities with Vector:           898 / 898 (100.0%)
  * Chunks with Vector:           5,260 / 5,260 (100.0%)

Provenance Integrity:
  * Entities with Direct Evidence:  898 / 898 (100.0%)

Total Database Disk Footprint:    89 MB
======================================================================

πŸ“ Repository Structure

archon-kb/
β”œβ”€β”€ config/
β”‚   └── mcp_clients_example.json   # Ready-to-use client JSON configurations
β”œβ”€β”€ docs/                          # Placeholder for your local markdown files
β”œβ”€β”€ examples/
β”‚   └── sample_hardware_kernel_doc.md # Reference technical specification
β”œβ”€β”€ migrations/
β”‚   └── init.sql                   # PostgreSQL 17 DDL + pgvector schema
β”œβ”€β”€ scripts/
β”‚   β”œβ”€β”€ import_file.py             # Single document ingestion engine
β”‚   β”œβ”€β”€ import_directory.py        # Recursive bulk directory ingester
β”‚   β”œβ”€β”€ reindex.py                 # Full database re-chunker & re-embedder
β”‚   β”œβ”€β”€ test_search.py             # Terminal CLI search testing utility
β”‚   └── validate_integrity.py      # Health & zero data loss auditor
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ config.py                  # Centralized configuration loader
β”‚   β”œβ”€β”€ mcp_server.py              # FastMCP server with stdio/sse transports
β”‚   β”œβ”€β”€ api/
β”‚   β”‚   β”œβ”€β”€ kb_service.py          # High-level Knowledge Base API
β”‚   β”‚   └── llm_tools.py           # Token-dense LLM search interface
β”‚   β”œβ”€β”€ embeddings/
β”‚   β”‚   └── embedding_engine.py    # Multi-backend vectorizer (Hash/ST/FastEmbed)
β”‚   β”œβ”€β”€ extraction/
β”‚   β”‚   └── entity_extractor.py    # Technical regex & graph link extractor
β”‚   β”œβ”€β”€ normalization/
β”‚   β”‚   └── normalizer.py          # Entity deduplication & conflict tracker
β”‚   β”œβ”€β”€ parser/
β”‚   β”‚   └── markdown_parser.py     # AST heading, table & code block parser
β”‚   └── retrieval/
β”‚       └── hybrid_search.py       # 5-Stage RRF Hybrid Retrieval Engine
β”œβ”€β”€ tests/
β”‚   β”œβ”€β”€ test_extractor_fixtures.py # Entity extraction test cases
β”‚   β”œβ”€β”€ test_parser_fixtures.py    # Structural parsing test cases
β”‚   └── test_retrieval_rrf.py      # Reciprocal Rank Fusion test cases
β”œβ”€β”€ .env.example
β”œβ”€β”€ .gitignore
β”œβ”€β”€ LICENSE
β”œβ”€β”€ pyproject.toml
β”œβ”€β”€ README.md
└── requirements.txt

βš™οΈ Environment Variables

Variable

Default

Description

PGHOST

localhost

PostgreSQL host

PGPORT

5432

PostgreSQL port

PGDATABASE

technical_kb

PostgreSQL database name

PGUSER

postgres

PostgreSQL username

PGPASSWORD

postgres

PostgreSQL password

EMBEDDING_MODEL

local-semantic-384

Model name or embedding provider

EMBEDDING_DIM

384

Embedding vector dimensions

KB_RECOGNIZED_FOLDERS

(defaults)

Comma-separated analysis workspace folder names


πŸ›‘οΈ License

This project is licensed under the MIT License Β© 2026 DeFexNN.

Available Tools

3 tools
get_kb_health_statusGet Kb Health StatusC

Returns the current health status, document counts, and integrity metrics of the Technical KB.

Inputs: project_path, confirm_project, project_context. Returns: object

lookup_technical_entityLookup Technical EntityC

Zero-hallucination lookup for a specific technical identifier. Returns canonical properties, implementation methods, graph relationships, and source provenance.

Inputs: identifier (required), project_path, confirm_project, project_context. Returns: object

search_technical_knowledgeSearch Technical KnowledgeC

5-stage hybrid retrieval across the knowledge base: Combines exact identifier matching, lexical full-text (GIN), and pgvector cosine similarity via RRF.

Inputs: query (required), limit, project_path, confirm_project, +1 more. Returns: object

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    B3.1/5.0

    Scored across 3 tools

    Disambiguation4/5

    lookup_technical_entity and search_technical_knowledge both retrieve technical info, but the descriptions clearly separate exact-identifier canonical lookup from broad 5-stage hybrid search. get_kb_health_status is unambiguously distinct (operational metrics only).

    Naming Consistency4/5

    All three follow a snake_case verb_noun pattern (get_/lookup_/search_ + object). The 'kb' abbreviation in get_kb_health_status is a minor deviation from the other two using full domain nouns, but the convention is still readable and predictable.

    Tool Count4/5

    Three focused tools suit a read-only technical KB retrieval server: health, point lookup, and search cover the core surface without bloat. It sits near the thin edge, but each tool earns its place with a distinct role.

    Completeness3/5

    Read paths are well covered (search + exact lookup + health), but there is no way to enumerate or browse entities, list available entity types/document sets, or fetch related entities except via lookup. Agents hitting an unknown identifier must fall back to search, which is a notable gap for a KB server.

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      Not graded
      maintenance
      Enables hybrid web search and intelligent content extraction, combining semantic search with documentation-optimized reading that strips noise and returns clean, token-efficient context for AI agents.
      2
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables AI coding assistants to search and retrieve information from a locally ingested knowledge base using hybrid search, grounded in user-curated documentation.
      17
      MIT
    • A
      license
      A
      quality
      D
      maintenance
      Enables AI agents to query Linux kernel source code, git history, LKML discussions, Patchwork patches, and documentation with evidence-ranked results, citations, and explicit assumptions or contradictions.
      16
      GPL 2.0
    • A
      license
      A
      quality
      B
      maintenance
      Provides coding agents with hybrid semantic and exact-identifier search across VHDL source, documentation, and general code, with cross-referencing and exact source attribution.
      8
      1
      MIT