Skip to main content
Glama
debugging-tools.ts4.06 kB
// Debugging and Monitoring MCP Tools import { ErrorHandler } from '../utils/error-handler.js'; import { logger, LogLevel } from '../utils/logger.js'; export function createDebuggingTools() { const tools: any[] = []; // ========== ERROR MONITORING ========== tools.push({ name: 'get_error_statistics', description: 'Get error statistics and recent error history', inputSchema: { type: 'object', properties: {} }, handler: async (args: any) => { const stats = ErrorHandler.getErrorStatistics(); return { content: [{ type: 'text', text: JSON.stringify(stats, null, 2) }] }; } }); tools.push({ name: 'clear_error_statistics', description: 'Clear error statistics and history', inputSchema: { type: 'object', properties: {} }, handler: async (args: any) => { ErrorHandler.clearErrorStatistics(); logger.info('Error statistics cleared'); return { content: [{ type: 'text', text: 'Error statistics cleared successfully' }] }; } }); // ========== LOGGING CONTROL ========== tools.push({ name: 'set_log_level', description: 'Set the logging level (DEBUG, INFO, WARN, ERROR)', inputSchema: { type: 'object', properties: { level: { type: 'string', description: 'Log level to set', enum: ['DEBUG', 'INFO', 'WARN', 'ERROR'] } }, required: ['level'] }, handler: async (args: any) => { const levelMap: Record<string, LogLevel> = { 'DEBUG': LogLevel.DEBUG, 'INFO': LogLevel.INFO, 'WARN': LogLevel.WARN, 'ERROR': LogLevel.ERROR }; const level = levelMap[args.level.toUpperCase()]; if (level !== undefined) { logger.setLevel(level); logger.info(`Log level set to ${args.level}`); return { content: [{ type: 'text', text: `Log level set to ${args.level}` }] }; } return { content: [{ type: 'text', text: 'Invalid log level. Use: DEBUG, INFO, WARN, ERROR' }] }; } }); tools.push({ name: 'enable_debug_mode', description: 'Enable or disable debug mode for detailed logging', inputSchema: { type: 'object', properties: { enabled: { type: 'boolean', description: 'Enable or disable debug mode' } }, required: ['enabled'] }, handler: async (args: any) => { logger.setDebugMode(args.enabled); const status = args.enabled ? 'enabled' : 'disabled'; logger.info(`Debug mode ${status}`); return { content: [{ type: 'text', text: `Debug mode ${status}` }] }; } }); // ========== HEALTH CHECK ========== tools.push({ name: 'health_check', description: 'Get server health status and diagnostics', inputSchema: { type: 'object', properties: {} }, handler: async (args: any) => { const errorStats = ErrorHandler.getErrorStatistics(); const uptime = process.uptime(); const memoryUsage = process.memoryUsage(); const health = { status: 'healthy', uptime: `${Math.floor(uptime / 60)} minutes`, memory: { heapUsed: `${Math.round(memoryUsage.heapUsed / 1024 / 1024)} MB`, heapTotal: `${Math.round(memoryUsage.heapTotal / 1024 / 1024)} MB`, rss: `${Math.round(memoryUsage.rss / 1024 / 1024)} MB` }, errors: { total: errorStats.totalErrors || 0, byCategory: errorStats.byCategory || {} }, process: { pid: process.pid, version: process.version, platform: process.platform } }; return { content: [{ type: 'text', text: JSON.stringify(health, null, 2) }] }; } }); return 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/mbrown1837/Ultimate-Elementor-MCP'

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