Skip to main content
Glama

hybrid-recall

License: MIT

A local, self-hosted retrieval stack exposed over the Model Context Protocol (MCP). It gives an LLM four tools:

  • sqlite - hybrid search over a document corpus you ingest (FTS5 keyword + semantic embeddings, fused with Reciprocal Rank Fusion).

  • retrieve - one unified search across the knowledge graph, memory, and docs, with KG-powered query expansion and RRF fusion.

  • memory - a semantic key/value store for cross-session notes (store / append / replace-section / search / get / list).

  • kg - an entity-relationship knowledge graph with hybrid search.

Everything runs on your machine. The only external dependency is an OpenAI-compatible embedding server (a small llama-server process), and an optional reranker. Nothing is sent to a third party.

How it fits together

  MCP client (Claude Desktop, etc.)
        |  stdio (JSON-RPC)
        v
  server.py  ->  sqlite / retrieve / memory / kg tools
        |                 |                |
        |                 |                +--> memory daemon (TCP :8767)
        |                 +--> knowledge_graph.jsonl
        +--> docs.db (FTS5 + 2560-d embeddings) + embed_cache (mmap)
                          |
                          v
             embedding server (llama-server :8000, Qwen3-Embedding-4B)

The docs corpus, memory, and knowledge graph all embed through the same model, so a single llama-server covers the whole stack.

Related MCP server: Hoard

Requirements

  • Python 3.10+

  • llama.cpp (llama-server on your PATH)

  • A GPU is recommended for the embedding model (it runs on CPU too, slower)

Quickstart

# 1. Install Python deps
pip install -r requirements.txt

# 2. Download the embedding model into ./models  (see models/README.md)
huggingface-cli download Qwen/Qwen3-Embedding-4B-GGUF \
  Qwen3-Embedding-4B-Q8_0.gguf --local-dir ./models

# 3. Start the embedding server (leave running in its own terminal)
scripts/start_embeddings.sh          # Windows: scripts\start_embeddings.bat

# 4. Start the memory daemon (needed for the memory + retrieve tools)
scripts/start_memory.sh              # Windows: scripts\start_memory.bat

# 5. Create the empty docs database
python init_databases.py

# 6. Ingest your documents (markdown, html, json, text, code)
python scripts/ingest_docs.py --source ./corpus     # ./corpus has sample docs

# 7. Embed the chunks (talks to the embedding server from step 3)
python scripts/embed_docs.py

# 8. (optional) Prebuild the mmap vector cache for instant search
python scripts/rebuild_mmap_cache.py

Then point your MCP client at server.py (see example_config.json):

{
  "mcpServers": {
    "hybrid-recall": {
      "command": "python",
      "args": ["/absolute/path/to/hybrid-recall/server.py"]
    }
  }
}

Configuration

All settings have sane localhost defaults; override them with environment variables or a .env file (see .env.example). The important ones:

Variable

Default

Purpose

EMBED_SERVER_URL

http://127.0.0.1:8000/v1/embeddings

embedding endpoint

RERANKER_URL

http://127.0.0.1:8001/v1/rerank

reranker (optional)

MEMORY_SERVICE_PORT

8767

memory daemon port

KNOWLEDGE_GRAPH_PATH

./data/knowledge_graph.jsonl

KG storage

DOCS_DB_PATH

./data/docs.db

docs corpus DB

To run the models on a different machine, point EMBED_SERVER_URL / RERANKER_URL at that host. The tools do not care where the servers live.

Reranking

Reranking is optional and off by default. Every search works without it and falls back to bi-encoder order if the reranker is not running. To enable it, start the reranker (scripts/start_reranker) and pass rerank=true on a call.

Notes

  • The docs corpus, memory store, and knowledge graph are all built from your own data. A fresh clone starts empty.

  • Index-time and query-time embeddings must come from the same model. If you switch embedding models, re-embed the corpus.

  • The memory tool is a small TCP daemon (scripts/start_memory); the docs and KG tools run in-process inside the MCP server.

Benchmarks

The design choices here (Qwen3-4B bi-encoder, cross-encoder reranking off by default, RRF fusion, BGE-reranker-v2-m3) are backed by real measurements: recall suites, a 10-strategy fusion A/B, reranker and embedding model bake-offs, and latency profiles. See benchmark.md. Short version: real embeddings + reranking moved retrieval MRR from 0.36 to 0.77 on a 32-query suite, and plain reranking beat every fancy fusion scheme tried against it.

License

MIT. See LICENSE.

Available Tools

4 tools
kgA

