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:
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:
| Scope | Who sees it |
|---|---|
local | You, in this project. The default. |
project | Everyone who works in this project, through a .mcp.json file in the repository. |
user | You, in 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 userShare 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:
{
"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
claude mcp listtwin-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.
MCP overview
Give an MCP client one end user's memory. One hosted URL; your key and the end user's id as two headers, or a sign-in for claude.ai and ChatGPT; and the same tools as the HTTP API.
Cursor
Add twin memory to Cursor as a remote MCP server in mcp.json, with your key read from the environment.