get_history_entry
Retrieve a specific version of a file from its history by providing the file path and entry index. Use this tool to access previous snapshots for recovery or enhanced context awareness.
Instructions
Get a specific history entry for a file
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| entryIndex | Yes | The index of the history entry (0 = most recent) | |
| filePath | Yes | The path to the file. Please provide an absolute path (e.g., "/Users/user/project/biome.json") for reliable matching. |
Implementation Reference
- src/index.ts:338-377 (handler)The primary handler function that retrieves a specific history entry for a given file path and index, validates inputs, and returns formatted content.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\`\`\``, }, ], }; }
- src/index.ts:78-98 (registration)Tool registration in the list tools response, including name, description, and input schema definition.{ 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 (handler)Dispatch handler in the main CallToolRequestSchema that validates parameters and calls the specific 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, ); }