Memgate

by denizayhan04

Not rated
GitHub

About

Access control, conflict resolution, and audit for shared agent memory.

Details

Author
denizayhan04
Categories
AI, Knowledge Base, Communication, Security

Setup

Install Memgate in your MCP client (Claude Desktop, Cursor, Windsurf, and others).

Repository: https://github.com/denizayhan04/memgate

Follow the installation instructions in the repository README, then restart your MCP client.

Access control, conflict resolution, and audit for shared agent memory.

Memgate sits in front of the memory your AI agents share. It decides who can read and write what, resolves conflicting writes, and records every operation — so a multi-agent system's memory stays trustworthy as it grows.

It speaksMCP, so agents connect with one config entry and no code changes.

Status: early but working. The core (policy, conflict handling, audit, MCP tools) runs and is tested end-to-end with real agents. Adapters for external memory backends and a hosted dashboard are on the roadmap, not built yet. Feedback and issues welcome.

A single agent's memory is easy: keep the conversation in context, done. But when several agents share one memory pool — one handling support, one writing code, one doing billing — that pool degrades:

- Conflicting writes.One agent records "customer is happy," another records "customer is angry." Nobody knows which is current.
- No access boundaries.The billing agent can read customer PII; the support agent can overwrite financial records. Nothing stops it.
- No accountability.When something goes wrong, there's no record of which agent wrote what, or when.

Memory stores like pgvector, Mem0, or Zepholdmemory well. They don'tgovernit. Memgate is the governance layer that sits on top.

Think of the shared memory as a ledger, and Memgate as the gatekeeper standing in front of it. Agents never touch the ledger directly — every request goes through the gate, which does three things:
- Policy— checks whether this agent's role may read or write this namespace. Default is deny.
- Conflict resolution— when a record already exists for an entity, applies the namespace's strategy (last-write-wins,versioned, orrequire-review) instead of silently clobbering it.
- Audit— appends every operation, allowed or denied, to an append-only log.

Identity is bound to the API key, not to anything the agent says. An agent cannot escalate its own privileges by claiming a different role.

Agent A ─┐ Agent B ─┼── MCP ──▶ [ Memgate ] ──▶ Postgres + pgvector Agent C ─┘ policy · conflict · audit
git clone https://github.com/denizayhan04/memgate cd memgate docker compose up --build

This starts Postgres (with pgvector), runs migrations, and serves the MCP endpoint on:8088.

docker compose exec memgate memgate agent create --name support-bot --role support # → API key (shown once): mg_live_...

Connect an MCP client (Claude Code, Cursor, or anything that speaks MCP). Add to your project's.mcp.json:

{ "mcpServers": { "memgate": { "type": "http", "url": "http://localhost:8088/mcp", "headers": { "Authorization": "Bearer mg_live_YOUR_KEY" } } } }

Now the agent hasmemory_write,memory_read, andmemory_searchtools, scoped to whatever its role allows.

docker compose exec memgate memgate audit --entity "customer:acme"
ID AT AGENT ACTION NAMESPACE ENTITY_KEY RESULT 14 2026-07-08T15:43:30Z test-eng write customer-data customer:acme denied 13 2026-07-08T15:43:14Z test-eng read customer-data customer:acme allowed 12 2026-07-08T15:41:05Z test-support read customer-data customer:acme allowed 11 2026-07-08T15:41:02Z test-support write customer-data customer:acme allowed

Two agents, one shared record, different permissions — the support agent writes and reads; the engineer reads but cannot write. Every attempt, allowed or denied, is on record.

Policies live in a YAML file (config/policies.example.yamlby default), not in the database — so they're versioned in git and reviewed like any other config. The rule isdefault deny: anything not explicitly granted is closed.

namespaces: customer-data: conflict_strategy: versioned # old record superseded, new active; history queryable tech-context: conflict_strategy: last-write-wins # new record overwrites old billing: conflict_strategy: require-review # write parked as pending until a human approves roles: support: customer-data: [read, write] tech-context: [read] engineer: tech-context: [read, write] customer-data: [read] finance-bot: billing: [read, write] customer-data: [read] auditor: "": [read]

The running server reloads the policy file without a restart, onSIGHUPor viamemgate reload.

When a write targets an entity that already has an active record:

- last-write-wins— the new record becomes active, the old one is marked superseded.
- versioned— same, but history is preserved and queryable (what did we know, and when).
- require-review— the new write is parked aspending_review; the existing record stays active until a human approves it.

memgate review list # list memories awaiting review memgate review approve <id> # make a pending memory active memgate review reject <id> # reject it
memgate serve Start the MCP (Streamable HTTP) server memgate migrate Apply SQL migrations memgate agent create --name N --role R Create an agent and print its API key memgate review list List memories awaiting review memgate review approve <id> Approve a pending memory memgate review reject <id> Reject a pending memory memgate reload Reload the policy YAML in a running server memgate audit [--entity K] [--namespace N] [--agent A] [--limit N] Show audit log, most recent first
make build # compile to bin/memgate make test # run tests make migrate # apply migrations (needs MEMGATE_DATABASE_URL) make run # run the MCP server locally make up # docker compose up --build make down # stop and remove services
export MEMGATE_DATABASE_URL="postgres://memgate:memgate@localhost:5432/memgate?sslmode=disable" go run ./cmd/memgate agent create --name support-bot --role support

- Backend-agnostic by design.The memory store is behind an interface. Today the only implementation is Postgres + pgvector; adapters for external stores (Mem0, Zep) can be added without touching the policy, conflict, or audit layers.
- Identity is the key, not the claim.An agent's role is resolved from its API key on every request. What the agent
says*about its role is irrelevant — there is no way to self-escalate.
- Audit is append-only.The audit log rejects updates and deletes at the database level, not just in application code.

- Backend adapters (Mem0, Zep)
- REST endpoints alongside MCP, for clients that don't speak MCP
- A read-only audit dashboard
- Team policy management and SSO (hosted)

Go · Postgres + pgvector ·mark3labs/mcp-go· MCP Streamable HTTP transport.

One shared context every AI tool your team uses reads and writes over MCP, so Claude Code, Cursor and ChatGPT stay current together.

Your company's brain, connected to Claude, ChatGPT, Gemini, Cursor, and VS Code. Turn your team's email history into shared memory that any AI assistant can query with natural language.

Provides a universal gateway for corporate AI tools, offering knowledge storage, access control, and proxying of external AI sources.

Cloud memory for Claude Code, Cursor, and any MCP-compatible agent. Context persists across sessions, projects, and teams.

Persistent memory for AI assistants and coding agents across ChatGPT, Claude, Cursor, and other MCP-compatible tools.

Local Work Model for AI agents that learns from real outcomes.

Auditable, self-improving knowledge & memory for AI agents over MCP — citation-enforced answers and a replayable why-trace, self-hosted on Postgres.

Local stdio MCP server for coding agents: shared troubleshooting memory, agent-to-agent help posts, replies, and a unified inbox. Quick start: npx -y agent-only-mcp

One shared, versioned memory for your AI agents across Claude Code, Cursor, Kiro and Grok, with a source on every answer and full history.

Open-source LLM knowledge base that turns team chat (Slack, Discord, Teams, Mattermost) into a typed knowledge graph and auto-generated wiki, exposed via a 28-tool MCP server.

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.