Skip to content

MCP Server

@kitbase/analytics-mcp is an MCP (Model Context Protocol) server that lets AI assistants query your Kitbase analytics data. Connect it to Claude Code, Cursor, or any MCP-compatible client and ask questions about your traffic, events, users, sessions, funnels, journeys, and frustration signals in natural language.

No Dashboard Required

Once connected, your AI assistant can answer questions like "How many visitors did we get last week?" or "Show me the signup funnel conversion rate" by querying the Kitbase API directly.

Installation

bash
npm install @kitbase/analytics-mcp
bash
pnpm add @kitbase/analytics-mcp
bash
yarn add @kitbase/analytics-mcp

Or run directly without installing:

bash
npx @kitbase/analytics-mcp

Configuration

The server is configured entirely through environment variables:

VariableRequiredDescription
KITBASE_API_KEYYesPrivate API key (must start with sk_kitbase_)
KITBASE_API_URLNoKitbase API base URL (default: https://api.kitbase.dev)

The project and environment are automatically resolved from the API key — no need to specify them manually.

WARNING

The MCP server requires a private API key (sk_kitbase_), not the public SDK token used in browser SDKs. Generate one from your Kitbase dashboard under Settings > API Keys.

Client Setup

Claude Code

Add to your Claude Code MCP configuration (.claude/settings.json or project-level .mcp.json):

json
{
  "mcpServers": {
    "kitbase-analytics": {
      "command": "npx",
      "args": ["@kitbase/analytics-mcp"],
      "env": {
        "KITBASE_API_KEY": "sk_kitbase_your_key_here"
      }
    }
  }
}

Cursor

Add to your Cursor MCP settings (.cursor/mcp.json):

json
{
  "mcpServers": {
    "kitbase-analytics": {
      "command": "npx",
      "args": ["@kitbase/analytics-mcp"],
      "env": {
        "KITBASE_API_KEY": "sk_kitbase_your_key_here"
      }
    }
  }
}

Other MCP Clients

The server communicates over stdio using the standard MCP protocol. Use the same configuration format — any MCP-compatible client will work.

Available Tools

The server exposes 15 tools across seven categories.

Web Analytics

ToolDescription
get_web_summarySummary KPIs (visitors, pageviews, bounce rate, etc.) with percentage changes vs previous period
get_web_timelineMetrics over time — timeseries data for charting trends
get_web_breakdownBreak down metrics by dimension (pages, countries, browsers, referrers, UTM params, etc.)
compare_periodsCompare analytics between two time periods — shows which dimension values changed the most

get_web_summary

Returns aggregate KPIs for the given date range along with percentage changes compared to the previous period.

ParameterTypeRequiredDescription
presetstringNoDate preset — see Date Filtering
fromstringNoStart date (YYYY-MM-DD)
tostringNoEnd date (YYYY-MM-DD)
timezonestringNoTimezone (default: UTC)
filtersstring[]NoFilters — see Filters

get_web_timeline

Returns timeseries data for a single metric, useful for charting trends over time.

ParameterTypeRequiredDescription
metricstringYesMetric to chart (visitors, pageviews, bounce_rate, visit_duration, views_per_visit)
presetstringNoDate preset
from / tostringNoExplicit date range (YYYY-MM-DD)
timezonestringNoTimezone (default: UTC)
filtersstring[]NoFilters

get_web_breakdown

Breaks down a metric by a given dimension — for example, top pages by visitors, or traffic by country.

ParameterTypeRequiredDescription
dimensionstringYesDimension to break down by (page, country, browser, os, device, referrer, utm_source, utm_medium, utm_campaign)
metricstringNoMetric to sort by (default: visitors)
presetstringNoDate preset
from / tostringNoExplicit date range (YYYY-MM-DD)
timezonestringNoTimezone (default: UTC)
filtersstring[]NoFilters
pagenumberNoPage number (0-indexed)
sizenumberNoPage size

compare_periods

Compares web analytics for a dimension across two date ranges, highlighting which values changed the most between the periods.

ParameterTypeRequiredDescription
dimensionstringYesDimension to compare (page, country, browser, os, device, referrer, utm_source, utm_medium, utm_campaign)
currentFromstringYesCurrent period start date (YYYY-MM-DD)
currentTostringYesCurrent period end date (YYYY-MM-DD)
previousFromstringYesPrevious period start date (YYYY-MM-DD)
previousTostringYesPrevious period end date (YYYY-MM-DD)
timezonestringNoTimezone (default: UTC)
limitnumberNoMax number of results (default: 10)
filtersstring[]NoFilters — see Filters

Events

ToolDescription
list_eventsList tracked events with filtering by name, user, or date range
get_event_statsAggregated event statistics with timeline and optional property breakdown

list_events

Lists individual tracked events with optional filtering and pagination.

ParameterTypeRequiredDescription
eventNamestringNoFilter by event name
userIdstringNoFilter by user ID
presetstringNoDate preset
from / tostringNoExplicit date range (YYYY-MM-DD)
timezonestringNoTimezone (default: UTC)
pagenumberNoPage number (0-indexed)
sizenumberNoPage size
sortstringNoSort order (asc or desc)

get_event_stats

Returns aggregated event counts, a timeline, and an optional breakdown by a property.

ParameterTypeRequiredDescription
eventNamestringNoFilter by event name
presetstringNoDate preset
from / tostringNoExplicit date range (YYYY-MM-DD)
timezonestringNoTimezone (default: UTC)
breakdownPropertystringNoProperty to break down by

Users

ToolDescription
list_usersList or search users in the project
get_user_summaryComprehensive analytics summary for a specific user (total events, first/last seen, top events, etc.)
get_user_activityDaily activity heatmap data for a specific user over the last N months
get_user_eventsPaginated event list for a specific user

list_users

Lists users with optional search and date filtering.

ParameterTypeRequiredDescription
searchstringNoSearch query (matches name, email, or user ID)
presetstringNoDate preset
from / tostringNoExplicit date range (YYYY-MM-DD)
timezonestringNoTimezone (default: UTC)
pagenumberNoPage number (0-indexed)
sizenumberNoPage size

get_user_summary

Returns a comprehensive analytics summary for a specific user, including total events, first/last seen timestamps, and top events.

ParameterTypeRequiredDescription
userIdstringYesThe user ID to look up
typestringYesWhether the user is identified or anonymous

get_user_activity

Returns daily activity heatmap data for a specific user over a configurable number of months. Useful for visualizing how active a user has been over time.

ParameterTypeRequiredDescription
userIdstringYesThe user ID to look up
typestringYesWhether the user is identified or anonymous
monthsnumberNoNumber of months of activity to return (default: 4)

get_user_events

Returns a paginated list of events for a specific user.

ParameterTypeRequiredDescription
userIdstringYesThe user ID to look up
typestringYesWhether the user is identified or anonymous
pagenumberNoPage number (0-indexed)
sizenumberNoPage size (default: 20)

Sessions

ToolDescription
list_sessionsList sessions with optional filtering
get_session_detailDetailed session info including all events in the session

list_sessions

Lists sessions with optional date filtering, pagination, and sorting.

ParameterTypeRequiredDescription
presetstringNoDate preset
from / tostringNoExplicit date range (YYYY-MM-DD)
timezonestringNoTimezone (default: UTC)
pagenumberNoPage number (0-indexed)
sizenumberNoPage size
sortstringNoSort order (asc or desc)

get_session_detail

Returns detailed information about a single session, including every event in that session.

ParameterTypeRequiredDescription
sessionIdstringYesThe session ID

Funnels

ToolDescription
analyze_funnelAnalyze a conversion funnel with ordered steps and get conversion rates between each step

analyze_funnel

Define a multi-step funnel and get conversion rates between each step.

ParameterTypeRequiredDescription
stepsobject[]YesOrdered funnel steps (minimum 2). Each step has eventName (string, required) and filters (string[], optional)
presetstringNoDate preset
from / tostringNoExplicit date range (YYYY-MM-DD)
timezonestringNoTimezone (default: UTC)

Journeys

ToolDescription
analyze_journeysAnalyze user navigation paths showing common routes through pages or events

analyze_journeys

Analyzes common navigation paths users take, optionally scoped to a start and/or end page.

ParameterTypeRequiredDescription
startPagestringNoStarting page path to analyze journeys from
endPagestringNoEnding page path to analyze journeys to
presetstringNoDate preset
from / tostringNoExplicit date range (YYYY-MM-DD)
timezonestringNoTimezone (default: UTC)
depthnumberNoMaximum path depth to analyze

Frustration Signals

ToolDescription
get_frustration_reportFrustration signals report (rage clicks, dead clicks) with top frustrated pages and elements

get_frustration_report

Returns a frustration signals report including rage clicks and dead clicks, with the top pages and elements where users showed frustration.

ParameterTypeRequiredDescription
presetstringNoDate preset — see Date Filtering
from / tostringNoExplicit date range (YYYY-MM-DD)
timezonestringNoTimezone (default: UTC)
limitnumberNoMax number of top pages/elements to return (default: 10)

Common Parameters

Date Filtering

Most tools accept date filtering via either a preset or an explicit date range:

  • preset — one of last_30_minutes, last_hour, today, yesterday, last_7_days, last_30_days, this_month, this_year
  • from / to — explicit date range in YYYY-MM-DD format
  • timezone — timezone for date calculations (default: UTC)

If both a preset and explicit dates are provided, the explicit dates take precedence.

Pagination

List endpoints support pagination:

  • page — page number (0-indexed)
  • size — number of items per page

Filters

Web analytics tools support filters in the format dimension:operator:values:

"country:is:US"
"browser:is:Chrome"
"page:contains:/blog"

Pass multiple filters as an array to combine them.

Example Prompts

Once connected, you can ask your AI assistant questions like:

QuestionTools Used
"How many visitors did we get last week?"get_web_summary
"What are our top pages by pageviews this month?"get_web_breakdown
"Show me the traffic trend for the past 30 days"get_web_timeline
"What countries are our users coming from?"get_web_breakdown
"Compare this week's traffic to last week by country"compare_periods
"How many signup events happened today?"get_event_stats
"Show me the signup funnel conversion rate"analyze_funnel
"What's the most common user journey from the homepage?"analyze_journeys
"Find sessions for user john@example.com"list_users + list_sessions
"Show me a summary of user U-123's activity"get_user_summary
"What has user U-123 been doing the last 4 months?"get_user_activity
"List the recent events for user U-123"get_user_events
"Which pages have the most rage clicks this week?"get_frustration_report

Requirements

  • Node.js 18+
  • A Kitbase private API key (sk_kitbase_)

Released under the MIT License.