mcp-memory-gateway

mcp-memory-gateway

An MCP server that provides memory management and gateway capabilities, enabling persistent storage and retrieval of contextual information across sessions.

Category
访问服务器

README

ThumbGate

CI Self-Healing npm License: MIT Node Sponsor Buy Me a Coffee Pro Pack

Pre-action gates that physically block AI coding agents from repeating known mistakes. Capture feedback, auto-promote repeated failures into prevention rules, and enforce them via PreToolUse hooks. This is a reliability layer for one sharp agent, without another planner or swarm.

Honest disclaimer: this is not RLHF weight training. It 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, Codex, Gemini, Amp, Cursor, OpenCode, and any MCP-compatible agent. Verification evidence lives in docs/VERIFICATION_EVIDENCE.md.

Why it exists

Most memory tools only help an agent remember. ThumbGate also enforces.

  • recall injects the right context at session start.
  • search_lessons shows promoted lessons plus the corrective action, lifecycle state, linked rules, linked gates, and the next harness fix the system should make.
  • search_rlhf searches 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.

Tech Stack

Core runtime

  • Node.js >=18.18.0
  • Module system: CommonJS CLI/server runtime
  • Primary entry points: CLI, MCP stdio server, authenticated HTTP API, OpenAPI adapters

Interfaces

Storage and retrieval

  • Local memory: JSONL logs in .claude/memory/feedback or .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_feedback returns correctiveActions[] — 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

Enforcement and automation

  • PreToolUse enforcement: scripts/gates-engine.js
  • Hook wiring: init --agent claude-code|codex|gemini
  • Browser automation / ops: playwright-core
  • Social analytics store: better-sqlite3

Billing and hosting

  • Billing: Stripe
  • Hosted API / landing page: Railway
  • Worker lane: Cloudflare Workers in workers/

Quick Start

# Install MCP server for your agent
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"

# Or auto-detect supported agents
npx mcp-memory-gateway init

# Auto-wire PreToolUse hooks
npx mcp-memory-gateway init --agent claude-code
npx mcp-memory-gateway init --agent codex
npx mcp-memory-gateway init --agent gemini

# Health and core workflows
npx mcp-memory-gateway doctor
npx mcp-memory-gateway lessons
npx mcp-memory-gateway dashboard

What Actually Works

Actually works Does not work
recall injects past context into the next session Thumbs up/down changing model weights
session_handoff and session_primer preserve continuity Agents magically remembering what happened last session
search_lessons exposes corrective actions, lifecycle state, linked rules, linked gates, and next harness fixes 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

How it works

  1. Capture structured feedback with context, tags, and optional reasoning traces.
  2. Validate signals and reject vague or unsafe entries before promotion.
  3. Promote useful feedback into searchable memory and principle/rule material.
  4. Auto-generate prevention rules from repeated failures.
  5. Enforce those rules through PreToolUse hooks before risky tool calls run.
  6. Expose the full state through MCP tools, the API, dashboards, and verification reports.

The serve command also runs a background watcher for external JSONL writes from hooks, CI, or companion tools.

Core Tools

Essential profile

These tools are the shortest path to value:

Tool Purpose
capture_feedback Accept up/down signal + context, validate, promote to memory
recall Recall relevant past failures and rules for the current task
search_lessons Search promoted lessons with corrective action, lifecycle state, rules, gates, and next harness fixes
search_rlhf Search raw RLHF state across feedback logs, ContextFS, and rules
prevention_rules Generate prevention rules from repeated mistakes
enforcement_matrix Inspect promotion rate, active gates, and rejection ledger
feedback_stats Approval rate and failure-domain summary
feedback_summary Human-readable recent feedback summary
estimate_uncertainty Bayesian uncertainty estimate for risky tags

Use the lean install when you want recall, gates, and lesson search first:

RLHF_MCP_PROFILE=essential claude mcp add rlhf -- npx -y mcp-memory-gateway serve

Free 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

For phone-safe remote ops, use the read-only dispatch surface:

RLHF_MCP_PROFILE=dispatch claude mcp add rlhf -- npx -y mcp-memory-gateway serve
npx mcp-memory-gateway dispatch

Guide: docs/guides/dispatch-ops.md

Pre-Action Gates

Gates are the enforcement layer. They do not ask the agent to cooperate.

Agent tries git push
→ PreToolUse hook fires
→ gates-engine checks rules
→ BLOCKED (for example: no PR thread check)

Built-in examples include:

  • push-without-thread-check
  • package-lock-reset
  • force-push
  • protected-branch-push
  • env-file-edit

Define custom gates in config/gates/custom.json.

Architecture

Pipeline: Capture → Validate → Remember → Distill → Prevent → Gate → Export

Context Engineering Architecture

For deeper packaging and topology details:

Operator Contract

If you are running autonomous agents against this repo or another repo that uses this workflow, keep these entry points visible:

Commercial and Proof Surfaces

License

MIT. See LICENSE.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选