|
| 1 | +# Timebook CLI |
| 2 | + |
| 3 | +Command-line client and **MCP server** for [Timebook](https://usetimebook.com) — track time, manage timers, and expose your Timebook account to AI agents (Claude, Codex, Cursor, …) over the [Model Context Protocol](https://modelcontextprotocol.io). |
| 4 | + |
| 5 | +[](https://www.npmjs.com/package/@squidcode/timebook-cli) |
| 6 | +[](./LICENSE) |
| 7 | + |
| 8 | +## Install |
| 9 | + |
| 10 | +```bash |
| 11 | +# one-off |
| 12 | +npx @squidcode/timebook-cli login |
| 13 | + |
| 14 | +# globally |
| 15 | +npm install -g @squidcode/timebook-cli |
| 16 | +timebook --help |
| 17 | +``` |
| 18 | + |
| 19 | +Requires Node.js **18.17+**. |
| 20 | + |
| 21 | +## Authenticate |
| 22 | + |
| 23 | +`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. |
| 24 | + |
| 25 | +```bash |
| 26 | +timebook login |
| 27 | +``` |
| 28 | + |
| 29 | +The token is stored at: |
| 30 | + |
| 31 | +- macOS: `~/Library/Preferences/timebook/config.json` |
| 32 | +- Linux: `~/.config/timebook/config.json` |
| 33 | +- Windows: `%APPDATA%\timebook\Config\config.json` |
| 34 | + |
| 35 | +The token never leaves your machine after login. To revoke it server-side, visit `https://usetimebook.com/settings/api-tokens`. |
| 36 | + |
| 37 | +## Use it as a CLI |
| 38 | + |
| 39 | +```bash |
| 40 | +timebook whoami |
| 41 | +timebook projects # list projects |
| 42 | +timebook clients # list clients |
| 43 | + |
| 44 | +timebook start -p "Acme website" -d "Wireframes" |
| 45 | +timebook status # show running timer |
| 46 | +timebook stop |
| 47 | + |
| 48 | +# manual entries |
| 49 | +timebook log -p "Acme website" -t 1h30m -d "Code review" |
| 50 | +timebook log -p PROJ_ID --start 2026-05-04T09:00 --end 2026-05-04T10:30 |
| 51 | + |
| 52 | +timebook entries --project "Acme website" -n 10 |
| 53 | +``` |
| 54 | + |
| 55 | +Duration formats accepted: `1h`, `45m`, `1h30m`, `1.5h`, `1:30`, or a bare number (interpreted as minutes — e.g. `90` → 1h 30m). |
| 56 | + |
| 57 | +## Use it as an MCP server |
| 58 | + |
| 59 | +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, …): |
| 60 | + |
| 61 | +### Claude Code / Claude Desktop |
| 62 | + |
| 63 | +```json |
| 64 | +{ |
| 65 | + "mcpServers": { |
| 66 | + "timebook": { |
| 67 | + "command": "npx", |
| 68 | + "args": ["-y", "@squidcode/timebook-cli", "mcp"] |
| 69 | + } |
| 70 | + } |
| 71 | +} |
| 72 | +``` |
| 73 | + |
| 74 | +Or, if installed globally: |
| 75 | + |
| 76 | +```json |
| 77 | +{ |
| 78 | + "mcpServers": { |
| 79 | + "timebook": { |
| 80 | + "command": "timebook", |
| 81 | + "args": ["mcp"] |
| 82 | + } |
| 83 | + } |
| 84 | +} |
| 85 | +``` |
| 86 | + |
| 87 | +The MCP server reuses the token saved by `timebook login` — run `timebook login` once in a terminal before starting the agent. |
| 88 | + |
| 89 | +### Tools exposed to the model |
| 90 | + |
| 91 | +| Tool | What it does | |
| 92 | +| ------------------ | ------------------------------------------------ | |
| 93 | +| `whoami` | Current authenticated user | |
| 94 | +| `list_projects` | All projects in scope | |
| 95 | +| `list_clients` | All clients in scope | |
| 96 | +| `get_active_timer` | The running timer, or `null` | |
| 97 | +| `start_timer` | Start a timer on a project | |
| 98 | +| `stop_timer` | Stop the running timer | |
| 99 | +| `log_time` | Log a manual entry (`duration` OR `start`+`end`) | |
| 100 | +| `list_entries` | Recent entries, optional project + date filters | |
| 101 | + |
| 102 | +## Configuration |
| 103 | + |
| 104 | +Override the API/web hosts (useful for self-hosted Timebook or local dev): |
| 105 | + |
| 106 | +```bash |
| 107 | +TIMEBOOK_API_URL=https://api.example.com \ |
| 108 | +TIMEBOOK_WEB_URL=https://example.com \ |
| 109 | +timebook login |
| 110 | +``` |
| 111 | + |
| 112 | +You can also pass `--api-url` and `--web-url` to `timebook login` once; subsequent commands re-use the saved values. |
| 113 | + |
| 114 | +## Develop |
| 115 | + |
| 116 | +```bash |
| 117 | +git clone https://github.com/squidcode/timebook-cli |
| 118 | +cd timebook-cli |
| 119 | +npm install |
| 120 | +npm run dev -- --help # tsx-powered hot-loop |
| 121 | +npm run build # emits dist/ |
| 122 | +npm run lint && npm run typecheck |
| 123 | +``` |
| 124 | + |
| 125 | +Pre-commit hooks (ESLint + Prettier via `lint-staged`) are wired up by `husky` on `npm install`. |
| 126 | + |
| 127 | +## Release |
| 128 | + |
| 129 | +`prepublishOnly` runs lint + typecheck + build, then: |
| 130 | + |
| 131 | +```bash |
| 132 | +npm publish --access public |
| 133 | +``` |
| 134 | + |
| 135 | +## License |
| 136 | + |
| 137 | +MIT © Squidcode LLC. See [LICENSE](./LICENSE). |
0 commit comments