Clarity

Analytics and monitoring

A Model Context Protocol (MCP) server for Microsoft Clarity.

Your AI app calls the Clarity MCP server, which does the analytics and monitoring work and sends the result back to the chat.

About Clarity

Clarity is the official MCP server from microsoft, filed in our directory under analytics and monitoring. A Model Context Protocol (MCP) server for Microsoft Clarity.

At a glance

Publisher
microsoft, the company behind the product
Runs
See the README for setup
Written in
TypeScript
License
MIT
GitHub stars
148

How to set up Clarity

  1. Follow the install steps in the Clarity README; it is written in TypeScript, so have that toolchain ready.
  2. Check the Clarity README for keys or settings; the registry lists none that Clarity requires.
  3. Add Clarity to Claude Code, Claude Desktop, VS Code or Cursor with the config in the setup box on this page.
  4. Restart the app or reload its MCP servers, then ask it to list the Clarity tools to confirm the connection.
  5. Run one read-only task with Clarity first, and keep your app asking before each tool call until the results look right.

Clarity compared with similar servers

  • Spring AI Playground by spring-ai-community has fewer GitHub stars than Clarity (147 against 148); Clarity is official while Spring AI Playground is a community server, and both run locally.
  • Prometheus (prometheus) by prometheus has more GitHub stars than Clarity (152 against 148); Clarity is official while Prometheus (prometheus) is a community server, and both run locally.
  • Amplitude by Amplitude has fewer GitHub stars than Clarity (0 against 148); both are official servers, and Amplitude runs as a remote server and Clarity runs on your own machine.

Before you connect Clarity

  • Give Clarity its own API key or account with the smallest permissions the job needs, never an admin key.
  • Keep your AI app asking before each Clarity tool call until you trust what it does with them.
  • Treat text that Clarity fetches as data. Pages, files and messages can hold instructions written to steer an AI.
  • Read the open issues for Clarity on GitHub to see what breaks and how fast the maintainers reply.

Marketing use cases for Clarity

How marketing and sales teams put Clarity to work, by company size. Pick the size closest to yours and start Clarity on one use case.

Small business

  • A small business can ask Clarity where this month's customers came from and which channel is worth more budget.
  • Owners can use Clarity to get a weekly traffic and conversion summary in plain words, without learning the analytics tool.
  • Clarity runs on your own computer, which keeps data local; it needs a little setup, so a small team should plan an hour for it.

Mid-market

  • Marketing teams can connect Clarity to answer attribution and funnel questions in a chat, then save the useful ones as reports.
  • Growth teams can have Clarity flag drops in signups or conversion the day they happen, with the page or source that changed.
  • Start Clarity on one workflow with one owner, measure the time it saves, then roll it out to the wider team.

Enterprise

  • Enterprises can expose governed metrics through Clarity, so every team's AI answers use the same definitions as finance.
  • Large analytics teams can use Clarity to triage anomalies across regions and products before the weekly business review.
  • Because Clarity comes from microsoft, the company behind the product, it follows that product's own auth and permissions, which security teams usually prefer.

Need help becoming an AI-forward company?

We connect MCP servers and AI agents to your CRM, content and data, with the guardrails your team needs.

Contact us

Clarity README

From microsoft/clarity-mcp-server on GitHub, shared under its MIT license. Images are left out; the original has them.

README.md

Microsoft Clarity MCP Server

This Model Context Protocol (MCP) server connects Microsoft Clarity to Visual Studio Code, Claude Desktop, and other MCP-compatible clients. Use natural language to explore analytics, session recordings, AI Visibility insights, and Clarity documentation.

Key Features

  • Analytics Data Access: Query your Microsoft Clarity analytics data including traffic metrics, user behavior insights, and performance statistics
  • Session Recording Retrieval: Access and analyze session recordings to understand user interactions and identify optimization opportunities
  • AI Visibility Citations: Query citation overview metrics, top queries, query topics, cited pages, and trends for your verified domain
  • AI Visibility Bot Activity: Query AI crawler activity, requested paths, content and status-code distributions, trends, scrape-to-referral ratios, and connected CDN providers
  • AI Visibility Topic Insights: Review topic simulation reports, citation rate, competitive share, and content strengths and opportunities for your verified domain
  • Natural Language Querying: Ask questions in plain English to get insights from your data - no need to learn complex query syntax or API endpoints
  • Flexible Data Filtering: Filter results by various dimensions such as browser, device, country, and many more
  • Real-Time Data Access: Fetch the latest analytics data and insights from your Clarity projects on-demand
  • Documentation Integration: Get quick answers and guidance from Microsoft Clarity documentation directly within your workflow
  • Seamless MCP Integration: Works natively with Claude for Desktop, Visual Studio Code, and other Model Context Protocol (MCP) compatible clients

