agent-magnet — Claude Code MCP server: memory and setup
This MCP server carries project context between sessions and AI tools. Use it for decisions, conventions, preferences, and past attempts.
claude mcp add --env MAGNET_USER_ID=<MAGNET_USER_ID> --env MAGNET_OPENAI_KEY=<MAGNET_OPENAI_KEY> --env MAGNET_LOCAL_MODE=<MAGNET_LOCAL_MODE> --env MAGNET_REDIS_URL=<MAGNET_REDIS_URL> --env MAGNET_PROJECT_ID=<MAGNET_PROJECT_ID> --transport stdio agent-magnet -- uvx agent-magnetWhat agent-magnet does
agent-magnet gives AI coding tools a persistent behavioral memory. It records project decisions, conventions, cautions, goals, preferences, failed approaches, and completed actions, then organizes those records for later use. The same memory can serve Claude, Cursor, and Codex.
The local setup starts with pip install agent-magnet followed by agent-magnet init. That command configures Claude Code, Claude Desktop, and Cursor. Codex and other MCP clients can use a manual setup with agent-magnet-mcp and the MAGNET_USER_ID environment variable.
Local operation needs no key. Team memory does require a paid Agent Magnet key. Configuration may also include MAGNET_OPENAI_KEY, MAGNET_LOCAL_MODE, MAGNET_REDIS_URL, and MAGNET_PROJECT_ID.
What it helps with
- carry project decisions into new sessions
- share context across Claude, Cursor, and Codex
- record conventions and team preferences
- remove stale memories after work is complete
- connect persistent context to an MCP client
Example prompts for the agent
- Remember that this project uses
PostgreSQLfor persistence. - Store the rule that API handlers belong in
src/api. - Forget the outdated warning about
legacy-auth.
How to install agent-magnet
Platform CLI
claude mcp add --env MAGNET_USER_ID=<MAGNET_USER_ID> --env MAGNET_OPENAI_KEY=<MAGNET_OPENAI_KEY> --env MAGNET_LOCAL_MODE=<MAGNET_LOCAL_MODE> --env MAGNET_REDIS_URL=<MAGNET_REDIS_URL> --env MAGNET_PROJECT_ID=<MAGNET_PROJECT_ID> --transport stdio agent-magnet -- uvx agent-magnetReplace <…> with your own values. uvx runs the command named after the package; if the README names another one, use uvx --from agent-magnet <command>
Platform CLI
codex mcp add agent-magnet --env MAGNET_USER_ID=<MAGNET_USER_ID> --env MAGNET_OPENAI_KEY=<MAGNET_OPENAI_KEY> --env MAGNET_LOCAL_MODE=<MAGNET_LOCAL_MODE> --env MAGNET_REDIS_URL=<MAGNET_REDIS_URL> --env MAGNET_PROJECT_ID=<MAGNET_PROJECT_ID> -- uvx agent-magnetReplace <…> with your own values. uvx runs the command named after the package; if the README names another one, use uvx --from agent-magnet <command>
Config file
{
"mcpServers": {
"agent-magnet": {
"command": "uvx",
"args": [
"agent-magnet"
],
"env": {
"MAGNET_USER_ID": "<MAGNET_USER_ID>",
"MAGNET_OPENAI_KEY": "<MAGNET_OPENAI_KEY>",
"MAGNET_LOCAL_MODE": "<MAGNET_LOCAL_MODE>",
"MAGNET_REDIS_URL": "<MAGNET_REDIS_URL>",
"MAGNET_PROJECT_ID": "<MAGNET_PROJECT_ID>"
}
}
}
}Replace <…> with your own values. uvx runs the command named after the package; if the README names another one, use uvx --from agent-magnet <command>
Config file
{
"servers": {
"agent-magnet": {
"type": "stdio",
"command": "uvx",
"args": [
"agent-magnet"
],
"env": {
"MAGNET_USER_ID": "<MAGNET_USER_ID>",
"MAGNET_OPENAI_KEY": "<MAGNET_OPENAI_KEY>",
"MAGNET_LOCAL_MODE": "<MAGNET_LOCAL_MODE>",
"MAGNET_REDIS_URL": "<MAGNET_REDIS_URL>",
"MAGNET_PROJECT_ID": "<MAGNET_PROJECT_ID>"
}
}
}
}Replace <…> with your own values. uvx runs the command named after the package; if the README names another one, use uvx --from agent-magnet <command>
Platform CLI
gemini mcp add -e MAGNET_USER_ID=<MAGNET_USER_ID> -e MAGNET_OPENAI_KEY=<MAGNET_OPENAI_KEY> -e MAGNET_LOCAL_MODE=<MAGNET_LOCAL_MODE> -e MAGNET_REDIS_URL=<MAGNET_REDIS_URL> -e MAGNET_PROJECT_ID=<MAGNET_PROJECT_ID> agent-magnet uvx agent-magnetReplace <…> with your own values. uvx runs the command named after the package; if the README names another one, use uvx --from agent-magnet <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 agent-magnet
How do I install agent-magnet in Claude Code?
Run claude mcp add agent-magnet -e MAGNET_USER_ID=<MAGNET_USER_ID> -- uvx agent-magnet.
What does agent-magnet do?
It keeps project decisions, conventions, goals, preferences, and prior attempts available across sessions. The memory can be used by several supported AI coding tools.
Does agent-magnet need an API key?
Local use works without a key. Shared team memory requires a paid Agent Magnet key.