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
| Name | Required | Description | Default |
|---|---|---|---|
| filename | No | Name of the log file to monitor (default: combined.log) | combined.log |
Implementation Reference
- local-logs-mcp-server.js:373-397 (handler)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 }; } }
- local-logs-mcp-server.js:152-162 (schema)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: [] }
- local-logs-mcp-server.js:149-163 (registration)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: [] } },
- local-logs-mcp-server.js:227-229 (registration)Dispatch case in handleToolCall that routes 'watch_log' calls to the watchLog method.case 'watch_log': result = this.watchLog(args?.filename); break;