Skip to main content

retain-memory

retain-memory is a small command-line tool and MCP server for keeping categorized memories in one local SQLite database. Memories have priorities from 1 (lowest) to 5 (highest) and UTC creation/update timestamps.

Categories are managed through the CLI or web interface. MCP clients can list categories and create, retrieve, update, or delete memories within them.

Category names can form a hierarchy using the Anki-style :: delimiter, for example projects::retain::release. Each part must be non-empty and cannot contain a colon. Categories can also have an optional description explaining what belongs in them. MCP category listings include these descriptions so clients can choose the appropriate leaf.

Installation

Install uv, then install the CLI from PyPI:

uv tool install retain-memory

To install the current source checkout instead:

uv tool install .

No setup is required before the first run. By default, Retain creates its database and settings at $XDG_DATA_HOME/retain/memory.db, or $HOME/.local/share/retain/memory.db when XDG_DATA_HOME is unset.

Set MEMORY_FILE to use a different database location:

export MEMORY_FILE="$HOME/.local/share/retain/memory.db"

CLI

Create and inspect categories:

retain category create projects
retain category list
retain category delete projects
retain category delete projects --force

Category deletion moves the full branch and its memories to the recoverable archive. --force is required to archive a branch that contains memories through the CLI.

Manage memories:

retain memory add projects "Publish the first release" --priority 5
retain memory list projects
retain memory get MEMORY_ID
retain memory update MEMORY_ID --content "Publish version 1.0" --priority 4
retain memory delete MEMORY_ID

Commands that return data print JSON. Category memory lists are ordered by priority descending and creation time descending.

Web interface

Start the local Flask interface with:

retain web

It provides memory and category editing, displays hierarchical categories as trees, and includes settings for the default priority, category size limit, memory word limit, and web host/port. Categories initially allow 100 memories and memories initially allow 500 words. Lowering a limit does not delete existing data. Saved host and port changes take effect on the next start. They can be overridden for one run:

retain web --host 0.0.0.0 --port 8080

MCP Installation

The PyPI package includes the retain-mcp stdio server. An MCP client can launch it without a separate installation through uvx. For clients using the common mcpServers configuration format:

{
  "mcpServers": {
    "retain": {
      "command": "uvx",
      "args": ["--from", "retain-memory", "retain-mcp"],
      "env": {
        "MEMORY_FILE": "/absolute/path/to/memory.db"
      }
    }
  }
}

If the package was installed with uv tool install retain-memory, use "command": "retain-mcp" and omit args. For development from this checkout, use "command": "uv" with "args": ["run", "--directory", "/absolute/path/to/retain", "retain-mcp"].

The MCP server exposes:

  • list_categories
  • create_category
  • update_category
  • delete_category
  • get_memories
  • add_memory
  • update_memory
  • delete_memory

list_categories exposes only leaf categories, and get_memories rejects categories that have subcategories. Reads never implicitly combine a parent with its descendants.

MCP delete_category archives the full category branch and its memories rather than permanently deleting them. Users can restore or permanently delete archive entries in the web UI. Clients such as OpenCode can independently allow, ask, or deny each category tool.

Development

uv sync --all-groups
uv run ruff check .
uv run ruff format --check .
uv run pytest
uv build

Publishing

The retain-memory PyPI project and its trusted publisher are already configured. No PyPI API token is stored in GitHub.

To prepare a release, update the package version and push the release commit:

uv version 0.2.0
git add pyproject.toml uv.lock
git commit -m "Release 0.2.0"
git push origin main

After CI passes, create and push an annotated tag matching the version in pyproject.toml:

git tag -a v0.2.0 -m "Release 0.2.0"
git push origin v0.2.0

The tag triggers publish.yml, which builds and publishes the wheel and source distribution through PyPI trusted publishing. Tags must use the v prefix and match the package version exactly.

Metadata

Release files for retain-memory 0.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for retain-memory 0.5.0
File Size Uploaded Provenance Actions
retain_memory-0.5.0.tar.gz 76.3 kB With provenance Details for retain_memory-0.5.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for retain-memory 0.5.0
File Interpreter ABI Platform Actions
retain_memory-0.5.0-py3-none-any.whl Python 3 none any Details for retain_memory-0.5.0-py3-none-any.whl

Total release size: 98.8 kB

Release files / retain_memory-0.5.0.tar.gz

Download URL retain_memory-0.5.0.tar.gz
Size 76.3 kB
Tags Source
SHA-256 checksum
How to use checksums
d5b2a750318c1798edd5b37b85d1d97b79f0c3525aed3af2dd58798489decc37
BLAKE2b-256 checksum
How to use checksums
6cfa32d8b8f3d655ceeab0402a416e0a3be2889b902e88b7204975364bd8a365
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 12, 2026.

Transparency log

Release files / retain_memory-0.5.0-py3-none-any.whl

Download URL retain_memory-0.5.0-py3-none-any.whl
Size 22.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
79bfa15b6ecda00c77c021cb78b6f72071f1ec4f39982065a235d0b550219f83
BLAKE2b-256 checksum
How to use checksums
d6d707a883305c082ac85ca3a78e838252374dc8eca4275bcf7442d6cb74bbde
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 12, 2026.

Transparency log

Security for retain-memory 0.5.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for retain_memory-0.5.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 12, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page