Skip to main content
Glama
Knowledge Graph Memory Server

Knowledge Graph Memory Server

by AgentWong

最適化されたメモリ MCP サーバー

これは、Claude AIのコーディング能力、優れたAIワークフロー、そしてプロンプト設計をテストし、実証するためのものです。これは、バックエンドにSQLiteを使用するPython Memory MCP Server(公式はJavaだと思います)のフォークです。

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

ローカルナレッジグラフを用いた永続メモリの基本実装。これにより、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"
  ]
}

Related MCP server: Knowledge Graph Memory Server

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", "--rm", "mcp/memory"]
    }
  }
}

NPX

{
  "mcpServers": {
    "memory": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-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ファイルをご覧ください。

Available Tools

9 tools
add_observationsAdd ObservationsB

Add new observations to existing entities in the knowledge graph

Inputs: observations (required). Returns: results

create_entitiesCreate EntitiesB

Create multiple new entities in the knowledge graph

Inputs: entities (required). Returns: entities

create_relationsCreate RelationsC

Create multiple new relations between entities in the knowledge graph. Relations should be in active voice

Inputs: relations (required). Returns: relations

delete_entitiesDelete EntitiesA

Delete multiple entities and their associated relations from the knowledge graph

Inputs: entityNames (required). Returns: message, success

delete_observationsDelete ObservationsC

Delete specific observations from entities in the knowledge graph

Inputs: deletions (required). Returns: message, success

delete_relationsDelete RelationsB

Delete multiple relations from the knowledge graph

Inputs: relations (required). Returns: message, success

open_nodesOpen NodesB

Open specific nodes in the knowledge graph by their names

Inputs: names (required). Returns: entities, relations

read_graphRead GraphB

Read the entire knowledge graph

Inputs: no named parameters. Returns: entities, relations

search_nodesSearch NodesB

Search for nodes in the knowledge graph based on a query

Inputs: query (required). Returns: entities, relations

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3.4/5.0

    Scored across 9 tools

    Disambiguation4/5

    Most tools have distinct purposes, but 'open_nodes' and 'search_nodes' could cause some confusion as both involve accessing nodes, though 'open_nodes' seems to retrieve specific nodes by name while 'search_nodes' queries based on criteria. The CRUD operations for entities, relations, and observations are clearly separated, reducing major overlap.

    Naming Consistency5/5

    All tool names follow a consistent verb_noun pattern with snake_case, such as 'add_observations', 'create_entities', and 'delete_relations'. This predictability makes it easy for agents to understand and use the tool set without confusion from mixed conventions.

    Tool Count5/5

    With 9 tools, the server is well-scoped for managing a knowledge graph, covering core operations like creation, deletion, reading, and searching. This count is appropriate as it provides comprehensive functionality without being overwhelming or too sparse for the domain.

    Completeness4/5

    The tool set offers strong coverage with CRUD operations for entities, relations, and observations, plus reading and searching capabilities. A minor gap is the lack of update tools for entities or relations, which might require workarounds like delete-and-recreate, but core workflows are well-supported.

    Related MCP Connectors

    Related MCP Servers