Matomo MCP Server
Connects to a Matomo Analytics instance via its Reporting API, exposing tools for traffic and live visitor metrics, pages, site search, performance, devices and browsers, referrers, search engines, AI assistants, campaigns, segment filtering, row evolution, and batch reporting.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
Matomo MCP Server
An MCP (Model Context Protocol) server that acts as a client to the Matomo Analytics API. It exposes Matomo analytics data as MCP tools, allowing any MCP-compatible LLM client (Claude Desktop, Claude Code, etc.) to query your Matomo instance using natural language.
In other words: it's an MCP server (tools over stdio) and a Matomo API client (HTTP requests) in one.
Direct connection to your Matomo instance, no remote proxy
23 analytics tools: traffic, pages, search, performance, traffic sources, bulk batching, row evolution, segment discovery, and Live-API-backed counting
Segment filtering on every time-based tool, including a
deviceshortcut for mobile/desktop slicingmatomo_count_visits_by_segmentbypasses the segment-archiving trap (works even when the API token lacksprocess_new_segment)matomo_batchruns multiple reports in a single HTTP round-tripCustom date ranges via
period=range+date=YYYY-MM-DD,YYYY-MM-DDServer-side response shaping:
hideColumns,showColumns,filter_truncate,filter_offset,format_metricsDocker ready or run with Node.js
Credentials stay local, never sent to third parties
Retry logic with exponential backoff and timeout handling
Supports self-signed certificates (common for internal servers)
Installation
Option 1: Docker
git clone https://github.com/lucaspretti/matomo-mcp-client
cd matomo-mcp-client
docker build -t matomo-mcp-server .
cp .env.example .env
# Edit .env with your Matomo URL and API tokenOption 2: Node.js
git clone https://github.com/lucaspretti/matomo-mcp-client
cd matomo-mcp-client
npm installRelated MCP server: GA4 MCP Server
Configuration
Environment Variables
Copy .env.example to .env and fill in your values:
Variable | Required | Description |
| Yes | Your Matomo instance URL |
| Yes | Matomo API token (Settings > Personal > Security > Auth Tokens) |
| No | Default site ID (default: 1) |
| No | Request timeout in ms (default: 30000) |
| No | Retry attempts (default: 3) |
| No | Initial retry delay in ms (default: 1000) |
MCP Client Configuration
Add to your MCP client configuration (e.g., claude_desktop_config.json):
Docker
{
"mcpServers": {
"matomo": {
"command": "docker",
"args": [
"run", "-i", "--rm",
"--env-file", "/absolute/path/to/.env",
"matomo-mcp-server"
]
}
}
}Node.js
{
"mcpServers": {
"matomo": {
"command": "node",
"args": ["/absolute/path/to/matomo-mcp-client.js"],
"env": {
"MATOMO_HOST": "https://matomo.example.com",
"MATOMO_TOKEN_AUTH": "your_token",
"MATOMO_DEFAULT_SITE_ID": "1"
}
}
}
}Restart your MCP client after saving the configuration.
Available Tools
Traffic
Tool | Description |
| Visit summary: unique visitors, total visits, actions, bounce rate, avg time |
| Real-time visitor counters for the last N minutes |
| Detailed info on recent visits: pages, referrer, device, location |
Pages
Tool | Description |
| Most visited page URLs with hits, time spent, load times |
| Most visited pages by title |
| Top landing pages where visitors enter the site |
| Top exit pages where visitors leave the site |
Site Search
Tool | Description |
| Keywords searched on the site's internal search |
| Search keywords that returned no results (content gaps) |
Performance
Tool | Description |
| Page load times: network, server, DOM processing, total |
| Visitor device types: desktop, smartphone, tablet |
| Visitor browsers: Chrome, Firefox, Safari, Edge |
Traffic Sources
Tool | Description |
| Referring websites sending traffic |
| Search engines: Google, Bing, DuckDuckGo |
| AI assistants: ChatGPT, Perplexity, Claude, Gemini |
| All traffic sources overview including campaigns |
Segment-aware & batching (v1.7.5–1.7.8)
Tool | Description |
| Count visits matching any segment via the Live API, bypassing segment archiving. Returns |
| List pre-defined (saved) segments. Those with |
| Run multiple API methods in one HTTP round-trip via |
| Time-series of a specific row label across periods (e.g. daily visits for one URL over 30 days). |
Common Parameters
Every time-based tool accepts the same scoping parameters:
Param | Type | Description |
| number | Site ID. Falls back to |
| enum |
|
| string |
|
| number | Number of rows to return (default: 10 for most tools, 500 for |
| string | Raw Matomo segment expression, e.g. |
| enum | Sugar for the most common device segments. Combines with |
device shortcuts
Value | Expands to |
|
|
|
|
|
|
|
|
|
|
mobile bundles smartphone + tablet + phablet because most callers mean
"not desktop". Use smartphone if you need handheld only.
Segment syntax
Matomo segments use , for OR and ; for AND. A few useful ones:
deviceType==smartphone,deviceType==tablet— mobile or tabletcountryCode==de;browserCode==FF— German visitors using FirefoxpageUrl=@bulletin/download— visits that saw any URL containingbulletin/downloadvisitorType==returning— returning visitors only
Full reference: https://developer.matomo.org/api-reference/reporting-api-segmentation
Segment archiving (important)
Matomo only returns aggregated metrics for a segment that has been archived
by the server. If your API token lacks the process_new_segment permission
and the segment isn't pre-archived, every reporting endpoint
(VisitsSummary.get, Actions.getPageUrls, etc.) silently returns zero
for every metric. This looks identical to "no traffic matched" but is
actually "the server refused to compute this on the fly".
If you pass segment / device and get empty results while an unsegmented
query returns data, you are hitting this. You have three options, in order of
effort:
Use
Live.getLastVisitsDetailsinstead — the live API serves raw per-visit data and does not require archiving, so arbitrary segments work immediately. The downside: you get a list of visits, not a pre-aggregated number, so you need to count client-side. A dedicatedmatomo_count_visits_by_segmenttool is planned for v1.7.5 (seeROADMAP.md). Until then, call Matomo directly:curl -s -X POST "$MATOMO_HOST/index.php" \ --data-urlencode "module=API" \ --data-urlencode "method=Live.getLastVisitsDetails" \ --data-urlencode "idSite=35" \ --data-urlencode "period=month" --data-urlencode "date=2026-03-01" \ --data-urlencode "segment=pageUrl=@bulletin/download;deviceType==smartphone,deviceType==tablet,deviceType==phablet" \ --data-urlencode "filter_limit=-1" \ --data-urlencode "format=JSON" \ --data-urlencode "token_auth=$MATOMO_TOKEN_AUTH" \ | jq 'length'Ask your Matomo admin to either (a) grant
process_new_segmenton your token, (b) enableenable_browser_archiving_triggeringfor the site, or (c) pre-archive the common segments (device, country, etc.). This is the right fix if you rely heavily on segmented reporting.Fallback via the Matomo UI: build the URL yourself and open it in a browser session that is logged in to Matomo — the UI uses the logged-in user's permissions, not the API token. Example:
https://<your-matomo>/index.php?module=CoreHome&action=index &idSite=35&period=range&date=2025-04-24,2026-04-24 &segment=deviceType%3D%3Dsmartphone%2CdeviceType%3D%3Dtablet%2CdeviceType%3D%3DphabletThen navigate to Behaviour → Pages and filter by your URL pattern.
The MCP server itself is not limited, it faithfully forwards the segment to Matomo. The restriction is entirely server-side and only affects the aggregated reporting endpoints, not the Live API.
Example Queries
"Show me today's visit statistics"
"What are the top 10 pages this week?"
"How many visitors are online right now?"
"What are people searching for on the site?"
"Show me page load performance for the last month"
"Which AI assistants are sending traffic?"
"What are the top entry pages yesterday?"
"How many mobile visits did
/bulletin/downloadget in the last 12 months?""Top pages for German visitors only, last 30 days"
"Smartphone traffic share this quarter"
Architecture
MCP Client (Claude Desktop/Code) <-> matomo-mcp-client (stdio) <-> Matomo API (HTTP POST)MCP client sends tool calls via stdio
Server translates to Matomo API requests (POST with token in body)
Results returned as JSON to the MCP client
Credits
Originally inspired by Openmost's matomo-mcp-client. This version was rewritten to connect directly to the Matomo API without a remote proxy, with an expanded set of analytics tools.
Resources
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Read and edit GA4, Search Console and Google Tag Manager from any MCP client. 29 tools.
Ask Claude, ChatGPT or any MCP client about your Google Analytics 4 and Search Console data, plus Bing Webmaster Tools when connected, for every site you manage, with one Google sign-in. Read only: traffic changes, why a page dropped, top queries and pages, quick-win queries, AI assistant referral traffic, URL indexing, sitemaps, custom GA4 reports and client reports. Built for site owners and agencies with many sites. Free for 1 site.
Hosted MCP server for marketing agencies: connect Google Ads, GA4, Search Console, Meta, LinkedIn and more to Claude or ChatGPT. Pull reports and make changes via OAuth login, no setup.
Connect your ads, shop, analytics, social, CRM and finance platforms once, then let Claude, ChatGPT, Cursor or any MCP client read, join and explain your numbers. Public statistics from the World Bank, IMF, Eurostat, OECD, WHO and SEC filings come as context, searchable and chartable from the same tools. Read-only by design, every number carries its source.
Related MCP Servers
- -licenseNot gradedqualityNot gradedmaintenanceEnables AI models to interact with Matomo analytics through a complete MCP server implementation. Provides tools for retrieving analytics data, managing sites, and generating reports with zero configuration setup.-
- AlicenseAqualityCmaintenanceConnects MCP clients like Claude Desktop to Google Analytics 4 Data API, enabling natural language queries for reports, top pages, traffic sources, conversions, realtime users, and period comparisons.7MIT
- AlicenseBqualityDmaintenanceEnables LLMs to directly query a Matomo analytics instance, execute reporting methods, fetch historical trends, report metadata, and dynamically generated chart images through typed MCP tools.6MIT
- AlicenseAqualityDmaintenanceEnables LLM applications to query and analyze Google Analytics 4 data through standard MCP interfaces, supporting service account and OAuth2 authentication.541 npmMIT