Skip to main content
Glama

sun_summarize

Summarizes chat sessions and saves them as .mdc files with key insights, outcomes, and next steps when using the -sun command.

Instructions

Summarize current session and save as .mdc file when -sun command is used. Use -sun for Chinese or -sun en for English

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sessionContentYesThe session content to summarize (conversation messages)
functionalityNoOptional: Main functionality or topic of the session
contextNoOptional: Additional context about the session
languageNoLanguage for the summary: zh for Chinese (default), en for English

Implementation Reference

  • src/server.ts:45-71 (registration)
    Registration of the 'sun_summarize' tool in the ListTools response, including name, description, and input schema.
    {
      name: 'sun_summarize',
      description: 'Summarize current session and save as .mdc file when -sun command is used. Use -sun for Chinese or -sun en for English',
      inputSchema: {
        type: 'object',
        properties: {
          sessionContent: {
            type: 'string',
            description: 'The session content to summarize (conversation messages)',
          },
          functionality: {
            type: 'string',
            description: 'Optional: Main functionality or topic of the session',
          },
          context: {
            type: 'string',
            description: 'Optional: Additional context about the session',
          },
          language: {
            type: 'string',
            enum: ['zh', 'en'],
            description: 'Language for the summary: zh for Chinese (default), en for English',
          },
        },
        required: ['sessionContent'],
      },
    },
  • Input schema for the sun_summarize tool defining parameters like sessionContent (required), functionality, context, and language.
    inputSchema: {
      type: 'object',
      properties: {
        sessionContent: {
          type: 'string',
          description: 'The session content to summarize (conversation messages)',
        },
        functionality: {
          type: 'string',
          description: 'Optional: Main functionality or topic of the session',
        },
        context: {
          type: 'string',
          description: 'Optional: Additional context about the session',
        },
        language: {
          type: 'string',
          enum: ['zh', 'en'],
          description: 'Language for the summary: zh for Chinese (default), en for English',
        },
      },
      required: ['sessionContent'],
    },
  • Main execution handler for sun_summarize tool. Parses input, delegates to summarizer and fileManager, formats and returns the response.
      private async handleSummarize(args: any) {
        const { sessionContent, functionality, context, language = 'zh' } = args;
    
        if (!sessionContent) {
          throw new Error('Session content is required');
        }
    
        // Parse session content into messages
        const sessionData = this.parseSessionContent(sessionContent, context);
    
        // Generate summary
        const summary = await this.summarizer.summarizeSession(sessionData, functionality, language);
    
        // Save to file
        const savedFile = await this.fileManager.saveSummary(summary);
    
        const isEnglish = summary.language === 'en';
    
        return {
          content: [
            {
              type: 'text',
              text: `✅ ${isEnglish ? 'Session summary saved!' : '会话总结已保存!'}
    
    📁 **${isEnglish ? 'File' : '文件'}**: ${savedFile.filename}
    📍 **${isEnglish ? 'Path' : '路径'}**: ${savedFile.path}
    🎯 **${isEnglish ? 'Functionality' : '功能'}**: ${summary.functionality}
    📊 **${isEnglish ? 'Status' : '状态'}**: ${summary.completionStatus}
    💬 **${isEnglish ? 'Messages' : '消息数'}**: ${summary.messageCount}
    
    ## ${isEnglish ? 'Core Essence' : '核心精髓'}
    ${summary.essence}
    
    ## ${isEnglish ? 'Key Points' : '关键要点'}
    ${summary.keyPoints.map(point => `• ${point}`).join('\n')}
    
    ## ${isEnglish ? 'Outcomes' : '完成成果'}
    ${summary.outcomes.map(outcome => `• ${outcome}`).join('\n')}
    
    ${summary.nextSteps && summary.nextSteps.length > 0 ? `## ${isEnglish ? 'Next Steps' : '后续步骤'}
    ${summary.nextSteps.map(step => `• ${step}`).join('\n')}` : ''}
    
    ---
    ${isEnglish ? 'Use `sun_list_summaries` to view all saved summaries' : '使用 `sun_list_summaries` 查看所有保存的总结'}
    ${isEnglish ? 'Use `sun_get_summary` to get specific summary content' : '使用 `sun_get_summary` 获取特定总结内容'}`,
            },
          ],
        };
      }
  • Core helper function in SessionSummarizer class that performs the actual session analysis and generates the structured summary used by the tool handler.
    async summarizeSession(sessionData: SessionData, functionality?: string, language: 'zh' | 'en' = 'zh'): Promise<SessionSummary> {
      const messages = sessionData.messages || [];
      const messageCount = messages.length;
    
      // Extract key information from messages
      const userMessages = messages.filter(m => m.role === 'user');
      const assistantMessages = messages.filter(m => m.role === 'assistant');
    
      // Analyze the conversation to extract essence and key points
      const analysis = this.analyzeConversation(messages, language);
    
      // Determine functionality if not provided
      const detectedFunctionality = functionality || this.detectFunctionality(messages, language);
    
      // Generate title
      const title = this.generateTitle(detectedFunctionality, language);
    
      // Determine completion status
      const completionStatus = this.determineCompletionStatus(messages);
    
      const summary: SessionSummary = {
        title,
        essence: analysis.essence,
        completionStatus,
        keyPoints: analysis.keyPoints,
        outcomes: analysis.outcomes,
        nextSteps: analysis.nextSteps,
        timestamp: new Date().toISOString(),
        messageCount,
        functionality: detectedFunctionality,
        language
      };
    
      return summary;
    }
  • Helper function that parses raw session content string into structured SessionData with messages array.
    private parseSessionContent(content: string, context?: string): SessionData {
      const messages: SessionMessage[] = [];
    
      // Try to parse different formats
      if (content.includes('Human:') || content.includes('Assistant:')) {
        // Parse conversation format
        const parts = content.split(/(?=Human:|Assistant:)/);
    
        for (const part of parts) {
          const trimmed = part.trim();
          if (!trimmed) continue;
    
          if (trimmed.startsWith('Human:')) {
            messages.push({
              role: 'user',
              content: trimmed.replace('Human:', '').trim(),
              timestamp: new Date().toISOString(),
            });
          } else if (trimmed.startsWith('Assistant:')) {
            messages.push({
              role: 'assistant',
              content: trimmed.replace('Assistant:', '').trim(),
              timestamp: new Date().toISOString(),
            });
          }
        }
      } else {
        // Treat as single message
        messages.push({
          role: 'user',
          content: content,
          timestamp: new Date().toISOString(),
        });
      }
    
      return {
        messages,
        startTime: new Date().toISOString(),
        context,
      };
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions saving as a .mdc file, which implies a write operation, but doesn't specify where it's saved, whether it overwrites existing files, what permissions are needed, or what happens on failure. For a tool that creates files, this leaves critical behavioral aspects undocumented.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is brief (two sentences) but contains confusing elements: the '-sun command' reference seems misplaced for an AI tool interface, and the second sentence repeats language information already in the schema. While not verbose, it includes content that doesn't effectively serve its purpose.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool that creates files with 4 parameters and no annotations or output schema, the description is inadequate. It doesn't explain the summary format, file naming conventions, error conditions, or how this tool relates to its siblings. The absence of output schema means the description should address return values, which it doesn't.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already fully documents all 4 parameters. The description adds no additional parameter information beyond what's in the schema, not explaining relationships between parameters or providing usage examples. This meets the baseline for high schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states the tool 'summarizes current session and saves as .mdc file', which provides a clear verb+resource combination. However, it doesn't differentiate from sibling tools like 'sun_get_summary' or 'sun_list_summaries', leaving ambiguity about when to use this versus retrieving existing summaries.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description mentions using '-sun command' for Chinese or '-sun en' for English, but this appears to be command-line syntax rather than guidance for AI agent usage. It provides no explicit when-to-use instructions, no exclusions, and no comparison to sibling tools, offering minimal practical guidance.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ChenYCL/sun-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server