You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Feature Request: Expose /usage data as structured JSON for MCP servers and hooks #26295
Feature Request: Expose /usage data as structured JSON for MCP servers and hooks
Problem
The /usage command in Claude Code CLI only works interactively in the REPL. There is no way to programmatically access usage data (session %, weekly %, extra usage) from:
MCP servers
Hooks (SessionStart, Stop, etc.)
Non-interactive mode (claude --print)
External scripts
Use Case
I'm building an MCP server plugin that tracks usage limits in real-time and warns the user when approaching session limits. Currently, the only workaround is to:
Launch a separate Claude instance with script command to capture terminal output
Parse ANSI escape codes from the status bar
Extract the usage percentage with regex
This is fragile and only captures the session limit from the yellow status bar - not the full breakdown (session/weekly/extra).
Proposed Solution
Expose /usage data via one or more of these methods:
CLI flag: claude --usage or claude usage that outputs JSON:
Hook context: Include usage data in SessionStart and Stop hook payloads
MCP resource: Expose as an MCP resource claude://usage that MCP servers can read
File-based: Write usage data to ~/.claude/usage.json updated periodically
Environment
Claude Code v2.1.44
Claude Pro plan
Debian Linux
Additional Context
This would enable the community to build usage-aware plugins, auto-save features, and cost management tools. I've already built a working MCP server plugin (usage-tracker) that uses a script command workaround to capture the status bar, but a proper API would be much more reliable.
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.
Activity
github-actions commentedon Mar 18, 2026
Closing for now — inactive for too long. Please open a new issue if this is still relevant.
github-actions commentedon Mar 26, 2026
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.