Compartment — Claude Code MCP server for encrypted agent memory
Local memory for AI agents: one encrypted vault on your machine, no network and no API key. What an agent learns in one session carries over to the next.
claude mcp add compartment -- uvx compartmentWhat Compartment does
Compartment keeps what an agent learns about you and your project in a single file on your own computer. Claude, Claude Desktop, Cursor, Codex and other MCP clients read and write it. There is no account and no key.
Every memory is one claim, stored with where it came from and when it was learned. Memories can expire: set expires and the entry is dropped after that date. A changed preference replaces the old one. Recall mixes vector and keyword search and answers in about 12 ms. The embedding model ships inside the package, and everything on disk is encrypted, vectors included, so your passphrase is the only way in.
A fresh vault starts with roughly 6,700 reference facts covering hardware, operating systems, ports, encodings and shell utilities. They behave like ordinary memories and one switch hides them from search. The store only accepts short claims: anything past 200 characters is rejected, along with entries that contain lists or headings. uvx has to be on your machine, otherwise the server will not start.
What it helps with
- carry a decision from an earlier session into a new project
- keep agent memory encrypted instead of sitting in plain JSON
- hide an outdated preference from search once it changes
- find a fact by meaning rather than an exact word
- give a memory an expiry date so it disappears on its own
Example prompts for the agent
- Remember that we only reply to this client on Fridays
- What do you know about this project's setup?
- Drop the old report format, we ship Markdown now
How to install Compartment
Platform CLI
claude mcp add compartment -- uvx compartmentuvx runs the command named after the package; if the README names another one, use uvx --from compartment <command>
Platform CLI
codex mcp add compartment -- uvx compartmentuvx runs the command named after the package; if the README names another one, use uvx --from compartment <command>
Config file
{
"mcpServers": {
"compartment": {
"command": "uvx",
"args": [
"compartment"
]
}
}
}uvx runs the command named after the package; if the README names another one, use uvx --from compartment <command>
Config file
{
"servers": {
"compartment": {
"type": "stdio",
"command": "uvx",
"args": [
"compartment"
]
}
}
}uvx runs the command named after the package; if the README names another one, use uvx --from compartment <command>
Platform CLI
gemini mcp add compartment uvx compartmentuvx runs the command named after the package; if the README names another one, use uvx --from compartment <command>
Step by step, with commands for each platform: How to add an MCP server to Claude Code, Codex, Cursor, VS Code, Gemini CLI and more
Questions about Compartment
How do I install Compartment in Claude Code?
Run claude mcp add compartment -- uvx compartment, then compartment init to create the vault.
What does Compartment do?
It is an MCP server for persistent memory: the agent writes claims with a source and a date, then finds them again through hybrid search. Everything stays on your machine in an encrypted file.
Does it need an API key or an internet connection?
No. The embedding model is part of the package, nothing goes over the network at runtime, and no account is involved.