get_recent_errors
Retrieve recent error entries from monitored log files for debugging and analysis, with optional file path filtering and result limit control.
Instructions
Get recent error analysis from monitored files
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filePath | No | Optional: specific file path to get errors from | |
| limit | No | Maximum number of recent errors to return |
Implementation Reference
- src/server.ts:144-161 (schema)Tool schema definition in ListToolsRequestHandler, including name, description, and input schema for filePath (optional) and limit (default 10){ name: 'get_recent_errors', description: 'Get recent error analysis from monitored files', inputSchema: { type: 'object', properties: { filePath: { type: 'string', description: 'Optional: specific file path to get errors from' }, limit: { type: 'number', default: 10, description: 'Maximum number of recent errors to return' } } } }
- src/server.ts:192-194 (registration)Tool registration/dispatch in the CallToolRequestHandler switch statementcase 'get_recent_errors': result = await this.handleGetRecentErrors(args); break;
- src/server.ts:415-424 (handler)MCP server handler for get_recent_errors tool that extracts parameters and delegates to FileWatcher.getRecentErrorsprivate async handleGetRecentErrors(args: any): Promise<MCPToolResult> { const { filePath, limit = 10 } = args; const recentErrors = await this.fileWatcher.getRecentErrors(filePath, limit); return { success: true, data: recentErrors }; }
- src/tools/fileWatcher.ts:104-123 (helper)Core helper function in FileWatcher class that implements the logic to retrieve recent errors from specific or all watched log files, sorting by timestampasync getRecentErrors(filePath?: string, limit: number = 10): Promise<LogAnalysis[]> { if (filePath) { const watchedFile = this.watchers.get(filePath); if (!watchedFile) { throw new Error(`File ${filePath} is not being watched`); } return watchedFile.errors.slice(-limit); } // Get recent errors from all watched files const allErrors: LogAnalysis[] = []; for (const watchedFile of this.watchers.values()) { allErrors.push(...watchedFile.errors); } // Sort by timestamp and return most recent return allErrors .sort((a, b) => b.metadata.timestamp.getTime() - a.metadata.timestamp.getTime()) .slice(0, limit); }