ActivityWatch MCP Server 使用说明

项目简介

ActivityWatch MCP Server 是一个基于 Model Context Protocol (MCP) 构建的服务器,它作为 ActivityWatch 时间追踪工具和 LLM (如 Claude) 之间的桥梁。通过此服务器,LLM 客户端可以安全地访问和查询您的 ActivityWatch 数据,从而实现更智能的上下文感知交互。

主要功能点

  • 列出 Bucket (List Buckets): 查看 ActivityWatch 中所有可用的数据存储桶 (buckets),您可以根据类型进行过滤。
  • 运行查询 (Run Queries): 使用 ActivityWatch 查询语言 (AQL) 执行强大的数据查询,检索您感兴趣的时间追踪数据。
  • 获取原始事件 (Get Raw Events): 直接从指定的 Bucket 中获取原始事件数据,用于更细粒度的数据分析。
  • 获取设置 (Get Settings): 访问 ActivityWatch 的配置设置,了解或修改服务器的行为。

安装步骤

  1. 安装 ActivityWatch: 确保您已经安装并运行了 ActivityWatch 时间追踪工具。
  2. 安装 Node.js: 确保您的系统安装了 Node.js (版本 v14 或更高)。
  3. 克隆仓库: 使用 Git 克隆 ActivityWatch MCP Server 仓库到本地:
    git clone https://github.com/8bitgentleman/activitywatch-mcp-server.git
    cd activitywatch-mcp-server
  4. 安装依赖: 在仓库目录下运行 npm 命令安装项目依赖:
    npm install
  5. 构建项目: 运行 npm 命令构建项目:
    npm run build

服务器配置

要将 ActivityWatch MCP Server 与 MCP 客户端 (例如 Claude for Desktop) 连接,您需要配置客户端以指向此服务器。以下是配置示例 (JSON 格式),您需要将其添加到您的 MCP 客户端配置文件中。

以 Claude for Desktop 为例:

  1. 打开 Claude for Desktop 的配置文件 (通常是 'claude_desktop_config.json'),文件路径如下:

    • Windows: '%APPDATA%\Claude\claude_desktop_config.json'
    • macOS: '~/Library/Application Support/Claude/claude_desktop_config.json'
  2. 在 'mcpServers' 字段中添加 ActivityWatch MCP Server 的配置。

如果您使用 npm 安装 (即将推出):

{
  "mcpServers": {
    "activitywatch": {
      "command": "activitywatch-mcp-server",  // 启动服务器的命令
      "args": []                                // 启动参数,这里为空
    }
  }
}

如果您从源码构建:

{
  "mcpServers": {
    "activitywatch": {
      "command": "node",                       // 使用 Node.js 运行
      "args": ["/path/to/activitywatch-mcp-server/dist/index.js"] // 服务器入口文件路径,请替换为实际路径
    }
  }
}

请注意: '/path/to/activitywatch-mcp-server/dist/index.js' 需要替换为您实际的 'activitywatch-mcp-server' 仓库 'dist/index.js' 文件的绝对路径。

  1. 重启 Claude for Desktop: 保存配置文件并重启 Claude for Desktop,您应该能在界面中看到 MCP 服务器已连接的图标。

基本使用方法

配置完成后,您可以在 MCP 客户端中通过自然语言指令调用 ActivityWatch MCP Server 的功能。以下是一些示例,您可以在 Claude 等客户端中尝试:

  • 查询 Bucket 列表: 询问 "What ActivityWatch buckets do I have?" (我有哪些 ActivityWatch buckets?)
  • 查询应用使用情况: 询问 "Can you show me which applications I've used the most today?" (可以展示我今天使用最多的应用吗?)
  • 查询浏览历史: 询问 "What websites have I spent the most time on today?" (我今天在哪些网站上花费的时间最多?)
  • 查询工作效率: 询问 "How much time have I spent in productivity apps today?" (我今天在工作效率应用上花费了多少时间?)
  • 查询设置: 询问 "What are my ActivityWatch settings?" (我的 ActivityWatch 设置是什么?) 或 "Can you check a specific setting in ActivityWatch?" (你能检查 ActivityWatch 中的某个特定设置吗?)

请参考仓库 README.md 中的 Example QueriesAvailable Tools 部分,了解更多查询示例和可用工具的详细信息。

信息

分类

生产力应用