Entity-relationship graph for structured facts. Use for entities with relationships - concepts, tools, people, patterns. Check here before semantic_search. For free-form text/learnings, use memory instead. Hybrid search (70% semantic + 30% keyword). Limits: 10K entities, 100 obs/entity. Audit log for destructive ops. Actions: create_entities, create_relations, add_observations, delete_entities, delete_relations, search, neighbors, stats, read, prune, remove_observation, update_entity, rename_entity, merge_entities, batch. IMPORTANT: Always specify entity_type when creating entities - omitting it defaults to 'unknown' which pollutes the graph. Knowledge graph is stored as JSONL.

ParametersJSON Schema
NameRequiredDescriptionDefault
modeNoSearch mode: hybrid (default, 70% semantic + 30% keyword), semantic (embeddings only), keyword (substring only)
depthNo
limitNo
namesNo
queryNo
actionYes
targetNoEntity to merge into (will be kept)
dry_runNoPrune: if true, just report candidates (default true)
updatesNoFields to update: entity_type, description, aliases, parent_type
entitiesNo
new_nameNoNew entity name for rename_entity
old_nameNoCurrent entity name for rename_entity
relationsNo
operationsNoList of operations for batch action. Each op needs 'op' key: {op: 'add_observations', entity_name: 'X', observations: [...]}, {op: 'create_relations', relations: [{from, to, relation_type}]}, {op: 'create_entities', entities: [...]}, {op: 'delete_entities', names: [...]}
preprocessNoExpand synonyms in search query (default True)
entity_nameNo
observationNoSingle observation text for remove_observation
max_age_daysNoPrune: only entities older than this (default 30)
observationsNo
source_entityNoEntity to merge from (will be deleted)
min_similarityNoMinimum semantic similarity threshold (default 0.25)
min_connectionsNoPrune: only entities with <= this many connections (default 0)

TDQS

A4.5/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, description carries full burden and delivers substantive behavioral context: limits (10K entities, 100 obs/entity), audit log for destructive ops, storage format (JSONL), default inference behavior for entity_type, and hybrid search weighting. Lacks detail on specific action side effects, but substantial coverage.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Description is dense but justified given 15 actions and multiple behavioral notes. Structured logically: purpose, usage, search mode, limits, actions, critical warning. No filler or redundancy despite length.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a high-complexity tool with 22 params, 15 actions, nested objects, and no output schema, the description covers purpose, usage, limits, audit, storage, search behavior, and a key input pitfall. Lacks per-action behavior and return formats, but provides a strong operational overview.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 59%, so this is moderate. The description adds critical semantics absent from schema by warning that omitting entity_type defaults to 'unknown', which pollutes the graph. Also mentions hybrid search weights and batch operation patterns (partially in schema). Adds value beyond structured definitions.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Description clearly defines the tool as an 'Entity-relationship graph for structured facts' and states it's for entities with relationships, listing example domains. It distinguishes from siblings by explicitly contrasting with memory ('free-form text/learnings') and positioning it before semantic_search, making purpose unambiguous.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Provides explicit when-to-use guidance: 'Use for entities with relationships - concepts, tools, people, patterns. Check here before semantic_search. For free-form text/learnings, use memory instead.' This directly addresses alternatives and search precedence.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

memoryA

On session start: get session:latest + project:overview. Semantic memory for cross-session persistence. Returns {success, results/value}. Actions: store (save key+message, full overwrite), append (add fragment to existing key without rewriting it - server concatenates and re-embeds), replace_section (in-place edit of marker-bounded region inside an existing entry), search (semantic query), get (exact key), delete, list. RAM-backed with async disk persist - use liberally. Key conventions: session:latest (current state), project:overview (architecture), learn: (discoveries), pref: (user prefs), todo:, code:. For large rolling docs (timelines, session logs) use append instead of store - massive token savings. For in-place section edits inside a long doc, use replace_section with HTML-comment markers like ''/''. Search is semantic with synonym expansion ('fast'->'quick'). Use preprocess=False for exact match. When encountering issues or problems search for related context. On milestones: store session:latest.

ParametersJSON Schema
NameRequiredDescriptionDefault
keyNoStorage key (e.g., 'learn:kg-patterns'). Required for store/append/replace_section/get/delete.
tagsNoTags for filtering (search/list) or storing. Auto-extracted from key prefix (learn:topic -> ['learn']).
limitNoMax results for search/list. Default: 10.
queryNoSemantic search query. Finds related content even with different wording.
actionYesstore=full overwrite, append=add fragment without rewrite, replace_section=in-place edit between markers, search=semantic query, get=exact key, delete=remove, list=all keys
offsetNoFor get: starting char offset into stored text. Use with _next_offset from prior response to page through large entries.
messageNoContent for store/append. For store: full content (overwrites). For append: only the new fragment to add. Markdown supported.
sort_byNoSort order for list: 'date' (newest first) or 'key' (alphabetical).
user_idNoUser namespace. Default: 'default'.
inclusiveNoFor replace_section: if False (default) preserve markers and replace only between them. If True, replace markers along with the content.
max_charsNoFor get: max chars to return from offset. 0 = all remaining. Response includes _total_chars and _next_offset if more data exists.
separatorNoFor append: string inserted between existing text and new fragment. Default '\n\n'. Pass '' for butt-join.
end_markerNoFor replace_section: closing marker. Convention: '<!-- name:end -->'. Must follow start_marker in the document.
new_contentNoFor replace_section: replacement content for the region between markers. Falls back to 'message' if not provided.
start_markerNoFor replace_section: opening marker. Convention: '<!-- name:start -->' (HTML comment, invisible in rendered markdown).
create_if_missingNoFor append (default True) and replace_section (default False): if True, create the key/section when it doesn't exist instead of erroring.

