Skip to main content
Glama

measuremysite-mcp

Cookieless web analytics your AI agent can read. A small analytics server for one website, with an MCP server built in, so Claude Code, Cursor or Codex can look at your traffic and help you decide what to do next.

You deploy it to your own Cloudflare account (Workers + D1, the free tier is enough for most small sites). Your data stays in your account.

This repo used to be called agentlytics-mcp. The worker, database, tracker (agentlytics.track) and MCP server keep that name so existing installs keep working.

Example questions an agent answers with measuremysite-mcp: audience, funnels, best channel and tracked launches

Example questions and answers; the numbers are illustrative.

Hosted MCP server: https://a.measuremy.site/mcp

Don't want to run it yourself? measuremy.site is the hosted version (site.measuremy/analytics in the MCP registry): the same MCP tools, plus a dashboard, AI explanations of traffic spikes, tracking of posts that mention you (Hacker News, Bluesky, YouTube...), alerts and weekly summaries. Streamable HTTP with OAuth: you sign in through the browser the first time, and no API key is pasted anywhere. 30-day free trial, no card; plans from $9 a month.

VS Code (Copilot): in .vscode/mcp.json, or MCP: Add Server → HTTP. VS Code asks you to sign in when the server starts.

{
  "servers": {
    "measuremysite": { "type": "http", "url": "https://a.measuremy.site/mcp" }
  }
}

Claude Code

claude mcp add --scope user --transport http measuremysite https://a.measuremy.site/mcp

Cursor (~/.cursor/mcp.json)

{ "mcpServers": { "measuremysite": { "url": "https://a.measuremy.site/mcp" } } }

On sign-in you create an account (or log in) and enter your site's domain. Then ask your agent to "add measuremy.site analytics to this project": the server hands it the script tag for your site. Docs: measuremy.site/docs/mcp.

The rest of this README covers the self-hosted version.

Related MCP server: KrystalView MCP Server

What your agent can do

Ask in plain words, for example:

  • "Why did traffic jump yesterday?" It finds the spike and the source, page or event behind it.

  • "Where do people drop off between the homepage and signup?" It builds a funnel and shows the biggest drop.

  • "What's working, and what should I post next?" It ranks channels by conversions and turns that into steps.

  • "Make a tracked link for my Reddit post, and check how it did next week."

Tools exposed over MCP:

Area

Tools

Traffic

get_overview, get_timeseries, top_sources, top_pages, top_countries, top_browsers, top_systems, list_events

Questions about visits

query_visits (filter and group by country, browser, OS, source, page, event, day), recent_visits

Spikes

find_traffic_spikes, explain_spike (ranked causes, plus your annotations)

Funnels

create_funnel, get_funnel, delete_funnel

Growth

get_whats_working, get_growth_actions

Campaigns

create_tracked_link, get_campaign_results, add_annotation

Plus a plan_marketing prompt that walks the agent through a data-backed plan.

Privacy

  • No cookies and nothing stored in the visitor's browser.

  • No IP address or user agent is stored. A visitor id is a hash that changes every day, so nobody can be followed from one day to the next.

  • Only browser and OS names (like "Firefox", "macOS") and the country Cloudflare reports are kept.

  • Raw events are deleted after 400 days; hourly totals are kept.

Check what applies where you and your visitors are; this is not legal advice.

Deploy

One click

Deploy to Cloudflare

The button copies this repo to your GitHub account, creates the D1 database, runs the migrations and deploys the worker. It asks for three settings:

  • SITE_DOMAIN: your website's domain, like example.com (no https:// or www)

  • HASH_SECRET: any long random string, used to make the daily visitor id

  • MCP_READ_KEY: another long random string, the key your AI agent uses

Generate the two random values with openssl rand -hex 32, and keep MCP_READ_KEY for connecting your agent below.

By hand

You need a Cloudflare account and Node.js 20+.

git clone https://github.com/developeron29/measuremysite-mcp.git
cd measuremysite-mcp
npm install
npx wrangler login
  1. Create the database and paste the printed database_id into wrangler.jsonc:

    npx wrangler d1 create agentlytics-mcp
  2. Set the three settings. Use long random values for the two keys, for example from openssl rand -hex 32:

    npx wrangler secret put SITE_DOMAIN     # e.g. example.com
    npx wrangler secret put HASH_SECRET     # makes the daily visitor id; never share it
    npx wrangler secret put MCP_READ_KEY    # the key your agent uses; keep it out of your repo

    Wrangler may offer to create the worker on the first secret put; say yes.

  3. Deploy (this also creates the tables):

    npm run deploy

