Skip to main content
Glama
debug.ts1.12 kB
import process from "node:process"; export type Debugger = (msg: unknown) => void; export function Debug(namespace: string): Debugger { const debugActive = process.env.SI_LANG_JS_LOG || process.env.SI_LOG; return (msg: unknown) => { if (debugActive) { try { const pretty_json = safeStringify(msg); for (const line of pretty_json.split("\n")) { process.stderr.write(`${namespace} ${line}\n`); } } catch { process.stderr.write( `${namespace} [Debug Error: Unable to stringify message]\n`, ); } } }; } function safeStringify(obj: unknown): string { const seen = new WeakSet(); return JSON.stringify(obj, (_, value) => { if (typeof value === "function") { return value.toString(); } if (typeof value === "object" && value !== null) { if (seen.has(value)) { return "[Circular]"; } seen.add(value); } if (value instanceof Error) { return { name: value.name, message: value.message, stack: value.stack, }; } return value; }, 2); }

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/systeminit/si'

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