maplestory-mcp-server
Version:
Official-style NEXON MapleStory MCP Server for Claude Desktop - Complete character info, union details, guild data, rankings, and game mechanics
121 lines • 4.41 kB
JavaScript
;
/**
* Health Check Tool for MCP Maple
* Provides system health and status information
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.HealthCheckTool = void 0;
const base_tool_1 = require("./base-tool");
class HealthCheckTool extends base_tool_1.EnhancedBaseTool {
name = 'health_check';
description = 'Check the health status of the MCP server and NEXON API connection';
inputSchema = {
type: 'object',
properties: {
includeDetails: {
type: 'boolean',
description: 'Whether to include detailed system information',
default: false,
},
},
additionalProperties: false,
};
metadata = {
category: base_tool_1.ToolCategory.UTILITY,
tags: ['health', 'status', 'system', 'api'],
examples: [
{
description: 'Basic health check',
arguments: {},
},
{
description: 'Detailed health check with system information',
arguments: {
includeDetails: true,
},
},
],
};
async executeImpl(args, context) {
const includeDetails = this.getOptionalBoolean(args, 'includeDetails', false);
const startTime = Date.now();
try {
// Check NEXON API health
const nexonHealthCheck = await context.nexonClient.healthCheck();
const healthInfo = {
status: 'healthy',
timestamp: new Date().toISOString(),
server: {
name: 'mcp-maple',
version: '1.0.0',
uptime: `${process.uptime().toFixed(2)}s`,
},
nexonApi: {
status: nexonHealthCheck.status,
timestamp: nexonHealthCheck.timestamp,
},
responseTime: `${Date.now() - startTime}ms`,
};
if (includeDetails) {
const memoryUsage = process.memoryUsage();
healthInfo.systemInfo = {
node: {
version: process.version,
platform: process.platform,
arch: process.arch,
},
memory: {
rss: `${Math.round(memoryUsage.rss / 1024 / 1024)}MB`,
heapTotal: `${Math.round(memoryUsage.heapTotal / 1024 / 1024)}MB`,
heapUsed: `${Math.round(memoryUsage.heapUsed / 1024 / 1024)}MB`,
external: `${Math.round(memoryUsage.external / 1024 / 1024)}MB`,
},
process: {
pid: process.pid,
ppid: process.ppid,
cwd: process.cwd(),
},
};
}
return this.formatResult(healthInfo, {
executionTime: Date.now() - startTime,
cacheHit: false,
apiCalls: 1,
});
}
catch (error) {
// Even if NEXON API fails, we can still report server health
const healthInfo = {
status: 'degraded',
timestamp: new Date().toISOString(),
server: {
name: 'mcp-maple',
version: '1.0.0',
uptime: `${process.uptime().toFixed(2)}s`,
},
nexonApi: {
status: 'unhealthy',
error: error instanceof Error ? error.message : String(error),
},
responseTime: `${Date.now() - startTime}ms`,
};
return this.formatResult(healthInfo, {
executionTime: Date.now() - startTime,
cacheHit: false,
apiCalls: 1,
});
}
}
validateImpl(args) {
// Validate includeDetails if provided
if ('includeDetails' in args) {
const value = args.includeDetails;
if (typeof value !== 'boolean') {
return false;
}
}
return true;
}
}
exports.HealthCheckTool = HealthCheckTool;
//# sourceMappingURL=health-check-tool.js.map