Skip to main content
Glama
noualit

llama-memory

by noualit

llama-memory

Postgres + PGVector를 기반으로 지속적인 대화 기록과 의미 기반 메모리를 제공하는 llama-server용 MCP 메모리 서비스입니다.

참고: 이 프로젝트는 로컬/데모 용도로만 사용하세요. 추가 보안 조치(HTTPS, 적절한 인증, 백업) 없이 인터넷에 직접 노출하지 마십시오.

기능

  • 의미 기반 메모리: 키워드가 아닌 의미로 메모리를 저장하고 검색합니다.

  • 대화 연결: LLM이 대화를 자동으로 생성하고 메모리를 대화에 연결합니다.

  • 세션 간 회상: "이전에 무슨 이야기를 나눴지?"라고 물으면 정확한 답변을 제공합니다.

  • MCP 프로토콜: llama.cpp에 내장된 MCP 지원과 직접 연동됩니다.

Related MCP server: engram

요구 사항

  • Python 3.11 (Miniconda 권장)

  • PGVector 확장이 포함된 PostgreSQL 16+

  • --jinja 플래그를 사용하는 llama.cpp (도구 호출에 필요)

  • llama.cpp에서 실행되는 nomic-embed-text (기본 포트 8081)

설치

# Clone the repo
git clone https://github.com/noualit/llama-memory-local.git
cd llama-memory-local

# Create environment
conda create -n llama-memory python=3.11
conda activate llama-memory

# Install dependencies
pip install -e .

환경 설정

.env.example을 .env로 복사한 후 편집하세요:

cp .env.example .env

예시:

# Database
DATABASE_URL="postgresql://postgres:yourpassword@localhost:5432/llamamem"

# Llama-server (LLM)
LLAMA_SERVER_BASE_URL="http://localhost:8080"

# Embedding model (nomic-embed-text via llama-server)
EMBEDDING_MODEL_URL="http://localhost:8081"

# Embedding model name (default: nomic-embed-text)
EMBEDDING_MODEL_NAME="nomic-embed-text"

# Service port
SERVICE_PORT=9001

데이터베이스 설정

데이터베이스를 생성하고 마이그레이션을 실행하세요:

psql -U postgres -c "CREATE DATABASE llamamem;"
alembic upgrade head

애플리케이션은 또한 시작 시 기본 스키마가 자동으로 반영되도록 보장합니다.

서비스 실행

# Using the script
.\scripts\run_server.ps1

# Or directly
python -m uvicorn app.main:app --host 0.0.0.0 --port 9001

llama.cpp를 시작합니다.

llama.cpp에 연결

llama.cpp의 MCP 환경 설정에 다음을 추가하세요:

{
  "mcpServers": {
    "llama-memory": {
      "url": "http://YOUR_SERVER_IP:9001/mcp"
    }
  }
}

서비스는 llama.cpp에서 접근 가능해야 합니다. 서로 다른 머신에서 실행 중이라면 localhost 대신 실제 IP를 사용하세요.

MCP 도구

도구

설명

create_conversation

새 대화 세션 생성

list_conversation

메모리 개수와 함께 대화 목록 표시

get_conversation_history

대화에 속한 모든 메모리 불러오기

search_memories

모든 메모리에서 의미 기반 검색

save_memory

중요한 사실이나 결정 저장

시스템 프롬프트

다음 중 하나를 사용할 수 있습니다:

  • 서비스에서 권장 시스템 프롬프트 얻기:

    • GET /system-prompt → 텍스트로 반환됩니다.

  • 또는 다음 최소 버전을 llama.cpp에 붙여넣으세요:

MEMORY WORKFLOW:
- At the start of each new conversation, call create_conversation with a short title.
- Use the conversation_id from create_conversation when calling save_memory.
- Before answering questions about past topics, call search_memories FIRST.
- When the user shares important information, save it with save_memory.
- If list_conversations has previous chats, check get_conversation_history for context.

상태 확인

curl http://localhost:9001/health

DB 상태, 임베딩 서비스 상태, 도구 수를 반환합니다.

아키텍처

상위 수준 구조:

  • app/main.py — FastAPI 앱, lifespan, /system-prompt 처리

  • app/settings.py — .env에서 가져오는 Pydantic 설정

  • app/clients/embeddings.py — nomic-embed-text 호출을 통한 벡터 생성

  • app/db/engine.py — asyncpg 연결 풀(싱글턴)

  • app/db/schema.py — 시작 시 테이블 자동 생성

  • app/mcp/endpoint.py — MCP 프로토콜 핸들러, 레이트 리미터

  • app/mcp/tools/ — 개별 도구 구현

  • migrations/ — Alembic 데이터베이스 마이그레이션

개발

# Run tests
pytest tests/ -v

# Run with auto-reload
python -m uvicorn app.main:app --host 0.0.0.0 --port 9001 --reload

기여 지침은 CONTRIBUTING.md 파일을 참조하세요.

라이선스

MIT (자세한 내용은 LICENSE 파일을 참조하세요.)

A
license - permissive license
Not graded
quality - not tested
C
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

  • A
    license
    Not graded
    quality
    C
    maintenance
    Persistent semantic memory server for AI assistants via MCP, enabling long-term context retention and semantic search across conversations.
    11
    MIT
  • A
    license
    Not graded
    quality
    C
    maintenance
    Provides persistent, local-first AI memory across sessions via MCP tools for storing, searching, and retrieving context from past interactions.
    1
    MIT
  • A
    license
    A
    quality
    D
    maintenance
    Provides persistent memory for AI assistants via MCP, enabling them to store and recall facts, preferences, and tasks across conversations using either local file storage or a cloud backend with semantic search.
    5
    14
    MIT
  • A
    license
    A
    quality
    D
    maintenance
    Provides persistent memory with semantic search for MCP-based AI agents, enabling them to store and recall information across sessions using vector embeddings.
    4
    1
    MIT

View all related MCP servers

Related MCP Connectors

  • Shared, governed long-term memory for AI agents across tools and sessions via MCP and REST.

  • Persistent memory for AI agents. Search, store, and recall across sessions.

  • Cross-AI personal memory. Save once in ChatGPT, recall in Claude, Mistral, Grok, or any MCP client.

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/noualit/llama-memory-local'

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