opencode-mem MCP server
2026년 11월 3일 커밋하이브리드 검색과 계층적 요약을 지원하는 PostgreSQL 기반의 AI 코딩 에이전트용 영구 메모리 인프라를 제공합니다.
다른 이름 Stranmor/opencode-mem
- 스타
- 3
- Tools
- 17
- 다운로드, 30일
- —
- 최신 버전
- —
- 마지막 커밋
- 2026년 11월 3일
- 라이선스
- MIT
opencode-mem MCP란?
opencode-mem은(는) MCP server입니다. 하이브리드 검색과 계층적 요약을 지원하는 PostgreSQL 기반의 AI 코딩 에이전트용 영구 메모리 인프라를 제공합니다. 17개 도구를 제공합니다. 예: search, timeline, get_observations.
프로젝트 README에서 생성된 요약
opencode-mem MCP server 정보
이 Rust 기반 MCP server의 주요 기능은 AI 코딩 에이전트를 위한 영구 메모리를 제공하는 것입니다. 개발자는 기본 데이터 저장소인 PostgreSQL 백엔드를 사용하여 에이전트의 관찰 기록을 저장하고 검색할 수 있습니다. IDE와 통합하거나 HTTP 및 CLI 엔드포인트를 통해 연결함으로써, 에이전트가 구조화된 메타데이터 추출과 계층적 요약을 통해 장기적인 컨텍스트를 유지할 수 있도록 돕습니다.
사용자는 PostgreSQL 연결 문자열과 LLM 기반 압축을 위한 OpenAI 호환 API 키를 설정하여 시스템을 구성할 수 있습니다. 이 서버는 PostgreSQL 전체 텍스트 검색과 pgvector 확장을 통한 벡터 검색을 결합하여 하이브리드 검색을 지원합니다. 이를 통해 특정 파일, 함수 또는 이전 결정 사항을 찾기 위한 시맨틱, 키워드 및 하이브리드 검색 경로를 활용할 수 있습니다. 아키텍처에는 대기 중인 관찰 기록을 처리하고 정보 밀도를 관리하기 위한 컨텍스트 인식 압축 기능이 포함된 메모리 파이프라인이 포함되어 있습니다.
활용 사례
- 1과거 코딩 결정 사항 조회AI 에이전트가 과거 관찰 기록을 검색하여 특정 라이브러리나 패턴이 선택된 이유를 파악할 수 있습니다.
- 2시맨틱 메모리 검색 수행개발자는 정확한 키워드를 사용하지 않더라도 시맨틱 이해를 통해 관련 있는 과거 이벤트를 찾을 수 있습니다.
- 3세션 요약 상세 분석에이전트가 상위 수준의 요약을 확장하여 세션 중에 발생한 구체적이고 세부적인 이벤트를 확인할 수 있습니다.
- 4글로벌 지식 베이스 관리사용자는 재사용 가능한 패턴, SKILL 또는 일반적인 실수 사례를 영구적인 지식 저장소에 저장하고 정리할 수 있습니다.
프로젝트의 README를 바탕으로 작성되었습니다. 모든 활용 사례는 해당 내용의 인용문과 대조하여 확인합니다.
opencode-mem MCP 도구 17
README에서 감지됨searchtimelineget_observationsmemory_getmemory_recentmemory_hybrid_searchmemory_semantic_searchsave_memoryknowledge_searchknowledge_saveknowledge_getknowledge_list
| search | — | |
| timeline | — | |
| get_observations | — | |
| memory_get | — | |
| memory_recent | — | |
| memory_hybrid_search | — | |
| memory_semantic_search | — | |
| save_memory | — | |
| knowledge_search | — | |
| knowledge_save | — | |
| knowledge_get | — | |
| knowledge_list | — |
도구 17개 모두 보기도구 수 줄이기
knowledge_deleteinfinite_expandinfinite_time_rangeinfinite_drill_hourinfinite_drill_minute
| knowledge_delete | — | |
| infinite_expand | — | |
| infinite_time_range | — | |
| infinite_drill_hour | — | |
| infinite_drill_minute | — |
구성
DATABASE_URLOPENCODE_MEM_API_KEYOPENCODE_MEM_API_URL
| 이름 | 설명 | 유형 |
|---|---|---|
| DATABASE_URL | — | |
| OPENCODE_MEM_API_KEY | — | |
| OPENCODE_MEM_API_URL | — |
자동 검사
2026년 11월 14일에 실행됨전체 보고서 →아직 인증되지 않았습니다. 서버는 80점 이상의 점수, 심각한 결함 없음, 그리고 검사에 충분한 데이터를 갖추어야 합니다. 검사 방식
- 소스 저장소 연결 및 접근 가능stranmor/opencode-mem is public and reachablegithub.com/stranmor/opencode-mem ↗통과
- 패키지가 이 저장소를 소스로 지정검사되지 않음
- 빌드 출처(Sigstore 증명)검사되지 않음
- 오픈 소스 라이선스 (OSI)MITspdx.org/licenses/MIT.html ↗통과
- 최근 1년 내 커밋 또는 릴리스Last commit or release 2026-11-03github.com/stranmor/opencode-mem ↗통과
- OpenSSF Scorecard검사되지 않음
- 패키지 이름이 인기 패키지와 유사하지 않음검사되지 않음
- 패키지와 의존성에 심각한 보안 권고 없음검사되지 않음
- 모델에 대한 숨겨진 지침 없음17 tool descriptions and the README read; no override phrases, credential paths or hidden characters통과
- 파괴적인 도구에 라벨 표시됨No tool named like delete, drop or exec통과
- 원격 endpoint가 MCP 핸드셰이크에 응답검사되지 않음
README
GitHub에서 보기opencode-mem
Persistent memory infrastructure for AI coding agents.
A Rust MCP server combining PostgreSQL full-text search, optional vector retrieval, and hierarchical summaries.
opencode-mem is a Rust MCP (Model Context Protocol) server for storing and retrieving agent observations. PostgreSQL is the canonical store; pgvector-backed embeddings and hierarchical summaries provide additional retrieval paths when configured.
Inspired by claude-mem, with a PostgreSQL-first architecture for OpenCode and MCP clients.
Core design
| Area | Current implementation |
|---|---|
| Runtime | Rust workspace with MCP stdio, HTTP, and CLI entrypoints |
| Storage | PostgreSQL, with pgvector used for vector retrieval |
| Retrieval | Full-text, keyword, semantic, and hybrid search paths |
| Memory pipeline | Queued observations, structured summaries, and drill-down |
| Privacy boundary | <private> filtering before persistence and model calls |
| Recovery | Visibility timeouts, dead-letter handling, and degraded-mode responses |
Implemented paths
- Hierarchical summaries can be expanded back to their stored source events.
- Hybrid retrieval combines PostgreSQL full-text results with vector similarity when embeddings are enabled.
- Structured metadata extraction records files, functions, libraries, errors, and decisions from model output.
- Context-aware compression can create a new observation, update a supplied candidate, or skip a low-value result.
- MCP, HTTP, and CLI entrypoints share the same PostgreSQL-backed service layer.
- Database connection failures are surfaced through circuit-breaker and degraded-mode paths.
Architecture
graph LR
A[AI Agent / IDE] -->|MCP stdio| B[opencode-mem]
A -->|HTTP :37777| B
B --> C[Queue Processor]
C --> D[LLM Compression]
D --> E[(PostgreSQL)]
E -->|pgvector| F[Semantic Search]
E -->|tsvector / GIN| G[Full-Text Search]
F & G --> H[Hybrid Results]
Crate Structure
crates/
├── core/ # Domain types (Observation, Session, Knowledge, etc.)
├── storage/ # PostgreSQL + pgvector + migrations + circuit breaker
├── embeddings/ # Vector embeddings (fastembed BGE-M3, 1024d, multilingual)
├── search/ # Hybrid search (FTS + keyword + semantic)
├── llm/ # LLM compression (OpenAI-compatible API)
├── service/ # Business logic (ObservationService, SessionService, QueueService)
├── http/ # HTTP API (Axum)
├── mcp/ # MCP server (stdio)
├── infinite-memory/ # Hierarchical infinite memory backend
└── cli/ # CLI binary
Installation
From source
git clone https://github.com/Stranmor/opencode-mem.git
cd opencode-mem
cargo build --release
# Binary: target/release/opencode-mem-cli
Quick Start
Prerequisites: latest stable Rust · PostgreSQL with pgvector extension
1. Configure
export DATABASE_URL="postgresql://localhost/opencode_mem"
read -rsp "Provider API key: " OPENCODE_MEM_API_KEY && printf '\n'
export OPENCODE_MEM_API_KEY
export OPENCODE_MEM_API_URL="https://api.openai.com" # or any compatible endpoint
Use a credential manager or protected environment file for persistent secrets;
do not commit database passwords or provider keys to opencode.json.
Migrations run automatically on first start.
2. Run
# MCP server (for IDE integration):
opencode-mem-cli mcp
# HTTP server (for dashboards and external integrations):
opencode-mem-cli serve
3. Integrate with OpenCode
Add to your opencode.json. OpenCode substitutes the already exported
environment variables at runtime, so the config remains safe to commit:
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"memory": {
"type": "local",
"command": ["/path/to/opencode-mem-cli", "mcp"],
"environment": {
"DATABASE_URL": "{env:DATABASE_URL}",
"OPENCODE_MEM_API_KEY": "{env:OPENCODE_MEM_API_KEY}",
"OPENCODE_MEM_API_URL": "{env:OPENCODE_MEM_API_URL}"
}
}
}
}
MCP Tools
The server exposes MCP tools for search, retrieval, knowledge, and summary drill-down. The recommended workflow is Search → Timeline → Get Observations so clients fetch full records only when needed.
| Tool | Description |
|---|---|
search |
Search memory with semantic understanding. Returns index with IDs. |
timeline |
Get chronological context within a time range. |
get_observations |
Fetch full details for specific observation IDs. |
memory_get |
Get a single observation by ID. |
memory_recent |
Get the most recent observations. |
memory_hybrid_search |
Combined FTS + keyword search. |
memory_semantic_search |
Pure semantic search with hybrid fallback. |
save_memory |
Save memory directly (bypasses LLM compression). |
knowledge_search |
Search the global knowledge base. |
knowledge_save |
Save a new knowledge entry (skill, pattern, gotcha). |
knowledge_get |
Get a knowledge entry by ID. |
knowledge_list |
List knowledge entries by type. |
knowledge_delete |
Delete a knowledge entry. |
infinite_expand |
Expand a summary to see child events. |
infinite_time_range |
Get events within a time range. |
infinite_drill_hour |
Drill from day summary to hour summaries. |
infinite_drill_minute |
Drill from hour summary to 5-minute summaries. |
__IMPORTANT |
Workflow documentation (3-Layer Pattern). |
HTTP API
HTTP endpoints are organized across the following handler modules:
observations— CRUD and bulk operations for observationssessions/sessions_api— Session lifecycle, summaries, retrievalsession_ops— Advanced operations (merge, split, archive)infinite— Deep-zoom endpoints (expand_summary,time_range,drill_hour,drill_minute)search— Semantic, FTS, and hybrid searchknowledge— Global knowledge base managementqueue— Pending queue and DLQ inspectioncontext— Context compilation for agent injectionadmin— Health checks, configuration, diagnostics
CLI
# Server
opencode-mem-cli serve # HTTP API server (port 37777)
opencode-mem-cli mcp # MCP stdio server
# Maintenance
opencode-mem-cli backfill-embeddings # Generate missing vector embeddings
opencode-mem-cli import-insights # Import legacy JSON insights
# Data Access
opencode-mem-cli search <query> # Search observations
opencode-mem-cli get <id> # Get observation by UUID
opencode-mem-cli recent # Recent observations
opencode-mem-cli projects # List tracked projects
opencode-mem-cli stats # Database statistics and queue health
# IDE Hooks
opencode-mem-cli hook context # Retrieve context for prompt injection
opencode-mem-cli hook session-init # Initialize a new session
opencode-mem-cli hook observe # Record an observation
opencode-mem-cli hook summarize # Trigger session summarization
Configuration
All configuration is via environment variables:
| Variable | Required | Default | Description |
|---|---|---|---|
DATABASE_URL |
Yes | — | PostgreSQL connection string |
OPENCODE_MEM_API_KEY |
Yes | — | API key for the LLM provider |
OPENCODE_MEM_API_URL |
No | https://api.openai.com |
OpenAI-compatible API base URL |
OPENCODE_MEM_MODEL |
No | — | Model for compression (e.g., gpt-4o) |
OPENCODE_MEM_DISABLE_EMBEDDINGS |
No | false |
Disable vector embeddings (1 or true) |
INFINITE_MEMORY_URL |
No | DATABASE_URL |
Separate DB for infinite memory |
OPENCODE_MEM_EXCLUDED_PROJECTS |
No | — | Glob patterns for excluded projects |
OPENCODE_MEM_FILTER_PATTERNS |
No | — | Custom noise filter patterns (regex) |
OPENCODE_MEM_DEDUP_THRESHOLD |
No | 0.85 |
Cosine similarity for dedup [0.0, 1.0] |
OPENCODE_MEM_INJECTION_DEDUP_THRESHOLD |
No | 0.80 |
IDE injection loop detection [0.0, 1.0] |
OPENCODE_MEM_EMBEDDING_THREADS |
No | cores - 1 |
ONNX embedding threads |
OPENCODE_MEM_MAX_RETRY |
No | 3 |
LLM compression retries |
OPENCODE_MEM_VISIBILITY_TIMEOUT |
No | 300s |
Queue visibility timeout |
OPENCODE_MEM_QUEUE_WORKERS |
No | 10 |
Concurrent queue workers |
OPENCODE_MEM_DLQ_TTL_DAYS |
No | 7 |
Dead letter queue retention |
OPENCODE_MEM_MAX_CONTENT_CHARS |
No | 500 |
Max chars per observation field |
OPENCODE_MEM_MAX_TOTAL_CHARS |
No | 8000 |
Max chars for LLM prompt |
OPENCODE_MEM_MAX_EVENTS |
No | 200 |
Max raw events per memory chunk |
Development
Prerequisites
- latest stable Rust
- PostgreSQL with
pgvectorextension - An OpenAI-compatible LLM API (for compression features)
Running Tests
export DATABASE_URL="postgresql://localhost/opencode_mem_test"
# Unit tests (no DB required)
cargo test --workspace
# Integration tests (requires running PostgreSQL)
cargo test --workspace -- --ignored
Code Quality
cargo fmt --all
cargo clippy --workspace -- -D warnings
Development constraints
- PostgreSQL remains the canonical persistence path.
- Missing or invalid data returns an explicit error or absence, not a fabricated value.
- Schema changes use forward migrations and preserve existing data.
- Privacy filtering must remain ahead of persistence, queues, embeddings, summaries, logs, and external model calls.
Project Status
Active pre-release project. Core MCP, HTTP, PostgreSQL, queue, and search paths are implemented, but release readiness depends on the current CI result and validation against a real OpenCode consumer. IDE-specific hooks remain outside the current scope. Infinite memory and semantic search should be treated as experimental until their deployment requirements and failure modes are documented and exercised end to end.
Contributing
Contributions welcome! See CONTRIBUTING.md for development setup and guidelines.
License
opencode-mem MCP 질문
opencode-mem MCP는 어떤 도구를 제공하나요?
17개 도구를 제공합니다. 예: search, timeline, get_observations, memory_get, memory_recent.
opencode-mem의 주요 저장소는 무엇인가요?
PostgreSQL이 서버의 기본 저장소 역할을 합니다.
어떤 검색 방식들을 사용할 수 있나요?
전체 텍스트, 키워드, 시맨틱 및 하이브리드 검색 경로를 지원합니다.
IDE 통합을 위해 MCP server로 실행하려면 어떻게 해야 하나요?
opencode-mem-cli mcp 명령어를 사용하여 MCP stdio server를 실행할 수 있습니다.
벡터 임베딩을 지원하나요?
네, pgvector를 사용하여 벡터 검색을 수행하며 fastembed BGE-M3를 통한 임베딩을 지원합니다.