The MCP Memory Gateway is a context engineering server that captures agent feedback, enforces pre-action gates to block known mistakes, and injects relevant past context into AI coding agent sessions for improved reliability and continuity.
Feedback & Memory
Capture feedback (
capture_feedback,capture_memory_feedback): Record up/down signals with context, reasoning, and rubric scores; vague feedback is rejected with a clarification promptRecall past context (
recall,commerce_recall): Vector-search relevant past feedback, memories, and prevention rules for the current taskView summaries & analytics (
feedback_summary,feedback_stats,dashboard): Approval rate trends, gate enforcement stats, and prevention impact overviewsGenerate prevention rules (
prevention_rules,get_reliability_rules): Auto-generate blocking rules from repeated failure patterns
Pre-Action Gates & Safety
Satisfy gates (
satisfy_gate): Record evidence that a gate condition is met (e.g., PR threads checked) with a 5-minute TTLGate statistics (
gate_stats): See blocked/warned counts and top triggered gates
Session Continuity
Session handoff (
session_handoff): Write a primer capturing git state, last task, next step, and blockersSession primer (
session_primer): Restore context at session start from the most recent handoff
Workflow Planning & Diagnosis
List & plan intents (
list_intents,plan_intent): View available workflows and generate checkpointed execution plans with policy gatesDiagnose failures (
diagnose_failure): Root-cause analysis for failed or suspect workflow stepsBootstrap agents (
bootstrap_internal_agent): Normalize GitHub/Slack/Linear triggers into startup context with recall packs and worktree sandboxesDelegation handoffs (
start_handoff,complete_handoff): Manage sequential agent delegation with verification outcomes
Context Engineering
Context packs (
construct_context_pack,evaluate_context_pack): Build and evaluate bounded context packs for large projects, closing the retrieval learning loopContext provenance (
context_provenance): Audit trail of recent context and retrieval decisionsEstimate uncertainty (
estimate_uncertainty): Bayesian uncertainty estimates for risky tags before acting
Business Metrics
Business metrics (
get_business_metrics): Retrieve Revenue, Conversion, and Customer metrics from the Semantic LayerSemantic entity descriptions (
describe_semantic_entity,describe_reliability_entity): Canonical definitions and state of Customer, Revenue, or Funnel entities
Export & Fine-Tuning
Export DPO pairs (
export_dpo_pairs): Build preference pairs from promoted memories for model fine-tuningExport Databricks bundle (
export_databricks_bundle): Export RLHF logs and proof artifacts as a Databricks-ready analytics bundleGenerate skills (
generate_skill): Auto-generate Claude skill files (SKILL.md) from clustered failure patterns
ThumbGate
npm package:
mcp-memory-gateway— install withnpx mcp-memory-gateway init
— Solo dev? Free tier has everything you need. Team or multi-repo? Pro syncs prevention rules across machines and team members. $49 one-time.
Thumbs down a mistake. It never happens again.
The safety net for vibe coding. Give your AI agent a thumbs-down and it auto-generates a prevention rule. Give a thumbs-up and it reinforces good behavior. Pre-action gates physically block the agent before it repeats a known mistake — a reliability layer for one sharp agent, without another planner or swarm.
Honest disclaimer: this is not RLHF weight training. ThumbGate is context engineering plus enforcement. Feedback becomes searchable memory, prevention rules, and gates that block known-bad actions before they execute.
Works with Claude Code, Cursor, Codex, Gemini, Amp, OpenCode, and any MCP-compatible agent.
Live Demo Dashboard | Landing Page | Verification Evidence
Most memory tools only help an agent remember. ThumbGate also enforces.
The problem without it:
BEFORE: Agent force-pushes to main. You correct it. Next session, it force-pushes again.
With ThumbGate (mcp-memory-gateway):
AFTER: Gate blocks the force-push before it executes. Agent can't repeat the mistake.
recallinjects the right context at session start.search_lessonsshows promoted lessons plus the corrective action, lifecycle state, linked rules, linked gates, and the next harness fix the system should make.search_rlhfsearches raw RLHF state across feedback logs, ContextFS memory, and prevention rules.Pre-action gates physically block tool calls that match known failure patterns.
Session handoff and primer keep continuity across sessions without adding an extra orchestrator.
Free and self-hosted users can invoke search_lessons directly through MCP, and via the CLI with npx mcp-memory-gateway lessons.
See it in action
$ npx mcp-memory-gateway serve
[gate] ⛔ Blocked: git push --force (rule: no-force-push, confidence: 0.94)
[gate] ✅ Passed: git push origin feature-branchQuick Start
# One command install — auto-detects your agent
npx mcp-memory-gateway init
# Or add the MCP server directly
claude mcp add rlhf -- npx -y mcp-memory-gateway serve
codex mcp add rlhf -- npx -y mcp-memory-gateway serve
amp mcp add rlhf -- npx -y mcp-memory-gateway serve
gemini mcp add rlhf "npx -y mcp-memory-gateway serve"
# Wire PreToolUse enforcement hooks
npx mcp-memory-gateway init --agent claude-code
npx mcp-memory-gateway init --agent codex
npx mcp-memory-gateway init --agent gemini
# Health check and inspect lessons
npx mcp-memory-gateway doctor
npx mcp-memory-gateway lessons
npx mcp-memory-gateway dashboardHow It Works
1. You give feedback → 👎 "Force-pushed and lost commits"
2. ThumbGate validates → Rejects vague signals, promotes actionable ones
3. Rules auto-generate → "Block git push --force to protected branches"
4. Gates enforce → PreToolUse hook fires → BLOCKED before execution
5. Agent improves → Same mistake never happens againPipeline: Capture → Validate → Remember → Distill → Prevent → Gate → Export

