Skip to content

MCP server, CLI and API

Ask an AI assistant about your website analytics

Statsy is web analytics with revenue attribution, and it comes with three ways to reach the numbers without opening a dashboard: a hosted Model Context Protocol (MCP) server that AI assistants connect to, a command line tool published on npm, and a REST API. Ask Claude which channel brought the most paying customers last month, print revenue by channel in a terminal, or pull a CSV into a warehouse. Same data, same permissions, included on every plan.

Last updated

The AI tools at a glance

MCP server
https://statsy.co/mcp
Works with
Claude Code, the Claude app (web and desktop), Cursor, VS Code, and any MCP client that speaks streamable HTTP
Tools exposed
13: sites, overview, time series, breakdowns, attribution, funnels, visitors, journeys, bots, goals, plus create goal and add note
CLI
npm install -g @statsy.co/cli, Node.js 20 or newer, MIT licence
REST API
JSON at https://api.statsy.co/api/v1 with account or site tokens
Access control
You approve each connection in the dashboard; the assistant gets exactly your role in the workspace

What is an analytics MCP server?

MCP is an open standard that lets an AI assistant call tools on a remote service. An analytics MCP server exposes reports as tools, so when you ask “why did revenue drop this week?” the assistant reads your real overview, breakdowns and attribution instead of guessing from training data. Statsy hosts one at https://statsy.co/mcp.

Without a server like this, an assistant can only reason about analytics you paste into the chat. With one, it can fetch the last 30 days by channel, compare them with the 30 days before, pull the funnel that lost people, and open one customer’s journey, all in a single answer. The tools return structured JSON, so the assistant can chain them and do arithmetic on the results.

Statsy’s server is stateless and speaks streamable HTTP, the current MCP transport. There is nothing to install or keep running on your machine. You add the URL to your assistant, approve the connection once in the Statsy dashboard, and start asking.

How do you connect Claude, Cursor or VS Code to Statsy?

Add the server URL to the client, then sign in when it asks. Your browser opens the Statsy dashboard to approve access for your workspace. The whole thing takes about a minute, and the MCP setup guide has every client’s exact steps.

Claude Code

claude mcp add --transport http statsy https://statsy.co/mcp

Then run /mcp, choose statsy and sign in.

Claude app

Open Settings, Connectors, Add custom connector, paste the server URL, connect, and approve access in the window that opens.

Cursor

{ "mcpServers": { "statsy": { "url": "https://statsy.co/mcp" } } }

In ~/.cursor/mcp.json or a project-level .cursor/mcp.json, then sign in from Cursor Settings, MCP.

VS Code

{ "servers": { "statsy": { "type": "http", "url": "https://statsy.co/mcp" } } }

In .vscode/mcp.json. Start the server from that file and sign in when VS Code asks.

Headless agents

A client that cannot open a browser sends an account token in an Authorization: Bearer header instead of signing in.

What can you ask an AI assistant about your analytics?

Anything the dashboard can answer, and comparisons the dashboard makes you do by hand. The server exposes thirteen tools and three ready-made prompts: a weekly review, “why did revenue change?” and “which channel should I double down on?”.

ToolWhat the assistant gets
list_sitesYour sites with id, public key, domain, time zone and currency. The starting point for every other tool.
get_overviewHeadline metrics for a period, optionally compared with the previous one.
get_timeseriesOne metric by hour, day, week or month, to find spikes and drops.
get_breakdownTop values of a dimension: channel, referrer, campaign, page, country, device, goal, AI source or keyword.
get_attributionRevenue by channel under last touch, first touch, linear, time decay or position based, with a 1 to 365 day lookback.
list_funnels, get_funnelSaved funnels, and a step-by-step report with drop-off and revenue per step.
search_visitorsVisitors by id, email, name, user id, country, city or path.
get_journeyOne visitor’s full timeline: pageviews, goals, marketing touches and payments.
get_botsBot and AI crawler requests by family, bot name or path.
list_goals, create_goalThe goals configured for a site, and a new pageview or event goal. Creating needs the editor or owner role.
add_noteA chart annotation such as a deploy or a launch. Needs the editor or owner role.

Questions that work well, taken from real sessions:

  • “Which channel brought the most revenue in the last 30 days, and how does that compare with the month before?”
  • “Why did conversions drop this week? Check channels, pages and countries.”
  • “Show the checkout funnel for the last 7 days and tell me which step lost the most people.”
  • “What did the customer with this email do before they paid?”
  • “How much of my traffic is AI crawlers, and which ones?”
  • “Add a note on today saying we shipped the new pricing page.”

Is there a command line tool for Statsy?

