Token导航 LogoToken导航TokenDH.com
MCP Matomo logo
数据服务未说明官方级别未说明来源级核验

MCP Matomo

MCP Server

一个MCP服务器,将Matomo分析API暴露给Claude和其他兼容MCP的AI助手使用。

工具数

63

提示词数

0

GitHub Stars

10

资源数

0
数据分析RustClaudeAPI集成Claude

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

FGRibreau

提供方

FGRibreau

最后核验

2026/5/17 20:21

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

详细介绍

MCP Matomo

A Model Context Protocol (MCP) server that exposes your Matomo Analytics API to Claude and other MCP-compatible AI assistants.

______________________________________________________________________

赞助商

France-Nuage

Host Matomo on sovereign French cloud. EU-only, re-internalisable.

Hook0

Forward Matomo events as signed webhooks to your stack. Self-hostable.

Natalia

AI voice agent calls back the visitors your funnel just lost. 24/7.

Netir

Hire vetted French freelance analytics engineers via marketplace.

NoBullshitConseil

Tech advisory without the bullshit. Data & analytics strategy.

Qualneo

Qualiopi LMS for French trainers. 32 indicators tracked end-to-end.

Recapro

Private AI for client analytics reviews. Transcribe & report sovereign.

有兴趣赞助吗? 联系

概述

该项目提供了一个MCP服务器,将所有可用的Matomo API方法公开为工具。

快速开始

先决条件

  • 防锈稳定(安装)
  • 具有API访问权限的Matomo实例
  • 您的matomo API令牌(部分)token_auth)

1.建设项目

git clone https://github.com/FGRibreau/mcp-matomo.git
cd mcp-matomo
cargo build --release

2.运行MCP服务器

服务器可以在启动时直接自检您的Matomo实例:

./target/release/mcp-matomo \
  --url https://your-matomo-instance.com \
  --token YOUR_API_TOKEN

服务器将:

  1. 连接到您的Matomo实例
  2. 获取所有可用的API方法
  3. 动态生成工具定义
  4. 开始在stdin/stdout上监听MCP消息

How to get your Matomo API token

  1. 登录您的Matomo实例
  2. 首选 设置 (齿轮图标)→ 个人安全
  3. 向下滚动至 身份验证令牌
  4. 点击 创建新令牌
  5. 为其命名并复制生成的令牌

替代方案:使用预先生成的OpenAPI规范

如果你喜欢更快的启动时间(跳过自检步骤),你可以使用预先生成的OpenAPI规范:

# Use a pre-generated spec
./target/release/mcp-matomo \
  --openapi matomo-api.json \
  --token YOUR_API_TOKEN
注: 您可以通过运行服务器来生成OpenAPI规范 --url 并保存输出或通过使用外部OpenAPI生成器。

配置

克劳德代码

将以下内容添加到您的Claude Code MCP设置中。您可以通过CLI执行此操作:

# Dynamic introspection (recommended)
claude mcp add matomo \
  --command /path/to/mcp-matomo \
  --args "--url" "https://your-matomo-instance.com" \
  --env "MCP_MATOMO_TOKEN=YOUR_API_TOKEN"

或者使用预先生成的OpenAPI规范来加快启动速度:

claude mcp add matomo \
  --command /path/to/mcp-matomo \
  --args "--openapi" "/path/to/matomo-api.json" \
  --env "MCP_MATOMO_TOKEN=YOUR_API_TOKEN"

或者手动将其添加到MCP设置文件中:

{
  "mcpServers": {
    "matomo": {
      "command": "/path/to/mcp-matomo",
      "args": ["--url", "https://your-matomo-instance.com"],
      "env": {
        "MCP_MATOMO_TOKEN": "YOUR_API_TOKEN"
      }
    }
  }
}

克劳德桌面版

添加 ~/Library/Application Support/Claude/claude_desktop_config.json (macOS)或 %APPDATA%\Claude\claude_desktop_config.json (Windows):

{
  "mcpServers": {
    "matomo": {
      "command": "/absolute/path/to/mcp-matomo",
      "args": ["--url", "https://your-matomo-instance.com"],
      "env": {
        "MCP_MATOMO_TOKEN": "YOUR_API_TOKEN"
      }
    }
  }
}

用法示例

配置后,您可以向Claude提出以下问题:

  • *“我昨天接待了多少客人?”*
  • *“显示本月访问量排名前10的国家”*
  • *“本周我最受欢迎的页面是什么?”*
  • *“将上周的流量与前一周进行比较”*
  • *“我的访客正在使用哪些设备?”*

