|
| 1 | +# MCP Setup Guide |
| 2 | + |
| 3 | +Connect agentmem to your coding agent in 2 minutes. Pick your tool. |
| 4 | + |
| 5 | +## Prerequisites |
| 6 | + |
| 7 | +```bash |
| 8 | +pip install quilmem[mcp] |
| 9 | +``` |
| 10 | + |
| 11 | +Verify it works: |
| 12 | + |
| 13 | +```bash |
| 14 | +agentmem --help |
| 15 | +``` |
| 16 | + |
| 17 | +If that prints the command list, you're good. |
| 18 | + |
| 19 | +--- |
| 20 | + |
| 21 | +## Claude Code |
| 22 | + |
| 23 | +Claude Code reads MCP config from `~/.claude/settings.json` (global) or `.claude/settings.json` (project-level). |
| 24 | + |
| 25 | +### Option A: CLI (fastest) |
| 26 | + |
| 27 | +```bash |
| 28 | +claude mcp add agentmem -- agentmem --db ./memory.db --project myproject serve |
| 29 | +``` |
| 30 | + |
| 31 | +That's it. Restart Claude Code. The 13 agentmem tools should appear. |
| 32 | + |
| 33 | +### Option B: Manual config |
| 34 | + |
| 35 | +Add this to `~/.claude/settings.json` (global) or `.claude/settings.json` in your project root: |
| 36 | + |
| 37 | +```json |
| 38 | +{ |
| 39 | + "mcpServers": { |
| 40 | + "agentmem": { |
| 41 | + "command": "agentmem", |
| 42 | + "args": ["--db", "./memory.db", "--project", "myproject", "serve"], |
| 43 | + "type": "stdio" |
| 44 | + } |
| 45 | + } |
| 46 | +} |
| 47 | +``` |
| 48 | + |
| 49 | +Replace `./memory.db` with wherever you want the database. Replace `myproject` with your project name (used for scoping if you run multiple projects on one DB). |
| 50 | + |
| 51 | +### If agentmem isn't on PATH |
| 52 | + |
| 53 | +Use the full Python path: |
| 54 | + |
| 55 | +```json |
| 56 | +{ |
| 57 | + "mcpServers": { |
| 58 | + "agentmem": { |
| 59 | + "command": "python", |
| 60 | + "args": ["-m", "agentmem", "--db", "./memory.db", "--project", "myproject", "serve"], |
| 61 | + "type": "stdio" |
| 62 | + } |
| 63 | + } |
| 64 | +} |
| 65 | +``` |
| 66 | + |
| 67 | +On Windows, you may need the full Python path: |
| 68 | + |
| 69 | +```json |
| 70 | +{ |
| 71 | + "mcpServers": { |
| 72 | + "agentmem": { |
| 73 | + "command": "C:/Python313/python.exe", |
| 74 | + "args": ["-m", "agentmem", "--db", "C:/path/to/memory.db", "--project", "myproject", "serve"], |
| 75 | + "type": "stdio" |
| 76 | + } |
| 77 | + } |
| 78 | +} |
| 79 | +``` |
| 80 | + |
| 81 | +### Verify |
| 82 | + |
| 83 | +In Claude Code, the agentmem tools should show up. Ask Claude to run `memory_health` to confirm the connection. |
| 84 | + |
| 85 | +--- |
| 86 | + |
| 87 | +## Cursor |
| 88 | + |
| 89 | +Cursor reads MCP config from `~/.cursor/mcp.json` (global) or `.cursor/mcp.json` (project root). |
| 90 | + |
| 91 | +Create or edit the file: |
| 92 | + |
| 93 | +```json |
| 94 | +{ |
| 95 | + "mcpServers": { |
| 96 | + "agentmem": { |
| 97 | + "command": "agentmem", |
| 98 | + "args": ["--db", "./memory.db", "--project", "myproject", "serve"] |
| 99 | + } |
| 100 | + } |
| 101 | +} |
| 102 | +``` |
| 103 | + |
| 104 | +If `agentmem` isn't on PATH, use the full Python path: |
| 105 | + |
| 106 | +```json |
| 107 | +{ |
| 108 | + "mcpServers": { |
| 109 | + "agentmem": { |
| 110 | + "command": "python", |
| 111 | + "args": ["-m", "agentmem", "--db", "./memory.db", "--project", "myproject", "serve"] |
| 112 | + } |
| 113 | + } |
| 114 | +} |
| 115 | +``` |
| 116 | + |
| 117 | +### Verify |
| 118 | + |
| 119 | +Open the command palette (`Ctrl+Shift+P` / `Cmd+Shift+P`), type "MCP", and check that agentmem appears as a connected server. You can also type "Open MCP Settings" to see the config. |
| 120 | + |
| 121 | +--- |
| 122 | + |
| 123 | +## Codex (OpenAI) |
| 124 | + |
| 125 | +Codex reads MCP config from `~/.codex/config.toml` (global) or `.codex/config.toml` (project root, trusted projects only). |
| 126 | + |
| 127 | +Add this to the config file: |
| 128 | + |
| 129 | +```toml |
| 130 | +[mcp_servers.agentmem] |
| 131 | +command = "agentmem" |
| 132 | +args = ["--db", "./memory.db", "--project", "myproject", "serve"] |
| 133 | +``` |
| 134 | + |
| 135 | +If `agentmem` isn't on PATH: |
| 136 | + |
| 137 | +```toml |
| 138 | +[mcp_servers.agentmem] |
| 139 | +command = "python" |
| 140 | +args = ["-m", "agentmem", "--db", "./memory.db", "--project", "myproject", "serve"] |
| 141 | +``` |
| 142 | + |
| 143 | +### Verify |
| 144 | + |
| 145 | +Run `codex` and ask it to use the `memory_health` tool. If it returns a health score, you're connected. |
| 146 | + |
| 147 | +--- |
| 148 | + |
| 149 | +## Windsurf |
| 150 | + |
| 151 | +Windsurf uses the same MCP config format as Cursor. Create `~/.windsurf/mcp.json` or `.windsurf/mcp.json` in your project: |
| 152 | + |
| 153 | +```json |
| 154 | +{ |
| 155 | + "mcpServers": { |
| 156 | + "agentmem": { |
| 157 | + "command": "agentmem", |
| 158 | + "args": ["--db", "./memory.db", "--project", "myproject", "serve"] |
| 159 | + } |
| 160 | + } |
| 161 | +} |
| 162 | +``` |
| 163 | + |
| 164 | +--- |
| 165 | + |
| 166 | +## Available MCP Tools |
| 167 | + |
| 168 | +Once connected, your agent has 13 tools: |
| 169 | + |
| 170 | +| Tool | What it does | |
| 171 | +|------|-------------| |
| 172 | +| `add_memory` | Store a typed memory (bug, decision, setting, procedure, context, feedback) | |
| 173 | +| `search_memory` | Full-text search with filters | |
| 174 | +| `recall_memory` | Context-budgeted retrieval — fits best memories into a token limit | |
| 175 | +| `update_memory` | Update a memory by ID | |
| 176 | +| `delete_memory` | Delete a memory by ID | |
| 177 | +| `list_memories` | List memories with optional type filter | |
| 178 | +| `save_session` | Save current work state before conversation ends | |
| 179 | +| `load_session` | Restore state at the start of a new session | |
| 180 | +| `promote_memory` | Advance trust: hypothesis -> active -> validated | |
| 181 | +| `deprecate_memory` | Mark as no longer true (excluded from recall) | |
| 182 | +| `supersede_memory` | Replace old memory with new one | |
| 183 | +| `memory_health` | Score the memory system 0-100 | |
| 184 | +| `memory_conflicts` | Find contradictions between active memories | |
| 185 | + |
| 186 | +--- |
| 187 | + |
| 188 | +## Tips |
| 189 | + |
| 190 | +**Start every session** by having your agent call `load_session`. This restores where the last session left off. |
| 191 | + |
| 192 | +**End every session** with `save_session`. Capture what's in progress, what's blocked, and what was decided. |
| 193 | + |
| 194 | +**Promote memories** that prove correct. A `validated` memory ranks higher than `active` in recall. A `hypothesis` ranks lowest. This is how your agent learns what to trust. |
| 195 | + |
| 196 | +**Run health checks** periodically. `memory_health` tells you if contradictions, stale rules, or orphaned references are degrading trust. |
| 197 | + |
| 198 | +**Use project scoping** if you work on multiple codebases. Each project gets isolated memory with `--project projectname`. |
| 199 | + |
| 200 | +--- |
| 201 | + |
| 202 | +## Troubleshooting |
| 203 | + |
| 204 | +**Tools don't appear after config change** |
| 205 | +Restart your editor. MCP servers are loaded at startup. |
| 206 | + |
| 207 | +**"Command not found" errors** |
| 208 | +Use the full path to Python and `-m agentmem` instead of the `agentmem` command directly. |
| 209 | + |
| 210 | +**Windows path issues** |
| 211 | +Use forward slashes in JSON config: `C:/Users/you/memory.db`, not backslashes. |
| 212 | + |
| 213 | +**Server starts but no tools appear** |
| 214 | +Check that you have the MCP extra installed: `pip install quilmem[mcp]`. The base package doesn't include the MCP dependency. |
| 215 | + |
| 216 | +**Multiple agents sharing one database** |
| 217 | +Use different `--project` values. Each project's memories are isolated in search and recall, but stored in the same file. |
0 commit comments