Matomo-MCP
matomo-mcp
与你的 Matomo Analytics 对话。 从 Claude、Cursor、VS Code 或任何 MCP 客户端。
15 个精心策划的只读分析工具 + 一个全 API 逃生舱。单一二进制文件,瞬时启动,上下文友好。
You ▸ How was traffic yesterday, and where did it come from?
Claude ▸ Yesterday you had 14,472 visits (11,416 unique visitors, 66% bounce rate).
Top acquisition channels:
1. Organic search — 6,120 visits (Google 92%)
2. Direct — 4,890 visits
3. AI assistants — 1,204 visits (↑ 31% vs. last week)
Want me to break down which landing pages converted best?你的 Matomo 仪表盘能回答的每一个问题,你的 AI 助手现在也能回答——包括追问、对比和"为什么"。
✨ 为什么选择 matomo-mcp?
🎯 精心策划,而非自动生成 | 15 个基于真实分析问题手工打造的工具——而不是 70+ 个自动生成的 API 镜像,后者会淹没模型的上下文并降低工具选择质量。 |
⚡ 瞬时启动 | 无需内省往返。一个静态二进制文件,无需 Node、无需 Python、无需运行时。毫秒级启动。 |
🔒 默认安全 | 只读报告工具。令牌仅通过 POST 发送(绝不出现在 URL/日志中),并从所有错误中脱敏。默认启用 TLS 验证。 |
🧠 上下文友好 | 每个报告都有行数限制,并设有硬性响应预算及可操作的指导——一次工具调用永远不会撑爆上下文窗口。 |
📡 包含实时功能 | 实时访客计数器和访问日志( |
🧰 永不受限 | 当策划工具无法覆盖时, |
🔁 弹性重试 | 对 429/5xx/网络故障自动重试并带退避。提供带提示注解的有用错误消息,模型可据此采取行动。 |
Related MCP server: mcp-server-wazuh
🚀 快速开始
1. 安装
预编译二进制文件(Linux、macOS、Windows)——从 Releases 获取,或者:
# Cargo
cargo install matomo-mcp
# From source
cargo install --git https://github.com/Liohtml/matomo-mcp
# Docker
docker pull ghcr.io/liohtml/matomo-mcp2. 获取 Matomo API 令牌
Matomo → 设置(⚙)→ 个人 → 安全 → 认证令牌 → 创建新令牌。 只需只读权限即可。
3. 验证连接
matomo-mcp --url https://your-matomo.example.com --token YOUR_TOKEN --check✓ Connected — Matomo version 5.2.1
✓ Token grants access to 3 site(s):
#1 My Shop (https://shop.example.com)
#2 Blog (https://blog.example.com)
#3 Docs (https://docs.example.com)4. 连接你的客户端 ⬇
🔌 连接你的客户端
claude mcp add matomo \
--env MATOMO_URL=https://your-matomo.example.com \
--env MATOMO_TOKEN=YOUR_TOKEN \
--env MATOMO_DEFAULT_SITE_ID=1 \
-- matomo-mcp添加到 claude_desktop_config.json(macOS:~/Library/Application Support/Claude/,Windows:%APPDATA%\Claude\):
{
"mcpServers": {
"matomo": {
"command": "matomo-mcp",
"env": {
"MATOMO_URL": "https://your-matomo.example.com",
"MATOMO_TOKEN": "YOUR_TOKEN",
"MATOMO_DEFAULT_SITE_ID": "1"
}
}
}
}.cursor/mcp.json(项目级)或 ~/.cursor/mcp.json(全局):
{
"mcpServers": {
"matomo": {
"command": "matomo-mcp",
"env": {
"MATOMO_URL": "https://your-matomo.example.com",
"MATOMO_TOKEN": "YOUR_TOKEN",
"MATOMO_DEFAULT_SITE_ID": "1"
}
}
}
}.vscode/mcp.json:
{
"servers": {
"matomo": {
"type": "stdio",
"command": "matomo-mcp",
"env": {
"MATOMO_URL": "https://your-matomo.example.com",
"MATOMO_TOKEN": "${input:matomo-token}",
"MATOMO_DEFAULT_SITE_ID": "1"
}
}
},
"inputs": [
{
"id": "matomo-token",
"type": "promptString",
"description": "Matomo API token",
"password": true
}
]
}任何通过 stdio 支持 MCP 的客户端都适用于通用配置格式:
{
"command": "matomo-mcp",
"args": [],
"env": {
"MATOMO_URL": "https://your-matomo.example.com",
"MATOMO_TOKEN": "YOUR_TOKEN",
"MATOMO_DEFAULT_SITE_ID": "1"
}
}{
"mcpServers": {
"matomo": {
"command": "docker",
"args": [
"run", "-i", "--rm",
"-e", "MATOMO_URL", "-e", "MATOMO_TOKEN", "-e", "MATOMO_DEFAULT_SITE_ID",
"ghcr.io/liohtml/matomo-mcp"
],
"env": {
"MATOMO_URL": "https://your-matomo.example.com",
"MATOMO_TOKEN": "YOUR_TOKEN",
"MATOMO_DEFAULT_SITE_ID": "1"
}
}
}
}运行一次服务器(在工作站、局域网机器或容器中),然后将任意数量的 MCP 客户端指向它:
matomo-mcp --url https://your-matomo.example.com --token YOUR_TOKEN --http 127.0.0.1:8080客户端通过 streamable HTTP 传输连接到 http://127.0.0.1:8080/mcp,例如:
claude mcp add --transport http matomo http://127.0.0.1:8080/mcp[!WARNING] HTTP 端点没有内置身份验证。请将其绑定到
127.0.0.1,或者在将其暴露到 localhost 之外之前,在前面放置带认证的反向代理(或防火墙)。
[!TIP] 设置
MATOMO_DEFAULT_SITE_ID,模型就无需再询问你指的是哪个站点。 手头没有令牌?可以试试公共演示:--url https://demo.matomo.cloud --default-site-id 1(无需令牌)。
🧭 工具
工具 | 可回答的问题 |
| "我们跟踪哪些站点?" |
| "上周我们获得了多少流量?" |
| "我们的热门页面有哪些?访客从哪里退出?" |
| "访客从哪里来?哪些营销活动有效?AI 助手给我们带来了什么流量?" |
| "配置器被打开过多少次?" |
| "每个目标的转化率是多少?" |
| "本月收入?最畅销的产品?" |
| "访客来自哪些国家/城市?" |
| "移动端还是桌面端?使用哪些浏览器?" |
| "访客在一天/一周中的什么时间访问?" |
| "访客在我们的网站上搜索什么——以及什么搜索不到?" |
| "现在谁在网站上?" |
| "哪些页面加载缓慢?" |
| "哪些部署或营销活动启动与那次流量激增吻合?" |
| 其他一切——漏斗、热图、自定义维度、Reporting API 的任何 |
所有工具都接受 site_id、period(day/week/month/year/range)、date
(today、yesterday、2026-07-01、last30 或 start,end 范围)、可选的
segment(例如 deviceType==mobile;country==DE)以及行数 limit。
可以尝试的提示词
"将本周流量与上周进行比较——发生了什么变化以及为什么?"
"本月按转化量排名的前 10 个落地页,附带跳出率。"
"我们是否从 ChatGPT 或 Perplexity 获得流量?3 个月的趋势。"
"哪些站内搜索没有返回结果?建议我们应该创建的内容。"
"访客日志中现在有什么异常情况?"
⚙️ 配置
标志 | 环境变量 | 默认值 | 描述 |
|
| — | Matomo 实例 URL(支持子目录安装,如 |
|
| — | API 令牌( |
|
| — | 当模型未指定站点时使用的站点 |
|
| — | 额外的 HTTP 头( |
|
|
| 每次请求的超时时间 |
|
|
| 截断前的响应预算 |
|
| — | 在此地址上通过 streamable HTTP 提供 MCP 服务,而非 stdio(端点: |
|
|
| 接受自签名 TLS 证书(明确选择加入) |
| — | — | 验证 URL + 令牌 + 站点访问权限,然后退出 |
🆚 这与 FGRibreau/mcp-matomo 有何不同?
mcp-matomo(本项目的灵感来源——谢谢!🙏)在启动时对你的 Matomo 实例进行内省,并为每个 API 方法生成一个 MCP 工具。matomo-mcp 则采取相反的方法:
matomo-mcp | mcp-matomo | |
工具集 | 15 个策划工具 + 逃生舱 | ~70+ 个生成工具 |
模型上下文成本 | 小且稳定 | 大且依赖实例 |
参数类型 | 精确、手写的枚举/默认值 | 从参数名称推断 |
启动 | 瞬时(无网络 I/O) | 内省往返(或缓存的规范文件) |
TLS 验证 | 默认开启 | 内省时禁用 |
子目录安装 | ✅ | 路径会被覆盖 |
响应大小保护 | 行数限制 + 硬性预算 | — |
瞬时错误重试 | ✅ | — |
实时(Live)工具 | ✅ | —(不属于报告元数据) |
如果你想要每个 API 方法都作为独立工具,请使用 mcp-matomo。如果你希望模型可靠地选择正确的工具且永不淹没其上下文,请使用 matomo-mcp。
🩺 故障排查
要么传入 --default-site-id 1(推荐),要么让模型先调用 matomo_list_sites。
运行 matomo-mcp --url ... --token ... --check。如果失败:重新生成令牌(设置 → 个人 → 安全),确保它至少对站点具有查看权限。
MATOMO_URL 必须指向 Matomo 根目录——即包含 index.php 的文件夹。对于 https://example.com/matomo/index.php,请使用 https://example.com/matomo/。
注入绕过标头:--header "CF-Access-Client-Id:..." --header "CF-Access-Client-Secret:..."(或通过 MATOMO_EXTRA_HEADERS)。
这是上下文保护在起作用。请求更少的行、更短的日期范围,或提高 --max-response-chars。
🗺️ 路线图
可流式 HTTP 传输(
--http,托管一次,连接多个客户端)matomo_annotations— 读取部署标记并将其与流量关联多实例支持(一个服务器,多个 Matomo 安装)
Homebrew tap 和 winget 清单
MCP 注册表列表(通过
server.json的官方注册表,Glama)
想更快得到其中某个功能?打开一个 issue — 或提交 PR,参见 CONTRIBUTING.md。
🛠️ 开发
cargo test # 37 tests, fully offline (wiremock)
cargo clippy --all-targets -- -D warnings
cargo run -- --url https://demo.matomo.cloud --default-site-id 1 --check架构和设计决策:docs/ARCHITECTURE.md。
📄 许可证与致谢
MIT。与 Matomo 无关联,也未获得其认可——Matomo 是 InnoCraft Ltd. 的注册商标。
使用 rmcp(官方 Rust MCP SDK)构建。灵感来自 FGRibreau/mcp-matomo。
MCP 注册表名称:
mcp-name: io.github.Liohtml/matomo-mcp
如果 matomo-mcp 能帮你省去一次仪表盘访问,一个 ⭐ 能帮助其他人找到它。
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseNot gradedqualityFmaintenanceMCP Server for Nutanix Prism Central14MIT
- MIT
- AlicenseBqualityBmaintenanceMCP Server for Apache Pinot1417Apache 2.0
- -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.
Related MCP Connectors
MCP server for Tinify image optimization — one tool, max optimization
MCP Server for agents to onboard, pay, and provision services autonomously with InFlow
MCP server for Blockscout
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/Liohtml/matomo-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server