Skip to main content

Local-first MCP memory backend for AI clients.

Project description

Memory Forge

Memory Forge is a local-first MCP memory backend for MCP-capable AI clients. It gives compatible clients a small set of tools for saving, searching, and summarizing durable project memories without sending the database to a cloud service.

V1 is intentionally boring in the best way: a Python MCP server, SQLite, and full-text search.

Features

  • Local SQLite database with FTS5 search.
  • MCP tools for remember, search, context, update, and forget.
  • Soft-delete by default so accidental forgets can be recovered from backups.
  • Project, tag, source-agent, and importance metadata.
  • Token-budgeted context retrieval to avoid duplicate long-term memory blocks.
  • Usage estimates on retrieved context so clients can see read cost.
  • Active-context compaction through memory_compact when clients send the working context they want Memory Forge to own.
  • Model-window budgeting with context_window_tokens, reserved_prompt_tokens, and reserved_output_tokens.
  • Fallback retrieval for focused queries that miss but project memory exists.
  • Works with any MCP client that can launch a stdio server.

Memory Budgeting

Memory Forge returns only the focused memory a client asks for. Use small memory_context budgets by default, then request more only when the task needs broader project orientation. A good starting point is max_chars: 2000 for normal coding tasks and max_chars: 6000 for broad project orientation.

If the client knows the model window, pass context_window_tokens, reserved_prompt_tokens, and reserved_output_tokens so Memory Forge budgets retrieved memory against the same window as the model call.

See Memory Model Guide for token-budget guidance and active-context compaction behavior.

Install

uv sync

Run the MCP server:

uv run memory-forge

Configure Codex to use Memory Forge and disable duplicate built-in memory:

uv run memory-forge-setup codex --from-checkout .

For an installed release, run:

memory-forge-setup codex

Preview the config change without writing:

memory-forge-setup codex --dry-run

By default the database is stored at:

%USERPROFILE%\.memory-forge\memory.db

Set a custom path with:

$env:MEMORY_FORGE_DB="C:\path\to\memory.db"
uv run memory-forge

MCP Tools

memory_remember

Save a durable memory.

{
  "content": "The API service uses SQLite for local development.",
  "tags": ["api", "local-dev"],
  "project": "example-project",
  "source_agent": "codex",
  "importance": 3
}

memory_search

Search memories with optional filters.

{
  "query": "SQLite local development",
  "project": "example-project",
  "tags": ["api"],
  "limit": 10
}

memory_context

Return compact prompt-ready context for an agent.

{
  "query": "database setup",
  "project": "example-project",
  "limit": 8,
  "max_chars": 2000,
  "context_window_tokens": 128000,
  "reserved_prompt_tokens": 24000,
  "reserved_output_tokens": 4000
}

The response includes context, count, max_chars, truncated, and the raw matching memories. It also includes usage with character count and rough token estimates, including whether the returned memory fits the declared model window budget. If a focused query misses but project or tag filters can still return relevant memories, fallback_used is true. Clients should inject only the context string into the working prompt.

memory_compact

Compact active context supplied by a client and optionally store the compacted result in Memory Forge.

{
  "active_context": "Current chat notes or working context supplied by the client.",
  "project": "example-project",
  "tags": ["handoff"],
  "source_agent": "codex",
  "max_chars": 2000,
  "context_window_tokens": 128000,
  "reserved_prompt_tokens": 24000,
  "reserved_output_tokens": 4000,
  "save": true
}

MCP servers cannot read a client's hidden prompt or chat buffer by themselves. Clients that want Memory Forge to handle active context should call memory_compact before the working context grows too large, then replace the bulky active context with only the returned compacted_context or saved memory reference. Appending compacted context while keeping the original transcript still spends the model window twice.

memory_update

Update content, tags, project, source agent, or importance.

{
  "memory_id": "memory-id",
  "importance": 5,
  "tags": ["api", "database"]
}

memory_forget

Archive by default, or hard-delete only when explicitly requested.

{
  "memory_id": "memory-id",
  "hard_delete": false
}

Development

uv run pytest

Client Integrations

Memory Forge's MCP server can only receive context a client explicitly sends. A richer client integration can handle more memory sources, such as:

  • configuring the client to disable duplicate built-in memory;
  • installing Memory Forge as the MCP memory backend;
  • importing accessible chat history when the user explicitly opts in;
  • indexing selected local files or repositories into compact memories.

These integrations should be explicit, local-first, and reversible. Memory Forge should not silently ingest private chats, secrets, or entire filesystems.

Codex

memory-forge-setup codex updates the local Codex config to:

  • disable built-in Codex memory;
  • register Memory Forge as the memory_forge MCP server;
  • point MEMORY_FORGE_DB at the local Memory Forge database.

Use --from-checkout PATH while developing from a local checkout. Use --dry-run to inspect the diff and --check in automation.

Next Clients

Claude Code is the next planned setup target. Its installer should follow the same pattern: configure Memory Forge as the memory backend, avoid duplicate built-in memory where possible, and keep imports or local indexing opt-in.

Roadmap

  • Export and import memories as JSONL.
  • Optional semantic search using local embeddings.
  • Memory compaction and conflict detection.
  • Claude Code setup helper.
  • Opt-in Codex history import and selected local-file indexing.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

memory_forge_mcp-0.1.0.tar.gz (61.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

memory_forge_mcp-0.1.0-py3-none-any.whl (13.7 kB view details)

Uploaded Python 3

File details

Details for the file memory_forge_mcp-0.1.0.tar.gz.

File metadata

  • Download URL: memory_forge_mcp-0.1.0.tar.gz
  • Upload date:
  • Size: 61.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.11 {"installer":{"name":"uv","version":"0.11.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for memory_forge_mcp-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3e2056bd223445bed927d4dee4d803dab188a5cd4ebde725f30118fa028aa36d
MD5 bd6991608f4b6b6f068ce26236966cfe
BLAKE2b-256 705883e28f6e7f8213f4ad8cbd1a3b6176b39a875cf516987f46d7b9ba736998

See more details on using hashes here.

File details

Details for the file memory_forge_mcp-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: memory_forge_mcp-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 13.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.11 {"installer":{"name":"uv","version":"0.11.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for memory_forge_mcp-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6689fbc5b65210813d12f7cf5c4609dc33a8d1a4646d13b4aeb2c4887cd9554a
MD5 35faded7f7a320e3b22adbbbbb29c38e
BLAKE2b-256 c358b0b337092e800f442df24068602861b27bf503a2cde59b6e493d9a1a69dd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page