Either way you get a worker URL like https://agentlytics-mcp.<you>.workers.dev. Opening it shows a status page with your domain. You can attach a custom domain such as stats.yourdomain.com in the Cloudflare dashboard.

Optional rate limit: to cap how often one IP can send hits, add this to wrangler.jsonc and deploy again:

"ratelimits": [{ "name": "COLLECT_LIMITER", "namespace_id": "1001", "simple": { "limit": 120, "period": 60 } }]

Add the tracker to your site

Put this in the <head> of every page:

<script defer src="https://YOUR-WORKER-URL/t.js"></script>

It counts pageviews, including client-side navigation in single-page apps. To count something that matters, like a signup:

agentlytics.track("signup", { plan: "pro" });

or without JavaScript, on any element:

<button data-agentlytics-event="cta_click">Start free</button>

Only pages on SITE_DOMAIN (and its subdomains) are counted.

Connect your agent

Claude Code

claude mcp add --scope user --transport http agentlytics https://YOUR-WORKER-URL/mcp --header "Authorization: Bearer YOUR_MCP_READ_KEY"

Cursor (.cursor/mcp.json or ~/.cursor/mcp.json)

{
  "mcpServers": {
    "agentlytics": {
      "url": "https://YOUR-WORKER-URL/mcp",
      "headers": { "Authorization": "Bearer YOUR_MCP_READ_KEY" }
    }
  }
}

Codex (~/.codex/config.toml)

[mcp_servers.agentlytics]
url = "https://YOUR-WORKER-URL/mcp"
bearer_token_env_var = "AGENTLYTICS_READ_KEY"

and export AGENTLYTICS_READ_KEY=YOUR_MCP_READ_KEY in the shell that starts Codex.

Then ask: "Use agentlytics to tell me how my site did this week." Spikes need a few days of traffic to compare against.

Let your agent do the setup

Point your coding agent at AGENTS.md: "Deploy measuremysite-mcp for my site by following AGENTS.md". It walks through every step and asks you before anything that needs your Cloudflare login.

Self-hosted or hosted?

measuremysite-mcp (this repo)

measuremy.site

MCP tools for your agent

Yes

Yes

Cookieless tracking, funnels, spikes, campaigns

Yes

Yes

Sites

One per deploy

Several, one account

Dashboard

No (ask your agent)

Yes, with filters and a public share link

AI explanations of spikes

No

Yes

Posts that mention you (HN, Lobsters, Bluesky, YouTube, Reddit)

No

Yes, on your traffic chart

Alerts, weekly email summary

No

Yes

Who runs it

You, on your Cloudflare account

Us

Price

Free (your Cloudflare usage)

30-day free trial, then from $9 a month

Develop

cp .dev.vars.example .dev.vars   # then edit the values
npm run db:migrate:local
npx wrangler dev
npm test
npm run typecheck

scripts/stdio.sh runs the server locally and serves MCP over stdio, for clients that start a server as a command (Glama uses it). It needs SITE_DOMAIN, HASH_SECRET and MCP_READ_KEY in the environment.

License

MIT. See LICENSE.

Available Tools

20 tools
add_annotationAInspect

Record something that may move traffic (deploy, launch, post, email, ad). Future spikes within 24h after it list it as a possible cause. Log what you ship or run.

Inputs: label (required), ts, kind.

create_funnelAInspect

Save a funnel: an ordered list of 2-8 steps visitors move through, e.g. ["/", "/login", "signup"]. A step starting with / is a page (exact path, or a prefix ending in , like /docs/); anything else is a custom event name (from agentlytics.track or an element with data-agentlytics-event). Returns the funnel with its first results. Visitors are matched within a single UTC day.

Inputs: name (required), steps (required), range.

delete_funnelCInspect

Delete a saved funnel by name or id.

Inputs: id, name.

explain_spikeAInspect

Ranked causes for one spike: which referrers/UTM sources, landing pages and custom events rose above baseline (with lift, % and share of the spike), plus annotations (deploys, posts, emails) in the preceding 24h.

Inputs: spike_id (required).

find_traffic_spikesAInspect

Detected traffic jumps (hourly pageviews far above the same hour in prior weeks), biggest first, each with its likely causes.

Inputs: limit, range.

get_campaign_resultsAInspect

Traffic and same-day conversions per tracked campaign (from create_tracked_link), newest first. Omit campaign for all.

Inputs: campaign.

get_funnelAInspect