Pre-Action Gates
Gates are the enforcement layer. They do not ask the agent to cooperate — they physically block the action.
Agent tries git push --force
→ PreToolUse hook fires
→ gates-engine checks rules
→ BLOCKED: no force pushes to protected branchesBuilt-in gates:
push-without-thread-check— block push if PR threads unresolvedforce-push— blockgit push --forceto protected branchesprotected-branch-push— block direct pushes to main/masterpackage-lock-reset— block destructive lock file changesenv-file-edit— block edits to.envfiles with secrets
Define custom gates in config/gates/custom.json.
What Actually Works
Actually works | Does not work |
| Thumbs up/down changing model weights |
| Agents magically remembering what happened last session |
| Feedback stats automatically improving behavior by themselves |
Pre-action gates block known-bad tool calls before execution | Agents self-correcting without context injection or gates |
Auto-promotion turns repeated failures into warn/block rules | Calling this "RLHF" in the strict training sense |
Rejection ledger shows why vague feedback was rejected | Vague signals silently helping the system |
Core MCP Tools
Essential profile
Tool | Purpose |
| Accept up/down signal + context, validate, promote to memory |
| Recall relevant past failures and rules for the current task |
| Search promoted lessons with corrective action, lifecycle state, rules, gates |
| Search raw RLHF state across feedback logs, ContextFS, and rules |
| Generate prevention rules from repeated mistakes |
| Inspect promotion rate, active gates, and rejection ledger |
| Approval rate and failure-domain summary |
| Bayesian uncertainty estimate for risky tags |
Lean install for recall + gates + lesson search only:
RLHF_MCP_PROFILE=essential claude mcp add rlhf -- npx -y mcp-memory-gateway serveFree and self-hosted users can invoke search_lessons directly through MCP to inspect corrective action per lesson. For broader retrieval across feedback logs, ContextFS memory, and prevention rules, use search_rlhf through MCP or the authenticated GET /v1/search API.
Dispatch profile
Phone-safe read-only surface for remote ops:
RLHF_MCP_PROFILE=dispatch claude mcp add rlhf -- npx -y mcp-memory-gateway serve
npx mcp-memory-gateway dispatchGuide: docs/guides/dispatch-ops.md
Tech Stack
Core runtime
Node.js
>=18.18.0Module system: CommonJS CLI/server runtime
Primary entry points: CLI, MCP stdio server, authenticated HTTP API, OpenAPI adapters
Interfaces
MCP stdio: adapters/mcp/server-stdio.js
HTTP API: src/api/server.js
OpenAPI surfaces: openapi/openapi.yaml, adapters/chatgpt/openapi.yaml
CLI:
npx mcp-memory-gateway ...
Storage and retrieval
Local memory: JSONL logs in
.claude/memory/feedbackor.rlhf/*Lesson DB (v0.8.0): SQLite + FTS5 full-text search via
better-sqlite3— dual-written alongside JSONL. Indexed by signal, domain, tags, importance. Replaces linear Jaccard token-overlap with sub-millisecond ranked search.Corrective actions (v0.8.0): On negative feedback,
capture_feedbackreturnscorrectiveActions[]— top 3 remediation steps inferred from similar past failures by tag/domain overlap.Context assembly: ContextFS packs and provenance logs
Default retrieval path: SQLite FTS5 (primary) with JSONL Jaccard fallback
Semantic/vector lane: LanceDB + Apache Arrow + local embeddings via Hugging Face Transformers
Intelligence layer
MemAlign-inspired dual recall: Principle-based memory (distilled rules) + episodic context (raw feedback with timestamps). Recall surfaces both lanes ranked by relevance.
Thompson Sampling: Bayesian multi-armed bandit over feedback tags — adapts gate sensitivity per failure domain based on observed positive/negative signal ratios.
Corrective action inference: On negative feedback, the lesson DB infers top-3 remediation steps from similar past failures by tag/domain overlap.
Bayesian belief update: Each memory carries a posterior belief that updates on new evidence — high-entropy contradictions auto-prune.
Enforcement and automation
PreToolUse enforcement: scripts/gates-engine.js
Hook wiring:
init --agent claude-code|codex|geminiBrowser automation / ops:
playwright-coreSocial analytics store:
better-sqlite3
Billing and hosting
Billing: Stripe
Hosted API / landing page: Railway
Worker lane: Cloudflare Workers in
workers/
Agent Integration Guides
Operator Contract
For autonomous agent runs against this or any repo using this workflow:
WORKFLOW.md — scope, proof-of-work, hard stops, done criteria
.github/ISSUE_TEMPLATE/ready-for-agent.yml — bounded intake template
.github/pull_request_template.md — proof-first PR handoff
Pro Pack
$49 one-time — hosted dashboard, priority support, commercial license.
License
MIT. See LICENSE.