UNPKG

context-optimizer-mcp-server

Version:

Context optimization tools MCP server for AI coding assistants - compatible with GitHub Copilot, Cursor AI, and other MCP-supporting assistants

84 lines 2.39 kB
"use strict"; /** * Logger utility for MCP server * * Since MCP servers communicate over stdio using JSON-RPC, all logging output * must be directed to stderr to avoid interfering with the protocol messages. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.Logger = void 0; class Logger { static logLevel = 'info'; static setLogLevel(level) { this.logLevel = level; } static getLogLevel() { return this.logLevel; } static shouldLog(level) { const levels = { error: 0, warn: 1, info: 2, debug: 3 }; return levels[level] <= levels[this.logLevel]; } static error(message, ...args) { if (this.shouldLog('error')) { console.error(`[ERROR] ${message}`, ...args); } } static warn(message, ...args) { if (this.shouldLog('warn')) { console.error(`[WARN] ${message}`, ...args); } } static info(message, ...args) { if (this.shouldLog('info')) { console.error(`[INFO] ${message}`, ...args); } } static debug(message, ...args) { if (this.shouldLog('debug')) { console.error(`[DEBUG] ${message}`, ...args); } } static success(message, ...args) { if (this.shouldLog('info')) { console.error(`[INFO] ${message}`, ...args); } } static config(message, ...args) { if (this.shouldLog('info')) { console.error(`[INFO] ${message}`, ...args); } } static startup(message, ...args) { if (this.shouldLog('info')) { console.error(`[INFO] ${message}`, ...args); } } static security(message, ...args) { if (this.shouldLog('info')) { console.error(`[INFO] ${message}`, ...args); } } static tools(message, ...args) { if (this.shouldLog('info')) { console.error(`[INFO] ${message}`, ...args); } } static file(message, ...args) { if (this.shouldLog('info')) { console.error(`[INFO] ${message}`, ...args); } } static shutdown(message, ...args) { if (this.shouldLog('info')) { console.error(`[INFO] ${message}`, ...args); } } } exports.Logger = Logger; //# sourceMappingURL=logger.js.map