2025-12-17 14:50:07 +09:00
|
|
|
/**
|
|
|
|
|
* Logger for MCP server
|
|
|
|
|
*
|
|
|
|
|
* CRITICAL: MCP servers communicate via STDIO (stdin/stdout).
|
|
|
|
|
* Using console.log() will corrupt the JSON-RPC protocol messages.
|
|
|
|
|
* ALL logging MUST use console.error() which writes to stderr.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
export const log = {
|
|
|
|
|
info: (msg: string, ...args: unknown[]) => {
|
|
|
|
|
console.error(`[MCP-DrawIO] [INFO] ${msg}`, ...args)
|
|
|
|
|
},
|
|
|
|
|
error: (msg: string, ...args: unknown[]) => {
|
|
|
|
|
console.error(`[MCP-DrawIO] [ERROR] ${msg}`, ...args)
|
|
|
|
|
},
|
|
|
|
|
debug: (msg: string, ...args: unknown[]) => {
|
2026-10-05 22:39:32 +09:00
|
|
|
// process is missing when the web app runs this code in the browser
|
|
|
|
|
if (typeof process !== "undefined" && process.env.DEBUG === "true") {
|
2025-12-17 14:50:07 +09:00
|
|
|
console.error(`[MCP-DrawIO] [DEBUG] ${msg}`, ...args)
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
warn: (msg: string, ...args: unknown[]) => {
|
|
|
|
|
console.error(`[MCP-DrawIO] [WARN] ${msg}`, ...args)
|
|
|
|
|
},
|
|
|
|
|
}
|