Anthropic

Memstate + Claude

Give Claude persistent, structured memory via MCP.

Claude is stateless by design — every conversation starts fresh. Memstate gives Claude a persistent memory layer via MCP, so your architecture decisions, project context, and past work are always available.

1

Get Your API Key

Sign up for free — no credit card required.

Sign Up Free

Already have an account? Go to API Keys →

2

Add MCP Configuration

Add this to your Claude MCP config file. Replace YOUR_API_KEY_HERE with your key.

MCP Configuration (JSON)
{
  "mcpServers": {
    "memstate": {
      "command": "npx",
      "args": ["-y", "@memstate/mcp"],
      "env": {
        "MEMSTATE_API_KEY": "YOUR_API_KEY_HERE"
      }
    }
  }
}
📁

Save to:

~/Library/Application Support/Claude/claude_desktop_config.json

Claude Code vs Claude Desktop

Claude Code (terminal): Add the config to ~/.claude.json under the mcpServers key, or run:

claude mcp add memstate -e MEMSTATE_API_KEY=YOUR_KEY -- npx -y @memstate/mcp

Claude Desktop (app): Add the config to the path shown above and restart the app.

3

Add Agent Rule

This rule tells Claude to load your project context before tasks and save summaries after — automatically, every session.

CLAUDE.md (project root)
# Memstate MCP - Memory Storage

This project uses Memstate MCP for persistent, versioned memory across sessions.

## REQUIRED: Start and end every task with memory

**BEFORE starting any task**, load existing context so you don't redo past work or revert intentional decisions:
```
memstate_get(project_id="<your_project>")
```

**AFTER completing any task**, save what you did so the next session has context:
```
memstate_remember(project_id="<your_project>", content="## Task Summary\n- What was done\n- Key decisions made\n- Files modified", source="agent")
```

These two calls are mandatory. Skipping them means the next session starts blind.

## Tool reference

| Tool | When to use |
|------|-------------|
| memstate_get | **Start of every task.** Browse project tree or fetch content at a keypath. |
| memstate_remember | **End of every task.** Save markdown summaries, notes, decisions. |
| memstate_search | Find memories by meaning when you don't know the exact keypath. |
| memstate_set | Store a single key=value fact (e.g. config.port). Not for summaries. |
| memstate_history | View version history of a keypath. |
| memstate_delete | Soft-delete a keypath (history preserved). |

## Project naming
Use a short snake_case name matching your repo or topic (e.g. my_app, api_service). All related memories should share the same project_id.

Create this file at: CLAUDE.md (project root)Claude Code memory docs

Test It — Onboard Your Project

Restart Claude, open a project, and paste this prompt. It will create your first memories and confirm everything is working.

Replace <your_project> with a short name for your repo (e.g. my_app).

Paste into your AI agent
I'm onboarding Memstate AI memory for this project. Please:
1. Analyze this codebase and write a concise high-level architecture overview in markdown — covering the main components, tech stack, key directories, and how data flows through the system.
2. Save it to Memstate using: memstate_remember(project_id="<your_project>", content="<the markdown>", source="agent")
3. Then call memstate_get(project_id="<your_project>") and show me the memory tree so I can confirm it worked.

What to expect

Your agent will analyze the codebase, write an architecture overview, save it to Memstate, then display the memory tree. You'll see structured memories like project.my_app.architecture — this context is now available in every future session automatically.