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.
Files changed (127) hide show
  1. package/.claude-plugin/commands/memory-forget.md +42 -0
  2. package/.claude-plugin/commands/memory-history.md +34 -0
  3. package/.claude-plugin/commands/memory-import.md +56 -0
  4. package/.claude-plugin/commands/memory-list.md +37 -0
  5. package/.claude-plugin/commands/memory-search.md +36 -0
  6. package/.claude-plugin/commands/memory-stats.md +34 -0
  7. package/.claude-plugin/hooks.json +59 -0
  8. package/.claude-plugin/plugin.json +24 -0
  9. package/.history/package_20260201112328.json +45 -0
  10. package/.history/package_20260201113602.json +45 -0
  11. package/.history/package_20260201113713.json +45 -0
  12. package/.history/package_20260201114110.json +45 -0
  13. package/Memo.txt +558 -0
  14. package/README.md +520 -0
  15. package/context.md +636 -0
  16. package/dist/.claude-plugin/commands/memory-forget.md +42 -0
  17. package/dist/.claude-plugin/commands/memory-history.md +34 -0
  18. package/dist/.claude-plugin/commands/memory-import.md +56 -0
  19. package/dist/.claude-plugin/commands/memory-list.md +37 -0
  20. package/dist/.claude-plugin/commands/memory-search.md +36 -0
  21. package/dist/.claude-plugin/commands/memory-stats.md +34 -0
  22. package/dist/.claude-plugin/hooks.json +59 -0
  23. package/dist/.claude-plugin/plugin.json +24 -0
  24. package/dist/cli/index.js +3539 -0
  25. package/dist/cli/index.js.map +7 -0
  26. package/dist/core/index.js +4408 -0
  27. package/dist/core/index.js.map +7 -0
  28. package/dist/hooks/session-end.js +2971 -0
  29. package/dist/hooks/session-end.js.map +7 -0
  30. package/dist/hooks/session-start.js +2969 -0
  31. package/dist/hooks/session-start.js.map +7 -0
  32. package/dist/hooks/stop.js +3123 -0
  33. package/dist/hooks/stop.js.map +7 -0
  34. package/dist/hooks/user-prompt-submit.js +2960 -0
  35. package/dist/hooks/user-prompt-submit.js.map +7 -0
  36. package/dist/services/memory-service.js +2931 -0
  37. package/dist/services/memory-service.js.map +7 -0
  38. package/package.json +45 -0
  39. package/plan.md +1642 -0
  40. package/scripts/build.ts +102 -0
  41. package/spec.md +624 -0
  42. package/specs/citations-system/context.md +243 -0
  43. package/specs/citations-system/plan.md +495 -0
  44. package/specs/citations-system/spec.md +371 -0
  45. package/specs/endless-mode/context.md +305 -0
  46. package/specs/endless-mode/plan.md +620 -0
  47. package/specs/endless-mode/spec.md +455 -0
  48. package/specs/entity-edge-model/context.md +401 -0
  49. package/specs/entity-edge-model/plan.md +459 -0
  50. package/specs/entity-edge-model/spec.md +391 -0
  51. package/specs/evidence-aligner-v2/context.md +401 -0
  52. package/specs/evidence-aligner-v2/plan.md +303 -0
  53. package/specs/evidence-aligner-v2/spec.md +312 -0
  54. package/specs/mcp-desktop-integration/context.md +278 -0
  55. package/specs/mcp-desktop-integration/plan.md +550 -0
  56. package/specs/mcp-desktop-integration/spec.md +494 -0
  57. package/specs/post-tool-use-hook/context.md +319 -0
  58. package/specs/post-tool-use-hook/plan.md +469 -0
  59. package/specs/post-tool-use-hook/spec.md +364 -0
  60. package/specs/private-tags/context.md +288 -0
  61. package/specs/private-tags/plan.md +412 -0
  62. package/specs/private-tags/spec.md +345 -0
  63. package/specs/progressive-disclosure/context.md +346 -0
  64. package/specs/progressive-disclosure/plan.md +663 -0
  65. package/specs/progressive-disclosure/spec.md +415 -0
  66. package/specs/task-entity-system/context.md +297 -0
  67. package/specs/task-entity-system/plan.md +301 -0
  68. package/specs/task-entity-system/spec.md +314 -0
  69. package/specs/vector-outbox-v2/context.md +470 -0
  70. package/specs/vector-outbox-v2/plan.md +562 -0
  71. package/specs/vector-outbox-v2/spec.md +466 -0
  72. package/specs/web-viewer-ui/context.md +384 -0
  73. package/specs/web-viewer-ui/plan.md +797 -0
  74. package/specs/web-viewer-ui/spec.md +516 -0
  75. package/src/cli/index.ts +570 -0
  76. package/src/core/canonical-key.ts +186 -0
  77. package/src/core/citation-generator.ts +63 -0
  78. package/src/core/consolidated-store.ts +279 -0
  79. package/src/core/consolidation-worker.ts +384 -0
  80. package/src/core/context-formatter.ts +276 -0
  81. package/src/core/continuity-manager.ts +336 -0
  82. package/src/core/edge-repo.ts +324 -0
  83. package/src/core/embedder.ts +124 -0
  84. package/src/core/entity-repo.ts +342 -0
  85. package/src/core/event-store.ts +672 -0
  86. package/src/core/evidence-aligner.ts +635 -0
  87. package/src/core/graduation.ts +365 -0
  88. package/src/core/index.ts +32 -0
  89. package/src/core/matcher.ts +210 -0
  90. package/src/core/metadata-extractor.ts +203 -0
  91. package/src/core/privacy/filter.ts +179 -0
  92. package/src/core/privacy/index.ts +20 -0
  93. package/src/core/privacy/tag-parser.ts +145 -0
  94. package/src/core/progressive-retriever.ts +415 -0
  95. package/src/core/retriever.ts +235 -0
  96. package/src/core/task/blocker-resolver.ts +325 -0
  97. package/src/core/task/index.ts +9 -0
  98. package/src/core/task/task-matcher.ts +238 -0
  99. package/src/core/task/task-projector.ts +345 -0
  100. package/src/core/task/task-resolver.ts +414 -0
  101. package/src/core/types.ts +841 -0
  102. package/src/core/vector-outbox.ts +295 -0
  103. package/src/core/vector-store.ts +182 -0
  104. package/src/core/vector-worker.ts +488 -0
  105. package/src/core/working-set-store.ts +244 -0
  106. package/src/hooks/post-tool-use.ts +127 -0
  107. package/src/hooks/session-end.ts +78 -0
  108. package/src/hooks/session-start.ts +57 -0
  109. package/src/hooks/stop.ts +78 -0
  110. package/src/hooks/user-prompt-submit.ts +54 -0
  111. package/src/mcp/handlers.ts +212 -0
  112. package/src/mcp/index.ts +47 -0
  113. package/src/mcp/tools.ts +78 -0
  114. package/src/server/api/citations.ts +101 -0
  115. package/src/server/api/events.ts +101 -0
  116. package/src/server/api/index.ts +18 -0
  117. package/src/server/api/search.ts +98 -0
  118. package/src/server/api/sessions.ts +111 -0
  119. package/src/server/api/stats.ts +97 -0
  120. package/src/server/index.ts +91 -0
  121. package/src/services/memory-service.ts +626 -0
  122. package/src/services/session-history-importer.ts +367 -0
  123. package/tests/canonical-key.test.ts +101 -0
  124. package/tests/evidence-aligner.test.ts +152 -0
  125. package/tests/matcher.test.ts +112 -0
  126. package/tsconfig.json +24 -0
  127. package/vitest.config.ts +15 -0
