Skip to main content
Glama
xxczaki
by xxczaki

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
NameRequiredDescriptionDefault
caseSensitiveNoWhether the search should be case sensitive
searchTermYesThe text to search for in history entries

Implementation Reference

  • 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, );
  • 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, },

Other Tools

Related 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