Skip to main content
Glama
skylarng89

CogMemory MCP Server

by skylarng89

CogMemory MCP Server

AI 코딩 에이전트를 위한 4가지 컨텍스트 하위 시스템을 제공하는 Model Context Protocol 통합 서버입니다:

  1. Memory — 결정, 규칙, 오류, 활성 컨텍스트, 변경 로그, 계획, 작업, 세션

  2. Knowledge Graph — 엔티티, 관계, 관찰

  3. Specs — 장문 문서(PRD/SRS), 선택적으로 KG 엔티티와 연결

  4. Code Graph — 정적 구조 그래프(심볼/엣지) + 명명된 실행 추적 + AI 생성 주석

저장소: SQLite (better-sqlite3 사용). 범위(scope)당 하나의 .db 파일.


빠른 시작

설치

git clone <repo> && cd cogmemory-mcp
pnpm install
pnpm run build

VS Code에서 구성

.vscode/mcp.json에 추가합니다(워크스페이스 범위):

{
  "servers": {
    "cogmemory": {
      "command": "node",
      "args": ["/absolute/path/to/cogmemory-mcp/dist/index.js"]
    }
  }
}

또는 전역에서 사용하려면 사용자 mcp.json에 추가합니다.

MCP Inspector로 실행(개발)

pnpm run inspect

Related MCP server: LumenCore

범위 구성 (Scope Configuration)

CogMemory는 다음 우선순위에 따라 범위를 결정합니다.

  1. .cogmemory/config.json (워크스페이스 루트):

    { "scope": "global" }
  2. 환경 변수: COGMEMORY_SCOPE=global

  3. 기본값: workspace

경로

범위

데이터베이스 경로

workspace

<workspace_root>/.cogmemory/memory.db

global

~/.cogmemory/global.db

워크스페이스 결정 및 멀티 루트 지원

CogMemory는 다음 우선순위로 워크스페이스 루트(.cogmemory/memory.db가 위치하는 곳)를 결정합니다.

  1. --workspace <path> CLI 인자 (최우선순위)

  2. COGMEMORY_WORKSPACE 환경 변수

  3. CWD에서 위로 이동하면서 .cogmemory/ 디렉터리를 포함하는 가장 가까운 상위 폴더를 찾습니다.

  4. CWD로 대체

멀티 루트 VS Code 워크스페이스

VS Code 멀티 루트 워크스페이스에서는 각 폴더가 개별 워크스페이스 루트입니다. CogMemory는 이를 이렇게 처리합니다:

  • 단일 루트 — 자동으로 동작합니다. VS Code가 CWD를 워크스페이스 폴더로 설정하고, --workspace가 mcp.json을 통해 전달됩니다.

  • 멀티 루트 — 각 워크스페이스 폴더는 고유한 .cogmemory/를 가질 수 있습니다. 각각 다른 --workspace 경로로 CogMemory를 지정하거나, 상위 디렉터리에 공용 .cogmemory/를 둡니다.

권장 멀티 루트 mcp.json (폴더별):

{
  "servers": {
    "cogmemory-frontend": {
      "command": "node",
      "args": [
        "/path/to/cogmemory-mcp/dist/index.js",
        "--workspace",
        "/path/to/frontend"
      ]
    },
    "cogmemory-backend": {
      "command": "node",
      "args": [
        "/path/to/cogmemory-mcp/dist/index.js",
        "--workspace",
        "/path/to/backend"
      ]
    }
  }
}

또는 공용 데이터베이스 사용 (모든 루트를 한곳에):

{
  "servers": {
    "cogmemory": {
      "command": "node",
      "args": [
        "/path/to/cogmemory-mcp/dist/index.js",
        "--workspace",
        "/shared/root"
      ]
    }
  }
}

또는 전역 범위 사용 (모든 워크스페이스에서 공유):

{
  "servers": {
    "cogmemory": {
      "command": "node",
      "args": ["/path/to/cogmemory-mcp/dist/index.js"]
    }
  }
}
export COGMEMORY_SCOPE=global

도구 참조

메모리 도구

도구

설명

start_session

작업 세션 시작 (세션 ID 반환)

end_session

세션 종료, 요약 저장

get_session_summary

결정, 오류, 변경 로그를 포함한 세션 세부 내용 조회

