Build a Custom Microsoft Clarity MCP That Connects to Any AI

Build a Custom Microsoft Clarity MCP That Connects to Any AI

Written by:Zahid

October 15, 2026

claritymcpaianalyticsclaudecursordeveloper-tools

Microsoft Clarity gives you free heatmaps, session recordings, and behavioral analytics. The problem is getting that data into the AI tools you already use every day.

Microsoft released an official Clarity MCP Server (@microsoft/clarity-mcp-server) so agents like Claude Desktop, Cursor, and Claude Code can query your analytics in natural language. It works, but it has real constraints. At Apexion Studio we run a custom version that plugs into our own analytics workflow and connects cleanly with multiple AI clients. This post explains the official server, where it falls short, and how you can build (or adapt) a custom one for your own site or clients.

What the Official Clarity MCP Gives You

The official server exposes three tools:

You start it with:

npx @microsoft/clarity-mcp-server --clarity_api_token=YOUR_TOKEN

Then add it to any MCP client config (Claude Desktop, Cursor, Claude Code, VS Code, etc.).

Important Limits

Clarity’s Data Export API enforces:

These limits are fine for occasional checks. They become frustrating when you want daily reports, historical trends, or to share the same data with multiple AI tools and team members.

Why a Custom MCP Makes Sense

A custom Clarity MCP can:

At Apexion Studio we use a Clarity integration through our own connector so analytics questions can be answered directly inside AI conversations about the site. The same pattern works for any agency or product team that wants Clarity data available wherever their AI tools live.

How to Build Your Own (High-Level)

You don’t have to start from scratch. Two practical paths:

  1. Wrap the official server — Run @microsoft/clarity-mcp-server as a dependency and add a thin layer that caches responses, logs usage, and presents a simpler tool interface.
  2. Write a small custom server — Use the official MCP TypeScript SDK (@modelcontextprotocol/sdk) and call the Clarity Data Export API yourself. This gives full control over tool names, parameters, and caching.

Minimal steps for a custom server:

  1. Generate a Clarity API token (Project Settings → Data Export).
  2. Create a Node/TypeScript project and install the MCP SDK.
  3. Define tools that accept natural-language or structured queries and map them to Clarity API calls.
  4. Add a simple in-memory or file-based cache keyed by query + date range.
  5. (Optional) Persist daily snapshots so historical queries become possible.
  6. Configure your AI client to start the server the same way it starts any other local MCP.

Example client config snippet (works with most MCP clients):

{
  "mcpServers": {
    "clarity-custom": {
      "command": "node",
      "args": ["./dist/index.js"],
      "env": {
        "CLARITY_API_TOKEN": "your-token-here"
      }
    }
  }
}

Once it is running, you can ask things like:

Offering This as a Service

For design and development studios, a lightweight custom Clarity MCP is a useful offering:

The official server already proves the concept. A small amount of customization removes the daily quota friction and makes the data available across whatever AI tools your team (or your clients) already use.

If you want help wiring Clarity into your own AI workflow or building a small custom MCP for a client project, the pattern is straightforward once the token and caching layer are in place.


Have you connected Clarity to an AI client yet? What questions do you wish you could ask it?

Related Articles