maplestorysea-mcp-server
Version:
NEXON MapleStory SEA API MCP Server for Claude Desktop - Complete character info, union details, guild data, rankings optimized for SEA servers
182 lines • 7.52 kB
JavaScript
;
/**
* Health Check Tool for MCP Maple
* Provides comprehensive system health and status information
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.HealthCheckTool = void 0;
const base_tool_1 = require("./base-tool");
const health_check_1 = require("../utils/health-check");
const server_utils_1 = require("../utils/server-utils");
class HealthCheckTool extends base_tool_1.EnhancedBaseTool {
name = 'health_check';
description = 'Check the comprehensive health status of the MapleStory SEA MCP server and all its components';
inputSchema = {
type: 'object',
properties: {
detailed: {
type: 'boolean',
description: 'Include detailed health information for all components (default: true)',
default: true,
},
component: {
type: 'string',
description: 'Check specific component only (nexon-api, cache, memory, process)',
enum: ['nexon-api', 'cache', 'memory', 'process'],
},
timeout: {
type: 'number',
description: 'Timeout for health checks in milliseconds (default: 5000)',
minimum: 1000,
maximum: 30000,
default: 5000,
},
},
additionalProperties: false,
};
metadata = {
category: base_tool_1.ToolCategory.SYSTEM,
tags: ['health', 'monitoring', 'status', 'diagnostics', 'system'],
examples: [
{
description: 'Comprehensive health check',
arguments: {},
},
{
description: 'Quick health status without details',
arguments: { detailed: false },
},
{
description: 'Check specific component',
arguments: { component: 'nexon-api' },
},
{
description: 'Health check with custom timeout',
arguments: { timeout: 10000 },
},
],
};
async executeImpl(args, context) {
const detailed = this.getOptionalBoolean(args, 'detailed', true);
const component = this.getOptionalString(args, 'component');
const timeout = this.getOptionalNumber(args, 'timeout', 5000);
try {
const startTime = Date.now();
// Create health manager with current API client
const healthManager = (0, health_check_1.createDefaultHealthManager)(context.nexonClient);
if (!detailed && !component) {
// Quick status check
const quickStatus = await healthManager.getQuickStatus();
const executionTime = Date.now() - startTime;
context.logger.info('Quick health check completed', {
status: quickStatus.status,
executionTime,
});
return this.formatResult({
status: quickStatus.status,
uptime: quickStatus.uptime,
timestamp: quickStatus.timestamp,
mode: 'quick',
}, {
executionTime,
cacheHit: false,
apiCalls: 0,
});
}
// Full health check
const healthStatus = await healthManager.runHealthChecks({ timeout });
const executionTime = Date.now() - startTime;
// Add SEA-specific schedule information
const timeUntilReset = (0, server_utils_1.getTimeUntilDailyReset)();
const nextDataUpdate = (0, server_utils_1.getNextDataUpdate)();
const seaScheduleInfo = {
currentTime: {
date: (0, server_utils_1.getCurrentSEADate)(),
time: (0, server_utils_1.getCurrentSEATime)(),
timezone: 'SGT (UTC+8)',
},
gameSchedules: {
dailyReset: {
next: (0, server_utils_1.formatSEADate)((0, server_utils_1.getNextDailyReset)(), true),
timeRemaining: `${timeUntilReset.hours}h ${timeUntilReset.minutes}m ${timeUntilReset.seconds}s`,
},
weeklyReset: {
next: (0, server_utils_1.formatSEADate)((0, server_utils_1.getNextWeeklyReset)(), true),
day: 'Wednesday 00:00 SGT',
},
dataUpdate: {
next: (0, server_utils_1.formatSEADate)(nextDataUpdate, true),
schedule: 'Daily at 08:00 SGT',
inProgress: (0, server_utils_1.isDuringDataUpdate)(),
},
},
maintenanceInfo: {
likelyMaintenance: (0, server_utils_1.isMaintenanceTime)(),
weeklyWindow: 'Wednesday 08:00-12:00 SGT',
emergencyWindow: 'Daily 01:00-06:00 SGT',
patchWindow: 'Tuesday 23:00 - Wednesday 03:00 SGT',
},
};
let result = {
...healthStatus,
seaSchedules: seaScheduleInfo,
};
// Filter for specific component if requested
if (component && healthStatus.details[component]) {
result = {
...healthStatus,
seaSchedules: seaScheduleInfo,
details: {
[component]: healthStatus.details[component],
},
};
}
context.logger.info('Health check completed', {
overallStatus: healthStatus.status,
componentsChecked: Object.keys(healthStatus.details).length,
executionTime,
component: component || 'all',
});
return this.formatResult({
...result,
mode: component ? 'component' : 'full',
}, {
executionTime,
cacheHit: false,
apiCalls: component === 'nexon-api' || !component ? 1 : 0,
});
}
catch (error) {
context.logger.error('Health check failed', {
component,
detailed,
timeout,
error: error instanceof Error ? error.message : String(error),
});
return this.formatError(`Health check failed: ${error instanceof Error ? error.message : String(error)}`);
}
}
validateImpl(args) {
// Validate detailed if provided
if ('detailed' in args && typeof args.detailed !== 'boolean') {
return false;
}
// Validate component if provided
if ('component' in args) {
const validComponents = ['nexon-api', 'cache', 'memory', 'process'];
if (!validComponents.includes(args.component)) {
return false;
}
}
// Validate timeout if provided
if ('timeout' in args) {
const timeout = args.timeout;
if (typeof timeout !== 'number' || timeout < 1000 || timeout > 30000) {
return false;
}
}
return true;
}
}
exports.HealthCheckTool = HealthCheckTool;
//# sourceMappingURL=health-check-tool.js.map