wakatime-mcp
# wakatime-mcp
A lightweight, read-only [Model Context Protocol (MCP)](https://modelcontextprotocol.io) server (`stdio` transport) for personal [WakaTime](https://wakatime.com) analytics, built as a standalone proof-of-concept for [`wakatime/wakatime-cli#1184`](https://github.com/wakatime/wakatime-cli/issues/1184).
## Tools & Question Mapping
Rather than mirroring every raw REST endpoint, `wakatime-mcp` exposes **4 high-signal read-only tools** mapped directly to the core developer questions highlighted in [`wakatime/wakatime-cli#1184`](https://github.com/wakatime/wakatime-cli/issues/1184):
| Developer Question | MCP Tool | WakaTime API v1 Endpoints Used | Key Behavior |
| :--- | :--- | :--- | :--- |
| **"What have I been working on?"** | `wakatime_recent_activity(range_str="last_7_days", project=None)` | `GET /users/current/summaries` | Aggregates coding time across projects, languages, editors, branches, and categories with human-readable durations, percentage shares, and daily breakdown. |
| **"What should I say in standup?"** | `wakatime_standup_brief(target_date="yesterday")` | `GET /users/current/summaries`, `GET /users/current/durations` | Compares previous coding day + today's progress by project and branch into concise `yesterday` / `today` / `focus` bullets. Automatically falls back up to 7 days if `yesterday` had `0s` (e.g., Monday standup after a weekend). |
| **"Am I on track?"** | `wakatime_goals_progress()` | `GET /users/current/goals`, `GET /users/current/status_bar/today` | Evaluates enabled daily and weekly goals (`more` and `less` targets) against live status-bar progress, returning `ahead` / `on_track` / `behind` and exact remaining minutes needed today. |
| **"Why is WakaTime showing weird numbers?"** | `wakatime_diagnostics(date_str="today")` | `GET /users/current`, `GET /users/current/machine_names`, `GET /users/current/user_agents`, `GET /users/current/durations` | Detects stale or missing heartbeats, unset/UTC profile timezone drift, multi-machine hostname splits, `Unknown Project` / untracked git branch slices, `writes_only` mode, and custom keystroke `timeout` windows (`default 15m`). |
## Authentication & Zero-Config Discovery
`wakatime-mcp` resolves credentials automatically in the following order:
1. **`WAKATIME_API_KEY` environment variable** (plus optional `WAKATIME_API_URL`, defaulting to `https://api.wakatime.com/api/v1`).
2. **`~/.wakatime.cfg` INI file** (also honoring `$WAKATIME_CONFIG` and `$WAKATIME_HOME/.wakatime.cfg`), reading `[settings] api_key`, `api_url`, `timeout`, and `hostname` — matching `wakatime-cli` out of the box with zero duplicate configuration.
Both modern `waka_...` keys and legacy UUID keys are encoded per WakaTime's HTTP Basic Auth specification (`Authorization: Basic <base64(api_key)>`).
### Security & Privacy Design
- **100% Read-Only Personal Scope:** Only `GET /users/current/*` endpoints are called; heartbeats, goals, and account settings are never mutated.
- **Automatic Secret Redaction:** `WakaTimeConfig`, `WakaTimeError`, and `redact_secrets()` scrub raw API keys, Base64 credentials, and query parameters from all `repr()` strings and error payloads.
- **TLS Enforcement:** Non-loopback `http://` `api_url` values are rejected by default unless `WAKATIME_ALLOW_INSECURE_HTTP=1` is explicitly set for local self-hosted testing.
## Quick Start
### Install
```bash
pip install git+https://github.com/khoap1220-hue/wakatime-mcp.git
```
Or run directly with [`uv`](https://docs.astral.sh/uv/):
```bash
uvx --from git+https://github.com/khoap1220-hue/wakatime-mcp.git wakatime-mcp
```
### Client Configuration (Claude Desktop / Cursor / VS Code / Continue)
If `~/.wakatime.cfg` is already configured on your machine by your IDE's WakaTime plugin, no extra `env` block is required:
```json
{
"mcpServers": {
"wakatime": {
"command": "uvx",
"args": [
"--from",
"git+https://github.com/khoap1220-hue/wakatime-mcp.git",
"wakatime-mcp"
]
}
}
}
```
Or pass `WAKATIME_API_KEY` explicitly:
```json
{
"mcpServers": {
"wakatime": {
"command": "wakatime-mcp",
"env": {
"WAKATIME_API_KEY": "waka_your_api_key_here"
}
}
}
}
```
## Development & Testing
```bash
pip install -e ".[dev]"
ruff check src tests
PYTHONDONTWRITEBYTECODE=1 python -B -m pytest
```
## Roadmap (Planned Next Phases)
This repository intentionally focuses on the **personal read-only core**. Planned next phases depending on maintainer direction in [`wakatime/wakatime-cli#1184`](https://github.com/wakatime/wakatime-cli/issues/1184):
- **Organization & Team Dashboards:** Scoped read-only tools for `/orgs/:org/dashboards/...` team summaries and project velocity.
- **OAuth 2.0 Flows:** Least-privilege OAuth2 scopes (`email`, `read_logged_time`, `read_stats`) with automatic token refresh.
- **Streamable HTTP Transport:** Remote MCP server deployment support alongside local `stdio`.
- **Optional Go CLI Bridge:** Evaluating a standalone binary/repository vs. a thin `wakatime-cli --serve-mcp` subcommand sharing `~/.wakatime.cfg` parsing.
## License
[MIT](LICENSE)
TDQS
Scored across 4 tools
Each tool has a distinct high-level purpose: diagnostics, recent activity, standup summary, and goal progress. The main overlap is between wakatime_recent_activity and wakatime_standup_brief, since both aggregate summaries, but their descriptions make the boundary reasonably clear.
All four tools use the same wakatime_ prefix and snake_case noun-phrase naming convention. There is no mixing of casing or verb styles.
Four focused tools fit the narrow WakaTime workflow use case well. Each tool maps to a clear question or task, with no obviously redundant or filler tools.
The surface covers diagnostics, activity review, standup reporting, and goal tracking, which are core personal WakaTime workflows. Minor gaps remain, such as project listing or more granular stats, but agents can work around these for the stated purposes.