Claude将自动使用适当的Matomo API工具来获取和分析您的分析数据。

可用工具

MCP服务器根据您的Matomo实例的API动态生成工具。以下是作为MCP工具公开的受支持的Matomo API方法的完整列表:

参观和交通概况

工具说明
VisitsSummary_get访问者行为概述(访问量、页面浏览量、跳出率、网站停留时间)
VisitFrequency_get比较回头客与新访客指标
API_get一次全面通话中的所有可用指标
MultiSites_getAll概述所有网站的指标
MultiSites_getOne特定网站的概述指标

页面和内容分析

工具说明
Actions_get访问者在您网站上的行为的基本概述
Actions_getPageUrls访问量最大的页面URL(分层文件夹结构)
Actions_getPageTitles已访问的页面标题
Actions_getEntryPageUrls进入页面(访问期间查看的第一页)
Actions_getEntryPageTitles参赛页面标题
Actions_getExitPageUrls退出页面(访问期间查看的最后一页)
Actions_getExitPageTitles退出页面的标题
Actions_getDownloads下载文件跟踪
Actions_getOutlinks访问者点击的出站链接
Contents_getContentNames查看和交互的内容名称
Contents_getContentPieces查看和交互的内容片段
PagePerformance_get页面加载时间和性能指标

网站搜索

工具说明
Actions_getSiteSearchKeywords在您的内部搜索引擎上搜索的关键字
Actions_getSiteSearchNoResultKeywords未返回结果的搜索关键字
Actions_getSiteSearchCategories访问者选择的搜索类别
Actions_getPageUrlsFollowingSiteSearch内部搜索后点击的页面
Actions_getPageTitlesFollowingSiteSearch内部搜索后点击的页面标题

流量来源和推荐人

工具说明
Referrers_get收购渠道概述
Referrers_getAll所有推荐人(网站、关键字、活动)统一
Referrers_getReferrerType按渠道类型(直接、搜索、社交等)分布
Referrers_getKeywords用于查找网站的搜索关键字
Referrers_getSearchEngines推荐访问者的搜索引擎
Referrers_getWebsites推荐网站
Referrers_getSocials引导访问者访问您网站的社交网络
Referrers_getCampaigns营销活动绩效
Referrers_getAIAssistants引导访问者访问您网站的人工智能助手

游客位置和人口统计

工具说明
UserCountry_getCountry各国游客
UserCountry_getContinent各大洲游客
UserCountry_getRegion按地区/州分列的游客
UserCountry_getCity按城市划分的游客
UserLanguage_getLanguage浏览器语言设置
UserLanguage_getLanguageCode精确的语言代码

设备与技术

工具说明
DevicesDetection_getType设备类型(台式机、移动设备、平板电脑)
DevicesDetection_getBrand设备品牌/制造商
DevicesDetection_getModel设备型号
DevicesDetection_getBrowsers浏览器类型
DevicesDetection_getBrowserVersions浏览器版本
DevicesDetection_getBrowserEngines浏览器渲染引擎
DevicesDetection_getOsFamilies操作系统系列
DevicesDetection_getOsVersions操作系统版本
DevicePlugins_getPlugin浏览器插件已启用
Resolution_getResolution屏幕分辨率
Resolution_getConfiguration操作系统+浏览器+分辨率组合

访客参与度

工具说明
VisitorInterest_getNumberOfVisitsPerPage按页面浏览量统计的访问量
VisitorInterest_getNumberOfVisitsPerVisitDuration按持续时间分列的访问
VisitorInterest_getNumberOfVisitsByVisitCount按访问次数统计的访客(第N次访问)
VisitorInterest_getNumberOfVisitsByDaysSinceLast自上次访问以来返回的访客天数

基于时间的分析

工具说明
VisitTime_getVisitInformationPerServerTime按服务器时间访问
VisitTime_getVisitInformationPerLocalTime按游客当地时间访问
VisitTime_getByDayOfWeek每周访问次数

目标与转化

工具说明
Goals_get目标转换概述
Goals_getDaysToConversion访客转换前几天
Goals_getVisitsUntilConversion转换前的访问次数

事件跟踪

工具说明
Events_getCategory活动类别
Events_getAction事件操作
Events_getName事件名称

用户与人工智能

