Toggl MCP服务器
Go内置的用于Toggl时间跟踪的轻量级MCP(模型上下文协议)服务器。
特性
时间录入管理
- ⚠️ start_time_entry -开始新的时间条目
- ⚠️ stop_time_entry -停止当前运行时间条目
- ✅ get_current_time_entry -获取当前运行时间条目
- ✅ get_time_entrys -通过可选的日期过滤获取时间条目
- ✅ get_time_entries_for_day -获取特定日期的时间条目(方便)
项目管理
- ✅ 创建项目 -创建新项目
- ✅ get_项目 -在工作区中获取项目
全部
- update_time_entry
- update_项目
超出范围
目前,我选择将这些排除在范围之外,以尽量减少意外破坏行为的风险。
- 🚫 删除项目
- 🚫 删除尝试
项目结构
togglgo-mcp/
├── main.go # Entry point
├── app/
│ ├── client.go # Toggl API client
│ ├── handlers.go # MCP tool handlers
│ ├── types.go # Type definitions
│ └── utils.go # Helper functions
├── go.mod
├── go.sum
└── README.md设置
- 从获取Toggl API令牌 Toggl轨道剖面图
- 设置环境变量:
export TOGGL_API_TOKEN=your_api_token_here安装
go mod tidy
go build -o toggl-mcp发展
先决条件
- 转到1.21或更高版本
- 用于测试的Toggl API令牌
建造和测试
# Install dependencies
go mod tidy
# Run tests
go test ./app -v
# Run tests with coverage
go test ./app -cover
# Build the binary
go build -o toggl-mcp
# Run the MCP server (for debugging)
./toggl-mcp使用Claude Desktop安装和使用
您可以通过在Claude配置文件中配置此MCP服务器,将其用作Claude Desktop(Anthropic的桌面应用程序)中的自定义工具。
1.构建MCP服务器
go build -o toggl-mcp3.配置克劳德桌面
编辑(或创建)您的Claude Desktop配置文件,通常位于:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - 窗户:
%APPDATA%\Claude\claude_desktop_config.json
添加一个指向二进制文件的部分,例如:
{
"mcpServers": {
"toggl": {
"command": "/Users/yourname/togglgo-mcp/toggl-mcp",
"env": {
"TOGGL_API_TOKEN": "your-token-here"
}
}
}
}注:
- 确保
command路径指向您构建的toggl-mcp二元的。 - 您可以设置
TOGGL_API_TOKEN在这里或shell环境中。 - Claude Desktop将根据需要启动MCP服务器。
4.启动克劳德桌面
- 重新启动克劳德桌面。它将检测并使用您的自定义MCP工具。
- 现在,您可以在Claude Desktop中使用Toggl工具。
api参考
时间输入工具
start_time_entry
description(必填)-时间输入说明workspace_id(必填)-工作区IDproject_id(可选)-项目ID
stop_time_entry
workspace_id(必填)-工作区ID
get_current_time_entry
无需参数。
get_time_entrys
start_date(可选)-开始日期(YYYY-MM-DD)end_date(可选)-结束日期(YYYY-MM-DD)
重要提示: Toggl API使用包含开始日期、独占结束日期逻辑。要获取单日(例如7月9日)的条目,请使用 start_date=2025-07-09 和 end_date=2025-07-10.
get_time_entries_for_day
date(必填)-获取条目的日期(YYYY-MM-DD)
方便的工具,自动处理一天的日期范围。
项目工具
创建项目
name(必填)-项目名称workspace_id(必填)-工作区IDcolor(可选)-项目颜色client_id(可选)-客户端ID
get_项目
workspace_id(必填)-工作区IDactive(可选)-按活动状态筛选
测试
该项目包括所有主要组件的全面测试覆盖率(86.4%)。
运行测试
# Run all tests
go test ./app
# Run tests with verbose output
go test ./app -v
# Run tests with coverage
go test ./app -cover
# Generate detailed coverage report
go test ./app -coverprofile=coverage.out
go tool cover -html=coverage.out -o coverage.html
# Generate function-level coverage report
go tool cover -func=coverage.out