Skip to main content
Glama

Zenith External-Engram

A lightweight, drop-in External-Engram memory layer for local LLMs (Ollama, llama.cpp, Claude Code, and MCP clients).

Compact local models (4B–12B) excel at reasoning and tool use, but waste context and parameters trying to memorize exact symbol names, C++ structs, CLI flags, and codebase patterns. Inspired by host-RAM N-gram / Engram conditional memory, Zenith External-Engram pairs:

  1. Exact Symbol & Trigram N-gram matching (pg_trgm) — instant recall on rare identifiers, error codes, and C++/Python symbols where dense vectors struggle.

  2. BM25-style Full-Text Search (tsvector + GIN) — fast keyword & multi-term recall.

  3. Dense Semantic Vector Search (pgvector) — conceptual recall via any local OpenAI-compatible embedding server (nomic-embed-text via Ollama or llama-server --embedding).

  4. Reciprocal Rank Fusion (RRF) — fuses all three signals into a single ranked result set in milliseconds.


Three Drop-In Interfaces on One Port (:8316)

Endpoint

Purpose

POST /search

Fast JSON API for hybrid N-gram + FTS + Vector RRF search

POST /mcp

Streamable HTTP MCP server (engram_search, engram_stats) for Claude Code & MCP clients

POST /v1/chat/completions

Drop-in OpenAI-compatible proxy for Ollama or llama.cpp — automatically injects high-confidence <engram_memory> snippets into context (override target with X-Upstream-URL, disable per-request with X-Engram-Disable: 1)


Related MCP server: koragraph

2-Minute Quickstart

1. Start Postgres (pgvector + pg_trgm)

docker compose up -d

2. Install Python dependencies

pip install -r requirements.txt

3. Ingest your codebases (Python, C/C++, TypeScript/JS, Go, Java, Markdown, Bash)

export DATABASE_URL="postgresql://engram:engram@127.0.0.1:5435/engram"
# Optional: point to Ollama or llama-server embeddings (768-dim nomic-embed-text)
export EMBED_URL="http://127.0.0.1:11434/v1/embeddings"
export EMBED_MODEL="nomic-embed-text"

python ingest.py /path/to/your/repo --tag my-repo --category backend

(Works with or without an embedding server — if EMBED_URL is unavailable, trigram N-gram + FTS search still runs out of the box.)

4. Start the External-Engram Server

export UPSTREAM_URL="http://127.0.0.1:11434"   # Ollama or any llama-server
python server.py

5. Use It Anywhere

Direct Hybrid Search:

curl -s http://127.0.0.1:8316/search \
  -H "Content-Type: application/json" \
  -d '{"query": "engram_gate", "top_k": 5}'

MCP Client (.mcp.json):

{
  "mcpServers": {
    "zenith_engram": {
      "type": "http",
      "url": "http://127.0.0.1:8316/mcp"
    }
  }
}

Drop-In Proxy for Ollama / llama.cpp: Point any OpenAI-compatible client at http://127.0.0.1:8316/v1. To target a specific llama-server slot instead of Ollama, pass header X-Upstream-URL: http://127.0.0.1:8080.


Tests

pytest -q

License

MIT

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

    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables coding agents to query a local, multi-repo code graph for symbol exploration, blast radius analysis, co-change mining, and durable code-anchored memory via MCP tools.
      247 npm
      16
      Business Source 1.1
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables MCP-based hybrid semantic code search over repositories, providing tools for searching code by meaning or keyword, retrieving symbol definitions, finding usages, reading chunks, and listing indexed repos.
      MIT