Skip to main content
Glama
xxczaki

Local History MCP Server

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,
    	);
    }
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 'Get' which suggests a read-only operation, but doesn't confirm if it's safe (e.g., non-destructive) or mention any side effects, permissions, or rate limits. The description is minimal and adds little beyond the basic action, failing to compensate for the lack of annotations.

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, front-loaded sentence that directly states the tool's purpose without any wasted words. It is appropriately sized for a simple retrieval tool, making it efficient and easy to parse.

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 for a tool with 2 parameters. It doesn't explain what a 'history entry' contains, the format of the return value, or any error conditions. While the schema covers parameters well, the overall context for usage and behavior is insufficient, especially compared to siblings that might overlap in functionality.

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%, with clear descriptions for both parameters in the input schema (e.g., 'filePath' as an absolute path, 'entryIndex' with 0 as most recent). The description adds no additional parameter semantics beyond what the schema provides, so it meets the baseline for high schema coverage without adding value.

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 action ('Get') and resource ('a specific history entry for a file'), making the purpose understandable. It doesn't explicitly differentiate from siblings like 'get_file_history' or 'get_history_stats', but the focus on a single entry is implied. The description avoids tautology by specifying what is retrieved rather than just restating the name.

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 like 'get_file_history' (which might list multiple entries) or 'restore_from_history' (which might modify state). It implies usage for retrieving a single entry but lacks explicit comparisons or exclusions, leaving the agent to infer context from tool names 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/xxczaki/local-history-mcp'

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