twin memory

Claude Code

Add twin memory to Claude Code as a remote HTTP MCP server, with your key and the end user as headers.

Add the server

Keep your key in an environment variable, then add the server with one command:

Terminal
export TWIN_MEMORY_API_KEY="tm_..."

claude mcp add --transport http twin-memory https://api.twinmemory.dev/v1/mcp \
  --header "Authorization: Bearer $TWIN_MEMORY_API_KEY" \
  --header "X-Twin-Account: user_42"

-t is short for --transport and -H for --header. The shell expands $TWIN_MEMORY_API_KEY when you run the command, so the key itself is written into Claude Code's configuration.

Use a read key if Claude should only search and read: it cannot write or erase. Use a read and write key if Claude should save what it learns: the server then lists memory_add too.

Choose a scope

--scope (or -s) says where the server is kept:

ScopeWho sees it
localYou, in this project. The default.
projectEveryone who works in this project, through a .mcp.json file in the repository.
userYou, in every project.
Every project
claude mcp add --transport http twin-memory https://api.twinmemory.dev/v1/mcp \
  --header "Authorization: Bearer $TWIN_MEMORY_API_KEY" \
  --header "X-Twin-Account: user_42" \
  --scope user

Share it through .mcp.json

With --scope project, Claude Code writes a .mcp.json file at the root of the project. You can also write it by hand. Claude Code expands ${VAR} in url and headers, so the key stays out of the file:

.mcp.json
{
  "mcpServers": {
    "twin-memory": {
      "type": "http",
      "url": "https://api.twinmemory.dev/v1/mcp",
      "headers": {
        "Authorization": "Bearer ${TWIN_MEMORY_API_KEY}",
        "X-Twin-Account": "user_42"
      }
    }
  }
}

Each person who uses the project sets TWIN_MEMORY_API_KEY in their own environment. ${VAR:-default} gives a fallback value.

An unset variable is sent as written

If TWIN_MEMORY_API_KEY is not set, the configuration still loads and claude mcp list warns about it, but the literal text ${TWIN_MEMORY_API_KEY} is sent as the key. The server then answers 401.

Check it

Terminal
claude mcp list

twin-memory should be listed as connected. In a session, ask Claude to call memory_overview: it answers with the directories and counts of user_42's memory.

A new end user with nothing written yet has no memory to read. Add something first with /v1/memory/add, or see Troubleshooting.


Sources checked 2026-10-21: code.claude.com/docs/en/mcp.

On this page