Skip to main content
Glama

Clarity Data Export MCP Server

Official
by microsoft
MIT License
187
48
  • Apple
utils.ts1.74 kB
import { CLARITY_API_TOKEN } from "./constants.js"; // Get configuration from environment variables or command-line arguments export const getConfigValue = (name: string, fallback?: string): string | undefined => { // Check command line args first (format: --name=value) const commandArg = process.argv.find(arg => arg.startsWith(`--${name}=`)); if (commandArg) { return commandArg.split('=')[1]; } // Then check environment variables if (process.env[name] || process.env[name.toUpperCase()]) { return process.env[name] || process.env[name.toUpperCase()]; } return fallback; }; export const tryAsync = async (input: string | URL | Request, init?: RequestInit | undefined): Promise<any> => { // Use provided token or fallback to environment/command-line variables // Check if we have the necessary credentials if (!CLARITY_API_TOKEN) { return { content: [ { type: "text", text: "No Clarity API token provided. Please provide a token via the 'token' parameter, CLARITY_API_TOKEN environment variable, or --clarity_api_token command-line argument.", }, ], }; } try { const response = await fetch(input, init); if (!response.ok) { throw new Error(`Endpoint request failed with status: ${input} ${response.status}`); } const data = await response.json(); return { content: [ { type: "text", text: JSON.stringify(data, null, 2), }, ], }; } catch (error) { console.error("Error during fetch:", error); return { content: [ { type: "text", text: "An error occurred while fetching the data.", }, ], }; } };

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/microsoft/clarity-mcp-server'

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