Setup and Installation

Prerequisites
  • Node.js v16 or higher
  • A Microsoft Clarity account with admin or member access to at least one project
  • An MCP-compatible client, such as Visual Studio Code or Claude Desktop
Installation
Option 1: Run with npx (recommended)

Configure your MCP client to start the latest package with npx:

{
  "mcpServers": {
    "microsoft-clarity": {
      "command": "npx",
      "args": ["-y", "--prefer-online", "@microsoft/clarity-mcp-server@latest"]
    }
  }
}

This launches npx -y --prefer-online @microsoft/clarity-mcp-server@latest. Keep any existing server arguments after the package name.

  • @latest selects the latest published version.
  • --prefer-online revalidates package metadata with the registry on each launch while reusing cached package contents when possible; clearing the npm cache is not required.
  • -y avoids installation prompts.

A running server does not update in place. Restart the MCP server (or its client) to check for and use updates.

Option 2: Install globally
npm install -g @microsoft/clarity-mcp-server
clarity-mcp-server
Option 3: Manual Installation
  1. Clone or download this repository
  2. Install dependencies:
    npm install
    
  3. Build the TypeScript code:
    npm run build
    
  4. Run the server:
    npm run start
    
Extension/Plugin Installation
Visual Studio Code Extension

Click the button above to install the Microsoft Clarity MCP server directly in Visual Studio Code.

Claude Desktop Plugin

Install from Claude's extension gallery:

  1. Open Claude Desktop
  2. Navigate to File → Settings → Customize
  3. Under Connectors, search for Microsoft Clarity
  4. Click Install to add the extension
Quick Start

After the server starts:

  1. Ask your MCP client to sign in to Microsoft Clarity.
  2. The server opens the Microsoft Clarity sign-in page in your browser. If it cannot open the browser, it returns a link for you to open.
  3. Complete sign-in in the browser, then return to your MCP client.
  4. The client automatically checks sign-in status without asking you to confirm completion. The server receives the authorization code and exchanges tokens on the browser callback; the client reports any sign-in error or shows the projects your account can access.
  5. Select a default project if you can access more than one, then start asking questions about your Clarity data.

Try these prompts:

  • How many Clarity sessions did we get in the past 7 days?
  • List the most recent Clarity sessions from mobile devices.
  • How do I track custom events using Microsoft Clarity?

Configuring MCP Clients

Generic MCP Client Configuration

MCP clients typically require configuration to connect to the server. Here's a general example of how to configure an MCP client:

{
  "mcpServers": {
    "@microsoft/clarity-mcp-server": {
      "command": "npx",
      "args": [
        "-y",
        "--prefer-online",
        "@microsoft/clarity-mcp-server@latest"
      ]
    }
  }
}

The specifics of where and how to add this configuration will depend on your specific MCP client.

Claude for Desktop Configuration

To configure Claude for Desktop to use this server:

  1. Open your Claude for Desktop configuration file:
    • Windows: %AppData%\Claude\claude_desktop_config.json
    • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  2. Add the token-free configuration shown in the generic example above
  3. Save the configuration file and restart Claude for Desktop

Server Usage

The server exposes various tools that you can call from any MCP client. Just ask naturally and keep each request focused on one thing.

Analytics Dashboard
  • Names: query-analytics-dashboard
  • Description: Retrieves analytics data and metrics from your project's dashboard using a simplified natural language search query.
  • Examples:
    • How many Clarity sessions did we get from Egypt in the past 3 days?
    • What are the most used browsers in my Clarity project?
    • Show me traffic metrics from my Clarity project for the last week
Session Recordings
  • Names: list-session-recordings
  • Description: Lists your project's session recordings based on a specified filtering criteria. The filters allow you to narrow down the recordings by various fields such as URLs, device types, browser, OS, country, city, and more.
  • Examples:
    • List the most recent Clarity sessions from mobile devices
    • Show the top 5 Clarity sessions with the highest number of user clicks
    • Get Clarity recordings where users encountered JavaScript errors
