Skip to main content
Glama
mariosss

Local Logs MCP Server

by mariosss

watch_log

Monitor a log file for real-time changes to track errors and debug applications by tailing log entries as they occur.

Instructions

Monitor a log file for changes

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filenameNoName of the log file to monitor (default: combined.log)combined.log

Implementation Reference

  • The watchLog method implements the core logic for the 'watch_log' tool. It checks if the specified log file exists, retrieves file stats, and returns monitoring status information.
    watchLog(filename = 'combined.log') {
      try {
        const filePath = path.join(this.logsDir, filename);
        
        if (!fs.existsSync(filePath)) {
          return { 
            watching: false, 
            message: `Log file ${filename} not found`,
            filename 
          };
        }
    
        const stats = fs.statSync(filePath);
        return { 
          watching: true, 
          file: filename,
          size: stats.size,
          sizeHuman: this.formatBytes(stats.size),
          lastModified: stats.mtime.toISOString(),
          message: `Monitoring ${filename} for changes`
        };
      } catch (error) {
        return { watching: false, error: error.message, filename };
      }
    }
  • Input schema for the 'watch_log' tool, defining the optional 'filename' parameter with default value.
    inputSchema: {
      type: 'object',
      properties: {
        filename: {
          type: 'string',
          description: 'Name of the log file to monitor (default: combined.log)',
          default: 'combined.log'
        }
      },
      required: []
    }
  • Tool registration in the 'tools/list' response, including name, description, and schema.
    {
      name: 'watch_log',
      description: 'Monitor a log file for changes',
      inputSchema: {
        type: 'object',
        properties: {
          filename: {
            type: 'string',
            description: 'Name of the log file to monitor (default: combined.log)',
            default: 'combined.log'
          }
        },
        required: []
      }
    },
  • Dispatch case in handleToolCall that routes 'watch_log' calls to the watchLog method.
    case 'watch_log':
      result = this.watchLog(args?.filename);
      break;

Tool Definition Quality

Score is being calculated. Check back soon.

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