Skip to main content
Glama
xxczaki
by xxczaki

get_history_entry

Retrieve a specific version of a file from local history by providing its file path and entry index to restore previous content or compare changes.

Instructions

Get a specific history entry for a 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.
entryIndexYesThe index of the history entry (0 = most recent)

Implementation Reference

  • The primary handler function that implements the logic for retrieving and formatting a specific history entry from VS Code local history based on file path and entry index.
    private async getHistoryEntry(filePath: string, entryIndex: number) { const history = this.historyParser.findHistoryByFilePath(filePath); if (!history) { return { content: [ { type: 'text', text: `No local history found for: ${filePath}`, }, ], }; } if (entryIndex < 0 || entryIndex >= history.entries.length) { return { content: [ { type: 'text', text: `Invalid entry index ${entryIndex}. Available indices: 0-${history.entries.length - 1}`, }, ], }; } const entry = history.entries[entryIndex]; return { content: [ { type: 'text', text: `History Entry ${entryIndex} for: ${history.originalFilePath}\n` + `Timestamp: ${new Date(entry.timestamp).toLocaleString()}\n` + `Size: ${entry.content.length} characters\n\n` + `Content:\n\`\`\`\n${entry.content}\n\`\`\``, }, ], }; }
  • The tool registration including name, description, and input schema definition for validating parameters (filePath: string, entryIndex: number).
    { name: 'get_history_entry', description: 'Get a specific history entry for a 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.', }, entryIndex: { type: 'number', description: 'The index of the history entry (0 = most recent)', }, }, required: ['filePath', 'entryIndex'], additionalProperties: false, }, },
  • src/index.ts:187-210 (registration)
    The dispatch handler in the CallToolRequest that validates input parameters and invokes the getHistoryEntry method.
    case 'get_history_entry': { if ( !args || typeof args !== 'object' || !('filePath' in args) || !('entryIndex' in args) ) { throw new McpError( ErrorCode.InvalidParams, 'Missing required parameters: filePath, entryIndex', ); } const filePathEntry = args.filePath as string; if (!path.isAbsolute(filePathEntry)) { throw new McpError( ErrorCode.InvalidParams, 'filePath must be an absolute path', ); } return await this.getHistoryEntry( filePathEntry, args.entryIndex as number, ); }

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