mcp_summarize_logs
Summarize log output to identify root causes by condensing content and highlighting errors or warnings for faster troubleshooting.
Instructions
Condense logs and highlight likely root causes.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| logs | Yes | Log output to summarize | |
| focus | No | Focus area (default: all) | |
| maxLines | No | Maximum lines to process (default: 500) |
Implementation Reference
- src/tools/code-assistance.ts:1068-1141 (handler)The implementation of the `summarizeLogs` tool, which uses an LLM to analyze and summarize log content, highlighting errors and key events.
async summarizeLogs( logs: string, options?: { focusOnErrors?: boolean; maxEvents?: number; } ): Promise<SummarizeLogsResult> { const focusOnErrors = options?.focusOnErrors ?? true; const maxEvents = options?.maxEvents ?? 20; const prompt = `You are an expert at log analysis. Analyze these logs and provide a summary. ${focusOnErrors ? 'Focus especially on errors and warnings.' : ''} Limit to ${maxEvents} most important events. Provide your response as JSON: { "summary": "High-level summary of the logs", "keyEvents": [ { "type": "error|warning|info|event", "message": "Event description", "timestamp": "if available", "count": 1 } ], "issues": [ { "severity": "critical|high|medium|low", "description": "Issue description", "recommendation": "How to fix" } ], "statistics": { "totalLines": 0, "errorCount": 0, "warningCount": 0, "timeRange": "if determinable" } }`; try { const responseText = await this.llmWrapper.callToolLlm( 'mcp_summarize_logs', [ { role: 'system', content: prompt }, { role: 'user', content: logs.substring(0, 30000) }, // Limit log size ], { type: 'summarize_logs', focusOnErrors, maxEvents } ); const parsed = this.parseJsonResponse(responseText, { summary: responseText, keyEvents: [], issues: [], }); return { success: true, summary: parsed.summary || '', keyEvents: (parsed.keyEvents || []).slice(0, maxEvents), issues: parsed.issues || [], statistics: parsed.statistics, }; } catch (error) { return { success: false, summary: '', keyEvents: [], issues: [], error: error instanceof Error ? error.message : 'Unknown error', }; } } - src/tools/code-assistance.ts:178-195 (schema)The type definition for the results returned by the `summarizeLogs` tool.
export interface SummarizeLogsResult { success: boolean; summary: string; keyEvents: Array<{ type: 'error' | 'warning' | 'info' | 'event'; message: string; timestamp?: string; count?: number; }>; issues: Array<{ severity: 'critical' | 'high' | 'medium' | 'low'; description: string; recommendation?: string; }>; statistics?: { totalLines: number; errorCount: number; warningCount: number; - src/server/tool-discovery.ts:189-191 (registration)Registration of the `mcp_summarize_logs` tool in the discovery layer.
'mcp_translate_code', 'mcp_summarize_logs', ],