Skip to main content
Glama
evangstav

Memory MCP Server

by evangstav

메모리 MCP 서버

데이터 일관성을 유지하기 위한 엄격한 유효성 검사 규칙을 통해 메모리 내 엔티티, 관계 및 관찰을 관리하는 지식 그래프 기능을 제공하는 모델 컨텍스트 프로토콜(MCP) 서버입니다.

설치

Claude Desktop에 서버를 설치하세요:

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

Related MCP server: MCP Memory Server - HTTP Streaming

데이터 유효성 검사 규칙

엔티티 이름

  • 소문자로 시작해야 함

  • 소문자, 숫자, 하이픈을 포함할 수 있음

  • 최대 100자

  • 그래프 내에서 고유해야 함

  • 유효한 이름 예시: python-project, meeting-notes-2024, user-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}")

검색 기능은 다음을 지원합니다:

  • 시간 관련 쿼리 (예: "most recent", "last", "latest")

  • 활동 쿼리 (예: "workout", "exercise")

  • 일반 엔티티 검색

  • 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: 엔티티 간의 잘못된 관계

응답 모델

모든 도구는 다음 모델을 사용하여 유형이 지정된 응답을 반환합니다:

EntityResponse

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

GraphResponse

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

OperationResponse

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에서 변경 사항 구현

A
license - permissive license
Not graded
quality - not tested
D
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

  • F
    license
    Not graded
    quality
    D
    maintenance
    Enables creation and management of knowledge graphs with entities, relationships, and observations through HTTP streaming. Supports persistent storage, search functionality, and CRUD operations for building and querying interconnected knowledge bases.
    2
  • A
    license
    C
    quality
    D
    maintenance
    Provides persistent memory and knowledge graph capabilities for AI assistants using local SQLite storage. Enables creating, searching, and managing entities, relationships, and observations with vector search support across conversations.
    7
    10
    15
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    Provides LLMs with persistent memory across conversations using a knowledge graph that stores entities, relationships, and observations with support for PostgreSQL or SQLite backends.
    102
    24
    MIT

View all related MCP servers

Related MCP Connectors

  • Manage TTRPG campaigns: NPCs, locations, factions, quests, sessions, lore, and knowledge graphs.

  • AI knowledge graph for architecture, portfolio, and digital strategy management.

  • End-to-end agent-managed company brain. Docs, diagrams, plans, Knowledge Graph. Lean & affordable.

View all MCP Connectors

Latest Blog Posts

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