Skip to main content
Glama

search_logs

Search terminal process logs using keywords or regex patterns to find specific information within captured output.

Instructions

Search logs for a keyword or regex

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesProcess identifier
keywordYesKeyword or regex to search for
regexNoUse regex search (optional)

Implementation Reference

  • The actual implementation of the log search logic within the ProcessManager class.
    async searchLogs(input: { id: string; keyword: string; regex?: boolean }): Promise<{ id: string; matches: string[] }> {
      const logFile = this.logFiles.get(input.id);
    
      if (!logFile) {
        throw new Error(`Process '${input.id}' not found`);
      }
    
      if (!fs.existsSync(logFile)) {
        throw new Error(`No logs found for process '${input.id}'`);
      }
    
      const matches = await this.logService.searchLog(
        logFile,
        input.keyword,
        input.regex
      );
    
      return { id: input.id, matches };
    }
  • src/index.ts:65-76 (registration)
    Tool registration for 'search_logs' in the MCP server setup.
      name: 'search_logs',
      description: 'Search logs for a keyword or regex',
      inputSchema: {
        type: 'object',
        properties: {
          id: { type: 'string', description: 'Process identifier' },
          keyword: { type: 'string', description: 'Keyword or regex to search for' },
          regex: { type: 'boolean', description: 'Use regex search (optional)' },
        },
        required: ['id', 'keyword'],
      },
    },
  • The request handler branch that executes the 'search_logs' tool.
    case 'search_logs': {
      const result = await processManager.searchLogs(args as any);
      return { content: [{ type: 'text', text: JSON.stringify(result) }] };
    }
  • Input and output type definitions for the 'search_logs' tool.
    export interface SearchLogsInput {
      id: string;
      keyword: string;
      regex?: boolean;
    }
    
    export interface SearchLogsOutput {
      id: string;
      matches: string[];
    }

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/h004888/mcp_terminal_process'

If you have feedback or need assistance with the MCP directory API, please join our Discord server