Knowledge Graph Memory Server

local-only server

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

Integrations

  • Implements persistent memory storage using a local knowledge graph to maintain information across different chat sessions, with capabilities for creating, retrieving, and manipulating structured memory data.

https://github.com/modelcontextprotocol/servers/tree/mainをフォークしました

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

ローカルナレッジグラフを用いた永続メモリの基本実装。これにより、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 (文字列): 関係の種類
    • 関係が存在しない場合はサイレント操作
  • グラフを読む
    • ナレッジグラフ全体を読む
    • 入力不要
    • すべてのエンティティと関係を含む完全なグラフ構造を返します
  • 検索ノード
    • 1つ以上のキーワードに基づいてノードを検索する
    • 入力: query (文字列)
      • スペースで区切られたキーワード(例:"budget utility")
      • 複数のキーワードはOR条件として扱われます
    • 検索範囲:
      • エンティティ名
      • エンティティタイプ
      • サブドメイン
      • 観察内容
    • マッチング動作:
      • 大文字と小文字を区別しない
      • 部分的な単語一致
      • どのキーワードもどのフィールドとも一致します
      • いずれかのキーワードに一致するエンティティを返します
    • 一致するエンティティとその関係を返します
    • クエリの例:
      • 単一キーワード:「予算」
      • 複数のキーワード:「予算ユーティリティ」
      • 特殊文字付き:「予算と実用性」
  • オープンノード
    • 名前で特定のノードを取得する
    • 入力: names (文字列[])
    • 戻り値:
      • 要求されたエンティティ
      • 要求されたエンティティ間の関係
    • 存在しないノードを黙ってスキップする

Claude Desktopでの使用

設定

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

ドッカー

{ "mcpServers": { "memory": { "command": "docker", "args": ["run", "-i", "--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 )

システムプロンプト

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

チャットのパーソナライズのためのプロンプトの例を以下に示します。このプロンプトは、 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" - When searching your memory, you can use multiple keywords to find related information - Example searches: * Single concept: "programming" * Related concepts: "programming python" * Specific domain with role: "work engineer" 3. Memory Creation: - 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) - When storing information, use specific and descriptive keywords that will help in future searches 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 c) Store facts about them as observations d) Use clear and searchable terms in entity names and observations to facilitate future retrieval

建物

ドッカー:

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

ライセンス

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

You must be authenticated.

A
security – no known vulnerabilities
F
license - not found
A
quality - confirmed to work

この MCP サーバーは、ローカル ナレッジ グラフを利用して対話全体にわたってユーザー情報を記憶することにより、チャット アプリケーションに永続的なメモリ統合を提供します。

  1. Core Concepts
    1. Entities
    2. Relations
    3. Observations
  2. API
    1. Tools
  3. Usage with Claude Desktop
    1. Setup
    2. System Prompt
    3. Building
    4. License
ID: mdsegdy7ox