Skip to main content
Glama

Memory MCP Server

by evangstav

メモリMCPサーバー

データの一貫性を維持するための厳密な検証ルールを備え、メモリ内のエンティティ、リレーション、および観測を管理するためのナレッジ グラフ機能を提供するモデル コンテキスト プロトコル (MCP) サーバー。

インストール

Claude Desktop にサーバーをインストールします。

mcp install main.py -v MEMORY_FILE_PATH=/path/to/memory.jsonl

データ検証ルール

エンティティ名

  • 小文字で始まる必要があります
  • 小文字、数字、ハイフンを含めることができます
  • 最大100文字
  • グラフ内で一意である必要があります
  • 有効な名前の例: python-projectmeeting-notes-2024user-john

エンティティタイプ

次のエンティティ タイプがサポートされています。

  • person :人間の実体
  • concept : 抽象的な考えや原則
  • project : 仕事の取り組みまたはタスク
  • document : あらゆる形式の文書
  • tool : ソフトウェアツールまたはユーティリティ
  • organization : 企業またはグループ
  • location : 物理的または仮想的な場所
  • event : 時間制限のある発生

観察

  • 空でない文字列
  • 最大500文字
  • エンティティごとに一意である必要があります
  • 事実と客観的な記述であるべきである
  • 関連する場合はタイムスタンプを含める

関係

次の関係タイプがサポートされています。

  • knows :人と人とのつながり
  • contains : 親子関係
  • uses : 別のエンティティを利用するエンティティ
  • created :著作者/創作関係
  • belongs-to :メンバーシップ/所有権
  • depends-on :依存関係
  • related-to :一般的な関係

追加の関係ルール:

  • ソースエンティティとターゲットエンティティの両方が存在する必要があります
  • 自己参照関係は許可されません
  • 循環依存は許可されません
  • 定義済みの関係タイプを使用する必要があります

使用法

サーバーは、ナレッジ グラフを管理するためのツールを提供します。

エンティティを取得

result = await session.call_tool("get_entity", { "entity_name": "example" }) if not result.success: if result.error_type == "NOT_FOUND": print(f"Entity not found: {result.error}") elif result.error_type == "VALIDATION_ERROR": print(f"Invalid input: {result.error}") else: print(f"Error: {result.error}") else: entity = result.data print(f"Found entity: {entity}")

グラフを取得

result = await session.call_tool("get_graph", {}) if result.success: graph = result.data print(f"Graph data: {graph}") else: print(f"Error retrieving graph: {result.error}")

エンティティを作成する

# Valid entity creation entities = [ Entity( name="python-project", # Lowercase with hyphens entityType="project", # Must be a valid type observations=["Started development on 2024-01-29"] ), Entity( name="john-doe", entityType="person", observations=["Software engineer", "Joined team in 2024"] ) ] result = await session.call_tool("create_entities", { "entities": entities }) if not result.success: if result.error_type == "VALIDATION_ERROR": print(f"Invalid entity data: {result.error}") else: print(f"Error creating entities: {result.error}")

観察を追加

# Valid observation result = await session.call_tool("add_observation", { "entity": "python-project", "observation": "Completed initial prototype" # Must be unique for entity }) if not result.success: if result.error_type == "NOT_FOUND": print(f"Entity not found: {result.error}") elif result.error_type == "VALIDATION_ERROR": print(f"Invalid observation: {result.error}") else: print(f"Error adding observation: {result.error}")

関係を作成する

# Valid relation result = await session.call_tool("create_relation", { "from_entity": "john-doe", "to_entity": "python-project", "relation_type": "created" # Must be a valid type }) if not result.success: if result.error_type == "NOT_FOUND": print(f"Entity not found: {result.error}") elif result.error_type == "VALIDATION_ERROR": print(f"Invalid relation data: {result.error}") else: print(f"Error creating relation: {result.error}")

検索メモリ

