search_history_content
Search for specific text within history entries stored in the Local History MCP Server. Supports case-sensitive or case-insensitive queries for precise file or content retrieval.
Instructions
Search for specific content across all history entries
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| caseSensitive | No | Whether the search should be case sensitive | |
| searchTerm | Yes | The text to search for in history entries |
Implementation Reference
- src/index.ts:489-548 (handler)The main handler function that performs regex search across all local history entries, collecting and formatting matches by file, entry index, timestamp, and match count.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:138-157 (registration)Tool registration in the ListToolsRequestHandler, 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, }, },
- src/index.ts:242-253 (registration)Handler dispatch and parameter validation in the CallToolRequestHandler switch statement.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, );
- src/index.ts:142-156 (schema)Input schema defining parameters for the search_history_content tool.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, },