Skip to main content
Glama
logger.ts1.93 kB
/** * Navidrome MCP Server - Logger Utility * Copyright (C) 2025 * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. */ class Logger { private debugMode = false; setDebug(enabled: boolean): void { this.debugMode = enabled; } /** * Sanitize URLs and other sensitive data from log messages * Removes credentials from URLs to prevent accidental exposure */ private sanitizeArgs(args: unknown[]): unknown[] { return args.map(arg => { if (typeof arg === 'string' && arg.includes('://')) { // Check if string contains URL with potential credentials return arg.replace( /(https?:\/\/)[^:/\s]*:[^@/\s]*@/g, '$1[CREDENTIALS_REDACTED]@' ).replace( /([?&])[up]=[^&\s]*/g, '$1[CREDENTIAL_REDACTED]' ); } return arg; }); } debug(...args: unknown[]): void { if (this.debugMode) { console.error('[DEBUG]', ...this.sanitizeArgs(args)); } } info(...args: unknown[]): void { console.error('[INFO]', ...this.sanitizeArgs(args)); } warn(...args: unknown[]): void { console.error('[WARN]', ...this.sanitizeArgs(args)); } error(...args: unknown[]): void { console.error('[ERROR]', ...this.sanitizeArgs(args)); } } export const logger = new Logger();

Latest Blog Posts

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/Blakeem/Navidrome-MCP'

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