Skip to main content
Glama
congtuuit

Knowledge MCP Server

by congtuuit

🧠 Knowledge MCP Server

The High-Performance, Local-First Second Brain & Knowledge Base for AI Agents

License: MIT Node.js Version TypeScript MCP Protocol PRs Welcome

English β€’ TiαΊΏng Việt β€’ Roadmap β€’ Setup Guide


πŸ’‘ What is Knowledge MCP?

Knowledge MCP Server is a blazing-fast, local-first Knowledge Management & Retrieval-Augmented Generation (RAG) system exposed via the open Model Context Protocol (MCP) standard.

It empowers AI coding assistants and autonomous agents (Antigravity IDE / CLI, Claude Code, Cursor, ChatGPT / Codex, Windsurf) to seamlessly search, read, create, and maintain your personal or enterprise knowledge vault with zero cloud dependencies and zero data leakage.

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”       Streamable HTTP       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  AI Assistants  β”‚ ──────────────────────────> β”‚        Knowledge MCP Server          β”‚
β”‚ (Antigravity /  β”‚                             β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚  Claude / Cursorβ”‚ <────────────────────────── β”‚ β”‚ Hybrid Search (BM25 + Vector)    β”‚ β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                             β”‚ β”‚ Anthropic Contextual Retrieval   β”‚ β”‚
                                                β”‚ β”‚ Heading-Aware Markdown Chunker   β”‚ β”‚
                                                β”‚ β”‚ Native SQLite FTS5 (Zero C++ bld)β”‚ β”‚
                                                β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
                                                β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Related MCP server: MCP Notes Server

✨ Key Highlights

  • ⚑ Native SQLite & FTS5 (Zero C++ Build Hell): Built on Node.js native node:sqlite (DatabaseSync). Starts in milliseconds without compilation errors on Windows, macOS, or Linux.

  • 🎯 Hybrid Search with RRF (k=60): Combines exact keyword matching (SQLite FTS5 BM25) with semantic understanding (Dense Vector Cosine Similarity) using Reciprocal Rank Fusion for pinpoint technical accuracy.

  • 🧩 Heading-Aware Markdown Chunking: Intelligently parses document structure along H1 > H2 > H3 hierarchy, preserving YAML Frontmatter metadata (gray-matter) without breaking context.

  • 🧬 Anthropic Contextual Retrieval: Generates succinct context annotations for each chunk before embedding, drastically reducing ambiguity and retrieval hallucinations.

  • πŸ”„ Incremental Ingestion (SHA256 Diffing): Reindexes only modified chunks, saving computing power and embedding latency.

  • ⚑ 1-Click All-in-One Setup (setup-and-run.bat): Automated setup script that prepares environment, builds, indexes, configures Antigravity rules, and starts the server in 30 seconds.

  • πŸ›‘οΈ Autonomous Agent Policy: Built-in rules and tool descriptions that prompt agents to automatically search your knowledge vault before answering technical queries.


πŸ“Š Feature Comparison Matrix

Feature

🧠 Knowledge MCP

πŸ“˜ Google NotebookLM

πŸ€– Mem0

πŸ““ Obsidian MCP

Primary Execution

Direct IDE Integration

Web App Tab

Cloud/Python SDK

Obsidian Desktop App

Privacy & Security

100% Local / On-Prem

Google Cloud

Cloud / SaaS

Local

Read & Write Memory

Yes (Bi-directional)

Read-Only

Yes

Yes

Search Architecture

BM25 + Vector RRF

Vector / Context Window

Graph + Vector

Regex / Plaintext

Technical Symbol Search

Pinpoint (FTS5 exact)

Fuzzy

Semantic only

Basic

Contextual Retrieval

Yes (Anthropic style)

No

No

No

Windows Installation

Zero C++ Build (Native)

Cloud

Needs C++ toolchains

Needs Obsidian Plugins

Protocol Support

MCP Streamable HTTP

Proprietary UI

Custom API / MCP

Local REST / MCP


πŸ—οΈ System Architecture

graph TD
    subgraph "AI Clients"
        AG[Antigravity IDE / CLI]
        CC[Claude Code / Desktop]
        CX[Codex / Cursor / Others]
    end

    subgraph "Knowledge MCP Server (:3900)"
        AUTH[Bearer Auth Middleware]
        HTTP[Streamable HTTP Transport - /mcp]
        TOOLS[MCP Tools Registry - 8 Tools]
        
        subgraph "Core Intelligence Engines"
            HYBRID[Hybrid Search Engine - RRF k=60]
            INGEST[Incremental Ingestion Pipeline]
            CHUNKER[Heading-Aware Markdown Chunker]
            EMBED[Vector Embedder - 9router / Ollama / OpenAI]
            CTX[Anthropic Contextualizer]
        end

        subgraph "Local Storage Layer"
            DB[(SQLite Database - knowledge.db)]
            FTS[FTS5 BM25 Full-Text Index]
            VEC[Float32 Vector BLOBs]
            VAULT[Vault Files - data/raw/*.md]
        end
    end

    AG -->|HTTP POST /mcp| AUTH
    CC -->|HTTP POST /mcp| AUTH
    CX -->|HTTP POST /mcp| AUTH

    AUTH --> HTTP --> TOOLS
    TOOLS --> HYBRID
    TOOLS --> INGEST
    
    HYBRID --> FTS
    HYBRID --> VEC
    
    INGEST --> CHUNKER --> CTX --> EMBED
    INGEST --> DB
    INGEST --> VAULT

πŸš€ Quick Start (30 Seconds)

Option 1: 1-Click All-in-One Launcher (Windows)

Double-click setup-and-run.bat at the root of the project:

.\setup-and-run.bat

The script automatically verifies Node.js, connects to your embedding gateway (e.g. 9router/Ollama), builds TypeScript, indexes your vault, registers Antigravity MCP configs, and launches the server!


Option 2: Manual Step-by-Step Setup

  1. Clone the repository:

    git clone https://github.com/your-username/knowledge-mcp.git
    cd knowledge-mcp
  2. Install dependencies:

    npm install
  3. Configure environment (.env):

    cp .env.example .env

    Sample .env configuration:

    VAULT_DIR=./data/raw
    DB_PATH=./db/knowledge.db
    PORT=3900
    
    # Embedding (Ollama or 9router OpenAI-compatible endpoint)
    EMBEDDING_BASE_URL=http://localhost:11434/v1
    EMBEDDING_MODEL=nomic-embed-text
    EMBEDDING_API_KEY=ollama
    EMBEDDING_DIM=768
    
    # Anthropic Contextual Retrieval (Optional)
    CONTEXTUAL_RETRIEVAL_ENABLED=false
    CHAT_BASE_URL=https://api.openai.com/v1
    CHAT_MODEL=gpt-4o-mini
    CHAT_API_KEY=your-key
    
    # Authentication (Optional for remote deployments)
    MCP_AUTH_TOKEN=
  4. Index your knowledge documents: Drop your Markdown files into data/raw/ and run:

    npm run reindex
  5. Start the MCP server:

    npm run build
    npm start

    Server endpoint: http://localhost:3900/mcp | Health check: http://localhost:3900/health.


πŸ› οΈ MCP Tool Reference

Knowledge MCP exposes 8 production-ready tools:

Tool Name

Parameters

Description

context_for_query

query: string, maxTokens?: number

Recommended primary tool. Assembles top relevant chunks into an LLM-ready Markdown block with sources.

hybrid_search

query: string, k?: number

Hybrid full-text (BM25) + dense vector search via Reciprocal Rank Fusion (RRF k=60).

keyword_search

query: string, k?: number

Exact keyword and phrase search via SQLite FTS5.

similar_notes

query: string, k?: number

Semantic cosine similarity vector search.

read_note

path: string

Read full content of a specific note file (path-traversal protected).

list_notes

prefix?: string

List all notes in the vault with optional directory prefix filter.

write_note

path: string, content: string, overwrite?: boolean

Create a new note file and instantly auto-reindex it into SQLite.

append_note

path: string, content: string

Append content to an existing note and instantly auto-reindex it.


πŸ”Œ Connecting to AI Clients

1. Antigravity IDE / CLI

Add to ~/.gemini/config/mcp_config.json:

{
  "mcpServers": {
    "knowledge-vault": {
      "serverUrl": "http://localhost:3900/mcp"
    }
  }
}

2. Claude Code & Claude Desktop

Add to .mcp.json or claude_desktop_config.json:

{
  "mcpServers": {
    "knowledge-vault": {
      "type": "streamable-http",
      "url": "http://localhost:3900/mcp"
    }
  }
}

3. Cursor & VS Code

Under IDE Settings > Features > MCP:

  • Name: knowledge-vault

  • Type: Streamable HTTP / SSE

  • URL: http://localhost:3900/mcp


πŸ§ͺ Testing

Run comprehensive unit and integration tests:

# Run all test suites (DB, Chunker, Search, MCP Server)
npm run test:all

πŸ—ΊοΈ Roadmap

Check out our ROADMAP.md for upcoming milestones:

  • ⚑ Phase 1: Real-Time Live File Watcher (chokidar).

  • βœ‚οΈ Phase 2: Surgical Note Editing (update_section, patch_frontmatter).

  • πŸ“„ Phase 3: Multi-Format Parsing (PDF, Word, Excel).

  • 🎯 Phase 4: Cross-Encoder Re-Ranking Pipeline.

  • πŸ–₯️ Phase 5: Local Web Dashboard & RAG Playground.


πŸ“œ License & Contribution

Distributed under the MIT License. Contributions, issues, and feature requests are welcome!

Related MCP Connectors

Related MCP Servers

  • A
    license
    B
    quality
    D
    maintenance
    Enables AI to manage Obsidian notes, including creation, reading, updating, deletion, full-text search, listing with filtering, sorting, and metadata extraction via the Model Context Protocol.
    8
    6 npm
    MIT
  • A
    license
    Not graded
    quality
    B
    maintenance
    Enables AI agents to manage Markdown notes via the Model Context Protocol, supporting creation, editing, searching, and conflict detection.
    MIT
  • A
    license
    Not graded
    quality
    B
    maintenance
    Enables AI agents to search, read, and traverse a local knowledge base of Markdown files using full-text search and relationship graph, reducing token usage.
    MIT
  • A
    license
    Not graded
    quality
    C
    maintenance
    Enables AI clients to search and retrieve notes from a local Markdown vault using hybrid keyword/semantic search, and to save typed memories with append and guarded replacement operations.
    MIT