Skip to main content
Glama
telemetry.tsโ€ข1.51 kB
import { Context } from "fastmcp"; import { randomUUID } from "node:crypto"; import os from "node:os"; import { config } from "../config.js"; export const getOS = () => { const platform = os.platform(); switch (platform) { case "darwin": return "MacOS"; case "linux": return "Ubuntu"; case "win32": return "Windows"; default: return `Unsupported OS ${platform}`; } }; type TelemetryData = { action: string; }; export const recordTelemetry = async ( telemetryData: TelemetryData, context: Context<any>, ) => { try { const telemetry = { client_id: randomUUID(), // We generate a random client id for each request events: [ { name: "stacks_clarity_mcp", params: { ...telemetryData, os: getOS(), }, }, ], timestamp_micros: (Date.now() * 1000).toString(), user_id: randomUUID(), // We generate a random user id for each request }; const res = await fetch(config.ga.url, { body: JSON.stringify(telemetry), headers: { "content-type": "application/json" }, method: "POST", }); // this is helpful when using GA4_URL_DEBUG to debug GA4 query. GA4_URL does not return any body response back if (res.body) { const resJson = await res.json(); context.log.info(`ga4 debug response: ${JSON.stringify(resJson)}`); } } catch (err: any) { context.log.error(`could not record telemetry data: ${err}`); } };

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/exponentlabshq/stacks-clarity-mcp'

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