Metadata-Version: 2.4
Name: memory-v2-mcp
Version: 2.1.0a2
Summary: MCP server for Memory v2: local-first long-term memory for AI agents
Author: DonParalon85
License: MIT
Project-URL: Homepage, https://github.com/DonParalon85/memory-v.2-alpha
Project-URL: Repository, https://github.com/DonParalon85/memory-v.2-alpha
Project-URL: Issues, https://github.com/DonParalon85/memory-v.2-alpha/issues
Keywords: mcp,model-context-protocol,memory,ai-agents,local-first,sqlite
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Software Development :: Libraries
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
License-File: NOTICE
Requires-Dist: mcp<3,>=2
Provides-Extra: test
Requires-Dist: pytest>=8; extra == "test"
Dynamic: license-file

# MCP server

Memory v2 exposes its API to any MCP-speaking agent through a small stdio
server. Works with Claude Desktop, Claude Code, Cursor and other MCP clients.

## Tools

| Tool | Purpose |
|---|---|
| `memory_health` | Check API availability |
| `memory_list_projects` | List projects |
| `memory_project_context` | Restore a project and its branches |
| `memory_search` | Search memories and messages |
| `memory_archive_conversation` | Archive a branch idempotently |
| `memory_upsert` | Store a fact, decision, constraint or preference |
| `memory_deprecate` | Retire an old memory, optionally with a replacement |

## Install

The project targets MCP SDK v2 (`MCPServer`, formerly `FastMCP`). The
requirement is `mcp>=2,<3`; `server.py` keeps a v1 fallback for older
environments.

```sh
python3 -m venv .venv-mcp
. .venv-mcp/bin/activate
pip install -r mcp/requirements.txt
```

Windows PowerShell:

```powershell
python -m venv .venv-mcp
.venv-mcp\Scripts\Activate.ps1
pip install -r mcp\requirements.txt
```

Environment:

| Variable | Default |
|---|---|
| `MEMORY_API` | `http://127.0.0.1:8002` |
| `MEMORY_API_TOKEN` | empty (local-only) |

## Claude Desktop

Config file:

- Windows: `%APPDATA%\Claude\claude_desktop_config.json`
- macOS: `~/Library/Application Support/Claude/claude_desktop_config.json`
- Linux: `~/.config/Claude/claude_desktop_config.json`

```json
{
  "mcpServers": {
    "memory-v2": {
      "command": "C:\\path\\to\\memory_v2.0\\.venv-mcp\\Scripts\\python.exe",
      "args": ["C:\\path\\to\\memory_v2.0\\mcp\\server.py"],
      "env": {
        "MEMORY_API": "http://127.0.0.1:8002"
      }
    }
  }
}
```

Restart Claude Desktop after editing the file. A `memory-v2` tool group should
appear.

## Claude Code

```sh
claude mcp add memory-v2 -- python /path/to/memory_v2.0/mcp/server.py
```

## Cursor

Put this in `~/.cursor/mcp.json` (or `.cursor/mcp.json` inside a project):

```json
{
  "mcpServers": {
    "memory-v2": {
      "command": "python",
      "args": ["/path/to/memory_v2.0/mcp/server.py"],
      "env": {
        "MEMORY_API": "http://127.0.0.1:8002"
      }
    }
  }
}
```

## Docker-only option (no local Python)

If the Memory stack is running under Docker, the same image can host the MCP
server:

```sh
docker run -i --rm --network memory-v2_default \
  -e MEMORY_API=http://memory:8002 \
  memory-v2:latest python /app/mcp/server.py
```

On Linux, `--network host` with `MEMORY_API=http://127.0.0.1:8002` also works.
On Docker Desktop for Windows, host networking differs; running the MCP server
natively in a Python venv is usually simpler.

## Testing

Run the stdio smoke test against a **dev/test** Memory API:

```sh
MEMORY_API=http://127.0.0.1:8103 python mcp/test_server.py
```

Or inside the Docker image (no local Python):

```sh
docker run --rm --network host \
  -e MEMORY_API=http://127.0.0.1:8103 \
  -v "$PWD/mcp:/app/mcp:ro" \
  --entrypoint python memory-v2:latest /app/mcp/test_server.py
```

The test refuses to run against a non-loopback API, so a dev run cannot touch a
shared database. It checks `initialize`, `tools/list`, every tool, archive
idempotency, and error responses, then removes the test conversation and test
memory it created.

Point it at any project you don't mind writing to:

```sh
MEMORY_API=http://127.0.0.1:8002 MEMORY_PROJECT_ID=2 python mcp/test_server.py
```

`MEMORY_PROJECT_ID` defaults to `1`. The server itself has no model or client
dependency: any MCP-capable app works. See `docs/integrations.md` for Claude
Desktop, Cursor, Cline, Continue, Windsurf, Zed and plain REST/OpenAI/Anthropic
tool schemas.

Run the server as a script (`python mcp/server.py`), not as
`python -m mcp.server` from the repository root: the project's `mcp/`
directory can otherwise shadow the installed SDK.

## Example prompts

- “Search my Memory for `AsyncSession` and show the source branch.”
- “Restore project 1 and summarize its open decisions.”
- “Archive this dialog as a branch in project 1 with external id
  `demo:fastapi:async-session:003`.”
- “Save a decision: schema changes go through Alembic.”

## Security

- The MCP server only talks to the Memory API; it does not open the database.
- Point `MEMORY_API` at a dev/test instance while developing. Never point the
  MCP server at a shared or production address by accident.
- Keep the API bound to `127.0.0.1` for local use.
- If you expose the API to a LAN, set `MEMORY_API_TOKEN` and pass it to the
  MCP server through the environment.
- Tool results may contain conversation text. Do not paste secrets into
  prompts.