Yes. @statsy.co/cli on npm installs a statsy command that prints the same reports as the dashboard, as tables in a terminal or as JSON in a script. It covers overviews, breakdowns, time series, funnels, live visitors, attribution and CSV export, and it is MIT licensed.

npm install -g @statsy.co/cli
statsy login                                   # paste an account token once
statsy sites use ws_yoursitekey
statsy stats --period 30d --breakdown channel --metric revenue
statsy attribution --model first --lookback 90
statsy visitors --live                         # one JSON line per visitor with --json
statsy export --dimension path --period 90d > pages.csv

In CI, set STATSY_TOKEN and skip statsy login. Colour turns off when output is piped, and exit codes separate general errors, missing authentication, forbidden requests and rate limits, so a cron job can branch on them. The full command list is in the CLI reference.

What about the REST API?

Every report is JSON over HTTPS at https://api.statsy.co/api/v1, authenticated with a bearer token. It also accepts payments from systems Statsy does not integrate with, through the Payment API, so revenue attribution works for any checkout you can call a URL from.

curl -H "Authorization: Bearer sta_your_token" \
  "https://api.statsy.co/api/v1/sites/ws_yoursitekey/attribution?model=last&lookback=90&from=30d"

Account tokens act for a whole workspace; site tokens are limited to one site and behave like an editor. Tokens are stored only as hashes and can be revoked at any time. Requests are limited to 60 a minute on Growth and ten times that on Scale. Start with the REST API overview.

Is it safe to give an AI assistant access to analytics?

Access is granted by you, in the dashboard, per connection, and scoped to one workspace with your own role. Viewers can only read. Nothing is granted by knowing the URL, connections are rate limited to 120 requests a minute, and removing the connection in your assistant revokes it.

  • OAuth 2.1 approval. The assistant never sees a password. You approve it once in the Statsy dashboard and can revoke it there or in the client.
  • Your role, not more. An assistant connected by a viewer cannot create goals or notes. An ended trial keeps the read tools working and refuses the writes.
  • No visitor secrets. The tools return the same aggregates, journeys and visitor fields the dashboard shows. Replay recordings are not exposed over MCP.
  • Tokens are hashed. Account tokens used by headless clients are stored as SHA-256 hashes, shown once at creation, and can be revoked immediately. See security.

Why does an analytics tool need an AI interface at all?

Because the useful questions are comparisons and causes, and dashboards are built for glances. “Which channel should I spend tomorrow on?” needs attribution under two models, a funnel and last month’s numbers side by side. An assistant with tools does that in one turn.

Statsy’s numbers are unusual in that revenue is in them: every sale from Stripe, Lemon Squeezy, Paddle, Polar or Razorpay is credited to the visits that led to it. So the assistant is not answering “which post got clicks?” but “which post brought paying customers?”, which is the question that changes what you do next. Read how that works in marketing attribution software.

Among the tools we compare against, DataFast also lists an MCP server and a CLI; see the DataFast comparison. We do not claim that others lack one. Check each vendor’s own pages.

AI analytics and MCP FAQ

Does Statsy have an MCP server?

Yes. Statsy hosts a Model Context Protocol server at https://statsy.co/mcp. Claude Code, the Claude app, Cursor, VS Code and any client that speaks streamable HTTP can connect, approve access in the dashboard, and read traffic, revenue attribution, funnels, visitors and journeys.

Which AI assistants work with Statsy?

Claude Code and the Claude app connect with a URL and a sign-in. Cursor and VS Code connect through their mcp.json files. Any other MCP client that supports streamable HTTP, including headless agents using an account token, works too.

Is there a Statsy CLI?

Yes. Install it with npm install -g @statsy.co/cli. It needs Node.js 20 or newer, signs in with an account token, prints reports as tables or JSON, streams CSV exports, and is MIT licensed.

Do the MCP server, CLI and API cost extra?

No. All three are included on every plan, from $9 a month, and during the 14-day free trial. Scale has ten times the API rate limits.

Can the assistant change my analytics setup?

Only two writes exist, create a goal and add a chart note, and both need the editor or owner role. Everything else is read-only. There is no tool that deletes data, changes billing or manages the team.

Does the MCP server expose visitor personal data?

It exposes what the dashboard shows to your role: aggregates, breakdowns, and the visitor fields you have identified, such as an email passed through statsy.identify. IP addresses are never stored anywhere in Statsy, and replay recordings are not available over MCP.

Can I use the CLI or API without the MCP server?

Yes. They are independent. The CLI suits a quick look and cron jobs, the API suits internal dashboards and warehouses, and the MCP server suits conversation. All three read the same data.
AI analytics with an MCP server, CLI and API · Statsy