# Tinylytics MCP

MCP is how you let an AI client work your Tinylytics account without you translating between the two. Connect Grok, Claude, Cursor, Codex, ChatGPT, or anything else that speaks the protocol, and you can ask about last week's traffic, create a site, or clear out a spam queue in conversation.

If the account owner has not signed up yet, start with [instructions for agents](/docs/agent_signup) and wait for them to activate before connecting anything here.

**Endpoint**

`https://tinylytics.app/mcp`

It is a hosted Streamable HTTP server running on the main Tinylytics host, so there is no separate `mcp.` subdomain to find.

<span id="quick-start"></span>
## 1. Endpoint and access

Custom connectors open a browser sign-in at that URL and receive a key. A key created under **Account → API keys** is accepted as a static `Authorization` header.

OAuth sessions appear under **Account → Connections**. Revoking one there disconnects that agent. Keys created by hand stay under API keys.

The sign-in page always starts on read only. An agent gets full access only when you pick it on that page, even if the agent asked for it. The page also shows where the agent sends you after you connect, and marks apps it does not recognise as unverified.

A key from an OAuth sign-in stops working after 90 days without use. Connect again to get a new one. Keys created by hand do not expire.

The server shares the HTTP API's rate limit of 1000 requests per hour per key. Clients send `Accept: application/json, text/event-stream`.

