Skip to main content
Glama
es6kr
by es6kr

get_session_files

Retrieve all files modified during a Claude Code session to track changes and review project history.

Instructions

Get list of all files changed in a session (from file-history-snapshot and tool_use)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_nameYesProject folder name
session_idYesSession ID

Implementation Reference

  • Registers the 'get_session_files' MCP tool, including input schema (project_name, session_id) and thin handler that delegates to session.getSessionFiles
    server.tool(
      'get_session_files',
      'Get list of all files changed in a session (from file-history-snapshot and tool_use)',
      {
        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.getSessionFiles(project_name, session_id))
        return {
          content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
        }
      }
    )
  • Core implementation of getSessionFiles: parses session messages, extracts unique file changes from 'file-history-snapshot' and 'tool_use' (Write/Edit) blocks
    export const getSessionFiles = (projectName: string, sessionId: string) =>
      Effect.gen(function* () {
        const messages = yield* readSession(projectName, sessionId)
        const fileChanges: FileChange[] = []
        const seenFiles = new Set<string>()
    
        for (const msg of messages) {
          // Check for file-history-snapshot type
          if (msg.type === 'file-history-snapshot') {
            const snapshot = msg as unknown as {
              type: string
              messageId?: string
              snapshot?: {
                trackedFileBackups?: Record<string, unknown>
                timestamp?: string
              }
            }
    
            const backups = snapshot.snapshot?.trackedFileBackups
            if (backups && typeof backups === 'object') {
              for (const filePath of Object.keys(backups)) {
                if (!seenFiles.has(filePath)) {
                  seenFiles.add(filePath)
                  fileChanges.push({
                    path: filePath,
                    action: 'modified',
                    timestamp: snapshot.snapshot?.timestamp,
                    messageUuid: snapshot.messageId ?? msg.uuid,
                  })
                }
              }
            }
          }
    
          // Also check tool_use for Write/Edit operations
          if (msg.type === 'assistant' && msg.message) {
            const assistantMsg = msg.message as {
              content?: Array<{ type: string; name?: string; input?: { file_path?: string } }>
            }
            const content = assistantMsg.content
            if (Array.isArray(content)) {
              for (const block of content) {
                if (block.type === 'tool_use' && (block.name === 'Write' || block.name === 'Edit')) {
                  const filePath = block.input?.file_path
                  if (filePath && !seenFiles.has(filePath)) {
                    seenFiles.add(filePath)
                    fileChanges.push({
                      path: filePath,
                      action: block.name === 'Write' ? 'created' : 'modified',
                      timestamp: msg.timestamp,
                      messageUuid: msg.uuid,
                    })
                  }
                }
              }
            }
          }
        }
    
        return {
          sessionId,
          projectName,
          files: fileChanges,
          totalChanges: fileChanges.length,
        } satisfies SessionFilesSummary
      })
  • TypeScript interface defining the output structure of getSessionFiles
    export interface SessionFilesSummary {
      sessionId: string
      projectName: string
      files: FileChange[]
      totalChanges: number
    }
  • Helper function readSession loads and parses session messages from .jsonl file, used by getSessionFiles
    export const readSession = (projectName: string, sessionId: string) =>
      Effect.gen(function* () {
        const filePath = path.join(getSessionsDir(), projectName, `${sessionId}.jsonl`)
        const content = yield* Effect.tryPromise(() => fs.readFile(filePath, 'utf-8'))
        const lines = content.trim().split('\n').filter(Boolean)
        return lines.map((line) => JSON.parse(line) as Message)
      })
  • Zod input schema for the MCP tool parameters
      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 full burden. It states the tool retrieves a list from specific sources but doesn't disclose behavioral traits such as read-only status, potential rate limits, error handling, or output format details. 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 with zero waste. It is appropriately sized and front-loaded, clearly stating the tool's purpose without unnecessary elaboration.

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

Completeness3/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 (2 required parameters, no output schema, no annotations), the description is minimally adequate. It covers the basic purpose but lacks details on behavioral traits and usage guidelines, leaving gaps in completeness for effective agent use.

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 documents both parameters (project_name and session_id). The description adds no additional meaning beyond what the schema provides, such as parameter interactions or usage context, meeting the baseline for high schema coverage.

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 verb 'Get' and the resource 'list of all files changed in a session', specifying the data sources (file-history-snapshot and tool_use). It distinguishes from siblings like get_session_diff (which likely shows differences) and list_sessions (which lists sessions, not files), but doesn't explicitly contrast them.

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?

No guidance on when to use this tool versus alternatives like get_session_diff or list_sessions. The description implies usage for retrieving file changes within a session but lacks explicit context, prerequisites, or exclusions.

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