claude-memory-layer 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/commands/memory-forget.md +42 -0
- package/.claude-plugin/commands/memory-history.md +34 -0
- package/.claude-plugin/commands/memory-import.md +56 -0
- package/.claude-plugin/commands/memory-list.md +37 -0
- package/.claude-plugin/commands/memory-search.md +36 -0
- package/.claude-plugin/commands/memory-stats.md +34 -0
- package/.claude-plugin/hooks.json +59 -0
- package/.claude-plugin/plugin.json +24 -0
- package/.history/package_20260201112328.json +45 -0
- package/.history/package_20260201113602.json +45 -0
- package/.history/package_20260201113713.json +45 -0
- package/.history/package_20260201114110.json +45 -0
- package/Memo.txt +558 -0
- package/README.md +520 -0
- package/context.md +636 -0
- package/dist/.claude-plugin/commands/memory-forget.md +42 -0
- package/dist/.claude-plugin/commands/memory-history.md +34 -0
- package/dist/.claude-plugin/commands/memory-import.md +56 -0
- package/dist/.claude-plugin/commands/memory-list.md +37 -0
- package/dist/.claude-plugin/commands/memory-search.md +36 -0
- package/dist/.claude-plugin/commands/memory-stats.md +34 -0
- package/dist/.claude-plugin/hooks.json +59 -0
- package/dist/.claude-plugin/plugin.json +24 -0
- package/dist/cli/index.js +3539 -0
- package/dist/cli/index.js.map +7 -0
- package/dist/core/index.js +4408 -0
- package/dist/core/index.js.map +7 -0
- package/dist/hooks/session-end.js +2971 -0
- package/dist/hooks/session-end.js.map +7 -0
- package/dist/hooks/session-start.js +2969 -0
- package/dist/hooks/session-start.js.map +7 -0
- package/dist/hooks/stop.js +3123 -0
- package/dist/hooks/stop.js.map +7 -0
- package/dist/hooks/user-prompt-submit.js +2960 -0
- package/dist/hooks/user-prompt-submit.js.map +7 -0
- package/dist/services/memory-service.js +2931 -0
- package/dist/services/memory-service.js.map +7 -0
- package/package.json +45 -0
- package/plan.md +1642 -0
- package/scripts/build.ts +102 -0
- package/spec.md +624 -0
- package/specs/citations-system/context.md +243 -0
- package/specs/citations-system/plan.md +495 -0
- package/specs/citations-system/spec.md +371 -0
- package/specs/endless-mode/context.md +305 -0
- package/specs/endless-mode/plan.md +620 -0
- package/specs/endless-mode/spec.md +455 -0
- package/specs/entity-edge-model/context.md +401 -0
- package/specs/entity-edge-model/plan.md +459 -0
- package/specs/entity-edge-model/spec.md +391 -0
- package/specs/evidence-aligner-v2/context.md +401 -0
- package/specs/evidence-aligner-v2/plan.md +303 -0
- package/specs/evidence-aligner-v2/spec.md +312 -0
- package/specs/mcp-desktop-integration/context.md +278 -0
- package/specs/mcp-desktop-integration/plan.md +550 -0
- package/specs/mcp-desktop-integration/spec.md +494 -0
- package/specs/post-tool-use-hook/context.md +319 -0
- package/specs/post-tool-use-hook/plan.md +469 -0
- package/specs/post-tool-use-hook/spec.md +364 -0
- package/specs/private-tags/context.md +288 -0
- package/specs/private-tags/plan.md +412 -0
- package/specs/private-tags/spec.md +345 -0
- package/specs/progressive-disclosure/context.md +346 -0
- package/specs/progressive-disclosure/plan.md +663 -0
- package/specs/progressive-disclosure/spec.md +415 -0
- package/specs/task-entity-system/context.md +297 -0
- package/specs/task-entity-system/plan.md +301 -0
- package/specs/task-entity-system/spec.md +314 -0
- package/specs/vector-outbox-v2/context.md +470 -0
- package/specs/vector-outbox-v2/plan.md +562 -0
- package/specs/vector-outbox-v2/spec.md +466 -0
- package/specs/web-viewer-ui/context.md +384 -0
- package/specs/web-viewer-ui/plan.md +797 -0
- package/specs/web-viewer-ui/spec.md +516 -0
- package/src/cli/index.ts +570 -0
- package/src/core/canonical-key.ts +186 -0
- package/src/core/citation-generator.ts +63 -0
- package/src/core/consolidated-store.ts +279 -0
- package/src/core/consolidation-worker.ts +384 -0
- package/src/core/context-formatter.ts +276 -0
- package/src/core/continuity-manager.ts +336 -0
- package/src/core/edge-repo.ts +324 -0
- package/src/core/embedder.ts +124 -0
- package/src/core/entity-repo.ts +342 -0
- package/src/core/event-store.ts +672 -0
- package/src/core/evidence-aligner.ts +635 -0
- package/src/core/graduation.ts +365 -0
- package/src/core/index.ts +32 -0
- package/src/core/matcher.ts +210 -0
- package/src/core/metadata-extractor.ts +203 -0
- package/src/core/privacy/filter.ts +179 -0
- package/src/core/privacy/index.ts +20 -0
- package/src/core/privacy/tag-parser.ts +145 -0
- package/src/core/progressive-retriever.ts +415 -0
- package/src/core/retriever.ts +235 -0
- package/src/core/task/blocker-resolver.ts +325 -0
- package/src/core/task/index.ts +9 -0
- package/src/core/task/task-matcher.ts +238 -0
- package/src/core/task/task-projector.ts +345 -0
- package/src/core/task/task-resolver.ts +414 -0
- package/src/core/types.ts +841 -0
- package/src/core/vector-outbox.ts +295 -0
- package/src/core/vector-store.ts +182 -0
- package/src/core/vector-worker.ts +488 -0
- package/src/core/working-set-store.ts +244 -0
- package/src/hooks/post-tool-use.ts +127 -0
- package/src/hooks/session-end.ts +78 -0
- package/src/hooks/session-start.ts +57 -0
- package/src/hooks/stop.ts +78 -0
- package/src/hooks/user-prompt-submit.ts +54 -0
- package/src/mcp/handlers.ts +212 -0
- package/src/mcp/index.ts +47 -0
- package/src/mcp/tools.ts +78 -0
- package/src/server/api/citations.ts +101 -0
- package/src/server/api/events.ts +101 -0
- package/src/server/api/index.ts +18 -0
- package/src/server/api/search.ts +98 -0
- package/src/server/api/sessions.ts +111 -0
- package/src/server/api/stats.ts +97 -0
- package/src/server/index.ts +91 -0
- package/src/services/memory-service.ts +626 -0
- package/src/services/session-history-importer.ts +367 -0
- package/tests/canonical-key.test.ts +101 -0
- package/tests/evidence-aligner.test.ts +152 -0
- package/tests/matcher.test.ts +112 -0
- package/tsconfig.json +24 -0
- package/vitest.config.ts +15 -0
|
@@ -0,0 +1,494 @@
|
|
|
1
|
+
# MCP Desktop Integration Specification
|
|
2
|
+
|
|
3
|
+
> **Version**: 1.0.0
|
|
4
|
+
> **Status**: Draft
|
|
5
|
+
> **Created**: 2026-02-01
|
|
6
|
+
> **Reference**: claude-mem (thedotmack/claude-mem)
|
|
7
|
+
|
|
8
|
+
## 1. 개요
|
|
9
|
+
|
|
10
|
+
### 1.1 문제 정의
|
|
11
|
+
|
|
12
|
+
현재 code-memory는 Claude Code CLI 전용:
|
|
13
|
+
|
|
14
|
+
1. **Claude Desktop 미지원**: 데스크톱 앱에서 메모리 검색 불가
|
|
15
|
+
2. **환경 분리**: CLI와 Desktop 간 메모리 공유 안 됨
|
|
16
|
+
3. **접근성 제한**: 터미널 없이는 메모리 활용 불가
|
|
17
|
+
|
|
18
|
+
### 1.2 해결 방향
|
|
19
|
+
|
|
20
|
+
**MCP (Model Context Protocol) 서버**:
|
|
21
|
+
- Claude Desktop에서 메모리 검색 도구 제공
|
|
22
|
+
- CLI와 동일한 메모리 저장소 공유
|
|
23
|
+
- 표준 MCP 프로토콜 준수
|
|
24
|
+
|
|
25
|
+
## 2. 핵심 개념
|
|
26
|
+
|
|
27
|
+
### 2.1 MCP 아키텍처
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
31
|
+
│ Claude Desktop │
|
|
32
|
+
│ ┌─────────────────────────────────────────────────────┐ │
|
|
33
|
+
│ │ MCP Client │ │
|
|
34
|
+
│ │ - Tool Discovery │ │
|
|
35
|
+
│ │ - Tool Invocation │ │
|
|
36
|
+
│ └────────────────────────┬────────────────────────────┘ │
|
|
37
|
+
└───────────────────────────┼─────────────────────────────────┘
|
|
38
|
+
│ stdio / HTTP
|
|
39
|
+
▼
|
|
40
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
41
|
+
│ MCP Server │
|
|
42
|
+
│ ┌─────────────────────────────────────────────────────┐ │
|
|
43
|
+
│ │ code-memory-mcp │ │
|
|
44
|
+
│ │ - mem-search tool │ │
|
|
45
|
+
│ │ - mem-timeline tool │ │
|
|
46
|
+
│ │ - mem-details tool │ │
|
|
47
|
+
│ └────────────────────────┬────────────────────────────┘ │
|
|
48
|
+
└───────────────────────────┼─────────────────────────────────┘
|
|
49
|
+
│
|
|
50
|
+
▼
|
|
51
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
52
|
+
│ Memory Storage │
|
|
53
|
+
│ ┌──────────────┐ ┌──────────────┐ │
|
|
54
|
+
│ │ DuckDB │ │ LanceDB │ │
|
|
55
|
+
│ │ Events │ │ Vectors │ │
|
|
56
|
+
│ └──────────────┘ └──────────────┘ │
|
|
57
|
+
└─────────────────────────────────────────────────────────────┘
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### 2.2 제공할 MCP 도구
|
|
61
|
+
|
|
62
|
+
| 도구 | 설명 | 입력 |
|
|
63
|
+
|------|------|------|
|
|
64
|
+
| `mem-search` | 메모리 검색 | query, filters |
|
|
65
|
+
| `mem-timeline` | 타임라인 조회 | ids, windowSize |
|
|
66
|
+
| `mem-details` | 상세 정보 조회 | ids |
|
|
67
|
+
| `mem-stats` | 통계 조회 | - |
|
|
68
|
+
|
|
69
|
+
### 2.3 MCP 프로토콜 버전
|
|
70
|
+
|
|
71
|
+
```typescript
|
|
72
|
+
const MCP_VERSION = '2024-11-05'; // 최신 MCP 사양
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## 3. MCP 서버 구현
|
|
76
|
+
|
|
77
|
+
### 3.1 서버 메타데이터
|
|
78
|
+
|
|
79
|
+
```typescript
|
|
80
|
+
const serverInfo = {
|
|
81
|
+
name: 'code-memory-mcp',
|
|
82
|
+
version: '1.0.0',
|
|
83
|
+
protocolVersion: MCP_VERSION,
|
|
84
|
+
capabilities: {
|
|
85
|
+
tools: {
|
|
86
|
+
listChanged: false
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### 3.2 도구 정의
|
|
93
|
+
|
|
94
|
+
```typescript
|
|
95
|
+
const tools = [
|
|
96
|
+
{
|
|
97
|
+
name: 'mem-search',
|
|
98
|
+
description: 'Search code-memory for relevant past conversations and insights',
|
|
99
|
+
inputSchema: {
|
|
100
|
+
type: 'object',
|
|
101
|
+
properties: {
|
|
102
|
+
query: {
|
|
103
|
+
type: 'string',
|
|
104
|
+
description: 'Search query'
|
|
105
|
+
},
|
|
106
|
+
topK: {
|
|
107
|
+
type: 'number',
|
|
108
|
+
description: 'Maximum results (default: 5)'
|
|
109
|
+
},
|
|
110
|
+
sessionId: {
|
|
111
|
+
type: 'string',
|
|
112
|
+
description: 'Filter by session ID'
|
|
113
|
+
},
|
|
114
|
+
eventType: {
|
|
115
|
+
type: 'string',
|
|
116
|
+
enum: ['prompt', 'response', 'tool', 'insight'],
|
|
117
|
+
description: 'Filter by event type'
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
required: ['query']
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
name: 'mem-timeline',
|
|
125
|
+
description: 'Get timeline context around specific memories',
|
|
126
|
+
inputSchema: {
|
|
127
|
+
type: 'object',
|
|
128
|
+
properties: {
|
|
129
|
+
ids: {
|
|
130
|
+
type: 'array',
|
|
131
|
+
items: { type: 'string' },
|
|
132
|
+
description: 'Memory IDs to get timeline for'
|
|
133
|
+
},
|
|
134
|
+
windowSize: {
|
|
135
|
+
type: 'number',
|
|
136
|
+
description: 'Number of items before/after (default: 3)'
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
required: ['ids']
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
name: 'mem-details',
|
|
144
|
+
description: 'Get full details of specific memories',
|
|
145
|
+
inputSchema: {
|
|
146
|
+
type: 'object',
|
|
147
|
+
properties: {
|
|
148
|
+
ids: {
|
|
149
|
+
type: 'array',
|
|
150
|
+
items: { type: 'string' },
|
|
151
|
+
description: 'Memory IDs to fetch'
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
required: ['ids']
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
name: 'mem-stats',
|
|
159
|
+
description: 'Get memory storage statistics',
|
|
160
|
+
inputSchema: {
|
|
161
|
+
type: 'object',
|
|
162
|
+
properties: {}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
];
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### 3.3 도구 실행
|
|
169
|
+
|
|
170
|
+
```typescript
|
|
171
|
+
async function handleToolCall(
|
|
172
|
+
name: string,
|
|
173
|
+
args: Record<string, unknown>
|
|
174
|
+
): Promise<ToolResult> {
|
|
175
|
+
const memoryService = await MemoryService.getInstance();
|
|
176
|
+
|
|
177
|
+
switch (name) {
|
|
178
|
+
case 'mem-search': {
|
|
179
|
+
const results = await memoryService.progressiveSearch(
|
|
180
|
+
args.query as string,
|
|
181
|
+
{
|
|
182
|
+
topK: args.topK as number,
|
|
183
|
+
filter: {
|
|
184
|
+
sessionId: args.sessionId as string,
|
|
185
|
+
eventType: args.eventType as string
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
);
|
|
189
|
+
|
|
190
|
+
return {
|
|
191
|
+
content: [
|
|
192
|
+
{
|
|
193
|
+
type: 'text',
|
|
194
|
+
text: formatSearchResults(results)
|
|
195
|
+
}
|
|
196
|
+
]
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
case 'mem-timeline': {
|
|
201
|
+
const timeline = await memoryService.getTimeline(
|
|
202
|
+
args.ids as string[],
|
|
203
|
+
{ windowSize: args.windowSize as number }
|
|
204
|
+
);
|
|
205
|
+
|
|
206
|
+
return {
|
|
207
|
+
content: [
|
|
208
|
+
{
|
|
209
|
+
type: 'text',
|
|
210
|
+
text: formatTimeline(timeline)
|
|
211
|
+
}
|
|
212
|
+
]
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
case 'mem-details': {
|
|
217
|
+
const details = await memoryService.getDetails(args.ids as string[]);
|
|
218
|
+
|
|
219
|
+
return {
|
|
220
|
+
content: [
|
|
221
|
+
{
|
|
222
|
+
type: 'text',
|
|
223
|
+
text: formatDetails(details)
|
|
224
|
+
}
|
|
225
|
+
]
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
case 'mem-stats': {
|
|
230
|
+
const stats = await memoryService.getStats();
|
|
231
|
+
|
|
232
|
+
return {
|
|
233
|
+
content: [
|
|
234
|
+
{
|
|
235
|
+
type: 'text',
|
|
236
|
+
text: formatStats(stats)
|
|
237
|
+
}
|
|
238
|
+
]
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
default:
|
|
243
|
+
throw new Error(`Unknown tool: ${name}`);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
## 4. 설치 및 설정
|
|
249
|
+
|
|
250
|
+
### 4.1 Claude Desktop 설정
|
|
251
|
+
|
|
252
|
+
**파일**: `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS)
|
|
253
|
+
|
|
254
|
+
```json
|
|
255
|
+
{
|
|
256
|
+
"mcpServers": {
|
|
257
|
+
"code-memory": {
|
|
258
|
+
"command": "npx",
|
|
259
|
+
"args": ["code-memory-mcp"],
|
|
260
|
+
"env": {
|
|
261
|
+
"MEMORY_PATH": "~/.claude-code/memory"
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
### 4.2 Windows 설정
|
|
269
|
+
|
|
270
|
+
**파일**: `%APPDATA%\Claude\claude_desktop_config.json`
|
|
271
|
+
|
|
272
|
+
```json
|
|
273
|
+
{
|
|
274
|
+
"mcpServers": {
|
|
275
|
+
"code-memory": {
|
|
276
|
+
"command": "npx.cmd",
|
|
277
|
+
"args": ["code-memory-mcp"],
|
|
278
|
+
"env": {
|
|
279
|
+
"MEMORY_PATH": "%USERPROFILE%\\.claude-code\\memory"
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
### 4.3 자동 설치 CLI
|
|
287
|
+
|
|
288
|
+
```bash
|
|
289
|
+
# 설치 명령
|
|
290
|
+
$ code-memory mcp install
|
|
291
|
+
|
|
292
|
+
Installing MCP server for Claude Desktop...
|
|
293
|
+
✓ Created MCP server configuration
|
|
294
|
+
✓ Updated Claude Desktop config
|
|
295
|
+
|
|
296
|
+
Restart Claude Desktop to use memory search.
|
|
297
|
+
|
|
298
|
+
# 제거 명령
|
|
299
|
+
$ code-memory mcp uninstall
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
## 5. 통신 프로토콜
|
|
303
|
+
|
|
304
|
+
### 5.1 stdio 기반 통신
|
|
305
|
+
|
|
306
|
+
```typescript
|
|
307
|
+
// MCP 서버 진입점
|
|
308
|
+
import { Server } from '@modelcontextprotocol/sdk/server';
|
|
309
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio';
|
|
310
|
+
|
|
311
|
+
const server = new Server(serverInfo, {
|
|
312
|
+
capabilities: {
|
|
313
|
+
tools: {}
|
|
314
|
+
}
|
|
315
|
+
});
|
|
316
|
+
|
|
317
|
+
// 도구 핸들러 등록
|
|
318
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
319
|
+
return { tools };
|
|
320
|
+
});
|
|
321
|
+
|
|
322
|
+
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
323
|
+
return handleToolCall(request.params.name, request.params.arguments);
|
|
324
|
+
});
|
|
325
|
+
|
|
326
|
+
// stdio 연결
|
|
327
|
+
const transport = new StdioServerTransport();
|
|
328
|
+
await server.connect(transport);
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
### 5.2 메시지 형식
|
|
332
|
+
|
|
333
|
+
```typescript
|
|
334
|
+
// 요청 예시
|
|
335
|
+
{
|
|
336
|
+
"jsonrpc": "2.0",
|
|
337
|
+
"id": 1,
|
|
338
|
+
"method": "tools/call",
|
|
339
|
+
"params": {
|
|
340
|
+
"name": "mem-search",
|
|
341
|
+
"arguments": {
|
|
342
|
+
"query": "DuckDB schema design"
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
// 응답 예시
|
|
348
|
+
{
|
|
349
|
+
"jsonrpc": "2.0",
|
|
350
|
+
"id": 1,
|
|
351
|
+
"result": {
|
|
352
|
+
"content": [
|
|
353
|
+
{
|
|
354
|
+
"type": "text",
|
|
355
|
+
"text": "Found 3 relevant memories:\n\n1. [mem:a7Bc3x] ..."
|
|
356
|
+
}
|
|
357
|
+
]
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
## 6. 출력 포맷
|
|
363
|
+
|
|
364
|
+
### 6.1 검색 결과
|
|
365
|
+
|
|
366
|
+
```markdown
|
|
367
|
+
## Memory Search Results
|
|
368
|
+
|
|
369
|
+
Found 3 relevant memories for "DuckDB schema":
|
|
370
|
+
|
|
371
|
+
### 1. [mem:a7Bc3x] (0.94)
|
|
372
|
+
**Session**: abc123 | **Date**: 2026-01-30
|
|
373
|
+
> DuckDB를 사용하여 이벤트 소싱 패턴을 구현하는 것이 좋습니다...
|
|
374
|
+
|
|
375
|
+
### 2. [mem:b8Xc2y] (0.87)
|
|
376
|
+
**Session**: def456 | **Date**: 2026-01-29
|
|
377
|
+
> 스키마 설계 시 인덱싱 전략을 고려해야 합니다...
|
|
378
|
+
|
|
379
|
+
---
|
|
380
|
+
Use `mem-details` with IDs for full content.
|
|
381
|
+
Use `mem-timeline` for context around these memories.
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
### 6.2 타임라인
|
|
385
|
+
|
|
386
|
+
```markdown
|
|
387
|
+
## Timeline Context
|
|
388
|
+
|
|
389
|
+
### Around [mem:a7Bc3x]
|
|
390
|
+
|
|
391
|
+
| Time | Type | Preview |
|
|
392
|
+
|------|------|---------|
|
|
393
|
+
| 14:00 | prompt | DB 스키마를 어떻게 설계할까요? |
|
|
394
|
+
| **14:05** | **response** | **[mem:a7Bc3x] DuckDB를 사용하여...** |
|
|
395
|
+
| 14:10 | prompt | 인덱스는 어떻게? |
|
|
396
|
+
| 14:15 | response | 다음 인덱스들을 추천합니다... |
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
### 6.3 상세 정보
|
|
400
|
+
|
|
401
|
+
```markdown
|
|
402
|
+
## Memory Details
|
|
403
|
+
|
|
404
|
+
### [mem:a7Bc3x]
|
|
405
|
+
|
|
406
|
+
**Session**: abc123
|
|
407
|
+
**Date**: 2026-01-30 14:05
|
|
408
|
+
**Type**: assistant_response
|
|
409
|
+
|
|
410
|
+
**Content**:
|
|
411
|
+
```
|
|
412
|
+
DuckDB를 사용하여 이벤트 소싱 패턴을 구현하는 것이 좋습니다.
|
|
413
|
+
|
|
414
|
+
이벤트는 불변이어야 하며, append-only 방식으로 저장합니다.
|
|
415
|
+
|
|
416
|
+
스키마 예시:
|
|
417
|
+
CREATE TABLE events (
|
|
418
|
+
event_id VARCHAR PRIMARY KEY,
|
|
419
|
+
event_type VARCHAR NOT NULL,
|
|
420
|
+
...
|
|
421
|
+
);
|
|
422
|
+
```
|
|
423
|
+
|
|
424
|
+
**Related Files**: src/core/event-store.ts
|
|
425
|
+
**Tools Used**: Read, Write
|
|
426
|
+
```
|
|
427
|
+
|
|
428
|
+
## 7. 보안
|
|
429
|
+
|
|
430
|
+
### 7.1 로컬 전용
|
|
431
|
+
|
|
432
|
+
```typescript
|
|
433
|
+
// MCP 서버는 로컬에서만 실행
|
|
434
|
+
// 네트워크 노출 없음
|
|
435
|
+
const server = new Server(serverInfo);
|
|
436
|
+
const transport = new StdioServerTransport(); // stdio만 사용
|
|
437
|
+
```
|
|
438
|
+
|
|
439
|
+
### 7.2 경로 검증
|
|
440
|
+
|
|
441
|
+
```typescript
|
|
442
|
+
function validateMemoryPath(path: string): boolean {
|
|
443
|
+
const resolved = path.resolve(path);
|
|
444
|
+
|
|
445
|
+
// 홈 디렉토리 하위만 허용
|
|
446
|
+
const home = os.homedir();
|
|
447
|
+
if (!resolved.startsWith(home)) {
|
|
448
|
+
throw new Error('Memory path must be under home directory');
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
return true;
|
|
452
|
+
}
|
|
453
|
+
```
|
|
454
|
+
|
|
455
|
+
### 7.3 민감 정보 필터링
|
|
456
|
+
|
|
457
|
+
```typescript
|
|
458
|
+
// MCP 응답에서도 privacy 필터 적용
|
|
459
|
+
function formatForMCP(content: string): string {
|
|
460
|
+
return applyPrivacyFilter(content, config.privacy).content;
|
|
461
|
+
}
|
|
462
|
+
```
|
|
463
|
+
|
|
464
|
+
## 8. 에러 처리
|
|
465
|
+
|
|
466
|
+
```typescript
|
|
467
|
+
// MCP 에러 응답
|
|
468
|
+
function handleError(error: Error): ToolResult {
|
|
469
|
+
return {
|
|
470
|
+
content: [
|
|
471
|
+
{
|
|
472
|
+
type: 'text',
|
|
473
|
+
text: `Error: ${error.message}`
|
|
474
|
+
}
|
|
475
|
+
],
|
|
476
|
+
isError: true
|
|
477
|
+
};
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
// 일반적인 에러 케이스
|
|
481
|
+
- Memory storage not found
|
|
482
|
+
- Invalid query parameters
|
|
483
|
+
- Permission denied
|
|
484
|
+
- Storage corrupted
|
|
485
|
+
```
|
|
486
|
+
|
|
487
|
+
## 9. 성공 기준
|
|
488
|
+
|
|
489
|
+
- [ ] `code-memory mcp install` 명령 동작
|
|
490
|
+
- [ ] Claude Desktop에서 `mem-search` 도구 사용 가능
|
|
491
|
+
- [ ] Progressive disclosure (search → timeline → details) 동작
|
|
492
|
+
- [ ] CLI와 동일한 메모리 저장소 공유
|
|
493
|
+
- [ ] Privacy 필터 적용
|
|
494
|
+
- [ ] 에러 시 적절한 메시지 반환
|