Back to MCP directory
publicPublicdnsLocal runtime

activitywatch-mcp-server

ActivityWatch MCP服务器是一个连接时间追踪工具ActivityWatch的中间件,允许Claude等LLM模型通过标准协议访问用户的时间追踪数据。

article

README

🚀 活动观察 MCP 服务器

活动观察 MCP 服务器可借助 Claude 等 AI 工具与 ActivityWatch 交互,实现对用户活动数据的查询与分析,助力用户更好地跟踪和理解自身活动情况。

🚀 快速开始

使用此 MCP 服务器前,需确保 Node.js 和 npm 已安装,且 ActivityWatch 服务器正在运行,默认地址为 http://localhost:5600

✨ 主要特性

  • 收集活动数据:从 ActivityWatch 收集详细的用户活动数据。
  • 时间范围筛选:支持指定时间段进行数据查询。
  • 多条件过滤:可以根据应用程序、状态(如是否空闲)等条件过滤数据。
  • 数据聚合:能够将活动数据按应用程序或其他属性进行汇总和统计。

📦 安装指南

从 npm 安装

npm install activitywatch-mcp-server

源码构建安装

  1. 克隆仓库:
git clone https://github.com/yourusername/activitywatch-mcp-server.git
cd activitywatch-mcp-server
  1. 安装依赖:
npm install
  1. 启动服务:
npm start

💻 使用示例

基础用法

连接 ActivityWatch

默认连接到 http://localhost:5600。如需更改,请修改源码中的配置。

获取浏览器活动

{
  "timeperiods": ["2024-10-28/2024-10-29"],
  "query": ["browser_events = query_bucket('aw-watcher-web'); RETURN = browser_events;"]
}

过滤空闲状态

{
  "timeperiods": ["2024-10-28/2024-10-29"],
  "query": [
    "afk_bucket = query_bucket('aw-watcher-afk_');",
    "not_afk_events = filter_keyvals(afk_bucket, 'status', ['not-afk']);",
    "window_events = query_bucket('aw-watcher-window_');",
    "final_events = filter_period_intersect(window_events, not_afk_events);",
    "RETURN = final_events;"
  ]
}

高级用法

获取窗口事件

window_events = query_bucket(find_bucket("aw-watcher-window_"));
RETURN = window_events;

按应用程序分组

window_events = query_bucket(find_bucket("aw-watcher-window_"));
events_by_app = merge_events_by_keys(window_events, ["app"]);
RETURN = sort_by_duration(events_by_app);

📚 详细文档

配置

默认连接地址为 http://localhost:5600。如需更改,请在代码中修改相应配置。

故障排除

ActivityWatch 未运行

如果服务出现连接错误,请确保 ActivityWatch 已启动并可通过 http://localhost:5600 访问。

查询错误

  • 检查查询语法
  • 确认桶 ID 正确
  • 验证时间段内有数据
  • 查看 ActivityWatch 日志获取更多信息

问题提示

当通过 Claude 运行查询时,确保 JSON 格式正确。特别是将所有查询语句放在一个字符串中:

{
  "timeperiods": ["2024-10-28/2024-10-29"],
  "query": ["statement1; statement2; RETURN = result;"]
}

📄 许可证

MIT

贡献

欢迎贡献!请随时提交 Pull Request。

help

Runtime guide

cloud

Hosted runtime

Hosted servers run from a provider-managed environment. You usually connect the MCP client to the hosted endpoint or follow the provider's authorization flow, without keeping a local process alive

  1. Open provider connection page
  2. Authorize or copy endpoint
  3. Connect from your MCP client
terminal

Local runtime / other methods

Local servers run on your own machine or infrastructure. You normally copy the server_config into your MCP client, install the required package, and provide env variables from env_schema when needed

  1. Copy server_config
  2. Install required package
  3. Fill env variables and restart client