sun_get_summary
Retrieve saved conversation summaries to review key insights, outcomes, and next steps from chat sessions.
Instructions
Get content of a specific summary file
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filename | Yes | Name of the summary file to retrieve |
Implementation Reference
- src/server.ts:80-94 (registration)Registration of the sun_get_summary tool in the ListToolsRequestSchema handler, defining name, description, and input schema.{ name: 'sun_get_summary', description: 'Get content of a specific summary file', inputSchema: { type: 'object', properties: { filename: { type: 'string', description: 'Name of the summary file to retrieve', }, }, required: ['filename'], }, }, ] as Tool[],
- src/server.ts:219-249 (handler)Primary handler function for executing the sun_get_summary tool. It validates the filename argument, calls FileManager.getSummary to retrieve the file content, and formats the MCP response with the summary markdown or an error.private async handleGetSummary(args: any) { const { filename } = args; if (!filename) { throw new Error('Filename is required'); } const content = await this.fileManager.getSummary(filename); if (!content) { return { content: [ { type: 'text', text: `❌ 未找到文件: ${filename}`, }, ], }; } return { content: [ { type: 'text', text: `📄 **${filename}** ${content}`, }, ], }; }
- src/server.ts:83-92 (schema)Input schema definition for the sun_get_summary tool, specifying an object with a required 'filename' string property.inputSchema: { type: 'object', properties: { filename: { type: 'string', description: 'Name of the summary file to retrieve', }, }, required: ['filename'], },
- src/fileManager.ts:228-251 (handler)Core file retrieval logic invoked by the tool handler. Reads the specified .mdc summary file, parses its metadata, and returns a SavedSummaryFile object or null if not found.async getSummary(filename: string): Promise<SavedSummaryFile | null> { const filePath = path.join(this.sunDir, filename); try { const exists = await fs.pathExists(filePath); if (!exists) { return null; } const content = await fs.readFile(filePath, 'utf-8'); const stats = await fs.stat(filePath); const summary = this.parseSummaryFromMarkdown(content, filename); return { filename, path: filePath, summary, createdAt: stats.birthtime.toISOString() }; } catch (error) { console.error(`Failed to get summary ${filename}:`, error); return null; } }
- src/fileManager.ts:181-223 (helper)Helper function that parses the markdown content of a summary file to extract structured SessionSummary data, supporting both English and Chinese.private parseSummaryFromMarkdown(content: string, filename: string): SessionSummary { // Detect language from content const isEnglish = content.includes('Session Overview') || content.includes('Timestamp'); // Extract title (first # heading) const titleMatch = content.match(/^# (.+)$/m); const title = titleMatch ? titleMatch[1] : filename.replace('.mdc', ''); // Extract basic info (support both languages) const timestampMatch = content.match(/\*\*(Timestamp|时间戳)\*\*: (.+)$/m); const statusMatch = content.match(/\*\*(Completion Status|完成状态)\*\*: (.+)$/m); const messageCountMatch = content.match(/\*\*(Message Count|消息数量)\*\*: (\d+)$/m); // Extract essence (support both languages) const essenceMatch = content.match(/## (Core Essence|核心精髓)\n([\s\S]*?)\n\n## /) || content.match(/## (Core Essence|核心精髓)\n([\s\S]*?)$/); const essence = essenceMatch ? essenceMatch[2].trim() : ''; // Extract key points (support both languages) const keyPointsMatch = content.match(/## (Key Points|关键要点)\n([\s\S]*?)\n\n## /) || content.match(/## (Key Points|关键要点)\n([\s\S]*?)$/); const keyPoints = keyPointsMatch ? keyPointsMatch[2].split('\n').filter(line => line.startsWith('- ')).map(line => line.substring(2)) : []; // Extract outcomes (support both languages) const outcomesMatch = content.match(/## (Outcomes|完成成果)\n([\s\S]*?)(\n\n## |\n\n---)/); const outcomes = outcomesMatch ? outcomesMatch[2].split('\n').filter(line => line.startsWith('- ')).map(line => line.substring(2)) : []; return { title, essence, completionStatus: (statusMatch ? statusMatch[2] : 'unknown') as any, keyPoints, outcomes, timestamp: timestampMatch ? timestampMatch[2] : new Date().toISOString(), messageCount: messageCountMatch ? parseInt(messageCountMatch[2]) : 0, functionality: filename.split('_').slice(2).join('_').replace('.mdc', ''), language: isEnglish ? 'en' : 'zh' }; }