Antlytics logoAntlytics
← Blog
4

Analytics for AI Coding Tools in 2026

How to connect analytics to Cursor, Claude Code, Windsurf, and other AI coding tools using MCP — and why the standard script-tag approach falls short.

Analytics for AI Coding Tools in 2026

In 2026, a meaningful portion of production web code is written with AI assistance. Cursor, Claude Code, Windsurf, Cline, and similar tools are used daily by developers and indie hackers to scaffold projects, add features, and debug issues.

These tools have changed how code gets written. They have not yet changed how analytics gets installed.

The dominant pattern is still: copy a script tag from a dashboard, paste it into a layout file, hope it works. AI tools occasionally automate the copy-paste, but they cannot create analytics accounts, verify installs, configure goals, or generate reports. The analytics workflow breaks at the boundary between the editor and the external service.

The Model Context Protocol (MCP) is the piece that closes this gap. This post explains how it works for analytics specifically, and what a fully agent-native analytics setup looks like in practice.


What MCP is and why it matters for analytics

MCP (Model Context Protocol) is an open protocol developed by Anthropic for connecting AI agents to external tools and data sources. It defines a standard interface for "servers" (tools that expose data and actions) and "clients" (AI systems that consume them).

In practice: an MCP server is a process that runs alongside your AI coding tool and exposes a set of typed tools — functions the AI can call. Claude Desktop, Cursor, Windsurf, Cline, and Zed all support MCP natively. When you connect an MCP server, the AI gains the ability to take real actions in the connected system.

For analytics, this means an AI agent can:

All without you leaving the editor, visiting a dashboard, or copying tracking IDs.


The standard pattern vs the MCP pattern

Standard pattern (without MCP):

  1. Developer visits analytics dashboard, creates a site manually
  2. Copies tracking ID from dashboard
  3. Asks AI tool to add analytics — provides the tracking ID
  4. AI writes the code (may be wrong for the framework)
  5. Developer verifies manually (or doesn't)
  6. Weeks later: realises events were not arriving because the layout component was wrong

MCP pattern:

  1. Developer asks: "Set up Antlytics on this project"
  2. AI calls create_site → gets tracking ID
  3. AI calls get_install_snippet with framework: "nextjs" → gets the correct component and instructions
  4. AI writes the code correctly for the detected framework
  5. AI calls check_install → confirms events are arriving
  6. Done. No dashboard visits, no manual ID copying, no guessing

The difference is not just convenience. It is verification. The AI agent can confirm the install worked — something the standard pattern cannot do.


Setting up MCP for analytics

Antlytics MCP server

The Antlytics MCP server uses OAuth 2.1 for authentication — no API keys to manage. The first time you connect, you authenticate via browser; subsequent connections use a stored token.

Claude Desktop (~/Library/Application Support/Claude/claude_desktop_config.json):

{
  "mcpServers": {
    "antlytics": {
      "command": "npx",
      "args": ["-y", "@antlytics/mcp"]
    }
  }
}

Cursor (.cursor/mcp.json in your project or ~/.cursor/mcp.json globally):

{
  "mcpServers": {
    "antlytics": {
      "command": "npx",
      "args": ["-y", "@antlytics/mcp"]
    }
  }
}

After adding the config, restart your AI tool. The Antlytics MCP server will prompt you to authenticate via browser on first use.

Full setup instructions are in the MCP docs.


What the agent can do

Once connected, you can ask your AI agent to handle analytics tasks in natural language. Here are the tool categories and example prompts:

Setup and install

Create a new Antlytics site for this project called "my-saas" 
and get the Next.js install snippet.

The agent calls create_site and get_install_snippet(framework: "nextjs"), then writes the <Analytics /> component into your layout.

Diagnostic

Check whether my Antlytics install is receiving data.

The agent calls check_install and reports: how many events arrived in the last hour, the last event timestamp, and any suggestions if data is missing.

Goal configuration

Add a conversion goal for visits to /thank-you on my site.

The agent calls create_goal with path_pattern: "/thank-you". Goals are immediately tracked — no dashboard visit required.

Reporting

Give me a traffic report for the last 7 days.

The agent calls generate_report and returns a formatted markdown report covering visitors, pageviews, top pages, referrers, UTM sources, countries, and devices — with period-over-period comparisons.

Ingest management

Pause data collection on my staging site.

The agent calls pause_ingest. Events from the staging tracking ID are silently dropped until you resume.


AI rules files

Beyond MCP, AI rules files are a lightweight way to teach your AI coding tool the correct analytics patterns for your project.

Running npx @antlytics/ai-rules adds Antlytics-specific instructions to:

After adding these files, asking your AI tool to "add analytics to this project" defaults to the Antlytics pattern rather than Google Analytics or a hallucinated placeholder. The instructions include the correct import path, the component API, and a note to use the MCP server if available.

This is useful even if you do not have MCP configured — it prevents the most common mistakes (wrong framework pattern, missing soft navigation tracking, GA4 by default).


The CLI installer

For the initial project setup, the CLI is the fastest path:

npx @antlytics/init

The installer:

  1. Detects your framework (Next.js, Nuxt, SvelteKit, Astro, or generic HTML)
  2. Opens a browser window for OAuth authentication
  3. Creates a new Antlytics site (or lets you select an existing one)
  4. Installs the correct package
  5. Writes the tracking component into your layout
  6. Verifies that events are arriving before exiting

It does not require you to visit the dashboard, copy a tracking ID, or configure anything manually. The verification step at the end confirms the install worked — something most analytics installers skip entirely.


Combining MCP + CLI + AI rules

For a complete developer workflow:

  1. Initial setup: npx @antlytics/init — handles install and verification in one command
  2. Ongoing management: MCP server in Claude Desktop or Cursor — create goals, check installs, generate reports from within the AI tool
  3. AI rules files: npx @antlytics/ai-rules — teaches all AI tools in the project the correct patterns for this codebase

After this setup, analytics is a first-class part of your AI-assisted development workflow. You can ask your agent to check traffic after a feature launch, generate a weekly report, or verify that a new page is being tracked — without touching the dashboard.


What this does not replace

MCP-connected analytics handles setup, management, and reporting well. It is not a replacement for:

The MCP server complements the dashboard — it does not replace it. The dashboard remains useful for ad-hoc exploration; the agent is useful for recurring tasks (weekly reports, install checks, goal setup) that would otherwise require repeated dashboard visits.


Getting started

The fastest path:

  1. Create an account — 14-day free trial, no card required
  2. Run npx @antlytics/init in your project
  3. Connect the MCP server to your AI tool (setup guide)
  4. Ask your agent: "Check if my analytics is set up correctly"

The quick-start guide covers the full workflow from install to first report.