Skip to main content
Glama

get_session_summary

Get session metadata—title, message count, dates, tags, favorites, and token stats—without downloading full messages.

Instructions

Get a quick summary of a session — title, message count, dates, tags, favorites, and token stats. Defaults to the current project. Cheaper than get_session when you only need metadata, not full messages.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sessionIdYesThe session UUID
projectIdNoProject ID (defaults to current project)

Implementation Reference

  • The handler function for the get_session_summary tool. It resolves the project, finds the session by UUID, retrieves metadata and parses the session, then returns a JSON summary with title, message counts, dates, tags, favorites, and token stats.
    // ─── get_session_summary ─────────────────────────────────────────
    server.tool(
      'get_session_summary',
      'Get a quick summary of a session — title, message count, dates, tags, favorites, and token stats. Defaults to the current project. Cheaper than get_session when you only need metadata, not full messages.',
      {
        sessionId: z.string().describe('The session UUID'),
        projectId: z.string().optional().describe('Project ID (defaults to current project)'),
      },
      async ({ sessionId, projectId }) => {
        try {
          const { fileScanner, sessionParser, metadataService, currentProjectId } = await getServices()
          const { project, projectId: resolvedId } = await resolveProject(fileScanner, projectId, currentProjectId)
    
          const sessions = await fileScanner.scanSessions(project.path)
          const session = sessions.find(s => s.sessionId === sessionId)
    
          if (!session) {
            return {
              content: [{ type: 'text', text: `Session not found: ${sessionId} in project "${project.name}"` }],
              isError: true,
            }
          }
    
          const meta = await metadataService.getMetadata(resolvedId, sessionId)
          const parsed = await sessionParser.parseSession(session.filePath)
    
          const userMessages = parsed.messages.filter(m => m.role === 'user').length
          const assistantMessages = parsed.messages.filter(m => m.role === 'assistant').length
    
          const summary = {
            sessionId,
            projectId: resolvedId,
            projectName: project.name,
            title: meta?.customTitle || session.title || sessionId,
            messageCount: parsed.messages.length,
            userMessages,
            assistantMessages,
            template: parsed.template,
            createdAt: session.createdAt,
            lastUpdated: session.lastUpdatedAt,
            isFavorited: meta?.isFavorited || false,
            isHidden: meta?.isHidden || false,
            tags: meta?.tags || [],
            notes: meta?.notes || null,
            tokens: parsed.stats?.tokens || null,
          }
    
          return {
            content: [{ type: 'text', text: JSON.stringify(summary, null, 2) }],
          }
        } catch (error) {
          return {
            content: [{ type: 'text', text: `Error getting summary: ${error.message}` }],
            isError: true,
          }
        }
      }
    )
  • Input schema for get_session_summary: sessionId (required string) and projectId (optional string, defaults to current project).
    {
      sessionId: z.string().describe('The session UUID'),
      projectId: z.string().optional().describe('Project ID (defaults to current project)'),
    },
  • Registration call: registerTools(server, getServices) which registers the get_session_summary tool on the MCP server.
    registerTools(server, getServices)
    registerResources(server, getServices)
    registerPrompts(server)
  • The resolveProject helper function used by get_session_summary to find the project by ID (with partial match fallback).
    async function resolveProject(fileScanner, projectId, currentProjectId) {
      const targetId = projectId || currentProjectId
      const projects = await fileScanner.scanProjects()
      const project = projects.find(p => p.id === targetId)
    
      if (!project) {
        // Try partial match (user might pass just the short name)
        const partial = projects.find(p =>
          p.name === targetId || p.id.endsWith(`-${targetId}`)
        )
        if (partial) return { project: partial, projectId: partial.id }
    
        const available = projects.slice(0, 10).map(p => `  ${p.id} (${p.name})`).join('\n')
        throw new Error(
          `Project not found: "${targetId}"\n\nAvailable projects:\n${available}${projects.length > 10 ? `\n  ... and ${projects.length - 10} more` : ''}`
        )
      }
    
      return { project, projectId: targetId }
  • The getServices helper that lazy-initializes and provides all services (fileScanner, sessionParser, metadataService, currentProjectId) used by the handler.
    async function getServices() {
      if (services) return services
    
      const projectRoot = getProjectRoot()
    
      // Resolve DB path: same location as the web server uses
      const serverDir = path.resolve(__dirname, '../..')
      const dbPath = path.join(serverDir, 'data', 'search.db')
    
      const searchDb = new SearchDatabase(dbPath)
      await searchDb.init()
    
      // Allow concurrent reads with web server (WAL mode + busy timeout)
      await searchDb.db.run('PRAGMA busy_timeout = 5000')
    
      const metadataService = new SessionMetadataService(searchDb)
      await metadataService.init()
    
      const memoryService = new MemoryService(searchDb)
      await memoryService.init()
    
      const fileScanner = new FileScanner(projectRoot)
      const sessionParser = new SessionParser()
    
      services = { searchDb, metadataService, memoryService, fileScanner, sessionParser, currentProjectId }
      console.error(`[claudex-mcp] Services initialized (project: ${currentProjectId}, projects: ${projectRoot})`)
      return services
    }
Behavior4/5

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

No annotations provided, so description carries full burden. It discloses that it returns metadata (title, message count, dates, tags, favorites, token stats) and is cheaper, but does not mention authentication requirements or error handling. Still, for a read-only summary, it is fairly transparent.

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?

Two sentences with no redundancy. Front-loaded with purpose and key differentiator. Every sentence adds value.

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

Completeness5/5

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

Given tool complexity is low, no output schema, and annotations absent, description adequately covers what the tool does, what it returns, and when to use it. No missing critical information.

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 coverage is 100% with basic descriptions. The description adds value by stating projectId defaults to current project, which matches schema but does not elaborate on format or constraints beyond schema.

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

Purpose5/5

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

Description clearly states it gets a quick summary of a session with specific fields (title, message count, etc.) and distinguishes it from get_session by noting it's cheaper and for metadata only.

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

Usage Guidelines5/5

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

Explicitly indicates when to use: 'cheaper than get_session when you only need metadata, not full messages', providing clear guidance 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/kunwar-shah/claudex'

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