result = await session.call_tool("search_memory", { "query": "most recent workout" # Supports natural language queries }) if result.success: if result.error_type == "NO_RESULTS": print(f"No results found: {result.error}") else: results = result.data print(f"Search results: {results}") else: print(f"Error searching memory: {result.error}")

検索機能は以下をサポートします:

  • 時間的なクエリ(例:「最新」、「最後」、「最新」)
  • アクティビティクエリ(例:「ワークアウト」、「エクササイズ」)
  • 一般的なエンティティ検索
  • 80%の類似度閾値を持つファジーマッチング
  • 重み付け検索:
    • エンティティ名(重み: 1.0)
    • エンティティタイプ(重み: 0.8)
    • 観察結果(重み:0.6)

エンティティの削除

result = await session.call_tool("delete_entities", { "names": ["python-project", "john-doe"] }) if not result.success: if result.error_type == "NOT_FOUND": print(f"Entity not found: {result.error}") else: print(f"Error deleting entities: {result.error}")

関係を削除

result = await session.call_tool("delete_relation", { "from_entity": "john-doe", "to_entity": "python-project" }) if not result.success: if result.error_type == "NOT_FOUND": print(f"Entity not found: {result.error}") else: print(f"Error deleting relation: {result.error}")

フラッシュメモリ

result = await session.call_tool("flush_memory", {}) if not result.success: print(f"Error flushing memory: {result.error}")

エラーの種類

サーバーは次のエラー タイプを使用します。

  • NOT_FOUND : エンティティまたはリソースが見つかりません
  • VALIDATION_ERROR : 入力データが無効です
  • INTERNAL_ERROR : サーバー側エラー
  • ALREADY_EXISTS : リソースが既に存在します
  • INVALID_RELATION : エンティティ間の関係が無効です

応答モデル

すべてのツールは、次のモデルを使用して入力された応答を返します。

エンティティレスポンス

class EntityResponse(BaseModel): success: bool data: Optional[Dict[str, Any]] = None error: Optional[str] = None error_type: Optional[str] = None

グラフレスポンス

class GraphResponse(BaseModel): success: bool data: Optional[Dict[str, Any]] = None error: Optional[str] = None error_type: Optional[str] = None

オペレーションレスポンス

class OperationResponse(BaseModel): success: bool error: Optional[str] = None error_type: Optional[str] = None

発達

テストの実行

pytest tests/

新機能の追加

  1. validation.pyの検証ルールを更新する
  2. tests/test_validation.pyにテストを追加する
  3. knowledge_graph_manager.pyに変更を実装する
-
security - not tested
A
license - permissive license
-
quality - not tested

hybrid server

The server is able to function both locally and remotely, depending on the configuration or use case.

データの一貫性を維持するための厳密な検証ルールを使用して、メモリ内のエンティティ、リレーション、および観測を管理するためのナレッジ グラフ機能を提供します。

  1. インストール
    1. データ検証ルール
      1. エンティティ名
      2. エンティティタイプ
      3. 観察
      4. 関係
    2. 使用法
      1. エンティティを取得
      2. グラフを取得
      3. エンティティを作成する
      4. 観察を追加
      5. 関係を作成する
      6. 検索メモリ
      7. エンティティの削除
      8. 関係を削除
      9. フラッシュメモリ
    3. エラーの種類
      1. 応答モデル
        1. エンティティレスポンス
        2. グラフレスポンス
        3. オペレーションレスポンス
      2. 発達
        1. テストの実行
        2. 新機能の追加

      Related MCP Servers

      • A
        security
        F
        license
        A
        quality
        Provides tools for managing project knowledge graphs, enabling structured representation of projects, tasks, milestones, resources, and team members.
        Last updated 4 months ago
        6
        7
        TypeScript
        • Apple
        • Linux
      • A
        security
        F
        license
        A
        quality
        Provides tools for managing quantitative research knowledge graphs, enabling structured representation of research projects, datasets, variables, hypotheses, statistical tests, models, and results.
        Last updated 4 months ago
        6
        6
        TypeScript
        • Apple
        • Linux
      • -
        security
        F
        license
        -
        quality
        Provides tools for managing qualitative research knowledge graphs, enabling structured representation of research projects, participants, interviews, observations, codes, themes, and findings.
        Last updated 4 months ago
        4
        TypeScript
        • Apple
        • Linux
      • A
        security
        F
        license
        A
        quality
        Provides tools for managing student knowledge graphs, enabling structured representation of courses, assignments, exams, concepts, and study resources.
        Last updated 4 months ago
        6
        TypeScript
        • Apple
        • Linux

      View all related MCP servers

      MCP directory API

      We provide all the information about MCP servers via our MCP API.

      curl -X GET 'https://glama.ai/api/mcp/v1/servers/evangstav/python-memory-mcp-server'

      If you have feedback or need assistance with the MCP directory API, please join our Discord server