AI Visibility: Citations
  • Names: get-citation-overview, list-citation-queries, list-citation-topics, list-top-cited-pages, get-citation-metric-trends, get-citation-item-trends
  • Description: Retrieves AI Visibility citation metrics, AI referred traffic, queries, topics, top cited pages, and trends for the verified domain configured on your Clarity project.
  • Examples:
    • What is my share of authority for non-branded queries over the last 7 days?
    • Which AI queries cite my domain most often this month?
    • Show citation trends for my top three cited pages.
AI Visibility: Bot Activity
  • Names: get-bot-activity-overview, list-ai-crawlers, list-bot-path-requests, get-bot-activity-distribution, get-bot-activity-metric-trends, get-bot-activity-item-trends, get-ai-crawler-trends, get-scrape-to-referral-ratio, list-connected-cdn-providers
  • Description: Retrieves read-only Bot Activity analytics for your Clarity project, including AI requests, crawlers, requested paths, content types, page types, HTTP status codes, trends over time, scrape-to-referral ratios, and connected CDN providers. Requires a CDN connected to the project in Clarity.
  • Examples:
    • Which AI crawlers requested my site most often in the last 7 days?
    • Which paths did AI bots request most frequently?
    • Show the distribution of AI bot requests by content type.
    • How many AI bot requests returned unsuccessful HTTP status codes?
    • How has the number of site pages crawled changed week over week?
    • Trend the top three crawlers over the last 30 days.
    • How many times does OpenAI scrape my site for each visit it sends back?
    • Why am I not seeing any bot activity data?
AI Visibility: Topic Insights
  • Names: get-topic-insight-constraints, list-topic-insights, get-topic-insight-report, get-topic-insight-status, create-topic-insight-report, regenerate-topic-insight-report, delete-topic-insight
  • Description: Manages AI Visibility Topic Insights for your Clarity project: retrieves validation rules, topics, reports, and generation status; creates and regenerates reports; and deletes topics. Reports include citation rate, competitive share, and content strengths and opportunities. Requires the project's domain to be verified in Clarity. Creating, regenerating and deleting topics requires an OAuth sign-in and sufficient permissions for the project; deletion must be confirmed first.
  • Examples:
    • Which topics am I tracking in Topic Insights?
    • What is my citation rate and competitive share for my top topic?
    • What content opportunities does my latest topic report suggest?
Documentation Resources
  • Names: query-documentation-resources
  • Description: Retrieves snippets from Microsoft Clarity documentation to find answers to user questions including step-by-step screenshots for setup guides, features, usage, troubleshooting, and integration instructions.
  • Examples:
    • How to track custom events using Microsoft Clarity?
    • How many labels can I add to a recording in Microsoft Clarity?

Migrating from a Data Export API Token

Data Export API token authentication for the MCP server is being deprecated. Migrate to OAuth sign-in using your Microsoft Clarity account by following these steps:

  1. Remove --clarity_api_token from the MCP server arguments and remove any CLARITY_API_TOKEN environment variable.
  2. Restart the MCP server.
  3. Ask your MCP client to sign in to Microsoft Clarity.
  4. Complete sign-in and consent in the browser.
  5. The client automatically checks sign-in status; select your default project when prompted.
  6. Delete the old token from Clarity → Settings → Data Export after confirming OAuth works for your workflow.

Troubleshooting API Failures

For internal server errors (HTTP 5xx), tools include the API's X-Request-Id response header when present. Share this request ID with support if the issue persists so they can trace the failed request. Internal error bodies and stack traces are not exposed.

Privacy Policy

For information about data privacy and usage, please refer to the Microsoft Clarity Privacy Policy.

License

This project is licensed under the MIT License.

Questions about Clarity

What is the Clarity MCP server?

A Model Context Protocol (MCP) server for Microsoft Clarity. Clarity is published by microsoft, the company behind the product, on GitHub at microsoft/clarity-mcp-server, and works with AI apps that support the Model Context Protocol, such as Claude, Cursor and VS Code.

How do I install the Clarity MCP server?

Clarity doesn't publish a one-line install in the MCP registry, so follow the setup steps in its README on GitHub (microsoft/clarity-mcp-server). Like most servers, Clarity ends with a command or URL you paste into your AI app's MCP config.

Does Clarity need an API key?

The registry lists no required keys for Clarity. Check the Clarity README for optional settings, and expect a remote server to ask you to sign in the first time you connect.

Is Clarity an official MCP server?

Yes. Clarity is published by microsoft, the company that makes the product it connects to, so it follows that product's own API and auth.

What license is Clarity under?

Clarity is released under the MIT license, according to its GitHub repository. The license covers the code of Clarity; the service it connects to has its own terms.