# Sugar

A local memory layer your coding agent reads and writes mid-session. Decisions, conventions and error patterns live in SQLite and come back on the next run.

- MCP server · `type=mcp` · Claude Code, Codex, Cursor, GitHub Copilot, Windsurf (Devin Desktop), Cline, Zed, Gemini CLI · ★ 98
- Author: roboticforce
- License: not stated · policy=link-only · description only; the file stays with the author
- Source: https://github.com/roboticforce/sugar
- Updated: 2026-10-14
- HTML: https://affpapa.org/en/nevibecode/mcp/sugar

## What it does

Sugar is an MCP server that lets your agent read and write memory during a session. Project entries sit in `.sugar/memory.db`, shared ones in `~/.sugar/memory.db`. There are seven memory types: `decision`, `preference`, `file_context`, `error_pattern`, `research`, `outcome`, `guideline`. Some expire — `error_pattern` after 90 days, `research` after 60, `outcome` after 30.

Search is semantic: sentence-transformers with all-MiniLM-L6-v2, 384-dim vectors, plus sqlite-vec. Install the plain package and you fall back to SQLite FTS5 keyword matching. Nothing leaves your machine. Results come back project-first, with reserved slots so global `guideline` entries always surface, then deduplicated across both stores.

You can fill memory from the shell too: `sugar remember "..." --type preference`, `sugar recall "authentication"`, `sugar memories --global`. The agent gets `search_memory`, `store_learning`, `recall`, `get_project_context` and `list_recent_memories`. Semantic search needs `pipx install 'sugarai[memory]'`; without it the server still runs, just on keywords.

## Requirements
- Needs: Python and uv (commands run via uvx)
- Environment variables: `ANTHROPIC_API_KEY`, `GITHUB_TOKEN`, `SUGAR_DEFAULT_REPO` — keys and tokens: ask the human for the values, never commit them or put them in shared files.

## Install

### Claude Code (native platform)

**Platform CLI**
```bash
claude mcp add --env ANTHROPIC_API_KEY=<ANTHROPIC_API_KEY> --env GITHUB_TOKEN=<GITHUB_TOKEN> --env SUGAR_DEFAULT_REPO=<SUGAR_DEFAULT_REPO> --transport stdio sugar -- uvx sugarai
```
Replace <…> with your own values. uvx runs the command named after the package; if the README names another one, use uvx --from sugarai <command>

### Codex

**Platform CLI**
```bash
codex mcp add sugar --env ANTHROPIC_API_KEY=<ANTHROPIC_API_KEY> --env GITHUB_TOKEN=<GITHUB_TOKEN> --env SUGAR_DEFAULT_REPO=<SUGAR_DEFAULT_REPO> -- uvx sugarai
```
Replace <…> with your own values. uvx runs the command named after the package; if the README names another one, use uvx --from sugarai <command>

### Cursor

**Config file**
File `.cursor/mcp.json`:
```json
{
    "mcpServers": {
        "sugar": {
            "command": "uvx",
            "args": [
                "sugarai"
            ],
            "env": {
                "ANTHROPIC_API_KEY": "<ANTHROPIC_API_KEY>",
                "GITHUB_TOKEN": "<GITHUB_TOKEN>",
                "SUGAR_DEFAULT_REPO": "<SUGAR_DEFAULT_REPO>"
            }
        }
    }
}
```
Replace <…> with your own values. uvx runs the command named after the package; if the README names another one, use uvx --from sugarai <command>

### GitHub Copilot

**Config file**
File `.vscode/mcp.json`:
```json
{
    "servers": {
        "sugar": {
            "type": "stdio",
            "command": "uvx",
            "args": [
                "sugarai"
            ],
            "env": {
                "ANTHROPIC_API_KEY": "<ANTHROPIC_API_KEY>",
                "GITHUB_TOKEN": "<GITHUB_TOKEN>",
                "SUGAR_DEFAULT_REPO": "<SUGAR_DEFAULT_REPO>"
            }
        }
    }
}
```
Replace <…> with your own values. uvx runs the command named after the package; if the README names another one, use uvx --from sugarai <command>

### Gemini CLI

**Platform CLI**
```bash
gemini mcp add -e ANTHROPIC_API_KEY=<ANTHROPIC_API_KEY> -e GITHUB_TOKEN=<GITHUB_TOKEN> -e SUGAR_DEFAULT_REPO=<SUGAR_DEFAULT_REPO> sugar uvx sugarai
```
Replace <…> with your own values. uvx runs the command named after the package; if the README names another one, use uvx --from sugarai <command>

## When to use it
- restore project context after the agent restarts
- record an architecture decision before it gets lost
- find old notes by meaning instead of exact wording
- keep coding standards across every project
- store a bug together with its fix

## Example prompts
- Search memory for everything about authentication and show what we decided on JWT
- Remember this: when tests fail with import errors, check `__init__.py` exports first

## Similar
- [openchronicle-mcp](https://affpapa.org/en/nevibecode/mcp/openchronicle-mcp.md) — MCP server · ★ 16
- [longhand](https://affpapa.org/en/nevibecode/plugins/longhand.md) — plugin · ★ 14
- [agentdb-query](https://affpapa.org/en/nevibecode/skills/agentdb-query.md) — skill · 745 installs
- [Memanto](https://affpapa.org/en/nevibecode/mcp/memanto.md) — MCP server · ★ 2341
- [marm-mcp-server](https://affpapa.org/en/nevibecode/mcp/marm-mcp-server.md) — MCP server · ★ 424
- [shodh-memory](https://affpapa.org/en/nevibecode/mcp/shodh-memory.md) — MCP server · ★ 316

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