Per-client setup is in [Set up in your agent](#set-up-in-your-agent).

<span id="set-up-in-your-agent"></span>
## 2. Set up in your agent

<span id="grok-connectors"></span>
### Grok, Claude.ai, and ChatGPT connectors

On [Grok Connectors](https://grok.com/connectors), Claude.ai custom connectors, or ChatGPT custom connectors:

1. Add a custom connector.
2. Paste `https://tinylytics.app/mcp` as the server URL.
3. Sign in to Tinylytics when the browser opens, pick read only or full access, and connect.

Manage that session later under **Account → Connections**.

<span id="grok"></span>
### Grok CLI

```bash
grok mcp add --transport http tinylytics https://tinylytics.app/mcp
```

That writes `~/.grok/config.toml`. It does not sign in.

Or add this to `~/.grok/config.toml`:

```toml
[mcp_servers.tinylytics]
url = "https://tinylytics.app/mcp"
```

The owner authenticates in Grok. They run `/mcps`, select tinylytics, and press `i`. They sign in and pick Full access if they need to create a site.

Then reload (`/mcps`, then `r`) or start a new session. Do that before calling tools. That connection appears under **Account → Connections**.

To skip OAuth and use an existing key:

```bash
export TINYLYTICS_API_KEY="tly-ro-your-api-key"
grok mcp add --transport http tinylytics https://tinylytics.app/mcp \
  --header "Authorization: Bearer ${TINYLYTICS_API_KEY}"
```

<span id="cursor"></span>
### Cursor

Add the server URL. Cursor will open a browser so you can sign in. That connection appears under Connections.

```json
{
  "mcpServers": {
    "tinylytics": {
      "url": "https://tinylytics.app/mcp"
    }
  }
}
```

Put that in `.cursor/mcp.json` or `~/.cursor/mcp.json`. To skip the browser, add an `Authorization` header with an existing key.

<span id="claude-code"></span>
### Claude Code

```bash
claude mcp add --transport http tinylytics https://tinylytics.app/mcp
```

Claude opens a browser so you can sign in. That connection appears under Connections. Add `--header "Authorization: Bearer ${TINYLYTICS_API_KEY}"` only if you want to skip that.

<span id="claude-desktop"></span>
### Claude Desktop

If your Claude Desktop build accepts a remote HTTP server, use the same JSON as Cursor in:

- macOS: `~/Library/Application Support/Claude/claude_desktop_config.json`
- Windows: `%APPDATA%\Claude\claude_desktop_config.json`

If it only launches local stdio servers, bridge to the hosted endpoint:

```json
{
  "mcpServers": {
    "tinylytics": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-remote",
        "https://tinylytics.app/mcp",
        "--header",
        "Authorization: Bearer ${TINYLYTICS_API_KEY}"
      ]
    }
  }
}
```

Restart Claude Desktop. Look for the MCP tools icon to confirm the connection.

<span id="codex"></span>
### Codex

```toml
[mcp_servers.tinylytics]
url = "https://tinylytics.app/mcp"
```

Add that to `~/.codex/config.toml`. Codex should prompt you to sign in. That connection appears under Connections. Use a header only if you already have a key.

<span id="generic"></span>
### Any other MCP client

Point the client at `https://tinylytics.app/mcp` with no header. If it supports MCP OAuth, it will open `/oauth/authorize`. Connected agents appear under Connections. If it only supports static headers, create a key under **Account → API keys** and send `Authorization: Bearer tly-ro-…`.

## 3. Team accounts

API keys stay personal. Tools that act on sites or groups accept optional `account_id`. Webhook tools do not: webhooks always belong to the key owner.

1. Call `list_accounts` (or `get_me`) to see personal and team accounts.
2. Pass a team `id` as `account_id` on later tools.
3. Omit `account_id` to stay on the personal account.

Team viewers can read the owner's sites and groups. Team admins can create, update, and delete the owner's sites. Team owners can also create, update, and delete the owner's groups.

This MCP server is for your own Tinylytics sites. It does not include sites provisioned through [Analytics for SaaS](/analytics-for-saas), the separate product for embedding Tinylytics in your own app. Those tenant sites have their own API.

## 4. Tools

Most tools map to one API v1 endpoint.

| Tool | API |
| --- | --- |
| `get_me` | `GET /api/v1/me` |
| `get_mcp_docs` | short in-tool contract (also `tinylytics://docs/mcp`) |
| `list_accounts` | `GET /api/v1/accounts` |
| `list_sites` / `get_site` / `create_site` / `update_site` / `delete_site` | sites |
| `update_site_features` | `PATCH /api/v1/sites/:id/features` |
| `list_hits` / `create_hit` | hits |
| `import_hits` | `POST /api/v1/sites/:id/hits/import` |
| `list_cross_site_referrals` | `GET /api/v1/cross_site_referrals` |
| `list_agent_visits` / `create_agent_visit` | AI crawler visits |
| `list_spam_hits` / `delete_spam_hits` | site spam analysis |
| `list_events` / `create_event` | events |
| `create_kudo` / `delete_kudo` | kudos |
| `list_insights` | insights |
| `get_uptime` / `list_uptime` | uptime |
| `get_content` | content |
| `list_content_issues` / `ignore_content_issue` / `unignore_content_issue` / `recheck_content_issue` | content issues |
| `list_seo_audits` / `get_seo_audit` / `run_seo_audit` / `recheck_seo_page` / `dismiss_seo_issue` / `restore_seo_issue` | SEO audits |
| `list_webhooks` / `get_webhook` / `create_webhook` / `update_webhook` / `delete_webhook` / `test_webhook` / `regenerate_webhook_secret` | webhooks (`generic`, `discord`, `mattermost`, `pushover`) |
| `list_groups` / `get_group` / `create_group` / `update_group` / `delete_group` | groups |
| `list_custom_widgets` / `preview_custom_widget` / `create_custom_widget` / `update_custom_widget` / `delete_custom_widget` / `add_custom_widget_to_site` / `remove_custom_widget_from_site` | custom widgets |

Use `site_id` and `group_id` in tools instead of putting ids in the URL path.

`list_cross_site_referrals` returns traffic from one of your sites to another for an account or a `group_id`, over a date range. Rows are source site, target site, hits, and unique hits when unique tracking is on. Only referrer hostnames that map to sites the key can access are included; open-web referrers are dropped. `www` and the bare apex count as the same site. Self-traffic stays in the list. An empty portfolio returns an empty list.

`import_hits` backfills history from another analytics tool. Each hit carries its own `created_at`, up to 1000 hits per call, with a full-access key. No webhooks fire, and importing the same hits twice adds them twice.

`list_spam_hits` and `delete_spam_hits` use the same 14-day analysis as the site Spam page. Filter with `score_filter`: `all`, `review`, `high_risk`, or `very_high_risk`. `delete_spam_hits` needs a full-access key; pass `score_filter` and/or `hit_ids`. Only hits currently flagged as spam are removed.

Clients that never open a browser can call `get_mcp_docs` or read the `tinylytics://docs/mcp` resource for auth, pagination ceilings, unique-field basis, groups, and empty-referrer gotchas. This page stays the long form.

`list_hits` `per_page` is max `100` when `grouped=true`, and max `25` for raw hits. The HTTP hits endpoint still allows up to `1000`.

`list_uptime` returns every monitor the key can see on the account in one call. Each row uses the same fields as `get_uptime` (`ssl_days_remaining`, `domain_remaining_days`, `is_down`, and the rest), plus `site_id` and `label`. Pass `expiring_within_days` to keep monitors whose SSL or domain remaining days is that many or fewer, soonest first. Optional `site_id` or `site_ids` limits the set. Sites that never had uptime switched on are listed under `no_monitor`; paused monitors stay in `monitors` with `enabled: false`. Both tools need an active subscription. `get_uptime` is still the one-site drill-down and errors when that site has no monitor.

`list_seo_audits`, `get_seo_audit`, and `run_seo_audit` work the [SEO audit](/docs/analytics/seo-audit) from an agent and need Ultra on the selected account. `get_seo_audit` returns the latest audit unless you pass `audit_id`, with the robots.txt and sitemap findings, search landing pages, AI crawler access and visits, the ranked fixes, and each audited page with its issues, search views, and broken links. `run_seo_audit` needs a full-access key and queues a run; the same limits as the dashboard apply, so it errors while an audit is running or within an hour of the last one. Poll `get_seo_audit` until `status` is `completed`, then until `recommendations.status` is no longer `pending`.

After an agent fixes a page, `recheck_seo_page` checks that one page again by its `page_id` from the latest audit and updates its issues and the audit's counts, without a new fix list. It has its own limits: once per page every two minutes, and not while a full audit is running. Poll `get_seo_audit` until the page's `rechecked_at` is after its `recheck_requested_at`. `dismiss_seo_issue` hides an intentional issue, such as `noindex` on a thank-you page, from the counts, issue lists, and future fix lists; pass the `code` and the page `path`, or no `path` for a site-wide issue. Dismissed issues appear under `dismissed_issues` in `get_seo_audit`, and `restore_seo_issue` undoes one by `dismissal_id`. All three need a full-access key.

`get_content` is a summary of [content monitoring](/docs/monitoring/content), and its `recent_issues` carry no ids. `list_content_issues` pages through every open broken link, mixed-content resource, and misspelled word, each with an `id` and a `kind`: `broken_link`, `mixed_content`, or `spelling`. Filter with `kind`, and pass `include_ignored=true` to see ignored issues as well. Spelling issues only appear while spell checking is on. To act on one, pass its `kind` and `id` (as `issue_id`) to `ignore_content_issue`, `unignore_content_issue`, or `recheck_content_issue`. Ignoring a misspelled word ignores it on every page, the same as the Content page. A recheck runs in the background, so call `list_content_issues` again after a minute. All three need a full-access key and an active subscription.

The custom widget tools build the cards on a site's overview from a Liquid template, like the editor under **Custom widgets**. `preview_custom_widget` renders a template against one site's numbers without saving it and returns any error with its line number. Save the template with `create_custom_widget`, then show it with `add_custom_widget_to_site`. A site shows up to six widgets, built-in ones included. `get_mcp_docs` has the template language and examples. The tools need Pro or Ultra, writes need a full-access key, and on a team only admins and owners can use them. These are not the embed `widgets` on `get_site`.

Full request fields and response shapes for the other tools match the [HTTP API](/docs/api). `list_sites` and `get_site` include optional plain-text `notes` and `group_ids`. Write notes with `update_site`; they are stored as rich text and returned as plain text.

`list_sites` and `get_site` also include `fetch_icon`. It's `true` by default for sites made with `create_site`, which then use the icon from the site's homepage, checked again every two weeks; pass `fetch_icon: false` to `create_site` to skip it. `update_site` changes it later: `false` keeps the current icon and stops the checks. Writes need a full-access key, and uploading an icon in the app turns it off.

`list_sites` and `get_site` also include `widgets`, the settings the site's script follows: `events`, `auto_events`, `beacon`, and each widget's on/off and style, with the names listed under [`GET /sites/:id`](/docs/api#get-site). Change them with `update_site` and a partial `widgets` object, such as `{ "events": true }`. Only the keys you send change. An unknown key or an invalid style fails the call and saves nothing. The write needs a full-access key, and it also stops Tinylytics filling the settings in from the old snippet's options. `update_site_features` covers monitoring only.

`list_sites` and `get_site` also include read-only `legacy_embed_options` and `legacy_embed_served_at`, the options the old `embed/<uid>.js` snippet last loaded with and when. Copy them into `widgets` with `update_site` before you swap the old snippet for the new script. Tinylytics never applies them itself: anyone can load the old snippet with any options, so the owner applies them with **Use these settings** on the dashboard or **Settings → Tracking**, or an agent copies them with `update_site`. See [Moving from the old embed](/docs/getting-started/embed#moving-from-the-old-embed).

<span id="unique-metrics"></span>
### Unique metrics

`list_sites` `period_unique_hits` and `list_hits` `summary.unique_visitors` are different counts. Do not equate them or sum one into a week review as if it were the other.

| Field | Tool | Counts |
| --- | --- | --- |
| `period_unique_hits` | `list_sites` with dates | Distinct `unique_hash` in the window (each hit with a blank hash counts as one). Same Unique rollup as the sites index. `null` when unique tracking is off. Period responses include `filters.unique_basis: "unique_hash"`. |
| `summary.unique_visitors` | `list_hits` | Distinct `visitor_hash` in the filtered window. Responses include `summary.unique_basis: "visitor_hash"`. |

For a **single site and date window**, use `list_hits` → `summary.unique_visitors`. Treat `list_sites` → `period_unique_hits` as the portfolio Unique rollup. `period_hits` and `summary.total_hits` can still checksum when the unique fields do not.

The names stay as they are. There is no silent rename.

For longer recipes — a human-approved broken-link loop, a spam cleanup in chat, a follow-up to Insights — see [LLM use cases](/docs/developer/llm-use-cases).