Skip to main content
Glama
es6kr
by es6kr

get_session_diff

Compare file changes and snapshot information between Claude Code conversation sessions to track project evolution and modifications.

Instructions

Get diff summary for a session including file changes and snapshot info

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_nameYesProject folder name
session_idYesSession ID

Implementation Reference

  • Core implementation of getSessionDiffSummary: reads session messages, derives session title from first human message, iterates through messages to find file-history-snapshot events, extracts unique file changes with backup previews, counts snapshots, and returns a structured summary.
    export const getSessionDiffSummary = (projectName: string, sessionId: string) =>
      Effect.gen(function* () {
        const messages = yield* readSession(projectName, sessionId)
    
        // Extract title
        const title = pipe(
          messages,
          A.findFirst((m) => m.type === 'human'),
          O.map((m) => {
            const msg = m.message as { content?: string } | undefined
            const content = msg?.content ?? ''
            return content.slice(0, 50) + (content.length > 50 ? '...' : '')
          }),
          O.getOrElse(() => 'Untitled')
        )
    
        const changes: FileDiffSummary['changes'] = []
        const seenFiles = new Set<string>()
        let snapshotCount = 0
    
        for (const msg of messages) {
          if (msg.type === 'file-history-snapshot') {
            snapshotCount++
            const snapshot = msg as {
              type: string
              snapshot?: {
                trackedFileBackups?: Record<string, { content?: string }>
              }
            }
    
            const backups = snapshot.snapshot?.trackedFileBackups
            if (backups && typeof backups === 'object') {
              for (const [filePath, backup] of Object.entries(backups)) {
                if (!seenFiles.has(filePath)) {
                  seenFiles.add(filePath)
                  const backupData = backup as { content?: string } | undefined
                  const content = backupData?.content ?? ''
                  changes.push({
                    path: filePath,
                    action: 'modified',
                    hasBackup: content.length > 0,
                    backupPreview: content.slice(0, 100) + (content.length > 100 ? '...' : ''),
                  })
                }
              }
            }
          }
        }
    
        return {
          sessionId,
          projectName,
          title,
          changes,
          totalFiles: changes.length,
          snapshotCount,
        } satisfies FileDiffSummary
      })
  • Registers the MCP tool 'get_session_diff' with server.tool, providing description, input schema, and a thin handler that invokes the core getSessionDiffSummary function and returns JSON response.
    server.tool(
      'get_session_diff',
      'Get diff summary for a session including file changes and snapshot info',
      {
        project_name: z.string().describe('Project folder name'),
        session_id: z.string().describe('Session ID'),
      },
      async ({ project_name, session_id }) => {
        const result = await Effect.runPromise(session.getSessionDiffSummary(project_name, session_id))
        return {
          content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
        }
      }
    )
  • Zod input schema defining required string parameters: project_name and session_id for the get_session_diff tool.
    {
      project_name: z.string().describe('Project folder name'),
      session_id: z.string().describe('Session ID'),
    },
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 states the tool retrieves a diff summary but doesn't describe the return format, whether it's read-only, any permissions required, or potential side effects. This is a significant gap for a tool with no annotation coverage.

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 directly states the tool's purpose without unnecessary words. It's appropriately sized and front-loaded, with every word contributing to clarity.

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 lack of annotations and output schema, the description is incomplete. It doesn't explain what the diff summary includes beyond 'file changes and snapshot info', nor does it cover behavioral aspects like safety or response format. For a tool with no structured data support, this leaves critical 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%, so the schema already documents both parameters ('project_name' and 'session_id') adequately. The description adds no additional meaning beyond what the schema provides, such as explaining how these parameters relate to the diff summary, which aligns with the baseline score when schema coverage is high.

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 ('diff summary for a session'), including what information it retrieves ('file changes and snapshot info'). However, it doesn't explicitly differentiate from sibling tools like 'get_session_files' or 'list_sessions', which might also retrieve session-related information.

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 prerequisites, exclusions, or compare it to siblings such as 'get_session_files' or 'list_sessions', leaving the agent to infer usage from the name alone.

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/es6kr/claude-sessions-mcp'

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