Skip to main content
Glama
logger.tsâ€ĸ1.97 kB
/** * Logger module for MCP-compatible logging * * This file provides logging utilities that work both in regular console mode * and with the MCP Inspector. It avoids direct console.log calls which can * interfere with MCP's JSON-RPC communication. */ // Logger functions for different log levels function createLogFn(level: string) { return (message: string, data?: any) => { if (process.env.DEBUG === "true") { // In debug mode with MCP Inspector, use process.stderr instead of console.log // This avoids interfering with MCP's JSON-RPC protocol const logObject = { level, timestamp: new Date().toISOString(), message, ...data, }; // Output to stderr which won't interfere with MCP communication process.stderr.write(JSON.stringify(logObject) + "\n"); } }; } // Export log functions export const logger = { info: createLogFn("INFO"), warn: createLogFn("WARN"), error: createLogFn("ERROR"), debug: createLogFn("DEBUG"), // Special handler for TLS config tlsConfig: (rejectUnauthorized: boolean) => { if (process.env.DEBUG === "true") { const message = `TLS certificate validation is ${ rejectUnauthorized ? "enabled" : "disabled" }`; process.stderr.write( JSON.stringify({ level: "INFO", timestamp: new Date().toISOString(), type: "TLS_CONFIG", message, rejectUnauthorized, }) + "\n" ); } }, // Special handler for CSRF token csrfToken: ( type: "fetch" | "success" | "error" | "retry", message: string, data?: any ) => { if (process.env.DEBUG === "true") { process.stderr.write( JSON.stringify({ level: type === "error" ? "ERROR" : "INFO", timestamp: new Date().toISOString(), type: `CSRF_${type.toUpperCase()}`, message, ...data, }) + "\n" ); } }, };

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/fr0ster/mcp-abap-adt'

If you have feedback or need assistance with the MCP directory API, please join our Discord server