Skip to main content
Glama
xxczaki

Local History MCP Server

by xxczaki

get_file_history

Retrieve complete version history for a specific file to enable recovery and track changes over time.

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

  • Main handler function that executes the tool logic: finds the file history using VSCodeHistoryParser, formats summaries of all entries, and returns a formatted text response.
    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}`,
    			},
    		],
    	};
    }
  • src/index.ts:62-77 (registration)
    Tool registration in the ListTools response, including name, description, and input schema.
    {
    	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 CallToolRequest switch statement: validates input parameters and delegates to 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);
    }
  • Key helper method called by the handler to locate the FileHistory object for the given file path by searching all histories.
    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;
    }
  • Input schema definition for the get_file_history tool, specifying the required filePath parameter.
    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,
    },
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. It states the action but doesn't disclose behavioral traits such as whether this is a read-only operation, if it requires specific permissions, what the output format looks like (e.g., list of entries with timestamps), or any rate limits. 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, clear sentence with zero waste. It's front-loaded with the core purpose, making it efficient and easy to parse, which is ideal for conciseness.

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 complexity of retrieving file history and the lack of annotations and output schema, the description is incomplete. It doesn't explain what 'complete history' includes (e.g., revisions, metadata), how results are structured, or any prerequisites. This leaves gaps for the agent to understand the tool's behavior fully.

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 the parameter 'filePath' fully documented in the input schema. The description doesn't add any meaning beyond what the schema provides (e.g., it doesn't clarify what 'complete history' entails or examples of file paths). Baseline 3 is appropriate as the schema handles the parameter documentation adequately.

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 'complete history for a specific file', making the purpose understandable. However, it doesn't explicitly differentiate from siblings like 'get_history_entry' (which might retrieve a single entry) or 'list_history_files' (which might list files with history), leaving room for ambiguity in sibling context.

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 is provided on when to use this tool versus alternatives. With siblings like 'get_history_entry', 'get_history_stats', and 'list_history_files', the description lacks explicit instructions or context for selection, leaving the agent to infer usage based on 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