Skip to main content
Glama

extract_compact_summary

Generate concise summaries of conversation sessions to identify key insights, solutions, tools, and file changes from Claude Historian data.

Instructions

Get intelligent summary of a conversation session with key insights

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
session_idYesSession ID to summarize
max_messagesNoMaximum messages to analyze (default: 10)
focusNoFocus area: solutions, tools, files, or allall

Implementation Reference

  • src/index.ts:181-205 (registration)
    Registration and input schema definition for the 'extract_compact_summary' tool in the MCP ListTools response.
    {
      name: 'extract_compact_summary',
      description: 'Get intelligent summary of a conversation session with key insights',
      inputSchema: {
        type: 'object',
        properties: {
          session_id: {
            type: 'string',
            description: 'Session ID to summarize',
          },
          max_messages: {
            type: 'number',
            description: 'Maximum messages to analyze (default: 10)',
            default: 10,
          },
          focus: {
            type: 'string',
            description: 'Focus area: solutions, tools, files, or all',
            enum: ['solutions', 'tools', 'files', 'all'],
            default: 'all',
          },
        },
        required: ['session_id'],
      },
    },
  • MCP CallToolRequestSchema handler case for 'extract_compact_summary': delegates to UniversalHistorySearchEngine.generateCompactSummary and formats output using BeautifulFormatter.formatCompactSummary.
    case 'extract_compact_summary': {
      const sessionId = args?.session_id as string;
      const maxMessages = (args?.max_messages as number) || 10;
      const focus = (args?.focus as string) || 'all';
    
      const universalResult = await this.universalEngine.generateCompactSummary(
        sessionId,
        maxMessages,
        focus
      );
      const formattedResult = this.formatter.formatCompactSummary(
        [universalResult.results as any],
        sessionId
      );
    
      return {
        content: [{ type: 'text', text: formattedResult }],
      };
    }
  • Core implementation of compact summary generation: resolves session ID, fetches messages via HistorySearchEngine.getSessionMessages, extracts tools/files/accomplishments/decisions, returns structured summary data.
    async generateCompactSummary(
      sessionId: string,
      maxMessages?: number,
      focus?: string
    ): Promise<UniversalSearchResult> {
      await this.initialize();
    
      // Get session data from Claude Code
      const allSessions = await this.claudeCodeEngine.getRecentSessions(20);
    
      // Support "latest" keyword - resolve to most recent session
      let resolvedSessionId = sessionId;
      if (sessionId.toLowerCase() === 'latest') {
        if (allSessions.length > 0) {
          resolvedSessionId = allSessions[0].session_id;
        } else {
          return {
            source: 'claude-code',
            results: {
              session_id: 'latest',
              end_time: null,
              start_time: null,
              duration_minutes: 0,
              message_count: 0,
              project_path: null,
              tools_used: [],
              files_modified: [],
              accomplishments: [],
              key_decisions: [],
            } as any,
            enhanced: false,
          };
        }
      }
    
      const sessionData = allSessions.find(
        (s) =>
          s.session_id === resolvedSessionId ||
          s.session_id.startsWith(resolvedSessionId) ||
          resolvedSessionId.includes(s.session_id) ||
          s.session_id.includes(resolvedSessionId.replace(/^.*\//, ''))
      );
    
      if (!sessionData) {
        return {
          source: 'claude-code',
          results: {
            session_id: resolvedSessionId,
            end_time: null,
            start_time: null,
            duration_minutes: 0,
            message_count: 0,
            project_path: null,
            tools_used: [],
            files_modified: [],
            accomplishments: [],
            key_decisions: [],
          } as any,
          enhanced: false,
        };
      }
    
      const messages = await this.claudeCodeEngine.getSessionMessages(
        sessionData.project_dir,
        sessionData.session_id
      );
      const sessionMessages = messages.slice(0, maxMessages || 100); // Increased from 50 to 100 for better extraction
    
      // Return rich session object with extracted content
      const richSummary = {
        session_id: sessionData.session_id,
        end_time: sessionData.end_time,
        start_time: sessionData.start_time,
        duration_minutes: sessionData.duration_minutes || 0,
        message_count: sessionMessages.length,
        project_path: sessionData.project_path,
        tools_used: this.extractToolsFromMessages(sessionMessages),
        files_modified: this.extractFilesFromMessages(sessionMessages),
        accomplishments: this.extractAccomplishmentsFromMessages(sessionMessages),
        key_decisions: this.extractDecisionsFromMessages(sessionMessages),
      };
    
      return {
        source: 'claude-code',
        results: richSummary as any,
        enhanced: this.claudeDesktopAvailable === true,
      };
    }
  • Helper function to format the compact summary data into a readable string with robot emoji header and structured JSON containing session metrics, tools, files, accomplishments, and decisions.
    formatCompactSummary(sessions: any[], sessionId?: string): string {
      if (sessions.length === 0) {
        const filter = sessionId ? `"${sessionId}"` : 'latest';
        return `${robots.summary} ${filter}\n\n{"session":null}`;
      }
    
      const s = sessions[0];
      // Create a useful header with project name and session info
      const projectName = s.project_path?.split('/').pop() || 'unknown';
      const shortId = s.session_id?.substring(0, 8) || sessionId?.substring(0, 8) || 'latest';
      const header = `${robots.summary} extracting summary from ${projectName} (${shortId})`;
      const structured = {
        session: {
          id: s.session_id?.substring(0, 8) || null,
          ts: this.formatTimestamp(s.end_time || s.start_time),
          duration: s.duration_minutes || 0,
          messages: s.message_count || 0,
          project: s.project_path?.split('/').pop() || null,
          tools: s.tools_used || null,
          files: s.files_modified || null,
          accomplishments: s.accomplishments || null,
          decisions: s.key_decisions || null,
        },
      };
    
      return `${header}\n\n${JSON.stringify(structured, null, 2)}`;
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions 'intelligent summary' and 'key insights', which hints at analysis behavior, but it doesn't describe critical traits like whether this is a read-only operation, potential rate limits, authentication needs, or what the output format looks like. For a tool with no annotations, this is a significant gap in transparency.

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

Conciseness5/5

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

The description is a single, efficient sentence that front-loads the core purpose ('Get intelligent summary of a conversation session') and adds a clarifying detail ('with key insights'). There is no wasted verbiage, and it is appropriately sized for the tool's complexity.

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?

Given the tool's moderate complexity (3 parameters, no annotations, no output schema), the description is incomplete. It lacks behavioral context, usage guidelines, and details on output format, which are crucial for an agent to use the tool effectively. The high schema coverage helps, but the description doesn't compensate for other gaps.

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?

The schema description coverage is 100%, meaning all parameters are documented in the schema. The description adds no additional semantic information about the parameters beyond what the schema provides, such as explaining the 'focus' options in more detail or giving examples. Thus, it meets the baseline score without compensating further.

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

Purpose4/5

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

The description clearly states the tool's purpose with a specific verb ('Get') and resource ('summary of a conversation session'), and it adds value by specifying 'intelligent summary' and 'key insights'. However, it doesn't explicitly differentiate this from sibling tools like 'search_conversations' or 'list_recent_sessions', which might also involve conversation analysis, so it doesn't reach the highest score.

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 provides no guidance on when to use this tool versus alternatives. It doesn't mention sibling tools like 'search_conversations' or 'list_recent_sessions', nor does it specify contexts or exclusions for usage. This leaves the agent without clear direction on tool selection.

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/Vvkmnn/claude-historian'

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