Knowledge Graph Memory Server

MIT License
7,903
40,097
  • Apple
  • Linux

local-only server

The server can only run on the client’s local machine because it depends on local resources.

ナレッジグラフメモリサーバー

ローカルナレッジグラフを用いた永続メモリの基本実装。これにより、Claude はチャットをまたいでユーザーに関する情報を記憶できます。

コアコンセプト

エンティティ

エンティティはナレッジグラフの主要なノードです。各エンティティには以下の要素が含まれます。

  • 一意の名前(識別子)
  • エンティティの種類(例:「人」、「組織」、「イベント」)
  • 観察リスト

例:

{ "name": "John_Smith", "entityType": "person", "observations": ["Speaks fluent Spanish"] }

関係

関係は、実体間の有向的なつながりを定義します。関係は常に能動態で表現され、実体同士がどのように相互作用し、関係するかを説明します。

例:

{ "from": "John_Smith", "to": "Anthropic", "relationType": "works_at" }

観察

観察とは、ある実体に関する個別の情報です。観察対象には以下のものがあります。

  • 文字列として保存
  • 特定のエンティティに添付
  • 個別に追加または削除可能
  • アトミックである必要があります(観察ごとに1つの事実)

例:

{ "entityName": "John_Smith", "observations": [ "Speaks fluent Spanish", "Graduated in 2019", "Prefers morning meetings" ] }

API

ツール

  • エンティティの作成
    • ナレッジグラフに複数の新しいエンティティを作成する
    • 入力: entities (オブジェクトの配列)
      • 各オブジェクトには次のものが含まれます。
        • name (文字列): エンティティ識別子
        • entityType (文字列): 型分類
        • observations (文字列[]): 関連する観測値
    • 既存の名前を持つエンティティを無視します
  • 関係を作成する
    • エンティティ間に複数の新しい関係を作成する
    • 入力: relations (オブジェクトの配列)
      • 各オブジェクトには次のものが含まれます。
        • from (文字列): ソースエンティティ名
        • to (文字列): ターゲットエンティティ名
        • relationType (文字列): 能動態における関係の種類
    • 重複関係をスキップする
  • 観察を追加する
    • 既存のエンティティに新しい観察を追加する
    • 入力: observations (オブジェクトの配列)
      • 各オブジェクトには次のものが含まれます。
        • entityName (文字列): 対象エンティティ
        • contents (文字列[]): 追加する新しい観察
    • エンティティごとに追加された観測値を返します
    • エンティティが存在しない場合は失敗します
  • エンティティの削除
    • エンティティとその関係を削除する
    • 入力: entityNames (string[])
    • 関連関係のカスケード削除
    • エンティティが存在しない場合はサイレント操作
  • 削除観測
    • エンティティから特定の観察を削除する
    • 入力: deletions (オブジェクトの配列)
      • 各オブジェクトには次のものが含まれます。
        • entityName (文字列): 対象エンティティ
        • observations (文字列[]): 削除する観測値
    • 観測が存在しない場合はサイレント操作
  • 関係を削除する
    • グラフから特定の関係を削除する
    • 入力: relations (オブジェクトの配列)
      • 各オブジェクトには次のものが含まれます。
        • from (文字列): ソースエンティティ名
        • to (文字列): ターゲットエンティティ名
        • relationType (文字列): 関係の種類
    • 関係が存在しない場合はサイレント操作
  • グラフを読む
    • ナレッジグラフ全体を読む
    • 入力不要
    • すべてのエンティティと関係を含む完全なグラフ構造を返します
  • 検索ノード
    • クエリに基づいてノードを検索する
    • 入力: query (文字列)
    • 検索範囲:
      • エンティティ名
      • エンティティタイプ
      • 観察内容
    • 一致するエンティティとその関係を返します
  • オープンノード
    • 名前で特定のノードを取得する
    • 入力: names (文字列[])
    • 戻り値:
      • 要求されたエンティティ
      • 要求されたエンティティ間の関係
    • 存在しないノードを黙ってスキップする

