ccusage 0.4.1 → 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.
- package/README.md +68 -0
- package/dist/arktype-C-GObzDh-Dj1DVoqC.js +5 -0
- package/dist/{calculate-cost-DMC4FhU4.js → calculate-cost-2IwHSzmi.js} +1 -1
- package/dist/calculate-cost.d.ts +5 -2
- package/dist/calculate-cost.js +1 -1
- package/dist/core-BgFXUe_h.js +693 -0
- package/dist/data-loader-LMCrJ-lW.d.ts +56 -0
- package/dist/{data-loader-BBdPk24U.js → data-loader-r5ZcMQy7.js} +122 -1608
- package/dist/data-loader.d.ts +4 -1
- package/dist/data-loader.js +4 -1
- package/dist/debug-BVxGf4UL.js +142 -0
- package/dist/debug.d.ts +39 -0
- package/dist/debug.js +7 -0
- package/dist/dist-C_i5I27w.js +469 -0
- package/dist/dist-FwNhpFrW.js +491 -0
- package/dist/effect-WSjEuzC9-BsxP11fz.js +10 -0
- package/dist/esm-vjyZjnpZ.js +1090 -0
- package/dist/{data-loader-D1LHcGfa.d.ts → index-BurjgCfW.d.ts} +323 -76
- package/dist/index-CISmcbXk-BotItq1T.js +23 -0
- package/dist/index.js +72 -265
- package/dist/logger-Cu4Ir1a5.js +977 -0
- package/dist/logger.d.ts +10 -0
- package/dist/logger.js +3 -0
- package/dist/mcp-DAzj5Pua.js +37580 -0
- package/dist/mcp.d.ts +15 -0
- package/dist/mcp.js +10 -0
- package/dist/pricing-fetcher-B5yPtoTB.js +60 -0
- package/dist/pricing-fetcher-DygIroMj.d.ts +21 -0
- package/dist/pricing-fetcher.d.ts +3 -0
- package/dist/pricing-fetcher.js +5 -0
- package/dist/shared-args-DN3jRldX.js +61 -0
- package/dist/shared-args.d.ts +94 -0
- package/dist/shared-args.js +8 -0
- package/dist/sury-DmrZ3_Oj-DhGOjCNc.js +10 -0
- package/dist/types-B3ib19os.d.ts +79 -0
- package/dist/types-CFnCBr2I.js +3586 -0
- package/dist/types-DFrbJmnT.js +41 -0
- package/dist/types.d.ts +3 -0
- package/dist/types.js +4 -0
- package/dist/utils-C7kg8MXN.js +10 -0
- package/dist/utils.d.ts +5 -0
- package/dist/utils.js +3 -0
- package/dist/valibot-CQk-M5rL-Cq5E7F3g.js +10 -0
- package/dist/zod-Db63SLXj-BWdcigdx.js +30 -0
- package/package.json +8 -1
- /package/dist/{prompt-_w55ddDU.js → prompt-IToGuko2.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
|
package/dist/calculate-cost.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import
|
|
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";
|
|
2
5
|
|
|
3
|
-
//#region calculate-cost.d.ts
|
|
6
|
+
//#region src/calculate-cost.d.ts
|
|
4
7
|
declare function calculateTotals(data: Array<DailyUsage | SessionUsage>): TokenTotals;
|
|
5
8
|
declare function getTotalTokens(tokens: TokenData): number;
|
|
6
9
|
declare function createTotalsObject(totals: TokenTotals): {
|
package/dist/calculate-cost.js
CHANGED