@@ -0,0 +1,550 @@
1
+ # MCP Desktop Integration Implementation Plan
2
+
3
+ > **Version**: 1.0.0
4
+ > **Status**: Draft
5
+ > **Created**: 2026-02-01
6
+
7
+ ## Phase 1: MCP 서버 기본 구조 (P0)
8
+
9
+ ### 1.1 프로젝트 설정
10
+
11
+ **파일**: `packages/mcp-server/package.json` (신규)
12
+
13
+ ```json
14
+ {
15
+ "name": "code-memory-mcp",
16
+ "version": "1.0.0",
17
+ "description": "MCP server for code-memory",
18
+ "main": "dist/index.js",
19
+ "bin": {
20
+ "code-memory-mcp": "./dist/index.js"
21
+ },
22
+ "scripts": {
23
+ "build": "esbuild src/index.ts --bundle --platform=node --outfile=dist/index.js",
24
+ "dev": "tsx src/index.ts"
25
+ },
26
+ "dependencies": {
27
+ "@modelcontextprotocol/sdk": "^1.0.0",
28
+ "code-memory-core": "workspace:*"
29
+ }
30
+ }
31
+ ```
32
+
33
+ **작업 항목**:
34
+ - [ ] MCP 서버 패키지 생성
35
+ - [ ] dependencies 설정
36
+ - [ ] 빌드 스크립트 설정
37
+
38
+ ### 1.2 서버 진입점
39
+
40
+ **파일**: `packages/mcp-server/src/index.ts` (신규)
41
+
42
+ ```typescript
43
+ #!/usr/bin/env node
44
+ import { Server } from '@modelcontextprotocol/sdk/server';
45
+ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio';
46
+ import {
47
+ ListToolsRequestSchema,
48
+ CallToolRequestSchema
49
+ } from '@modelcontextprotocol/sdk/types';
50
+
51
+ import { tools } from './tools';
52
+ import { handleToolCall } from './handlers';
53
+
54
+ const server = new Server(
55
+ {
56
+ name: 'code-memory-mcp',
57
+ version: '1.0.0'
58
+ },
59
+ {
60
+ capabilities: {
61
+ tools: {}
62
+ }
63
+ }
64
+ );
65
+
66
+ // 도구 목록 핸들러
67
+ server.setRequestHandler(ListToolsRequestSchema, async () => {
68
+ return { tools };
69
+ });
70
+
71
+ // 도구 호출 핸들러
72
+ server.setRequestHandler(CallToolRequestSchema, async (request) => {
73
+ const { name, arguments: args } = request.params;
74
+ return handleToolCall(name, args || {});
75
+ });
76
+
77
+ // stdio 연결 및 시작
78
+ async function main() {
79
+ const transport = new StdioServerTransport();
80
+ await server.connect(transport);
81
+ console.error('code-memory MCP server started');
82
+ }
83
+
84
+ main().catch(console.error);
85
+ ```
86
+
87
+ **작업 항목**:
88
+ - [ ] 서버 초기화
89
+ - [ ] 핸들러 등록
90
+ - [ ] stdio 연결
91
+
92
+ ### 1.3 도구 정의
93
+
94
+ **파일**: `packages/mcp-server/src/tools.ts` (신규)
95
+
96
+ ```typescript
97
+ import { Tool } from '@modelcontextprotocol/sdk/types';
98
+
99
+ export const tools: Tool[] = [
100
+ {
101
+ name: 'mem-search',
102
+ description: 'Search code-memory for relevant past conversations and insights. Returns a compact index of results - use mem-details to get full content.',
103
+ inputSchema: {
104
+ type: 'object',
105
+ properties: {
106
+ query: {
107
+ type: 'string',
108
+ description: 'Natural language search query'
109
+ },
110
+ topK: {
111
+ type: 'number',
112
+ description: 'Maximum number of results (default: 5, max: 20)'
113
+ },
114
+ sessionId: {
115
+ type: 'string',
116
+ description: 'Optional: filter by specific session ID'
117
+ },
118
+ eventType: {
119
+ type: 'string',
120
+ enum: ['prompt', 'response', 'tool', 'insight'],
121
+ description: 'Optional: filter by event type'
122
+ }
123
+ },
124
+ required: ['query']
125
+ }
126
+ },
127
+ {
128
+ name: 'mem-timeline',
129
+ description: 'Get chronological context around specific memories. Useful for understanding the conversation flow.',
130
+ inputSchema: {
131
+ type: 'object',
132
+ properties: {
133
+ ids: {
134
+ type: 'array',
135
+ items: { type: 'string' },
136
+ description: 'Memory IDs (from mem-search) to get timeline for'
137
+ },
138
+ windowSize: {
139
+ type: 'number',
140
+ description: 'Number of items before/after each ID (default: 3)'
141
+ }
142
+ },
143
+ required: ['ids']
144
+ }
145
+ },
146
+ {
147
+ name: 'mem-details',
148
+ description: 'Get full content of specific memories. Use after mem-search to get complete information.',
149
+ inputSchema: {
150
+ type: 'object',
151
+ properties: {
152
+ ids: {
153
+ type: 'array',
154
+ items: { type: 'string' },
155
+ description: 'Memory IDs to fetch full details for'
156
+ }
157
+ },
158
+ required: ['ids']
159
+ }
160
+ },
161
+ {
162
+ name: 'mem-stats',
163
+ description: 'Get statistics about the memory storage (total events, sessions, etc.)',
164
+ inputSchema: {
165
+ type: 'object',
166
+ properties: {}
167
+ }
168
+ }
169
+ ];
170
+ ```
171
+
172
+ **작업 항목**:
173
+ - [ ] mem-search 도구 정의
174
+ - [ ] mem-timeline 도구 정의
175
+ - [ ] mem-details 도구 정의
176
+ - [ ] mem-stats 도구 정의
177
+
178
+ ## Phase 2: 핸들러 구현 (P0)
179
+
180
+ ### 2.1 도구 핸들러
181
+
182
+ **파일**: `packages/mcp-server/src/handlers.ts` (신규)
183
+
184
+ ```typescript
185
+ import { ToolResult } from '@modelcontextprotocol/sdk/types';
186
+ import { MemoryService } from 'code-memory-core';
187
+ import { formatSearchResults, formatTimeline, formatDetails, formatStats } from './formatters';
188
+
189
+ let memoryService: MemoryService | null = null;
190
+
191
+ async function getMemoryService(): Promise<MemoryService> {
192
+ if (!memoryService) {
193
+ memoryService = await MemoryService.getInstance({
194
+ storagePath: process.env.MEMORY_PATH || '~/.claude-code/memory'
195
+ });
196
+ }
197
+ return memoryService;
198
+ }
199
+
200
+ export async function handleToolCall(
201
+ name: string,
202
+ args: Record<string, unknown>
203
+ ): Promise<ToolResult> {
204
+ try {
205
+ const service = await getMemoryService();
206
+
207
+ switch (name) {
208
+ case 'mem-search':
209
+ return await handleMemSearch(service, args);
210
+
211
+ case 'mem-timeline':
212
+ return await handleMemTimeline(service, args);
213
+
214
+ case 'mem-details':
215
+ return await handleMemDetails(service, args);
216
+
217
+ case 'mem-stats':
218
+ return await handleMemStats(service);
219
+
220
+ default:
221
+ return {
222
+ content: [{ type: 'text', text: `Unknown tool: ${name}` }],
223
+ isError: true
224
+ };
225
+ }
226
+ } catch (error) {
227
+ return {
228
+ content: [{ type: 'text', text: `Error: ${(error as Error).message}` }],
229
+ isError: true
230
+ };
231
+ }
232
+ }
233
+
234
+ async function handleMemSearch(
235
+ service: MemoryService,
236
+ args: Record<string, unknown>
237
+ ): Promise<ToolResult> {
238
+ const query = args.query as string;
239
+ const topK = Math.min((args.topK as number) || 5, 20);
240
+
241
+ const results = await service.progressiveSearch(query, {
242
+ topK,
243
+ filter: {
244
+ sessionId: args.sessionId as string,
245
+ eventType: args.eventType as string
246
+ }
247
+ });
248
+
249
+ return {
250
+ content: [{
251
+ type: 'text',
252
+ text: formatSearchResults(results)
253
+ }]
254
+ };
255
+ }
256
+
257
+ // 다른 핸들러들도 유사하게 구현
258
+ ```
259
+
260
+ **작업 항목**:
261
+ - [ ] handleMemSearch 구현
262
+ - [ ] handleMemTimeline 구현
263
+ - [ ] handleMemDetails 구현
264
+ - [ ] handleMemStats 구현
265
+ - [ ] 에러 처리
266
+
267
+ ### 2.2 포맷터
268
+
269
+ **파일**: `packages/mcp-server/src/formatters.ts` (신규)
270
+
271
+ ```typescript
272
+ import { ProgressiveSearchResult, TimelineItem, FullDetail, Stats } from 'code-memory-core';
273
+
274
+ export function formatSearchResults(results: ProgressiveSearchResult): string {
275
+ const lines: string[] = [
276
+ '## Memory Search Results',
277
+ '',
278
+ `Found ${results.index.length} relevant memories:`,
279
+ ''
280
+ ];
281
+
282
+ for (let i = 0; i < results.index.length; i++) {
283
+ const item = results.index[i];
284
+ const score = item.score.toFixed(2);
285
+ const date = new Date(item.timestamp).toLocaleDateString();
286
+
287
+ lines.push(`### ${i + 1}. [mem:${item.id}] (${score})`);
288
+ lines.push(`**Session**: ${item.sessionId.slice(0, 8)} | **Date**: ${date}`);
289
+ lines.push(`> ${item.summary}`);
290
+ lines.push('');
291
+ }
292
+
293
+ lines.push('---');
294
+ lines.push('*Use `mem-details` with IDs for full content.*');
295
+ lines.push('*Use `mem-timeline` for context around these memories.*');
296
+
297
+ return lines.join('\n');
298
+ }
299
+
300
+ export function formatTimeline(items: TimelineItem[]): string {
301
+ const lines: string[] = [
302
+ '## Timeline Context',
303
+ '',
304
+ '| Time | Type | Preview |',
305
+ '|------|------|---------|'
306
+ ];
307
+
308
+ for (const item of items) {
309
+ const time = new Date(item.timestamp).toLocaleTimeString();
310
+ const marker = item.isTarget ? '**' : '';
311
+ const preview = item.preview.slice(0, 50) + (item.preview.length > 50 ? '...' : '');
312
+
313
+ lines.push(`| ${marker}${time}${marker} | ${item.type} | ${marker}${preview}${marker} |`);
314
+ }
315
+
316
+ return lines.join('\n');
317
+ }
318
+
319
+ export function formatDetails(details: FullDetail[]): string {
320
+ return details.map(detail => {
321
+ const date = new Date(detail.timestamp).toLocaleString();
322
+
323
+ return [
324
+ `## Memory Details: [mem:${detail.id}]`,
325
+ '',
326
+ `**Session**: ${detail.sessionId}`,
327
+ `**Date**: ${date}`,
328
+ `**Type**: ${detail.type}`,
329
+ '',
330
+ '**Content**:',
331
+ '```',
332
+ detail.content,
333
+ '```',
334
+ ''
335
+ ].join('\n');
336
+ }).join('\n---\n\n');
337
+ }
338
+
339
+ export function formatStats(stats: Stats): string {
340
+ return [
341
+ '## Memory Statistics',
342
+ '',
343
+ `- **Total Events**: ${stats.eventCount}`,
344
+ `- **Total Vectors**: ${stats.vectorCount}`,
345
+ `- **Sessions**: ${stats.sessionCount}`,
346
+ `- **Storage Size**: ${(stats.storageSize / 1024 / 1024).toFixed(2)} MB`,
347
+ ''
348
+ ].join('\n');
349
+ }
350
+ ```
351
+
352
+ **작업 항목**:
353
+ - [ ] formatSearchResults 구현
354
+ - [ ] formatTimeline 구현
355
+ - [ ] formatDetails 구현
356
+ - [ ] formatStats 구현
357
+
358
+ ## Phase 3: 설치 CLI (P0)
359
+
360
+ ### 3.1 MCP 설치 명령
361
+
362
+ **파일**: `src/cli/commands/mcp.ts` (신규)
363
+
364
+ ```typescript
365
+ import { Command } from 'commander';
366
+ import * as fs from 'fs';
367
+ import * as path from 'path';
368
+ import * as os from 'os';
369
+
370
+ export const mcpCommand = new Command('mcp')
371
+ .description('Manage MCP server for Claude Desktop');
372
+
373
+ mcpCommand
374
+ .command('install')
375
+ .description('Install MCP server for Claude Desktop')
376
+ .action(async () => {
377
+ const configPath = getClaudeDesktopConfigPath();
378
+ const config = loadOrCreateConfig(configPath);
379
+
380
+ // MCP 서버 설정 추가
381
+ config.mcpServers = config.mcpServers || {};
382
+ config.mcpServers['code-memory'] = {
383
+ command: 'npx',
384
+ args: ['code-memory-mcp'],
385
+ env: {
386
+ MEMORY_PATH: path.join(os.homedir(), '.claude-code', 'memory')
387
+ }
388
+ };
389
+
390
+ // 설정 저장
391
+ fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
392
+
393
+ console.log('✓ MCP server configuration added');
394
+ console.log('');
395
+ console.log('Restart Claude Desktop to use memory search.');
396
+ console.log('');
397
+ console.log('Available tools:');
398
+ console.log(' - mem-search: Search past conversations');
399
+ console.log(' - mem-timeline: Get context around memories');
400
+ console.log(' - mem-details: Get full memory content');
401
+ console.log(' - mem-stats: View storage statistics');
402
+ });
403
+
404
+ mcpCommand
405
+ .command('uninstall')
406
+ .description('Remove MCP server from Claude Desktop')
407
+ .action(async () => {
408
+ const configPath = getClaudeDesktopConfigPath();
409
+ const config = loadOrCreateConfig(configPath);
410
+
411
+ if (config.mcpServers?.['code-memory']) {
412
+ delete config.mcpServers['code-memory'];
413
+ fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
414
+ console.log('✓ MCP server configuration removed');
415
+ } else {
416
+ console.log('MCP server was not installed');
417
+ }
418
+ });
419
+
420
+ mcpCommand
421
+ .command('status')
422
+ .description('Check MCP server installation status')
423
+ .action(async () => {
424
+ const configPath = getClaudeDesktopConfigPath();
425
+
426
+ if (!fs.existsSync(configPath)) {
427
+ console.log('Claude Desktop config not found');
428
+ return;
429
+ }
430
+
431
+ const config = JSON.parse(fs.readFileSync(configPath, 'utf-8'));
432
+
433
+ if (config.mcpServers?.['code-memory']) {
434
+ console.log('✓ MCP server is installed');
435
+ console.log('');
436
+ console.log('Configuration:');
437
+ console.log(JSON.stringify(config.mcpServers['code-memory'], null, 2));
438
+ } else {
439
+ console.log('✗ MCP server is not installed');
440
+ console.log('');
441
+ console.log('Run "code-memory mcp install" to install');
442
+ }
443
+ });
444
+
445
+ function getClaudeDesktopConfigPath(): string {
446
+ if (process.platform === 'darwin') {
447
+ return path.join(os.homedir(), 'Library', 'Application Support', 'Claude', 'claude_desktop_config.json');
448
+ } else if (process.platform === 'win32') {
449
+ return path.join(process.env.APPDATA || '', 'Claude', 'claude_desktop_config.json');
450
+ } else {
451
+ return path.join(os.homedir(), '.config', 'claude', 'claude_desktop_config.json');
452
+ }
453
+ }
454
+
455
+ function loadOrCreateConfig(configPath: string): any {
456
+ const dir = path.dirname(configPath);
457
+ if (!fs.existsSync(dir)) {
458
+ fs.mkdirSync(dir, { recursive: true });
459
+ }
460
+
461
+ if (fs.existsSync(configPath)) {
462
+ return JSON.parse(fs.readFileSync(configPath, 'utf-8'));
463
+ }
464
+
465
+ return {};
466
+ }
467
+ ```
468
+
469
+ **작업 항목**:
470
+ - [ ] install 명령 구현
471
+ - [ ] uninstall 명령 구현
472
+ - [ ] status 명령 구현
473
+ - [ ] 플랫폼별 경로 처리
474
+
475
+ ## Phase 4: 테스트 및 문서 (P1)
476
+
477
+ ### 4.1 통합 테스트
478
+
479
+ **파일**: `packages/mcp-server/tests/integration.test.ts` (신규)
480
+
481
+ ```typescript
482
+ import { handleToolCall } from '../src/handlers';
483
+
484
+ describe('MCP Server', () => {
485
+ test('mem-search returns results', async () => {
486
+ const result = await handleToolCall('mem-search', {
487
+ query: 'test query'
488
+ });
489
+
490
+ expect(result.isError).toBeFalsy();
491
+ expect(result.content[0].type).toBe('text');
492
+ });
493
+
494
+ test('mem-details returns full content', async () => {
495
+ const result = await handleToolCall('mem-details', {
496
+ ids: ['test-id']
497
+ });
498
+
499
+ expect(result.isError).toBeFalsy();
500
+ });
501
+
502
+ test('invalid tool returns error', async () => {
503
+ const result = await handleToolCall('invalid-tool', {});
504
+
505
+ expect(result.isError).toBe(true);
506
+ });
507
+ });
508
+ ```
509
+
510
+ **작업 항목**:
511
+ - [ ] 도구별 테스트
512
+ - [ ] 에러 케이스 테스트
513
+ - [ ] E2E 테스트 (실제 Claude Desktop)
514
+
515
+ ## 파일 목록
516
+
517
+ ### 신규 파일
518
+ ```
519
+ packages/mcp-server/
520
+ ├── package.json
521
+ ├── tsconfig.json
522
+ ├── src/
523
+ │ ├── index.ts # 서버 진입점
524
+ │ ├── tools.ts # 도구 정의
525
+ │ ├── handlers.ts # 도구 핸들러
526
+ │ └── formatters.ts # 출력 포맷터
527
+ └── tests/
528
+ └── integration.test.ts
529
+
530
+ src/cli/commands/mcp.ts # CLI 명령
531
+ ```
532
+
533
+ ### 수정 파일
534
+ ```
535
+ package.json # 워크스페이스 설정
536
+ src/cli/index.ts # mcp 명령 등록
537
+ ```
538
+
539
+ ## 마일스톤
540
+
541
+ | 단계 | 완료 기준 |
542
+ |------|----------|
543
+ | M1 | MCP 서버 패키지 구조 |
544
+ | M2 | 도구 정의 |
545
+ | M3 | 핸들러 구현 |
546
+ | M4 | 포맷터 구현 |
547
+ | M5 | CLI 설치 명령 |
548
+ | M6 | 테스트 |
549
+ | M7 | 문서화 |
550
+ | M8 | npm 배포 |