Skip to main content

A Python MCP stdio instance for adding memory to AI coding agents

Project description

OpenCode Memory

Give your AI coding agent a persistent memory across sessions.

What It Does

OpenCode Memory enables AI agents to remember information between conversations:

  • Remember your preferences - Coding style, editor settings, workflow preferences
  • Recall project context - Architecture decisions, tech stack, coding conventions
  • Track ongoing work - Current focus areas, recent decisions, sprint goals
  • Archive discussions - Save important conversations for future reference

Why It Matters

Without memory, AI assistants start fresh every session. You repeat yourself constantly. Context is lost. Decisions get forgotten.

OpenCode Memory solves this by providing persistent, searchable storage that your AI agent can access in every conversation.

Key Features

Feature Benefit
Semantic Search Find memories by meaning, not just keywords
Categorized Storage Organize memories with tags for easy filtering
Conversation Archive Store full discussions as readable markdown files
Memory Expiration Auto-expire time-sensitive information
Zero LLM Dependency No extra AI costs - your agent handles intelligence

Quick Start

1. Install

Using uv (recommended):

uv tool install opencode-memory

Or run directly without installing:

uvx opencode-memory --stdio

Using pip:

pip install opencode-memory

2. Configure Environment

export OPENAI_API_KEY="sk-your-api-key"
export OPENCODE_MEM_HISTORY_DIRECTORY="$HOME/.opencode/memory/history"
export OPENCODE_MEM_FAISS_DIRECTORY="$HOME/.opencode/memory/faiss"

3. Add to Your AI Agent

For opencode, add to your MCP configuration:

Using uv (recommended):

{
  "mcpServers": {
    "memory": {
      "command": "uvx",
      "args": ["opencode-memory", "--stdio"],
      "env": {
        "OPENAI_API_KEY": "sk-your-api-key",
        "OPENCODE_MEM_HISTORY_DIRECTORY": "$HOME/.opencode/memory/history",
        "OPENCODE_MEM_FAISS_DIRECTORY": "$HOME/.opencode/memory/faiss"
      }
    }
  }
}

Using pip:

{
  "mcpServers": {
    "memory": {
      "command": "opencode-memory",
      "args": ["--stdio"],
      "env": {
        "OPENAI_API_KEY": "sk-your-api-key",
        "OPENCODE_MEM_HISTORY_DIRECTORY": "$HOME/.opencode/memory/history",
        "OPENCODE_MEM_FAISS_DIRECTORY": "$HOME/.opencode/memory/faiss"
      }
    }
  }
}

That's it. Your AI agent now has memory.

How It Works

Two Storage Layers

  1. Memory Layer - Semantic storage for facts, preferences, and insights

    • Vector-based similarity search
    • Filter by categories and metadata
    • Automatic expiration for time-sensitive info
  2. Conversation Layer - Markdown files for complete discussion history

    • Human-readable format
    • Searchable with standard tools
    • Version control friendly

No Built-in LLM

This is intentional. Your AI agent already has LLM capabilities. OpenCode Memory handles only storage and retrieval, keeping things simple and cost-effective.

Usage Patterns

Preference Memory

When you mention a preference, your AI agent stores it:

You: "I always use tabs for indentation"

AI: [Stores memory: "User prefers tabs for indentation"]
    [Categories: preferences, formatting]

Future sessions will remember and apply this preference automatically.

Project Context

Your AI agent maintains awareness of your project:

AI: [Stores memory: "Project uses FastAPI + PostgreSQL + Redis"]
    [Categories: project-context, tech-stack]
    [Metadata: {project: "my-app"}]

When you start a new session, the AI recalls relevant context.

Current Focus

Track what you're working on:

AI: [Stores memory: "Currently implementing OAuth2 authentication"]
    [Categories: current-focus]
    [Expires: end of sprint]

Conversation Archive

Important discussions are saved:

AI: [Stores conversation: "Database Schema Design"]
    [Contains: All messages about schema decisions]
    [Saved as: Database_Schema_Design_20240115_103000.md]

Configuration

Required Variables

Variable Description
OPENAI_API_KEY For embedding generation
OPENCODE_MEM_HISTORY_DIRECTORY Where to store files
OPENCODE_MEM_FAISS_DIRECTORY Where to store vector index

Optional Variables

Variable Default Description
OPENCODE_MEM_EMBEDDING_MODEL text-embedding-3-large OpenAI embedding model
OPENCODE_MEM_EMBEDDING_PROVIDER openai Embedding provider
OPENCODE_MEM_EMBEDDING_BASE_URL - Custom API endpoint

Documentation

  • API.md - Complete tool reference with examples
  • DESIGN.md - Architecture decisions and rationale

Requirements

  • Python 3.10+
  • OpenAI API key

Development

# Clone and install
git clone https://github.com/anomalyco/opencode-memory.git
cd opencode-memory
pip install -e ".[dev]"

# Run tests
pytest

# Run linter
ruff check .

License

MIT

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

opencode_memory-0.1.5.tar.gz (135.3 kB view details)

Uploaded Source

Built Distribution

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

opencode_memory-0.1.5-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

Details for the file opencode_memory-0.1.5.tar.gz.

File metadata

  • Download URL: opencode_memory-0.1.5.tar.gz
  • Upload date:
  • Size: 135.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for opencode_memory-0.1.5.tar.gz
Algorithm Hash digest
SHA256 ecb8b5e60bcb87d5c47eb5d84b369d0f4bcde8d2dd4142c823836dbaff2e7c28
MD5 35f0c496311e3ef5956b9e4d62701fa1
BLAKE2b-256 c51b59bb07fc9a23310f8278620e2b010a189844be6827b4b847593e4e53efbb

See more details on using hashes here.

Provenance

The following attestation bundles were made for opencode_memory-0.1.5.tar.gz:

Publisher: release.yml on Mickael-Roger/opencode-memory

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file opencode_memory-0.1.5-py3-none-any.whl.

File metadata

File hashes

Hashes for opencode_memory-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 1519d115aee3c176eb62cc5f78448c52fbb3f3d468a9d49075c84d600fe168aa
MD5 3231fb6282300fcbf369c4ce1f721a7f
BLAKE2b-256 bfa7406cc539432e1ede435db85b2a1b946d4dd778a010ee19377a464f2079b3

See more details on using hashes here.

Provenance

The following attestation bundles were made for opencode_memory-0.1.5-py3-none-any.whl:

Publisher: release.yml on Mickael-Roger/opencode-memory

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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