Skip to main content
Glama
errors.tsโ€ข6.44 kB
import type { ErrorSummary } from '../types/index.js'; import type { LogParser } from '../log-parser.js'; export function createGetErrorSummary(logParser: LogParser): any { return { name: 'get_error_summary', description: 'Get a comprehensive summary of all detected errors, categorized by type and severity', inputSchema: { type: 'object', properties: { limit: { type: 'number', description: 'Maximum number of recent errors to include', default: 10, }, }, additionalProperties: false, }, handler: async (args: { limit?: number }): Promise<{ content: Array<{ type: 'text'; text: string }> }> => { const limit = args.limit || 10; const errorHistory = logParser.getHistory(); const errorCounts = logParser.getErrorCounts(); const categoryCounts = logParser.getCategoryCounts(); const fileCounts = logParser.getFileCounts(); const recentErrors = logParser.getRecentErrors(limit); const summary: ErrorSummary = { total: errorHistory.length, byCategory: categoryCounts, bySeverity: errorCounts, recent: recentErrors, files: fileCounts, }; let summaryText = `๐Ÿ“‹ **Error Summary Report**\n\n`; summaryText += `**Total Errors**: ${summary.total}\n\n`; // Severity breakdown summaryText += `**By Severity**:\n`; summaryText += ` โ€ข ๐Ÿ”ด Critical: ${summary.bySeverity.critical}\n`; summaryText += ` โ€ข ๐ŸŸก Warning: ${summary.bySeverity.warning}\n`; summaryText += ` โ€ข ๐Ÿ”ต Info: ${summary.bySeverity.info}\n\n`; // Category breakdown summaryText += `**By Category**:\n`; Object.entries(summary.byCategory) .filter(([_, count]) => count > 0) .sort(([, a], [, b]) => b - a) .forEach(([category, count]) => { const emoji = getCategoryEmoji(category); summaryText += ` โ€ข ${emoji} ${category}: ${count}\n`; }); summaryText += '\n'; // File breakdown (top 10) const fileEntries = Object.entries(summary.files) .sort(([, a], [, b]) => b - a) .slice(0, 10); if (fileEntries.length > 0) { summaryText += `**Top Files with Errors**:\n`; fileEntries.forEach(([file, count]) => { summaryText += ` โ€ข ${file}: ${count}\n`; }); summaryText += '\n'; } // Recent errors if (summary.recent.length > 0) { summaryText += `**Recent Errors** (${summary.recent.length}):\n`; summary.recent.forEach((error, index) => { const severityEmoji = getSeverityEmoji(error.severity); const categoryEmoji = getCategoryEmoji(error.category); summaryText += `${index + 1}. ${severityEmoji} ${categoryEmoji} **${error.category}** `; summaryText += `(${error.timestamp.toLocaleTimeString()})\n`; summaryText += ` ${error.message}\n`; if (error.file) { summaryText += ` ๐Ÿ“„ ${error.file}`; if (error.line) { summaryText += `:${error.line}`; if (error.column) { summaryText += `:${error.column}`; } } summaryText += '\n'; } summaryText += '\n'; }); } return { content: [{ type: 'text', text: summaryText }] }; }, }; } export function createGetFileErrors(logParser: LogParser): any { return { name: 'get_file_errors', description: 'Get all errors associated with a specific file', inputSchema: { type: 'object', properties: { filepath: { type: 'string', description: 'The file path to get errors for', }, }, required: ['filepath'], additionalProperties: false, }, handler: async (args: { filepath: string }): Promise<{ content: Array<{ type: 'text'; text: string }> }> => { const errors = logParser.getErrorsForFile(args.filepath); let errorText = `๐Ÿ“„ **Errors for File: ${args.filepath}**\n\n`; if (errors.length === 0) { errorText += `โœ… No errors found for this file.\n`; return { content: [{ type: 'text', text: errorText }] }; } errorText += `**Total Errors**: ${errors.length}\n\n`; errors.forEach((error, index) => { const severityEmoji = getSeverityEmoji(error.severity); const categoryEmoji = getCategoryEmoji(error.category); errorText += `${index + 1}. ${severityEmoji} ${categoryEmoji} **${error.severity.toUpperCase()}** - ${error.category}\n`; errorText += ` **Message**: ${error.message}\n`; if (error.line) { errorText += ` **Location**: Line ${error.line}`; if (error.column) { errorText += `, Column ${error.column}`; } errorText += '\n'; } errorText += ` **Time**: ${error.timestamp.toLocaleString()}\n`; errorText += ` **ID**: ${error.id}\n\n`; }); return { content: [{ type: 'text', text: errorText }] }; }, }; } export function createClearErrorHistory(logParser: LogParser): any { return { name: 'clear_error_history', description: 'Clear all stored error history', inputSchema: { type: 'object', properties: {}, additionalProperties: false, }, handler: async (): Promise<{ content: Array<{ type: 'text'; text: string }> }> => { logParser.clearHistory(); return { content: [{ type: 'text', text: '๐Ÿงน **Error history cleared successfully.**\n\nAll stored errors have been removed from memory.' }] }; }, }; } function getSeverityEmoji(severity: string): string { switch (severity) { case 'critical': return '๐Ÿ”ด'; case 'warning': return '๐ŸŸก'; case 'info': return '๐Ÿ”ต'; default: return 'โšช'; } } function getCategoryEmoji(category: string): string { switch (category) { case 'typescript': return '๐Ÿ”ท'; case 'svelte': return '๐ŸŸ '; case 'vite': return 'โšก'; case 'network': return '๐ŸŒ'; case 'build': return '๐Ÿ”จ'; case 'runtime': return 'โš™๏ธ'; case 'accessibility': return 'โ™ฟ'; case 'unknown': return 'โ“'; default: return '๐Ÿ“'; } }

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/mntlabs/devserver-mcp'

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