Skip to main content
Glama

mcp-moe-hybrid-sdk

License: MIT MCP Spec Python

Production-grade, zero-bloat Python AI SDK & Full-Stack Server uniting Model Context Protocol (MCP 2025-11-25 JSON-RPC 2.0), Hardware- & SLA-Aware Sparse Top-2 Mixture-of-Experts (MoE) Query Routing, SQLite WAL + FTS5 BM25 + Cosine Vector Reciprocal Rank Fusion (RRF) Hybrid RAG, and Deterministic Secret/PII Redaction.


System Architecture

flowchart LR
    Client["SDK / Bento Web UI / Agent Host"] -->|"JSON-RPC 2.0 POST /mcp"| Guard["RedactionGuard (API Key / Bearer / Email Scrub)"]
    Guard --> Disp["McpJsonRpcDispatcher (2025-11-25)"]
    Disp -->|"moe_route_query"| Router["SparseTop2MoeRouter (VRAM + Latency SLA)"]
    Disp -->|"rag_upsert / rag_hybrid_search"| Vault["HybridKnowledgeVault (SQLite WAL)"]
    Vault --> FTS["FTS5 BM25 Lexical Index"]
    Vault --> Vec["L2 Dense N-Gram Vector Cosine"]
    FTS --> RRF["Reciprocal Rank Fusion (k=60)"]
    Vec --> RRF

Related MCP server: memo-mcp

Empirical Golden-Suite Benchmarks (benchmarks/run_golden_eval.py)

Subsystem

Golden Queries

Accuracy / Recall@1

$p_{50}$ Latency

$p_{95}$ Latency

External Runtime Dependencies

Hybrid RAG (FTS5 BM25 + Vector RRF)

100

1.0000 (100%)

0.2795 ms

0.4660 ms

0 (Stdlib sqlite3 WAL + FTS5)

Sparse Top-2 MoE Router (4 Tiers)

100

1.0000 (100%)

0.0087 ms

0.0122 ms

0 (Deterministic math + SLA guard)


Quickstart

1. Local Install & Test Gate

pip install -e .
python -m unittest discover -s tests -v
python benchmarks/run_golden_eval.py

2. Launch Full-Stack MCP Server + Interactive Bento Web Showcase

python -m mcp_moe_sdk.server
# Open http://127.0.0.1:8090 for the interactive UI or query GET /health & POST /mcp

3. Containerized Deployment

docker build -t mcp-moe-hybrid-sdk:1.0.0 .
docker run --rm -p 8090:8090 mcp-moe-hybrid-sdk:1.0.0

Python SDK Usage

from mcp_moe_sdk import HybridKnowledgeVault, McpJsonRpcDispatcher, SparseTop2MoeRouter

vault = HybridKnowledgeVault(":memory:")
vault.upsert(
    doc_id="rfc-01",
    title="SQLite WAL FTS5 + Dense Vector RRF",
    body="Fuses exact BM25 keyword matches with cosine similarity.",
    tags=["rag", "sqlite", "fts5"],
)

router = SparseTop2MoeRouter()
decision = router.route(
    "Prove Black-Scholes convexity theorem and MoE invariant",
    max_vram_gib=6.0,
    latency_sla_ms=1200.0,
)
print(decision["selected_tier"], decision["top2_sparse_gates"])

mcp = McpJsonRpcDispatcher(vault=vault, router=router)
resp = mcp.handle({
    "jsonrpc": "2.0",
    "id": 1,
    "method": "tools/call",
    "params": {"name": "rag_hybrid_search", "arguments": {"query": "BM25 cosine RRF", "top_k": 3}},
})

License

Released under the MIT License.

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
      Not graded
      maintenance
      Enables agents to retrieve relevant context via a zero-dependency hybrid search engine that blends sparse keyword-based lexical ranking with dense vector similarity scores into one fused result set, then refines it with knowledge graph triplet expansion and lost-in-the-middle context reordering. It also provides episodic memory consolidation, recency decay, and semantic query caching, exposed as a JSON-RPC 2.0 stdio MCP server for clients such as Claude Desktop, Cursor, and Windsurf.
      MIT
    • F
      license
      Not graded
      quality
      B
      maintenance
      Enables agents to store documents and atomic facts with provenance in a local SQLite knowledge base, then search them through fused keyword, exact, semantic, entity, graph and fact retrieval arms that return one ranked list where every result carries its address, trust level and a reason for its rank. A read-only terminal and loopback web view let humans inspect the same searches, timelines, entity neighbourhoods and agent-written pages without being able to alter the knowledge base.
      -
    • A
      license
      Not graded
      quality
      A
      maintenance
      Gives every AI agent a shared, persistent memory by ingesting Obsidian vaults, code, transcripts, bookmarks and terminal sessions into a three-tier SQLite FTS5 store, then serving token-optimized hybrid retrieval, classification, promotion and cross-source synthesis over MCP and REST. This lets multiple agents read from and write to one compounding brain so each session starts with better context than the last.
      10 npm
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables MCP clients like Claude, Cursor, and Windsurf to search a local document knowledge base using four-layer retrieval fusion (vector similarity, BM25 keywords, knowledge graph traversal, and metadata filtering) with cross-encoder reranking. Also lets agents index documents, add single documents, list indexed sources, and run health diagnostics, with models kept warm between queries so no GPU, PyTorch, or API keys are needed.
      100 PyPI
      12
      MIT