ccusage 0.4.2 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/README.md +68 -0
  2. package/dist/arktype-C-GObzDh-Dj1DVoqC.js +5 -0
  3. package/dist/calculate-cost.d.ts +4 -4
  4. package/dist/calculate-cost.js +1 -1
  5. package/dist/core-BgFXUe_h.js +693 -0
  6. package/dist/{data-loader-DtCt7sNl.d.ts → data-loader-LMCrJ-lW.d.ts} +3 -3
  7. package/dist/{data-loader-B8mdiY5r.js → data-loader-r5ZcMQy7.js} +2 -2
  8. package/dist/data-loader.d.ts +4 -4
  9. package/dist/data-loader.js +4 -4
  10. package/dist/{debug-Oce2b5bO.js → debug-BVxGf4UL.js} +4 -4
  11. package/dist/debug.js +5 -5
  12. package/dist/dist-C_i5I27w.js +469 -0
  13. package/dist/{dist-D6rk8Ra5.js → dist-FwNhpFrW.js} +30 -1
  14. package/dist/effect-WSjEuzC9-BsxP11fz.js +10 -0
  15. package/dist/esm-vjyZjnpZ.js +1090 -0
  16. package/dist/index-CISmcbXk-BotItq1T.js +23 -0
  17. package/dist/index.js +48 -9
  18. package/dist/{logger-nCODI08N.js → logger-Cu4Ir1a5.js} +2 -2
  19. package/dist/logger.js +1 -1
  20. package/dist/mcp-DAzj5Pua.js +37580 -0
  21. package/dist/mcp.d.ts +15 -0
  22. package/dist/mcp.js +10 -0
  23. package/dist/{pricing-fetcher-bvi4lbXl.js → pricing-fetcher-B5yPtoTB.js} +2 -2
  24. package/dist/{pricing-fetcher-BqlslEH3.d.ts → pricing-fetcher-DygIroMj.d.ts} +1 -1
  25. package/dist/pricing-fetcher.d.ts +2 -2
  26. package/dist/pricing-fetcher.js +3 -3
  27. package/dist/{shared-args-DWaGio0e.js → shared-args-DN3jRldX.js} +3 -3
  28. package/dist/shared-args.js +6 -6
  29. package/dist/sury-DmrZ3_Oj-DhGOjCNc.js +10 -0
  30. package/dist/{types-BfZ5dOy7.d.ts → types-B3ib19os.d.ts} +1 -1
  31. package/dist/types-CFnCBr2I.js +3586 -0
  32. package/dist/{types-DjlBTM5P.js → types-DFrbJmnT.js} +1 -1
  33. package/dist/types.d.ts +2 -2
  34. package/dist/types.js +2 -2
  35. package/dist/utils.js +1 -1
  36. package/dist/valibot-CQk-M5rL-Cq5E7F3g.js +10 -0
  37. package/dist/zod-Db63SLXj-BWdcigdx.js +30 -0
  38. package/package.json +2 -1
  39. /package/dist/{calculate-cost-BnufbprY.js → calculate-cost-2IwHSzmi.js} +0 -0
  40. /package/dist/{index-Bazt8Nfd.d.ts → index-BurjgCfW.d.ts} +0 -0
  41. /package/dist/{prompt-BwcIpzWm.js → prompt-IToGuko2.js} +0 -0
  42. /package/dist/{utils-BeihwpHn.js → utils-C7kg8MXN.js} +0 -0
package/README.md CHANGED
@@ -73,6 +73,12 @@ npx ccusage@latest
73
73
 
74
74
  # Using bunx
75
75
  bunx ccusage
