Skip to main content
Glama
microsoft

Clarity Data Export MCP Server

Official
by microsoft

query-analytics-dashboard

Read-only

Analyze Microsoft Clarity data by asking natural language questions about user behavior, session metrics, and device performance with specific time ranges.

Instructions

Fetch Microsoft Clarity analytics data using a simplified natural language search query. The query should be focused on one specific data retrieval or aggregation task. Avoid complex multi-purpose queries. Time ranges should be explicitly specified when possible. If no time range is provided, prompt the user to specify one.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesA natural language search query string for filtering and shaping analytics data. The query should be specific and include temporal constraints when available. (e.g., 'Top browsers last 3 days', 'The active time duration for mobile devices in United States last week'). Time ranges should be explicitly specified when possible. If no time range is provided, prompt the user to specify one.

Implementation Reference

  • src/index.ts:43-57 (registration)
    Registers the 'query-analytics-dashboard' tool (via ANALYTICS_DASHBOARD_TOOL constant) on the MCP server. Specifies description, input schema (SearchRequest), metadata, and an inline async handler function that extracts the query parameter, determines the local timezone, and delegates to the queryAnalyticsDashboardAsync helper function.
    // Register the query-analytics-data tool
    server.tool(
      ANALYTICS_DASHBOARD_TOOL,             /* Name */
      ANALYTICS_DASHBOARD_DESCRIPTION,      /* Description */
      SearchRequest,                        /* Parameter Schema */
      {                                     /* Metadata & Annotations */
        title: "Query Analytics Dashboard",
        readOnlyHint: true,
        destructiveHint: false,
        openWorldHint: false
      },
      async ({ query }) => {
        return await queryAnalyticsDashboardAsync(query, Intl.DateTimeFormat().resolvedOptions().timeZone);
      }
    );
  • Core handler implementation for the 'query-analytics-dashboard' tool. Performs an authenticated POST request to the Microsoft Clarity analytics dashboard API endpoint (ANALYTICS_DASHBOARD_URL) with the provided query and timezone, using the tryAsync utility.
    export async function queryAnalyticsDashboardAsync(
      query: string,
      timezone: string,
    ): Promise<any> {
      return await tryAsync(ANALYTICS_DASHBOARD_URL, {
        method: 'POST',
        headers: {
          'Content-Type': 'application/json',
          ...(CLARITY_API_TOKEN ? { 'Authorization': `Bearer ${CLARITY_API_TOKEN}` } : {}),
        },
        body: JSON.stringify({
          query: query,
          timezone: timezone,
        })
      });
    }
  • Zod-based input schema (SearchRequest) for the 'query-analytics-dashboard' tool, consisting of a single 'query' field validated against SearchQuery (a descriptive string for natural language analytics queries).
    export const SearchRequest = {
      query: SearchQuery,
    };
  • Defines essential constants for the 'query-analytics-dashboard' tool: the tool name (ANALYTICS_DASHBOARD_TOOL), description (ANALYTICS_DASHBOARD_DESCRIPTION), API endpoint URL (ANALYTICS_DASHBOARD_URL), and optional auth token (CLARITY_API_TOKEN). Used across registration, handler, and schema.
    // Tool names.
    export const ANALYTICS_DASHBOARD_TOOL = "query-analytics-dashboard";
    export const DOCUMENTATION_TOOL = "query-documentation-resources";
    export const SESSION_RECORDINGS_TOOL = "list-session-recordings";
    
    // Tool descriptions.
    export const ANALYTICS_DASHBOARD_DESCRIPTION = "Fetch Microsoft Clarity analytics data using a simplified natural language search query. The query should be focused on one specific data retrieval or aggregation task. Avoid complex multi-purpose queries. Time ranges should be explicitly specified when possible. If no time range is provided, prompt the user to specify one.";
    export const DOCUMENTATION_DESCRIPTION = "Retrieve Microsoft Clarity documentation snippets for finding answers to user questions including step-by-step screenshots for setup guides, features, usage, troubleshooting, and integration instructions. The query should be focused on one specific documentation topic or question. Avoid complex multi-purpose queries.";
    export const SESSION_RECORDINGS_DESCRIPTION = "List Microsoft Clarity session recordings based on specified filters. The filters allow you to narrow down the recordings by various criteria such as URLs, device types, browser, OS, country, city, and more. The date filter is required and must be in UTC ISO 8601 format.";
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare readOnlyHint=true, destructiveHint=false, and openWorldHint=false, so the agent knows this is a safe, read-only operation with limited scope. The description adds useful context about query constraints (single-task focus, time range importance) and the fallback behavior ('prompt the user to specify one'), which goes beyond annotations. However, it doesn't describe rate limits, authentication needs, or response format details.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized with four sentences that each add value: purpose statement, query constraints, time range guidance, and fallback behavior. It's front-loaded with the core functionality. Some minor redundancy with the schema description exists, but overall it's efficient.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the single parameter with 100% schema coverage and annotations covering safety/scope, the description adds reasonable context about query constraints and user prompting. However, with no output schema, the description doesn't explain what data format or structure is returned, which is a gap for an analytics tool. The description is adequate but not comprehensive for this complexity level.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100% with one parameter 'query' fully documented in the schema. The description reinforces the same constraints (natural language, specific, include time ranges) but doesn't add significant new semantic information beyond what's already in the schema. The baseline of 3 is appropriate when the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb 'fetch' and resource 'Microsoft Clarity analytics data' with the mechanism 'simplified natural language search query'. It distinguishes from sibling tools like 'list-session-recordings' by focusing on analytics data retrieval rather than recordings or documentation. However, it doesn't explicitly contrast with 'query-documentation-resources' beyond the analytics focus.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context for when to use this tool: for 'one specific data retrieval or aggregation task' with 'time ranges explicitly specified'. It warns against 'complex multi-purpose queries'. While it doesn't explicitly name sibling alternatives, it implies this is for analytics queries rather than documentation or recordings. No explicit exclusions are provided.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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

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