Skip to main content

情景+实体记忆 MCP 服务

Project description

Memory MCP Service

English | 中文

A scenario + entity memory MCP service that provides persistent memory capabilities for Claude Code.

Features

  • Episodes: Dialogue scenes divided by task/function
  • Entities: Structured knowledge units (decisions, concepts, preferences, etc.)
  • Dual-layer storage: User-level (cross-project) + Project-level (project isolated)
  • Real-time cache: Messages are stored in real-time to prevent loss
  • Semantic retrieval: Vector-based semantic search

Installation

Windows One-click Installation

Run install.bat file in the project root directory:

install.bat

Mac/Linux One-click Installation

chmod +x install.sh
./install.sh

The installation script will automatically create a Python 3.10 virtual environment (venv310) and install dependencies.

Configure Claude Code

Important

This package depends on chromadb which uses Pydantic V1, not compatible with Python 3.14+.

Required: Use local source code with venv310 virtual environment (Python 3.10).

Add MCP Server

# Windows:
claude mcp add memory-mcp -s user -- "C:\path\to\memory-mcp\venv310\Scripts\python.exe" -m src.server

# Mac/Linux:
claude mcp add memory-mcp -s user -- /path/to/memory-mcp/venv310/bin/python -m src.server

Manual Configuration File

Edit ~/.claude/settings.json and add:

{
  "mcpServers": {
    "memory-mcp": {
      "command": "C:\\path\\to\\memory-mcp\\venv310\\Scripts\\python.exe",
      "args": ["-m", "src.server"],
      "cwd": "C:\\path\\to\\memory-mcp"
    }
  }
}

Configure Hooks (Optional)

Important: Hooks are only available with local source code installation.

Hooks enable automatic message saving. Once configured, conversations will be saved without manual memory tool calls.

Add to following hooks configuration to ~/.claude/settings.json:

Mac/Linux:

{
  "hooks": {
    "SessionStart": [{
      "matcher": ".*",
      "hooks": [{
        "type": "command",
        "command": "/path/to/venv310/bin/python",
        "args": ["/path/to/memory-mcp/session_start.py"]
      }]
    }],
    "UserPromptSubmit": [{
      "matcher": ".*",
      "hooks": [{
        "type": "command",
        "command": "/path/to/venv310/bin/python",
        "args": ["/path/to/memory-mcp/auto_save.py"]
      }]
    }],
    "Stop": [{
      "matcher": ".*",
      "hooks": [{
        "type": "command",
        "command": "/path/to/venv310/bin/python",
        "args": ["/path/to/memory-mcp/save_response.py"]
      }]
    }],
    "SessionEnd": [{
      "matcher": ".*",
      "hooks": [{
        "type": "command",
        "command": "/path/to/venv310/bin/python",
        "args": ["/path/to/memory-mcp/session_end.py"]
      }]
    }]
  }
}

Windows (requires cmd wrapper):

{
  "hooks": {
    "SessionStart": [{
      "matcher": ".*",
      "hooks": [{
        "type": "command",
        "command": "cmd",
        "args": ["/c", "C:\\path\\to\\memory-mcp\\venv310\\Scripts\\python.exe", "C:\\path\\to\\memory-mcp\\session_start.py"]
      }]
    }],
    "UserPromptSubmit": [{
      "matcher": ".*",
      "hooks": [{
        "type": "command",
        "command": "cmd",
        "args": ["/c", "C:\\path\\to\\memory-mcp\\venv310\\Scripts\\python.exe", "C:\\path\\to\\memory-mcp\\auto_save.py"]
      }]
    }],
    "Stop": [{
      "matcher": ".*",
      "hooks": [{
        "type": "command",
        "command": "cmd",
        "args": ["/c", "C:\\path\\to\\memory-mcp\\venv310\\Scripts\\python.exe", "C:\\path\\to\\memory-mcp\\save_response.py"]
      }]
    }],
    "SessionEnd": [{
      "matcher": ".*",
      "hooks": [{
        "type": "command",
        "command": "cmd",
        "args": ["/c", "C:\\path\\to\\memory-mcp\\venv310\\Scripts\\python.exe", "C:\\path\\to\\memory-mcp\\session_end.py"]
      }]
    }]
  }
}

Hooks Description:

Hook Name Purpose
SessionStart Create new episode when session starts
UserPromptSubmit Save user-submitted messages
Stop Save assistant responses
SessionEnd Close episode and remove project trust

Verify Configuration

claude mcp list

Expected output should show memory-m-mcp: ... - ✓ Connected

Usage

Automatic Mode (With Hooks)

After configuring hooks, conversations are automatically saved without manual operation.

Manual Mode

Manually call memory tools:

# Start a new task
memory_start("Login Function Development", ["auth"])

# Record a decision
memory_add_entity("Decision", "Adopt JWT + Redis solution", "Consider distributed deployment")

# Retrieve history
memory_recall("Login scheme")

# Close task
memory_close_episode("Completed JWT login function development")

Tools List

  • memory_start_episode: Start a new episode
  • memory_close_episode: Close an episode
  • memory_get_current_episode: Get current episode
  • memory_add_entity: Add entity
  • memory_confirm_entity: Confirm candidate entity
  • memory_reject_candidate: Reject candidate
  • memory_deprecate_entity: Deprecate entity
  • memory_get_pending: Get pending entities
  • memory_recall: Comprehensive retrieval
  • memory_search_by_type: Search by type
  • memory_get_episode_detail: Get episode detail
  • memory_list_episodes: List all episodes by time
  • memory_stats: Get statistics
  • memory_encoder_status: Check encoder status
  • memory_cache_message: Manually cache a message
  • memory_clear_cache: Clear message cache
  • memory_cleanup_messages: Clean up old messages

Entity Types

User-level (cross-project shared)

  • Preference: User preferences
  • Concept: General concepts
  • Habit: Work habits

Project-level (project isolated)

  • Decision: Project decisions
  • Episode: Development episodes
  • File: File descriptions
  • Architecture: Architecture designs

Storage Locations

  • User-level: ~/.claude-memory/ (Windows: %APPDATA%/claude-memory/)
  • Project-level: {project-root}/.claude/memory/

License

MIT License - see LICENSE file for details.

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

chenxiaofie_memory_mcp-0.1.2.tar.gz (21.0 kB view details)

Uploaded Source

Built Distribution

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

chenxiaofie_memory_mcp-0.1.2-py3-none-any.whl (23.2 kB view details)

Uploaded Python 3

File details

Details for the file chenxiaofie_memory_mcp-0.1.2.tar.gz.

File metadata

  • Download URL: chenxiaofie_memory_mcp-0.1.2.tar.gz
  • Upload date:
  • Size: 21.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for chenxiaofie_memory_mcp-0.1.2.tar.gz
Algorithm Hash digest
SHA256 904791621e778b250b819f0508396dddb067560c0a2a0683d71228f622cc0f04
MD5 d846907738579ab7131f58affb32f534
BLAKE2b-256 271e569e022bc035d4c43edf5f3686fecb97ec95b20280b4bc1155be09970bce

See more details on using hashes here.

File details

Details for the file chenxiaofie_memory_mcp-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for chenxiaofie_memory_mcp-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b8c53ec0f491063180d520e5fdf46f08cf9363d4b9bde16b434e5f83a8e8b3cf
MD5 53cc660496fa6b4fe84254edd1c7b69b
BLAKE2b-256 802bb73636608cdb481765150ae666c6dd17e14438654e39835be063e9537866

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