mcp-moe-hybrid-sdk
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
mcp-moe-hybrid-sdk
Author: NAHIAN AKHTAR · Senior AI Systems & QA Automation Engineer (New York, NY) · nahianakhtar.github.io
A Python SDK and HTTP server with zero external runtime dependencies, uniting an MCP 2025-11-25 Streamable JSON-RPC 2.0 server, a hardware and SLA aware Sparse Top-2 MoE router, and an embedded SQLite WAL (FTS5 BM25 + dense vector cosine RRF) Hybrid RAG engine. Built for local evaluation, governance enforcement, and single-container deployment without external vector databases or API keys.
Problem Solved
Zero External Runtime Dependencies: Runs entirely on Python 3.10+ stdlib and embedded SQLite
WAL/FTS5with no external vector DB, Redis, or orchestration cluster required.VRAM & Latency SLA Routing: Routes prompts across 4 expert tiers (
edge_fast_json,rag_grounded_synthesis,code_and_systems_verifier,frontier_moe_math_architect) under configurable VRAM and latency budgets.Built-In Production Governance: Enforces secret and PII redaction (
RedactionGuard), sliding-window request/token rate limiting (X-RateLimit-*, HTTP429 Retry-After), W3Ctraceparent+ OTLP/JSON telemetry, and MCP2025-11-25controls (OAuthProtectedResourceGuardRFC 9728/.well-known/oauth-protected-resource, RFC 7636PKCE S256, & RFC 8707/6750 audience-boundBearerintrospection,Mcp-Session-Id+Last-Event-IDSSE replay,roots/listfile://confinement,elicitation/samplingHITL checks, JSON-Schema 2020-12outputSchemavalidation, cooperativenotifications/cancelled).Offline Reproducibility: Every unit test, protocol check, and golden dataset benchmark runs reproducibly offline with zero external API keys.
Related MCP server: memo-mcp
Architecture Overview
flowchart LR
Client["Client (SDK / Web UI / Agent Host)"] -->|"POST/GET/DELETE /mcp (W3C traceparent)"| Limiter["SlidingWindowTokenRateLimiter"]
Limiter --> Guard["RedactionGuard"]
Guard --> Disp["McpJsonRpcDispatcher (MCP 2025-11-25)"]
Disp -->|"moe_route_query"| Router["SparseTop2MoeRouter"]
Disp -->|"rag_upsert_document / rag_hybrid_search"| Vault["HybridKnowledgeVault (SQLite WAL)"]
Disp -->|"otlp_export_telemetry / GET /metrics/otlp"| OTLP["OtlpTelemetryExporter"]
Vault --> FTS["FTS5 BM25"]
Vault --> Vec["Dense Vector Cosine"]
FTS --> RRF["Reciprocal Rank Fusion (k=60)"]
Vec --> RRFLayer | Implementation / Surface | Role |
Core Engine |
| |
HTTP + UI Server |
| |
MCP Tools |
|
|
MCP Resources & Prompts |
|
|
30-Second Quickstart
Local Install & Server
uv venv --python 3.12 .venv
uv pip install --python .venv/bin/python -e ".[dev]"
.venv/bin/python -m mcp_moe_sdk.server
# Listens on http://127.0.0.1:8090 (override with MCP_HOST / MCP_PORT)Containerized Deployment
docker build -t mcp-moe-hybrid-sdk:1.9.0 .
docker run --rm -p 8090:8090 mcp-moe-hybrid-sdk:1.9.0Sample CLI / MCP & Python SDK Usage
MCP HTTP (curl)
# 1. Health & governance snapshot
curl -s http://127.0.0.1:8090/health
# 2. Initialize MCP 2025-11-25 session (returns Mcp-Session-Id response header)
curl -i -s -X POST http://127.0.0.1:8090/mcp \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-11-25","capabilities":{}}}'
# 3. Call Sparse Top-2 MoE router tool
curl -s -X POST http://127.0.0.1:8090/mcp \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"moe_route_query","arguments":{"prompt":"Verify SQLite WAL FTS5 RRF"}}}'
# 4. Call Hybrid RAG search tool
curl -s -X POST http://127.0.0.1:8090/mcp \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"rag_hybrid_search","arguments":{"query":"SQLite FTS5 RRF","top_k":3}}}'Additional endpoints: GET /metrics/otlp exports OTLP/JSON telemetry, GET /mcp with Mcp-Session-Id + Last-Event-ID replays missed SSE events, and DELETE /mcp terminates an active session.
Python SDK
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}},
})
print(resp["result"]["structuredContent"])Verified Test & Benchmark Commands
Run the exact CI and Docker verification commands offline:
.venv/bin/ruff check .
PYTHONPATH=src .venv/bin/pytest -q
PYTHONPATH=src .venv/bin/python benchmarks/run_golden_eval.pyCheck | Scope | Verified Result |
Lint ( | Full repository |
|
Test Suite ( | Offline unit, protocol & edge-case tests |
|
Golden Eval ( |
|
|
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…
This server cannot be deployed
Maintenance
Related MCP Connectors
Cloud or self-hosted knowledge for AI agents: hybrid search, reranking, GraphRAG, scoped MCP tools.
Private, multimodal knowledge store for agents: hybrid search with cited, provenance-backed results.
AI routing, memory, guardrails, and governance. Routes across Claude, GPT, Gemini.
Persistent memory, hybrid search and a goal graph for AI agents, over stdio or remote HTTP.
Related MCP Servers
- AlicenseNot gradedqualityNot gradedmaintenanceEnables 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
- FlicenseNot gradedqualityBmaintenanceEnables 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.-
- AlicenseNot gradedqualityAmaintenanceGives 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 npmMIT
- AlicenseNot gradedqualityDmaintenanceEnables 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.42 PyPI12MIT