TMetric MCP服务器
用于TMetric时间跟踪集成的最小模型上下文协议服务器。
特性
- 列出TMetric项目
- 启动/停止计时器
- 检查当前计时器状态
- GitLab问题集成
- 删除时间条目
安装
npm install
npm run build配置
设置TMetric API令牌:
export TMETRIC_API_TOKEN="your_token_here"使用Claude代码
使用添加TMetric MCP服务器 claude mcp add 命令。您可以在不同的范围内安装:
用户范围(全局-所有项目)
适用于您的用户的所有项目:
一个衬垫:
claude mcp add --scope user tmetric-mcp --env TMETRIC_API_TOKEN=your_token_here -- node /path/to/tmetric-mcp-server/build/index.js互动:
claude mcp add tmetric-mcp --scope user出现提示时,配置:
- 命令:
node - 参数:
/path/to/tmetric-mcp-server/build/index.js - 环境变量:
TMETRIC_API_TOKEN=your_token_here
项目范围(具体项目)
仅在当前项目目录中可用:
一个衬垫:
claude mcp add --scope project tmetric-mcp --env TMETRIC_API_TOKEN=your_token_here -- node /path/to/tmetric-mcp-server/build/index.js互动:
claude mcp add tmetric-mcp --scope project出现提示时,使用与上述相同的设置进行配置。
本地作用域(当前目录)
仅在当前工作目录中可用:
一个衬垫:
claude mcp add --scope local tmetric-mcp --env TMETRIC_API_TOKEN=your_token_here -- node /path/to/tmetric-mcp-server/build/index.js互动:
claude mcp add tmetric-mcp --scope local出现提示时,使用与上述相同的设置进行配置。
替代方案:使用npx(来自GitHub)
您可以使用npx直接从GitHub运行(无需克隆或构建):
一个衬垫:
claude mcp add --scope user tmetric-mcp --env TMETRIC_API_TOKEN=your_token_here -- npx -y github:guglielmo/tmetric-minimal-mcp互动:
claude mcp add tmetric-mcp --scope user出现提示时,配置:
- 命令:
npx - 参数:
-y github:guglielmo/tmetric-minimal-mcp - 环境变量:
TMETRIC_API_TOKEN=your_token_here
替代方案:使用npx(来自本地路径)
如果您已在本地克隆了存储库:
一个衬垫:
claude mcp add --scope user tmetric-mcp --env TMETRIC_API_TOKEN=your_token_here -- npx -y /path/to/tmetric-mcp-server互动:
claude mcp add tmetric-mcp --scope user出现提示时,配置:
- 命令:
npx - 参数:
-y /path/to/tmetric-mcp-server - 环境变量:
TMETRIC_API_TOKEN=your_token_here
可用工具
list_tmetric-projects()
获取可用项目的列表。
get_current_timer()
检查计时器是否正在运行。
start_timer(项目id、任务名称、任务url?)
开始跟踪项目/任务的时间。
stop_timer()
停止当前计时器并返回所花费的时间。
delete_time_entry(entry_id?)
删除时间条目。
发展
# Watch mode
npm run watch
# Run directly with tsx
npm run dev测试
运行测试
# Run all tests once
npm test
# Run tests in watch mode (re-runs on file changes)
npm run test:watch
# Run tests with coverage report
npm run test:coverage
# Run tests with interactive UI
npm run test:ui测试覆盖率
该项目具有全面的测试覆盖范围,包括:
- 100%报表覆盖率 跨所有模块
- 97%以上的分支机构覆盖率 对于边缘情况
- 所有公用设施功能的单元测试(
utils.ts) - TMetric API客户端的完全集成测试(
tmetric-client.ts) - 使用模拟HTTP请求
nock用于可靠的测试
看 测试.md 有关测试策略和如何编写新测试的详细信息。
手动测试
通过启动对话并使用以下命令,使用Claude Code测试MCP服务器:
- “列出我的TMetric项目”
- “在项目12345上为问题#123启动计时器:修复错误”
- “我在做什么?”
- “停止计时器”
故障排除
“TMETRIC_API_TOKEN是必需的”
请确保您已经使用API令牌设置了环境变量。
“初始化TMetric客户端失败”
请检查您的API令牌是否有效,以及您是否可以通过网络访问TMetric。
“计时器已在运行”
这是预期的行为。在启动新计时器之前,请先停止当前计时器。
用途
此MCP服务器依赖于以下Claude Code技能:
- 发行时间跟踪 -自动化跨GitLab/GitHub和TMetric的同步问题状态跟踪和时间记录
许可证
麻省理工学院
