Skip to main content
Glama
mariosss

Local Logs MCP Server

by mariosss

search_logs

Search local log files for specific text patterns to identify errors, debug applications, and monitor system activity.

Instructions

Search for specific text in log files

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesText to search for in logs
filenameNoLog file to search (default: combined.log)combined.log
linesNoNumber of matching lines to return (default: 10)

Implementation Reference

  • The `searchLogs` method that executes the tool logic: reads the specified log file, searches for lines containing the query (case-insensitive), collects up to `maxLines` matches with line numbers and extracted timestamps, and returns structured results.
    searchLogs(query, filename = 'combined.log', maxLines = 10) {
      try {
        const filePath = path.join(this.logsDir, filename);
        
        if (!fs.existsSync(filePath)) {
          return { 
            matches: [], 
            message: `Log file ${filename} not found`,
            query,
            filename 
          };
        }
    
        const content = fs.readFileSync(filePath, 'utf8');
        const lines = content.split('\n');
        const matches = [];
    
        for (let i = 0; i < lines.length && matches.length < maxLines; i++) {
          if (lines[i].toLowerCase().includes(query.toLowerCase())) {
            matches.push({
              lineNumber: i + 1,
              content: lines[i].trim(),
              timestamp: this.extractTimestamp(lines[i])
            });
          }
        }
    
        return {
          matches,
          query,
          filename,
          matchCount: matches.length,
          message: `Found ${matches.length} matches for "${query}" in ${filename}`
        };
      } catch (error) {
        return { matches: [], error: error.message, query, filename };
      }
    }
  • Input schema for the `search_logs` tool as returned in `tools/list`, defining required `query` parameter and optional `filename` and `lines`.
    {
      name: 'search_logs',
      description: 'Search for specific text in log files',
      inputSchema: {
        type: 'object',
        properties: {
          query: {
            type: 'string',
            description: 'Text to search for in logs'
          },
          filename: {
            type: 'string',
            description: 'Log file to search (default: combined.log)',
            default: 'combined.log'
          },
          lines: {
            type: 'number',
            description: 'Number of matching lines to return (default: 10)',
            default: 10
          }
        },
        required: ['query']
      }
    }
  • Registration/dispatch in the `handleToolCall` switch statement that routes `tools/call` for 'search_logs' to the handler method.
    case 'search_logs':
      result = this.searchLogs(args?.query, args?.filename, args?.lines);
      break;
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. It states the action ('search') but doesn't disclose behavioral traits like whether this is a read-only operation (implied but not stated), performance characteristics, rate limits, authentication needs, or what happens when no matches are found. For a search tool with zero annotation coverage, this leaves significant gaps in understanding its behavior.

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 directly states the tool's purpose without unnecessary words. It's appropriately sized for a straightforward search tool and front-loaded with the core functionality. Every word earns its place.

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

Completeness2/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 with filtering), lack of annotations, and no output schema, the description is incomplete. It doesn't explain return values (e.g., format of results, error handling), behavioral constraints, or how it differs from sibling tools. For a search operation with multiple parameters and no structured output documentation, more context is needed.

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 documents all three parameters (query, filename, lines) with descriptions and defaults. The description adds no additional parameter semantics beyond what's in the schema, such as search syntax (e.g., regex support) or filename constraints. Baseline 3 is appropriate when schema does the heavy lifting.

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 verb ('search') and resource ('log files') with specificity about searching for 'specific text'. It distinguishes from siblings like 'get_log_files' (list files) and 'tail_log' (stream recent entries), but doesn't explicitly differentiate from 'get_errors' which might also search logs. Purpose is clear but sibling differentiation could be more explicit.

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?

No guidance on when to use this tool versus alternatives like 'get_errors' (which might filter for errors), 'tail_log' (for real-time monitoring), or 'watch_log' (for continuous watching). The description provides basic functionality but no context about appropriate use cases or exclusions.

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/mariosss/local-logs-mcp-server'

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