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 the install.bat file in the project root directory:

# Double-click to run or execute from command line
install.bat

Mac/Linux One-click Installation

Run the install.sh file in the project root directory:

# Execute from command line
chmod +x install.sh
./install.sh

Manual Installation

cd .claude/memory-mcp

# Create virtual environment
python -m venv venv310

# Activate virtual environment
# Windows:
venv310\Scripts\activate
# Mac/Linux:
source venv310/bin/activate

# Install dependencies
pip install -e .

Configure Claude Code

1. MCP Service Configuration

Method 1: Add using command line (recommended)

claude mcp add memory-mcp -- python -m src.server

Method 2: Manual configuration in settings.json

Edit ~/.claude/settings.json (global configuration):

{
  "mcpServers": {
    "memory-mcp": {
      "command": "/path/to/your/venv/bin/python",
      "args": ["-m", "src.server"],
      "cwd": "/path/to/your/memory-mcp",
      "env": {
        "CLAUDE_PROJECT_ROOT": "/path/to/your/project"
      }
    }
  },
  "hooks": {
    "SessionStart": [
      {
        "matcher": ".*",
        "hooks": [
          {
            "type": "command",
            "command": "/path/to/your/venv/bin/python",
            "args": ["/path/to/your/memory-mcp/session_start.py"],
            "env": {}
          }
        ]
      }
    ],
    "UserPromptSubmit": [
      {
        "matcher": ".*",
        "hooks": [
          {
            "type": "command",
            "command": "/path/to/your/venv/bin/python",
            "args": ["/path/to/your/memory-mcp/auto_save.py"],
            "env": {}
          }
        ]
      }
    ],
    "Stop": [
      {
        "matcher": ".*",
        "hooks": [
          {
            "type": "command",
            "command": "/path/to/your/venv/bin/python",
            "args": ["/path/to/your/memory-mcp/save_response.py"],
            "env": {}
          }
        ]
      }
    ],
    "SessionEnd": [
      {
        "matcher": ".*",
        "hooks": [
          {
            "type": "command",
            "command": "/path/to/your/venv/bin/python",
            "args": ["/path/to/your/memory-mcp/session_end.py"],
            "env": {}
          }
        ]
      }
    ]
  }
}

2. Hooks Functionality

The project provides 4 automated hooks to implement complete session lifecycle management:

Hook Name File Function Description
SessionStart session_start.py Automatically creates a scenario when a session starts and begins monitoring the terminal lifecycle
UserPromptSubmit auto_save.py Automatically saves user messages to the memory system when they submit a prompt
Stop save_response.py Saves assistant responses to the memory system when the session stops
SessionEnd session_end.py Sends a close signal to the monitoring process when the session ends, which is responsible for closing the scenario and generating a summary

3. Verify Configuration

# Check MCP server status
claude mcp list

# Expected output
Checking MCP server health...
playwright: npx @playwright/mcp@latest -  Connected
memory-mcp: /path/to/your/venv/bin/python -m src.server -  Connected

Tools List

Message Cache

  • memory_cache_message: Cache messages

Episode Management

  • memory_start_episode: Start a new episode
  • memory_close_episode: Close an episode
  • memory_get_current_episode: Get current episode

Entity Management

  • 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

Retrieval

  • memory_recall: Comprehensive retrieval
  • memory_search_by_type: Search by type
  • memory_get_episode_detail: Get episode detail

Statistics

  • memory_stats: Get statistics

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 scenes
  • File: File descriptions
  • Architecture: Architecture designs

Storage Locations

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

Example Usage

# Start a new task
Claude call: memory_start_episode("Login Function Development", ["auth"])

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

# Retrieve history
Claude call: memory_recall("Login scheme")

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

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.0.tar.gz (21.7 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.0-py3-none-any.whl (24.0 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for chenxiaofie_memory_mcp-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6985ab51dc8dc88eb60a233c0429480785f71f3546da007ce9498b1e57ab4731
MD5 02034c613523a05def9153b4a7297d63
BLAKE2b-256 f6660b9898f244b748e5cb0501e7104405d03282e23ccb825854a61897fe7df5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chenxiaofie_memory_mcp-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 54833993dbcff2858676cc9b33eeae796bb514025fd12f154515ce51ee6ea30e
MD5 3228194475b024c96501c9ea89f336db
BLAKE2b-256 aafa911ed2c671e9583bde67c5efd886f15b2c8081a2a0bdc031983451bf5c8e

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