Skip to main content
Glama
xxczaki
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, );

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