Skip to main content
Glama
xxczaki

Local History MCP Server

by xxczaki

search_history_content

Find specific text across all file history snapshots to locate previous versions or recover content from Cursor/VS Code Local History.

Instructions

Search for specific content across all history entries

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
searchTermYesThe text to search for in history entries
caseSensitiveNoWhether the search should be case sensitive

Implementation Reference

  • The handler function that searches for the given term across all local history entries, collects matches with details like file path, entry index, timestamp, and match count, and formats the results.
    private async searchHistoryContent(
    	searchTerm: string,
    	caseSensitive: boolean,
    ) {
    	const histories = this.historyParser.getAllFileHistories();
    	const results: Array<{
    		file: string;
    		entryIndex: number;
    		timestamp: string;
    		matchCount: number;
    	}> = [];
    
    	const searchRegex = new RegExp(
    		searchTerm.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'),
    		caseSensitive ? 'g' : 'gi',
    	);
    
    	for (const history of histories) {
    		history.entries.forEach((entry, index) => {
    			const matches = entry.content.match(searchRegex);
    			if (matches) {
    				results.push({
    					file: history.originalFilePath,
    					entryIndex: index,
    					timestamp: new Date(entry.timestamp).toLocaleString(),
    					matchCount: matches.length,
    				});
    			}
    		});
    	}
    
    	if (results.length === 0) {
    		return {
    			content: [
    				{
    					type: 'text',
    					text: `No matches found for "${searchTerm}" in local history.`,
    				},
    			],
    		};
    	}
    
    	const resultsText = results
    		.map(
    			(result) =>
    				`📄 ${result.file}\n` +
    				`   └── Entry ${result.entryIndex} (${result.timestamp})\n` +
    				`   └── ${result.matchCount} match${result.matchCount === 1 ? '' : 'es'}`,
    		)
    		.join('\n\n');
    
    	return {
    		content: [
    			{
    				type: 'text',
    				text: `🔍 Found ${results.length} entries containing "${searchTerm}":\n\n${resultsText}`,
    			},
    		],
    	};
    }
  • src/index.ts:137-157 (registration)
    Registration of the tool in the listTools response, including name, description, and input schema definition.
    {
    	name: 'search_history_content',
    	description:
    		'Search for specific content across all history entries',
    	inputSchema: {
    		type: 'object',
    		properties: {
    			searchTerm: {
    				type: 'string',
    				description: 'The text to search for in history entries',
    			},
    			caseSensitive: {
    				type: 'boolean',
    				description: 'Whether the search should be case sensitive',
    				default: false,
    			},
    		},
    		required: ['searchTerm'],
    		additionalProperties: false,
    	},
    },
  • Input schema defining parameters: searchTerm (required string) and caseSensitive (optional boolean).
    inputSchema: {
    	type: 'object',
    	properties: {
    		searchTerm: {
    			type: 'string',
    			description: 'The text to search for in history entries',
    		},
    		caseSensitive: {
    			type: 'boolean',
    			description: 'Whether the search should be case sensitive',
    			default: false,
    		},
    	},
    	required: ['searchTerm'],
    	additionalProperties: false,
    },
  • Dispatch handler in the CallToolRequestSchema switch case: validates input arguments and invokes the searchHistoryContent method.
    case 'search_history_content':
    	if (!args || typeof args !== 'object' || !('searchTerm' in args)) {
    		throw new McpError(
    			ErrorCode.InvalidParams,
    			'Missing required parameter: searchTerm',
    		);
    	}
    	return await this.searchHistoryContent(
    		args.searchTerm as string,
    		((args as Record<string, unknown>).caseSensitive as boolean) ??
    			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 of behavioral disclosure. While 'Search' implies a read-only operation, the description doesn't specify whether this is a simple text search or includes metadata, what format results return, whether there are rate limits, or if authentication is required. For a search tool with zero annotation coverage, this leaves significant behavioral gaps.

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, efficient sentence that clearly states the tool's core function. There's zero wasted verbiage or redundancy. It's appropriately sized for a simple search tool and front-loads the essential information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (search operation with 2 parameters) and the absence of both annotations and an output schema, the description is minimally adequate but incomplete. It covers the basic purpose but lacks crucial context about result format, search behavior, and how this differs from sibling tools. For a search function without output schema, more detail about what gets returned would be helpful.

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?

Schema description coverage is 100%, so the schema already fully documents both parameters (searchTerm and caseSensitive). The description adds no additional parameter semantics beyond what's in the schema - it doesn't explain search syntax, match behavior, or result formatting. With complete schema coverage, the baseline score of 3 is appropriate.

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 tool's purpose: 'Search for specific content across all history entries' - this specifies the verb (search), resource (history entries), and scope (all entries). However, it doesn't explicitly differentiate from sibling tools like 'get_history_entry' or 'list_history_files', which likely serve different purposes but could overlap in functionality.

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. With siblings like 'get_history_entry' (likely retrieves a specific entry), 'list_history_files' (likely lists files in history), and 'restore_from_history' (likely restores content), there's clear potential for confusion about which tool to use for different history-related tasks. The description offers no explicit when/when-not instructions or alternative recommendations.

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