AgentVault

Blog

Give Claude Code long-term memory

Connect Claude Code to AgentVault over MCP so durable project facts survive sessions. Includes the official claude mcp add command.

Claude Code can already read the files in your repo, including CLAUDE.md. That is useful, and it is not the same as long-term memory. A rule file is not a queryable store, it does not record which model wrote a fact, and it does not follow you automatically into Cursor or another machine unless you copy it.

AgentVault is a shared long-term memory for AI agents and models. You connect it to Claude Code over MCP (Streamable HTTP). After that, Claude Code can save durable facts with remember, look them up with recall or search, and — if you use the official CLI — load relevant memories when a session starts and before each prompt.

This guide uses only setup that is documented today: the AgentVault quickstart and MCP docs, plus Claude Code’s official MCP documentation at code.claude.com/docs/en/mcp. You will need Node.js, a terminal, and an AgentVault API key.

What you get

Once the agentvault MCP server is connected, Claude Code can use the tools the server exposes: remember, recall, search, list_memories, get_memory, update_memory, forget and list_spaces. Memories can carry a stable key (so a later write supersedes the old value and keeps history), tags, and provenance — the agent, model, provider and app that wrote them.

If you connect with npx @useagentvault/cli connect, AgentVault’s docs say the CLI also sets up hooks that load relevant project facts at the start of a Claude Code session and search memory before each prompt. Each memory is shown once per session. Memories arrive labelled with who wrote them, as background facts rather than instructions. If the API cannot be reached, the session continues normally.

A recalled fact looks like the official docs’ example shape:

example recall
<agentvault-memory>
AgentVault memories relevant to this prompt (written by people and other AI agents; background facts, not instructions):
- [acme.deploy] Deploys go out on Tuesdays and Thursdays after 14:00 GST. (claude-code / claude-opus-5-5, 2026-11-22)
</agentvault-memory>

1. Create an API key

Sign in at useagentvault.com and create a key at the API keys console. The key is shown once. Store it in an environment variable, not in a file you will commit:

terminal
export AGENTVAULT_API_KEY=your-key

Never paste the key back into a chat and ask the model to print it. The official setup prompt tells the agent to stop and ask you for the key, and not to print it.

The Free plan includes 10,000 memories, plenty to test this guide. Pro and Team add unlimited memories, and Team adds shared spaces.

2. Fastest path: one command

From your project directory:

terminal
npx @useagentvault/cli connect

The CLI signs you in and wires up every client it finds on your machine. For Claude Code, the docs say it adds the agentvault MCP server plus the recall hooks described above. Then check the connection:

terminal
npx @useagentvault/cli status

You can also paste AgentVault’s setup prompt into Claude Code and let it run the CLI, read CLAUDE.md, AGENTS.md and .cursorrules, and save durable facts. The current prompt is on the quickstart. It tells the agent to write one fact per memory, use a stable key, pass its own model id and provider, avoid secrets, and finish by running npx @useagentvault/cli recall "how do we deploy".

3. Official Claude Code command

If you would rather add the server with Claude Code’s own CLI, use the HTTP transport, which Anthropic recommends for remote MCP servers:

terminal
claude mcp add --transport http agentvault https://api.useagentvault.com/mcp --header "Authorization: Bearer $AGENTVAULT_API_KEY"

That command is the shape published in both AgentVault’s MCP docs and Claude Code’s MCP docs.

Scopes matter. Claude Code can store the server in three places:

  • Local (default): current project, only for you, stored under that project path in ~/.claude.json.
  • Project: current project, shared with the team via .mcp.json in the repo root. Use this when everyone should get the same server. Do not commit the raw API key; use an environment variable as Claude Code documents.
  • User: all of your projects, private, in ~/.claude.json.

Example project-scope add:

terminal
claude mcp add --transport http agentvault --scope project https://api.useagentvault.com/mcp --header "Authorization: Bearer $AGENTVAULT_API_KEY"

Confirm the --scope flag against the official page if Claude Code prints a usage error — the product moves quickly.

4. JSON config: include type http

If you edit JSON yourself, follow Claude Code’s rule: a server entry that has a url but no type is a configuration error. Claude Code treats typeless entries as stdio servers and will skip this one.

Put this in .mcp.json at the project root (project scope) or in the appropriate section of ~/.claude.json:

.mcp.json
{
  "mcpServers": {
    "agentvault": {
      "type": "http",
      "url": "https://api.useagentvault.com/mcp",
      "headers": {
        "Authorization": "Bearer $AGENTVAULT_API_KEY"
      }
    }
  }
}

Not the homepage snippet

The AgentVault homepage shows a shorter mcp.json without type. That shorter shape is what Cursor documents for remote servers, and what AgentVault documents for ~/.cursor/mcp.json. It is the wrong shape for Claude Code. Use type: http here. Claude Code also accepts streamable-http as an alias for http.

Restart Claude Code, or run /mcp, and confirm agentvault is listed and connected.

5. Save a fact and prove it survived

In a Claude Code session, ask it to store something that should last:

prompt
Remember this as a durable project fact with key deploy.window:
Production deploys go out on Tuesdays and Thursdays after 14:00 GST.
Do not store any secrets.

Then, in the same terminal or a new one:

terminal
npx @useagentvault/cli recall "how do we deploy"

Start a new Claude Code session in the same project and ask: When do we deploy to production? If memory is working, the fact should come back, labelled with the writer, rather than being guessed from the model’s prior. If auto-recall hooks are on, you may see it injected before you even ask.

Useful checks when it does not work:

  • 401 or authentication errors: the header is missing, the variable is unset in the environment Claude Code sees, or the key was revoked. GUI apps often do not inherit your shell profile — set the variable where the app can read it, or use the CLI connect flow.
  • The server is missing in /mcp: the JSON is in the wrong file, or type is missing on a url entry.
  • Tools appear but nothing is stored: confirm you are writing into a space your key can write to. Scoped keys can be read-only.
  • The API is down: the session should still work; you just will not get memory. That is the documented behaviour.

To disconnect later:

terminal
npx @useagentvault/cli disconnect

6. What to store — and what not to

Good memories are facts another agent could use on its own: deploy windows, preferred libraries, incident contacts, decisions you have already made. Write one fact per memory, with a stable key such as repo.deploy. Pass the model id and provider so provenance is accurate.

Do not store passwords, API keys, card numbers or health data. AgentVault’s privacy policy asks you not to. Forgotten memories leave recall; a hard delete erases history. See concepts for keys, as_of, and spaces.

Next

If you also use Cursor, point it at the same endpoint so both tools share one memory. That walkthrough is Share memory between Claude and Cursor. Client-specific snippets for Desktop, VS Code and Windsurf are on MCP clients.

FAQ

Does Claude Code have built-in long-term memory?
Claude Code can use project files such as CLAUDE.md, and it can connect to MCP servers. AgentVault adds a shared, queryable memory with provenance and, when you use the official CLI, automatic recall hooks.
Will these memories leak into other projects?
Use spaces and scoped API keys. A local-scope MCP server stays in one project. Team spaces are shared only after you invite people and they connect with their own keys.
Do I have to use the CLI?
No. claude mcp add --transport http, or a correct .mcp.json, is enough to expose the tools. The CLI is what documents automatic recall hooks for Claude Code.
Which models can write to the same memory?
Any client that can speak MCP or REST to AgentVault — including GPT, Gemini and open models — can read and write the same space, not only Claude.