Skip to content

Commit c0bc8c4

Browse files
feat: MCP server — expose session data to Claude Code (v0.4.0)
Adds `claudewatch mcp` subcommand implementing a JSON-RPC 2.0 stdio server compatible with the Model Context Protocol. Exposes three tools: get_session_stats, get_cost_budget, get_recent_sessions. Configure in ~/.claude.json mcpServers to make tools available inside Claude Code sessions.
2 parents c469d4f + f31cdb2 commit c0bc8c4

9 files changed

Lines changed: 2127 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
All notable changes to claudewatch are documented here.
44

5+
## [v0.4.0] - 2026-02-28
6+
7+
### Added
8+
9+
- **MCP server** — new `mcp` subcommand runs a JSON-RPC 2.0 stdio server compatible with the [Model Context Protocol](https://modelcontextprotocol.io). Exposes three tools to Claude Code and other MCP clients: `get_session_stats` (most recent completed session with cost and token breakdown), `get_cost_budget` (today's estimated spend vs a configurable daily budget), and `get_recent_sessions` (last N sessions with friction scores and cost, default 5, max 50). Start with `claudewatch mcp` or add `--budget <USD>` to enable budget tracking. Configure in `~/.claude.json` under `mcpServers` to make the tools available inside Claude Code sessions.
10+
511
## [v0.3.0] - 2026-02-28
612

713
### Added

README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ claudewatch track --compare
207207
| `track` | Snapshot metrics to SQLite, diff against previous |
208208
| `log` | Inject custom metrics (scale, boolean, counter, duration) |
209209
| `watch` | Background daemon with desktop alerts on friction spikes |
210+
| `mcp` | Run an MCP stdio server for Claude Code integration |
210211

211212
### `claudewatch fix`
212213

@@ -235,6 +236,36 @@ claudewatch watch --stop # stop background daemon
235236

236237
Notifies on: friction spikes, new stale patterns, agent kill rate increases, zero-commit streaks.
237238

239+
### `claudewatch mcp`
240+
241+
Run claudewatch as an MCP ([Model Context Protocol](https://modelcontextprotocol.io)) stdio server. This makes your session data directly queryable from inside Claude Code sessions without leaving the terminal.
242+
243+
```bash
244+
claudewatch mcp # start MCP server on stdio
245+
claudewatch mcp --budget 20 # enable daily budget tracking ($20 limit)
246+
```
247+
248+
**Configure in Claude Code** by adding to `~/.claude.json`:
249+
250+
```json
251+
{
252+
"mcpServers": {
253+
"claudewatch": {
254+
"command": "/usr/local/bin/claudewatch",
255+
"args": ["mcp", "--budget", "20"]
256+
}
257+
}
258+
}
259+
```
260+
261+
**Tools exposed:**
262+
263+
| Tool | Description |
264+
|------|-------------|
265+
| `get_session_stats` | Most recent completed session: cost, tokens, duration, project |
266+
| `get_cost_budget` | Today's estimated spend vs your daily budget |
267+
| `get_recent_sessions` | Last N sessions (default 5, max 50) with friction scores and cost |
268+
238269
### `claudewatch metrics --json`
239270

240271
Machine-readable JSON export for all metrics sections. Use for time-series analysis, cost dashboards, CI/CD integration, or custom queries.

0 commit comments

Comments
 (0)