Skip to content

Summary

Self-hosted persistent memory for coding agents: hooks capture what you do, and an MCP server lets any agent recall it across sessions and across tools.

Features

  • Automatic capture through agent hooks — no manual save step
  • Hybrid retrieval: BM25 keyword search, vector similarity and knowledge-graph structure
  • 54 memory tools over MCP, with a 7-tool fallback when the server is unreachable
  • Shared server across agents, so memory follows you between tools
  • Free on-device semantic recall via EMBEDDING_PROVIDER=local (all-MiniLM-L6-v2)
  • Local viewer UI on port 3113 for inspecting stored memory
  • Self-hosted with no external database dependency; REST API alongside MCP

Installation

Set up this MCP server in your favorite AI agent — copy a ready-made configuration below.

Any MCP-compatible agent

Most agents (Claude, Cursor, Windsurf, VS Code, and more) read a standard mcpServers configuration.

  1. Open your agent's MCP configuration file.
  2. Merge the snippet below into it, filling in the environment variables with your own values.
  3. Restart the agent — the "agentmemory" tools will be available.
{
  "mcpServers": {
    "agentmemory-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "@agentmemory/mcp"
      ],
      "env": {
        "AGENTMEMORY_URL": "http://localhost:3111"
      }
    }
  }
}

Description

The problem it solves

Every new agent session starts from nothing. You re-explain the architecture, the conventions, the thing you tried last week that did not work. agentmemory records that context as you work and serves it back to whichever agent asks for it, so the knowledge outlives a single session and is shared between the tools you use rather than trapped in one.

How it works

A local memory server runs on your machine and exposes three interfaces: MCP, a REST API, and native hooks. Hooks are the part that makes it low-effort — the agent's own tool calls and interactions are captured automatically as you work, compressed into searchable observations, with no manual "remember this" step. Any agent that supports hooks, MCP or REST can attach, and they all share the same memory server, so a note captured while working in one editor is available in the next.

Retrieval is hybrid rather than embeddings-only: BM25 keyword search, vector similarity, and structural matches from a knowledge graph. That matters for the keyless default — with no API key configured, vector embeddings are off and recall runs on BM25 alone, which handles keyword queries but not semantic ones. Setting EMBEDDING_PROVIDER=local gives free on-device semantic search; the first request downloads the Xenova/all-MiniLM-L6-v2 model and inference is local from then on.

The project reports 95.2% retrieval accuracy (R@5) on the LongMemEval-S benchmark and 92% fewer tokens than passing full context, and ships a demo command that seeds sample sessions so you can check recall yourself.

Running it

Node.js 20 or newer. npx -y @agentmemory/agentmemory@latest is the canonical install and start command. The runtime uses four local ports — 3111 for REST and MCP over HTTP, 3112 for iii streams, 3113 for the viewer UI, and 49134 for the engine's WebSocket worker — and stores state in the platform data directory (~/Library/Application Support/agentmemory on macOS, $XDG_DATA_HOME/agentmemory on Linux, %APPDATA%\agentmemory on Windows), overridable with --data-dir.

One caveat worth knowing before you install: agentmemory pins iii-engine v0.11.2 and will not attach to a different version, so if you already run your own iii you need to stop it first. It installs the pinned engine under ~/.agentmemory/bin and leaves your copy alone.

Wiring it up

The MCP entry is identical across every host that uses the mcpServers config shape — Claude Desktop, Cursor, Cline, Roo Code, Gemini CLI and others — and points at the thin @agentmemory/mcp shim, which re-exposes the main package's MCP entrypoint and exposes 54 memory tools when the server is reachable (falling back to 7 core tools when it is not). AGENTMEMORY_URL defaults to http://localhost:3111, so the same entry covers both a local server and a remote or reverse-proxied deployment. Apache 2.0.

Related MCP Servers

New

InfluxData's official MCP server for InfluxDB 3 — schema discovery, bounded SQL and InfluxQL queries, line-protocol writes and token administration across Core, Enterprise and Cloud.

Featured

Mixpanel's official hosted MCP server — 80+ tools for querying product analytics, building boards, managing cohorts and metrics, and reading session replays.

Browse all MCP servers →