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.

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

--force is required to delete a category that contains memories.

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 and web host/port. 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
  • get_memories
  • add_memory
  • update_memory
  • delete_memory

It does not expose category creation or deletion. Create categories with retain category create NAME before adding memories through MCP.

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.2.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.2.0
File Size Uploaded Provenance Actions
retain_memory-0.2.0.tar.gz 71.1 kB With provenance Details for retain_memory-0.2.0.tar.gz

Built distribution (wheel)

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

Total release size: 89.4 kB

Release files / retain_memory-0.2.0.tar.gz

Download URL retain_memory-0.2.0.tar.gz
Size 71.1 kB
Tags Source
SHA-256 checksum
How to use checksums
a52d4368139ed95407eeff11a73e16a2e6df6453f966546e08bc14601ff108dc
BLAKE2b-256 checksum
How to use checksums
29d302c55102d11e556099c2bf25af8aae770cb405ee18ac9d0bebf2f059bd55
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.2.0-py3-none-any.whl

Download URL retain_memory-0.2.0-py3-none-any.whl
Size 18.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cd58e84cc9565a677515193acbde2b89070368c604b4ae1d826b9c432e156fe4
BLAKE2b-256 checksum
How to use checksums
f2163c1ad07611212aa807ea8351cf52f68a1d0adcaddcf136c506916c533ead
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.2.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.2.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