Timebook CLI
以下摘录自该仓库的 README(片段) · 在 GitHub 读完整 README →
Command-line client and **MCP server** for Timebook — track time, manage timers, and expose your Timebook account to AI agents (Claude, Codex, Cursor, …) over the Model Context Protocol.
Install
Requires Node.js **18.17+**.
Authenticate
timebook login opens your browser, you log into Timebook (or use an existing session) and pick a scope (which clients/projects this token can touch). The browser delivers the token back to a short-lived loopback HTTP listener, which the CLI then writes to a config file with 0600 permissions.
The token is stored at:
- macOS: ~/Library/Preferences/timebook/config.json
- Linux: ~/.config/timebook/config.json
- Windows: %APPDATA%\timebook\Config\config.json
The token never leaves your machine after login. To revoke it server-side, visit https://usetimebook.com/settings/api-tokens.
Use it as a CLI
Duration formats accepted: 1h, 45m, 1h30m, 1.5h, 1:30, or a bare number (interpreted as minutes — e.g. 90 → 1h 30m).
**Edit / delete authorization:** an API token can only modify entries it created itself. JWT sessions (the web UI) and admin tokens bypass this rule. Invoiced entries are locked for everyone via the API. A 403 with a friendly message is returned on a denied attempt — fix the entry from the web UI or with the token that created it.
Use it as an MCP server
The same binary speaks MCP over stdio when invoked with timebook mcp. Drop it into any MCP-aware host (Claude Code, Claude Desktop, Codex, Cursor, …):
Claude Code / Claude Desktop
Or, if installed globally:
The MCP server reuses the token saved by timebook login — run timebook login once in a terminal before starting the agent.
Use it as a remote MCP (Claude.ai web)
Timebook also runs as a hosted Streamable-HTTP MCP server at **https://usetimebook.com/mcp** with full OAuth 2.0 (Dynamic Client Registration + PKCE + refresh-token rotation). No CLI install required — Claude.ai discovers it via the standard well-known endpoints:
- Auth-server metadata: https://usetimebook.com/.well-known/oauth-authorization-server
- Resource metadata: https://usetimebook.com/.well-known/oauth-protected-resource/mcp
Connect from Claude.ai → Settings → Connectors → Add → paste https://usetimebook.com/mcp. You'll be redirected to Timebook's consent page once, then Claude can use all the same tools listed below. Same OAuth-style permissions you'd see for any first-class connector.
The HTTP endpoint also accepts Authorization: Bearer tbk_* (your existing API token) for any client that prefers token-paste over OAuth — including server-to-server use.
Tools exposed to the model
| Tool | What it does |
| ------------------ | ------------------------------------------------------------------------------------------------------------------------- |
| whoami | Current authenticated user (read-only) |
| list_projects | All projects in scope (read-only) |
| list_clients | All clients in scope (read-only) |
| get_active_timer | The running timer, or null (read-only) |
| start_timer | Start a timer on a project |
| stop_timer | Stop the running timer |
| log_time | Log a manual entry (duration OR startTime+endTime) |
| list_entries | Recent entries (default 50, max 500), project + date filters |