Skip to main content
Glama

SearXNG Server

logging.ts1.66 kB
import { Server } from "@modelcontextprotocol/sdk/server/index.js"; import { LoggingLevel } from "@modelcontextprotocol/sdk/types.js"; // Logging state let currentLogLevel: LoggingLevel = "info"; // Logging helper function export function logMessage(server: Server, level: LoggingLevel, message: string, data?: unknown): void { if (shouldLog(level)) { try { // Merge message and data together for the notification body const notificationData = data !== undefined ? (typeof data === 'object' && data !== null ? { message, ...data } : { message, data }) : { message }; server.notification({ method: "notifications/message", params: { level, data: notificationData } }).catch((error) => { // Silently ignore "Not connected" errors during server startup // This can happen when logging occurs before the transport is fully connected if (error instanceof Error && error.message !== "Not connected") { console.error("Logging error:", error); } }); } catch (error) { // Handle synchronous errors as well if (error instanceof Error && error.message !== "Not connected") { console.error("Logging error:", error); } } } } export function shouldLog(level: LoggingLevel): boolean { const levels: LoggingLevel[] = ["debug", "info", "warning", "error"]; return levels.indexOf(level) >= levels.indexOf(currentLogLevel); } export function setLogLevel(level: LoggingLevel): void { currentLogLevel = level; } export function getCurrentLogLevel(): LoggingLevel { return currentLogLevel; }

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/ihor-sokoliuk/mcp-searxng'

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