Where visitors drop off. Shows, for each step, how many visitors reached it, the share of the first step and of the previous step, how many were lost, and the biggest drop. Pass name or id for a saved funnel, steps to try an unsaved one, or nothing to get every saved funnel.

Inputs: id, name, range, steps.

get_growth_actionsAInspect

Ranked, concrete growth actions derived from this site's data (channels to double down on, pages to promote, what caused past spikes, best time to publish), each with evidence, steps, a suggested tracked link and how to measure it. Use this to build and then execute a marketing plan.

Inputs: range.

get_overviewAInspect

Visitors and pageviews for the range, change vs the previous equal-length period, plus top sources, pages and events. Start here.

Inputs: range.

get_timeseriesCInspect

Pageviews and unique visitors over time, bucketed by hour or day.

Inputs: range, granularity.

get_whats_workingAInspect

Evidence for marketing planning: channels ranked by conversions with growth and conversion rate, growing pages, and spike causes that recur. Use this before proposing marketing ideas.

Inputs: range.

list_eventsBInspect

Custom events (from agentlytics.track) ranked by count.

Inputs: limit, range.

query_visitsAInspect

Answer questions about this site's visits: count pageviews (or custom events) and unique visitors that match filters, optionally grouped. Examples: iOS visitors from the US last week (os=iOS, country=US); where Firefox users come from (browser=Firefox, group_by=source); signups per country (event=signup, group_by=country); /pricing views per day (page=/pricing, group_by=day). Only counts are returned; the site stores no IP addresses or user agents.

Inputs: os, page, type, event, +7 more.

recent_visitsAInspect

The most recent individual visits (newest first) matching the same filters as query_visits: time, page, source, country, browser, OS and event properties. visitor is a short code that changes daily, so it only shows which rows on one day came from the same browser. No IP addresses or user agents are stored.

Inputs: os, page, type, event, +6 more.

top_browsersBInspect

Browsers ranked by pageviews: Chrome, Firefox, Safari, Edge, Opera, Samsung Internet, Other. Visits recorded before browser tracking began are Unknown.

Inputs: limit, range.

top_countriesBInspect

Visitor countries ranked by pageviews, with the country name ("XX" is unknown).

Inputs: limit, range.

top_pagesCInspect

Pages ranked by pageviews.

Inputs: limit, range.

top_sourcesBInspect

Traffic sources (UTM source, else referrer host, else direct) ranked by pageviews.

Inputs: limit, range.

top_systemsBInspect

Operating systems ranked by pageviews: Windows, macOS, iOS, Android, Linux, ChromeOS, Other. Visits recorded before this tracking began are Unknown.

Inputs: limit, range.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3.4/5.0

    Scored across 20 tools

    Disambiguation4/5

    Most tools have clearly distinct purposes: the top_* family splits cleanly by dimension, and query_visits (aggregates) vs recent_visits (individual rows) are well separated. The only mildly fuzzy boundary is between get_whats_working and get_growth_actions, which both deal with marketing evidence/planning, though one analyzes and the other prescribes actions.

    Naming Consistency4/5

    Names use consistent snake_case and mostly follow verb_noun or prefix_noun patterns (get_overview, create_funnel, top_pages, delete_funnel). Minor deviations like recent_visits, find_traffic_spikes, and explain_spike break the strict pattern but remain readable and predictable.

    Tool Count4/5

    20 tools is on the heavy side but each covers a distinct analytics surface (traffic, sources, geo, tech, funnels, campaigns, spikes, annotations), so the set feels justified rather than padded. It sits at the upper edge of the ideal 3-15 range but is reasonable for a full-featured web analytics platform.

    Completeness4/5

    Coverage is broad: overview, timeseries, dimensional breakdowns, custom queries, raw recent visits, funnel create/get/delete, spike detection and explanation, annotations, tracked links, and campaign results. Minor gaps exist (no funnel update, limited event management), but core analytics and lifecycle workflows are covered with no obvious dead ends.

    Maintenance

    ActivitySlowing
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      D
      maintenance
      Privacy friendly, cookieless web analytics built MCP-first. "Add analytics to my Next.js app" → an AI agent runs the setup_analytics_for_site tool, picks the right install snippet, edits your layout file, and verifies the script is loading. OAuth onboarding, no API keys to paste.
      28
      1
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables AI assistants to answer growth questions in plain English by connecting to marketing and product data via 49 MCP tools.
      22
      MIT
    • A
      license
      A
      quality
      D
      maintenance
      First-party web analytics MCP server for AI agents, providing 42 tools to query traffic, events, funnels, conversions, sources, and performance data.
      40
      45 npm
      MIT