remember_decision

근거와 태그와 함께 결정 기록

remember_convention

규약 기록/업데이트 (디자인 토큰, 패턴, 스타일, 명명)

log_error

시그니처와 해결 방법과 함께 오류 기록

set_active_context

키로 현재 초점/작업 upsert

get_active_context

키로 현재 초점 읽기

log_change

변경 로그 항목 추가

add_plan_item

로드맵 항목 추가

update_plan_status

플랜 상태 변경

create_task

작업 생성 (선택적으로 플랜과 연결)

update_task_status

작업 상태 변경

recall

결정/규칙/오류/변경 로그에 대한 통합 검색

지식 그래프 도구

도구

설명

create_entity

엔티티 추가 (name+type 기준 중복 제거)

create_relation

유형이 지정된 관계로 두 엔티티 연결

add_observation

엔티티에 사실 첨부

search_knowledge

엔티티, 관계, 관찰 내용 검색

션 도구

도구

설명

create_spec

장문 문서 저장

get_spec

ID 또는 정확한 제목으로 조회

update_spec

내용/제목 업데이트, 버전 자동 상향

Code Graph 도구

도구

설명

index_codebase

워크스페이스를 탐색하며 ts-morph(JS/TS)로 심볼+엣지 추출

query_code_graph

심볼의 호출자/호출 대상/임포트 조회(1-hop)

generate_codemap

진입 심볼부터 BFS, 추적/주석 추가 가능한 부분 그래프 생성

annotate_symbol

심볼 또는 추적에 내러티브 텍스트 첨부

아키텍처

cogmemory-mcp/
├── src/
│   ├── index.ts                 # entry point, server bootstrap
│   ├── config.ts                # scope resolution, path resolution
│   ├── types.ts                 # shared TS types mirroring schema
│   ├── db/
│   │   ├── connection.ts        # DB open/close, pragma setup
│   │   ├── schema.sql           # full schema (reference)
│   │   └── migrate.ts           # idempotent schema application
│   ├── tools/
│   │   ├── memory.ts            # decisions/conventions/errors/context/changelog/recall
│   │   ├── plan-tasks.ts        # plan + tasks tools
│   │   ├── sessions.ts          # start/end session, summary
│   │   ├── knowledge-graph.ts   # entities/relations/observations
│   │   ├── specs.ts             # spec CRUD
│   │   ├── code-graph.ts        # index_codebase, query_code_graph
│   │   └── codemap.ts           # generate_codemap, annotate_symbol
│   └── indexing/
│       ├── ts-analyzer.ts       # ts-morph symbol/edge extraction
│       └── walker.ts            # file discovery, gitignore respect
├── schema.sql                   # reference copy
├── package.json
├── tsconfig.json
└── README.md

스키마 (15개 테이블)

  • Memory (8): sessions, decisions, conventions, errors, context, changelog, plan, tasks

  • Knowledge Graph (3): entities, relations, observations

  • Specs (1): specs

  • Code Graph (4): symbols, edges, execution_traces, codemap_annotations


프레그마 (Pragmas)

커넥션이 열릴 때마다 설정:

PRAGMA journal_mode = WAL;
PRAGMA foreign_keys = ON;

개발

pnpm run dev        # Run with tsx (no build step)
pnpm run build      # Compile TypeScript
pnpm run start      # Run compiled output
pnpm run inspect    # Launch MCP Inspector
pnpm run smoke-test # Run smoke test script

라이선스

MIT

Maintenance

ActivityMaintained
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    D
    maintenance
    Provides AI coding assistants with persistent project memory to retain architectural decisions, code patterns, and domain knowledge across sessions. It stores data locally in a SQLite database, allowing agents to remember, recall, and manage project-specific context using full-text search.
    8 npm
    Apache 2.0
  • A
    license
    A
    quality
    B
    maintenance
    Provides persistent cross-session memory and full-text search for AI coding assistants, storing project context, decisions, and preferences while enabling searchable access to conversation history via local SQLite.
    8
    1
    MIT
  • A
    license
    A
    quality
    B
    maintenance
    Acts as a persistent memory and cross-tool shared context store, and builds a queryable codebase knowledge graph to slash token usage via structural answers.
    9
    37 npm
    19
    MIT