UNPKG

maplestory-mcp-server

Version:

Official-style NEXON MapleStory MCP Server for Claude Desktop - Complete character info, union details, guild data, rankings, and game mechanics

119 lines 4.13 kB
"use strict"; /** * Logging utilities for MCP Maple * Provides structured logging for API operations and errors */ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.McpLogger = void 0; const winston_1 = __importDefault(require("winston")); class McpLogger { logger; constructor(component = 'mcp-maple') { // In MCP mode (no port specified), disable console logging to avoid JSON pollution const isMcpMode = !process.env.MCP_PORT && !process.argv.includes('--port'); this.logger = winston_1.default.createLogger({ level: process.env.LOG_LEVEL || 'info', format: winston_1.default.format.combine(winston_1.default.format.timestamp(), winston_1.default.format.json(), winston_1.default.format.printf(({ timestamp, level, message, component: comp, ...meta }) => { return JSON.stringify({ timestamp, level, component: comp || component, message, ...meta, }); })), defaultMeta: { component }, silent: isMcpMode, transports: isMcpMode ? [] : [ new winston_1.default.transports.Console({ stderrLevels: ['error', 'warn', 'info', 'debug'], consoleWarnLevels: [], format: winston_1.default.format.combine(winston_1.default.format.colorize(), winston_1.default.format.simple()), }), ], }); // Add file transport in production if (process.env.NODE_ENV === 'production') { this.logger.add(new winston_1.default.transports.File({ filename: 'logs/error.log', level: 'error', })); this.logger.add(new winston_1.default.transports.File({ filename: 'logs/combined.log', })); } } info(message, context) { this.logger.info(message, context); } warn(message, context) { this.logger.warn(message, context); } error(message, context) { this.logger.error(message, context); } debug(message, context) { this.logger.debug(message, context); } // Specialized logging methods logApiRequest(endpoint, params) { this.info('API Request Started', { operation: 'api_request', endpoint, ...(params && { params }), }); } logApiResponse(endpoint, duration, success) { if (success) { this.info('API Request Completed', { operation: 'api_response', endpoint, duration, success, }); } else { this.warn('API Request Failed', { operation: 'api_response', endpoint, duration, success, }); } } logApiError(endpoint, error, duration) { this.error('API Request Error', { operation: 'api_error', endpoint, error: error.message || error, ...(duration !== undefined && { duration }), }); } logCharacterOperation(operation, characterName, context) { this.info(`Character ${operation}`, { operation: `character_${operation}`, characterName, ...context, }); } logGuildOperation(operation, guildName, worldName, context) { this.info(`Guild ${operation}`, { operation: `guild_${operation}`, guildName, worldName, ...context, }); } logMcpOperation(operation, toolName, context) { this.info(`MCP ${operation}`, { operation: `mcp_${operation}`, toolName, ...context, }); } } exports.McpLogger = McpLogger; //# sourceMappingURL=logger.js.map