Claude Desktopでの使用

設定

claude_desktop_config.json に以下を追加します:

ドッカー

{ "mcpServers": { "memory": { "command": "docker", "args": ["run", "-i", "-v", "claude-memory:/app/dist", "--rm", "mcp/memory"] } } }

NPX

{ "mcpServers": { "memory": { "command": "npx", "args": [ "-y", "@modelcontextprotocol/server-memory" ] } } }

カスタム設定のNPX

サーバーは次の環境変数を使用して構成できます。

{ "mcpServers": { "memory": { "command": "npx", "args": [ "-y", "@modelcontextprotocol/server-memory" ], "env": { "MEMORY_FILE_PATH": "/path/to/custom/memory.json" } } } }
  • MEMORY_FILE_PATH : メモリストレージ JSON ファイルへのパス (デフォルト: サーバー ディレクトリ内のmemory.json )

VS Code インストール手順

素早くインストールするには、以下のワンクリック インストール ボタンのいずれかを使用します。

手動でインストールする場合は、VS Code のユーザー設定 (JSON) ファイルに次の JSON ブロックを追加します。Ctrl Ctrl + Shift + Pを押してPreferences: Open Settings (JSON)と入力すると、このブロックを追加できます。

オプションとして、ワークスペース内の.vscode/mcp.jsonというファイルに追加することもできます。これにより、他のユーザーと設定を共有できるようになります。

.vscode/mcp.jsonファイルではmcpキーは必要ないことに注意してください。

NPX

{ "mcp": { "servers": { "memory": { "command": "npx", "args": [ "-y", "@modelcontextprotocol/server-memory" ] } } } }

ドッカー

{ "mcp": { "servers": { "memory": { "command": "docker", "args": [ "run", "-i", "-v", "claude-memory:/app/dist", "--rm", "mcp/memory" ] } } } }

システムプロンプト

メモリの利用に関するプロンプトはユースケースによって異なります。プロンプトを変更することで、モデルはメモリの頻度と種類を適切に判断できるようになります。

チャットのパーソナライズのためのプロンプトの例を以下に示します。このプロンプトは、 Claude.ai プロジェクトの「カスタム指示」フィールドで使用できます。

Follow these steps for each interaction: 1. User Identification: - You should assume that you are interacting with default_user - If you have not identified default_user, proactively try to do so. 2. Memory Retrieval: - Always begin your chat by saying only "Remembering..." and retrieve all relevant information from your knowledge graph - Always refer to your knowledge graph as your "memory" 3. Memory - While conversing with the user, be attentive to any new information that falls into these categories: a) Basic Identity (age, gender, location, job title, education level, etc.) b) Behaviors (interests, habits, etc.) c) Preferences (communication style, preferred language, etc.) d) Goals (goals, targets, aspirations, etc.) e) Relationships (personal and professional relationships up to 3 degrees of separation) 4. Memory Update: - If any new information was gathered during the interaction, update your memory as follows: a) Create entities for recurring organizations, people, and significant events b) Connect them to the current entities using relations b) Store facts about them as observations

建物

ドッカー:

docker build -t mcp/memory -f src/memory/Dockerfile .

ライセンス

このMCPサーバーはMITライセンスに基づいてライセンスされています。つまり、MITライセンスの条件に従って、ソフトウェアを自由に使用、改変、配布することができます。詳細については、プロジェクトリポジトリのLICENSEファイルをご覧ください。

-
security - not tested
A
license - permissive license
-
quality - not tested

ローカルナレッジグラフを用いた永続メモリの基本実装。これにより、Claude はチャットをまたいでユーザーに関する情報を記憶できます。

  1. Core Concepts
    1. Entities
    2. Relations
    3. Observations
  2. API
    1. Tools
  3. Usage with Claude Desktop
    1. Setup
  4. VS Code Installation Instructions
    1. NPX
    2. Docker
    3. System Prompt
    4. Building
    5. License
ID: an7spipwyo