TDQS

A4.6/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries full burden and does so thoroughly. It discloses RAM-backed async disk persistence, server-side concatenation and re-embedding for append, semantic search with synonym expansion ('fast'->'quick'), full-overwrite semantics for store, and marker behavior for replace_section. It even mentions preprocess=False for exact match, adding genuine behavioral nuance.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Although lengthy, the description is densely packed and logically structured: it opens with the most critical startup routine, then defines the tool's purpose, summarizes actions, lists key conventions, and ends with targeted usage tactics. Every sentence earns its place given the tool's complexity (7 actions, 16 params).

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The description covers the main use cases, return shape ({success, results/value}), persistence semantics, and key conventions. It lacks detailed per-action return schemas and explicit error-handling behavior. Given no output schema and high complexity, it is mostly complete but not exhaustive.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so baseline is 3. The description adds value by clarifying action semantics (store=full overwrite, append=add fragment, replace_section=in-place edit), explaining the purpose of markers, and providing key conventions like 'learn:<topic>'. The reference to preprocess=False is extra, though the parameter is not in the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool is 'semantic memory for cross-session persistence' and enumerates seven specific actions (store, append, replace_section, search, get, delete, list), along with key naming conventions. This distinguishes it from sibling tools by explicitly framing its role as a persistent memory system.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides strong when-to-use guidance: 'On session start: get session:latest + project:overview', 'When encountering issues or problems search for related context', and 'On milestones: store session:latest'. It also advises using append for large rolling docs and replace_section for in-place edits. However, it never explicitly contrasts with sibling tools like sqlite/retrieve/kg, so it lacks explicit when-not-to-use alternatives.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

retrieveA

Unified retrieval across KG, Memory, and Docs with KG-powered query expansion. Use for conceptual queries where keyword search fails. Automatically expands query using KG domain knowledge (e.g., 'transformer optimization' -> includes KV cache, Flash Attention). Fuses results via reciprocal rank fusion. Returns results with source attribution. Default: compact=true (shorter snippets, ~500-800 tokens). Use compact=false for full content (~2000 tokens).

ParametersJSON Schema
NameRequiredDescriptionDefault
limitNoMax results (default: 10)
queryYesSearch query
rerankNoUse cross-encoder reranking for better relevance (default: false). Requires a running reranker.
compactNoLow token mode: shorter snippets (200 chars). Default: true. Set false for full content (500 chars).
sourcesNoSources to search (default: ['kg', 'docs', 'memory'])
doc_typeNoFilter docs by type (markdown, json, code, etc.)
doc_sourceNoFilter docs by source (github, arxiv, devdocs, etc.)
expand_queryNoUse KG for query expansion (default: true)
rerank_top_nNoCandidates to fetch before reranking (default: 20). Only used if rerank=true.
semantic_thresholdNoMin similarity for semantic search (default: 0.5)

TDQS

A4.2/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It explains key internal behaviors: KG-powered query expansion with an example, reciprocal rank fusion, source attribution, and compact mode token estimates. However, it does not explicitly state whether the operation is read-only or side-effect-free, though the nature of retrieval implies it.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is about 80 words and front-loads the core purpose in the first sentence. Every sentence adds value: purpose, usage scenario, expansion behavior, fusion method, output attribution, and compact defaults. It is dense but not verbose.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a complex tool with 10 parameters and no output schema, the description provides a strong high-level overview, including expansion, fusion, and sourcing. However, it does not describe the return result structure beyond 'source attribution,' nor does it explain how parameters interact (e.g., rerank requiring rerank_top_n). This is adequate but not fully complete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the baseline is 3. The description adds some extra context for specific parameters: compact mode token counts (~500-800 vs ~2000) and expand_query behavior, but these details are also partially in the schema. The description does not meaningfully improve understanding of the more complex parameters like rerank or semantic_threshold.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's function: 'Unified retrieval across KG, Memory, and Docs' with a specific verb ('retrieve') and resource scope. It also distinguishes itself from sibling tools by focusing on conceptual queries and knowledge-graph expansion, making its role unique.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description tells the agent when to use the tool: 'Use for conceptual queries where keyword search fails.' It provides a clear context but does not explicitly mention when to avoid it or direct users to alternatives like the sibling tools (sqlite, memory, kg), so it misses an explicit exclusion list.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