工具说明
UserId_getUsers每个用户ID的度量
AIAgents_getAI代理跟踪
注: 可用的确切工具取决于您的Matomo实例配置和安装的插件。使用 --url 动态发现特定实例的所有可用方法。

CLI 参考

MCP服务器可以动态地内省Matomo,也可以使用预先生成的OpenAPI规范:

mcp-matomo [OPTIONS]

Options:
  -u, --url             Matomo instance URL (e.g., https://matomo.example.com)
                             When provided, introspects the Matomo API at startup
                             [env: MCP_MATOMO_URL]

  -o, --openapi     Path to a pre-generated OpenAPI JSON file
                             Use for faster startup with a cached spec
                             [env: MCP_MATOMO_OPENAPI_FILE]

  -t, --token         Matomo API token (token_auth)
                             [env: MCP_MATOMO_TOKEN]

  -s, --site-id     Site ID for API introspection [default: 1]
                             [env: MCP_MATOMO_SITE_ID]

  -h, --help                 Print help
  -V, --version              Print version

注: 要么 --url--openapi 必须提供。

______________________________________________________________________

HTTP配置

用户代理

所有HTTP请求都包含一个自定义的User-Agent标头:

User-Agent: mcp-matomo/

这对于在Matomo服务器日志中识别MCP请求或配置防火墙/代理规则非常有用。

额外标头

您可以使用 MCP_MATOMO_EXTRA_HEADERS 环境变量。

变量格式描述
MCP_MATOMO_EXTRA_HEADERSHeader1:Value1,Header2:Value2为每个HTTP请求添加自定义标头

示例用例:

  • 绕过身份验证代理(零信任、OAuth2代理)
  • 添加自定义跟踪标题
  • 在多租户设置中传递租户标识符
# Single header
export MCP_MATOMO_EXTRA_HEADERS="X-Auth-Bypass:secret-token"

# Multiple headers
export MCP_MATOMO_EXTRA_HEADERS="Authorization:Bearer xyz,X-Tenant-Id:acme-corp"

# In Claude Code configuration
claude mcp add matomo \
  --command /path/to/mcp-matomo \
  --args "--url" "https://your-matomo-instance.com" \
  --env "MCP_MATOMO_TOKEN=YOUR_API_TOKEN" \
  --env "MCP_MATOMO_EXTRA_HEADERS=X-Custom:value"

JSON配置:

{
  "mcpServers": {
    "matomo": {
      "command": "/path/to/mcp-matomo",
      "args": ["--url", "https://your-matomo-instance.com"],
      "env": {
        "MCP_MATOMO_TOKEN": "YOUR_API_TOKEN",
        "MCP_MATOMO_EXTRA_HEADERS": "X-Auth-Bypass:secret,X-Tenant:acme"
      }
    }
  }
}

发展

# Build debug version
cargo build

# Run tests
cargo test

# Run with logging
RUST_LOG=debug ./target/debug/mcp-matomo --openapi matomo-api.json --token YOUR_TOKEN

故障排除

“没有可用的工具”

如果使用动态内省(--url):

  1. 验证您的Matomo实例是否可访问
  2. 请检查您的API令牌是否具有正确的权限
  3. 尝试指定其他 --site-id 如果你有多个网站

如果使用预先生成的规范(--openapi):

  1. 确保您的OpenAPI JSON文件有效并包含路径
  2. 尝试使用 --url 而是动态地重新生成规范

“401未经授权”错误

  1. 验证您的API令牌是否正确
  2. 检查令牌是否具有足够的权限(至少是“查看”权限)
  3. 确保令牌正确传递(通过 --token 旗帜或 MCP_MATOMO_TOKEN 任何人)

“连接被拒绝”或超时

  1. 验证您的Matomo实例是否可以从您的计算机访问
  2. 检查防火墙或VPN要求
  3. 如果使用 --url,确保URL正确并包含协议(https://)
  4. 如果使用 --openapi,确保规范中的URL与您当前的Matomo URL匹配

贡献

欢迎投稿!请随时提交拉取请求。

许可证

MIT许可证-请参阅 许可证 了解详情。

致谢

目录标签

目录标签

数据分析RustClaudeAPI集成本地部署AI集成网站分析API服务MCP协议

支持客户端

Claude

接入字段

传输方式(transport,传输协议)

未说明

鉴权方式(authType,认证方式)

token

工具数量(toolCount,工具数)

63

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

未说明token部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

仍需确认:installCommand

来源信息

继续浏览同类 MCP