Skip to main content
Glama
xxczaki
by xxczaki

get_file_history

Retrieve the full history of a specific file to track changes, restore previous versions, or enhance context awareness. Provide the file's absolute path for accurate results.

Instructions

Get the complete history for a specific file

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filePathYesThe path to the file. Please provide an absolute path (e.g., "/Users/user/project/biome.json") for reliable matching.

Implementation Reference

  • src/index.ts:62-77 (registration)
    Registration of the 'get_file_history' tool in the ListToolsRequestSchema handler, including the tool name, description, and input schema definition.
    { name: 'get_file_history', description: 'Get the complete history for a specific file', inputSchema: { type: 'object', properties: { filePath: { type: 'string', description: 'The path to the file. Please provide an absolute path (e.g., "/Users/user/project/biome.json") for reliable matching.', }, }, required: ['filePath'], additionalProperties: false, }, },
  • Dispatch handler in the CallToolRequestSchema switch statement: validates the filePath argument and delegates to the private getFileHistory method.
    case 'get_file_history': { if (!args || typeof args !== 'object' || !('filePath' in args)) { throw new McpError( ErrorCode.InvalidParams, 'Missing required parameter: filePath', ); } const filePathHistory = args.filePath as string; if (!path.isAbsolute(filePathHistory)) { throw new McpError( ErrorCode.InvalidParams, 'filePath must be an absolute path', ); } return await this.getFileHistory(filePathHistory); }
  • Primary handler function that executes the tool logic: retrieves the file history using the parser, formats a textual summary of all entries, or reports no history found.
    private async getFileHistory(filePath: string) { const history = this.historyParser.findHistoryByFilePath(filePath); if (!history) { return { content: [ { type: 'text', text: `No local history found for: ${filePath}`, }, ], }; } const entriesText = history.entries .map( (entry, index) => `[${index}] ${new Date(entry.timestamp).toLocaleString()}\n` + ` File: ${entry.relativePath}\n` + ` Size: ${entry.content.length} characters`, ) .join('\n\n'); return { content: [ { type: 'text', text: `History for: ${history.originalFilePath}\n` + `Total entries: ${history.entries.length}\n\n` + `History entries (most recent first):\n\n${entriesText}`, }, ], }; }
  • Supporting utility method in VSCodeHistoryParser that finds and returns the FileHistory object matching the given file path (with URI handling and normalization).
    public findHistoryByFilePath(targetFilePath: string): FileHistory | null { const histories = this.getAllFileHistories(); // Convert URI to path if needed const cleanTargetPath = uriToPath(targetFilePath); const normalizedTarget = path.resolve(cleanTargetPath); for (const history of histories) { const cleanHistoryPath = uriToPath(history.originalFilePath); const normalizedHistory = path.resolve(cleanHistoryPath); // Exact match if (normalizedTarget === normalizedHistory) { return history; } // Case-insensitive match (for case-insensitive filesystems) if (normalizedTarget.toLowerCase() === normalizedHistory.toLowerCase()) { return history; } } return null; }

Other Tools

Related 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/xxczaki/local-history-mcp'

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