sqliteA

SQLite database operations + document-corpus search. Commands: catalog, exec, list_databases, open_database, health_check, docs_search, docs_semantic_search, docs_hybrid, docs_full, docs_context, docs_search_in_doc. docs_search: FTS5 keyword search over the ingested docs corpus. Use for exact terms, API names, phrases. docs_semantic_search: Embedding similarity search over docs. Use for general queries. docs_hybrid: PREFER THIS Run both keyword + semantic with RRF fusion. Best recall. docs_full: Retrieve complete document by exact path. Use sql param with path from search results. Wildcard % optional for fuzzy match. docs_context: Expand around a chunk - params: {chunk_id, before, after}. docs_search_in_doc: Hybrid search within a specific document - params: {query, limit, threshold}. sql=path. Returns chunk positions. All docs search commands: query via 'sql' param. docs_* filters: {doc_type, source, limit, threshold}. docs_* results are pre-chunked - do NOT use file reads; run more searches or use docs_context/docs_full instead.

ParametersJSON Schema
NameRequiredDescriptionDefault
sqlNoSQL query, or search query for docs_search
writeNo
paramsNoQuery params or search filters: {doc_type, source, limit, threshold}
commandYes
sqlite_fileNoDatabase path: absolute or relative (resolved under ./data/). Ignored for docs_* commands.

TDQS

A4/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. It does disclose that docs_* results are pre-chunked and advises against file reads. However, it fails to mention that the 'exec' command can perform arbitrary SQL writes, and does not warn about destructive actions or the need for the 'write' flag. This is a significant transparency gap for a tool that can mutate the database.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is long but well-structured: a brief overview, a list of commands, then detailed explanations for each key command. Every sentence serves a purpose, and the use of bold command names and concise phrases makes it scannable. The density is justified given the tool's complexity, though it could be slightly trimmed for the most basic database commands.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The docs_* commands are thoroughly explained, including behavior, params, and when to use them. However, the basic database commands (catalog, exec, list_databases, open_database, health_check) are only listed without any explanation of their purpose, return values, or side effects. Given that there is no output schema, the description fails to fully compensate for the complexity of the database operations.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description adds substantial meaning beyond the schema. It clarifies that the 'sql' param doubles as a search query for docs_search, and it details command-specific params like {chunk_id, before, after} for docs_context and {query, limit, threshold} for docs_search_in_doc. While the schema already covers 60% of parameters, the description fills gaps and provides practical semantics for the other 40%.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's dual purpose: 'SQLite database operations + document-corpus search.' It then enumerates specific commands, and explicitly distinguishes between keyword search, semantic search, hybrid search, full-document retrieval, context expansion, and in-document search. This level of specificity and differentiation from siblings (retrieve, memory, kg) is excellent.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides explicit when-to-use guidance for each docs_* command: 'Use for exact terms, API names, phrases' for docs_search, 'Use for general queries' for docs_semantic_search, and '*PREFER THIS*' for docs_hybrid. It also advises against file reads and recommends alternatives, making the usage intent crystal clear.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. 4 tool updatesv0.1.0
    • First observedkg
    • First observedmemory
    • First observedretrieve
    • First observedsqlite

TDQS

A4.1/5.0
Disambiguation4/5

Each tool has a distinct primary domain (sqlite for SQLite and doc search, retrieve for unified cross-source retrieval, memory for persistent key-value store, kg for graph), but retrieval functions overlap—sqlite's docs_search and retrieve both cover docs, and memory/kg each have search. Descriptions help, but an agent might still be uncertain which search to use.

Naming Consistency2/5

Tool names are all lowercase but mix verb (retrieve) and nouns (sqlite, memory, kg); no consistent verb_noun pattern. Within sqlite, multi-word subcommands use underscores, but tool-level naming is inconsistent.

Tool Count5/5

Four tools is well-scoped for a hybrid recall server covering docs, unified retrieval, memory, and knowledge graph; each earns its place without feeling bloated or sparse.

Completeness4/5

Covers the main retrieval surfaces (docs, memory, KG, unified) with CRUD on memory and KG and doc search operations; minor gaps like missing bulk document management are present, but core workflows are covered.

Maintenance

ActivitySlowing
ResponsivenessNo issues

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/cutlerbenjamin1-cmd/hybrid-recall'

If you have feedback or need assistance with the MCP directory API, please join our Discord server