76
+
77
+ # Using pnpm
78
+ pnpm dlx ccusage
79
+
80
+ # Using Deno with security flags
81
+ deno run -E -R=$HOME/.claude/projects/ -S=homedir -N='raw.githubusercontent.com:443' npm:ccusage@latest
76
82
  ```
77
83
 
78
84
  ### Local Installation
@@ -175,6 +181,68 @@ All commands support the following options:
175
181
  - **`calculate`**: Always calculates costs from token counts using model pricing, ignores any pre-calculated `costUSD` values
176
182
  - **`display`**: Always uses pre-calculated `costUSD` values only, shows $0.00 for entries without pre-calculated costs
177
183
 
184
+ ### MCP (Model Context Protocol) Support
185
+
186
+ Exposes usage data through Model Context Protocol for integration with other tools:
187
+
188
+ ```bash
189
+ # Start MCP server with stdio transport (for local integration)
190
+ ccusage mcp
191
+
192
+ # Start MCP server with HTTP stream transport (for remote access)
193
+ ccusage mcp --type http --port 8080
194
+
195
+ # Control cost calculation mode
196
+ ccusage mcp --mode calculate
197
+ ```
198
+
199
+ The MCP server supports both **stdio** and **HTTP stream** transports:
200
+ - **stdio** (default): Best for local integration where the client directly spawns the process
201
+ - **HTTP stream**: Best for remote access when you need to call the server from another machine or network location
202
+
203
+ Available MCP tools:
204
+ - `daily`: Returns daily usage reports (accepts `since`, `until`, `mode` parameters)
205
+ - `session`: Returns session usage reports (accepts `since`, `until`, `mode` parameters)
206
+
207
+ #### Claude Desktop Configuration Example
208
+
209
+ <div align="center">
210
+ <img src="https://github.com/ryoppippi/ccusage/blob/main/docs/mcp-claude-desktop.avif?raw=true">
211
+ </div>
212
+
213
+ To use ccusage MCP with Claude Desktop, add this to your Claude Desktop configuration file:
214
+
215
+ **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
216
+ **Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
217
+
218
+ ```json
219
+ {
220
+ "mcpServers": {
221
+ "ccusage": {
222
+ "command": "npx",
223
+ "args": ["ccusage@latest", "mcp"],
224
+ "env": {}
225
+ }
226
+ }
227
+ }
228
+ ```
229
+
230
+ Or if you have ccusage installed globally:
231
+
232
+ ```json
233
+ {
234
+ "mcpServers": {
235
+ "ccusage": {
236
+ "command": "ccusage",
237
+ "args": ["mcp"],
238
+ "env": {}
239
+ }
240
+ }
241
+ }
242
+ ```
243
+
244
+ After adding this configuration, restart Claude Desktop. You'll then be able to use the ccusage tools within Claude to analyze your usage data.
245
+
178
246
  ## Output Example
179
247
 
180
248
  ### Daily Report
@@ -0,0 +1,5 @@
1
+ //#region node_modules/xsschema/dist/arktype-C-GObzDh.js
2
+ const getToJsonSchemaFn = async () => (schema) => schema.toJsonSchema();
3
+
4
+ //#endregion
5
+ export { getToJsonSchemaFn };
@@ -1,7 +1,7 @@
1
- import "./index-Bazt8Nfd.js";
2
- import "./pricing-fetcher-BqlslEH3.js";
3
- import { TokenData, TokenTotals } from "./types-BfZ5dOy7.js";
4
- import { DailyUsage, SessionUsage } from "./data-loader-DtCt7sNl.js";
1
+ import "./index-BurjgCfW.js";
2
+ import "./pricing-fetcher-DygIroMj.js";
3
+ import { TokenData, TokenTotals } from "./types-B3ib19os.js";
4
+ import { DailyUsage, SessionUsage } from "./data-loader-LMCrJ-lW.js";
5
5
 
6
6
  //#region src/calculate-cost.d.ts
7
7
  declare function calculateTotals(data: Array<DailyUsage | SessionUsage>): TokenTotals;
@@ -1,3 +1,3 @@
1
- import { calculateTotals, createTotalsObject, getTotalTokens } from "./calculate-cost-BnufbprY.js";
1
+ import { calculateTotals, createTotalsObject, getTotalTokens } from "./calculate-cost-2IwHSzmi.js";
2
2
 
3
3
  export { calculateTotals, createTotalsObject, getTotalTokens };