A local, offline CLI for rough estimates of tool-definition size in Diff v1 snapshots. It does not connect to MCP servers, execute tools, use a tokenizer, or report actual model context usage. Node.js 20 or newer is required; there are no dependencies. The JavaScript modules are internal and are not a public API.
node bin/joons-mcp-context-budget.js validate examples/snapshot.json
node bin/joons-mcp-context-budget.js measure examples/snapshot.json --format json
node bin/joons-mcp-context-budget.js check examples/snapshot.json --max-tokens 1000
node bin/joons-mcp-context-budget.js build examples/snapshot.json --out output
For each tool, serialize the six values name, title, description, input schema, output schema and annotations as a compact canonical JSON array. Object keys are sorted by UTF-16 code units. Estimate ceil(UTF-8 bytes / chars-per-token) + tool-overhead for each tool and then sum. Defaults are 4 and 12. The four attribution parts are bytes, not separate token counts; array framing belongs to name and title. No context window size or usage percentage is implied.
Duplicate description bytes count all but one copy of each SHA-256 group of non-null raw UTF-8 descriptions, separately globally and within each server. This is an indicator of duplication, not token savings. Server shares use largest-remainder allocation in basis points.
Reports omit server names, descriptions, schemas, paths, timestamps and hashes. --details explicitly includes tool names, which can expose sensitive internal information even after credential-shaped identifiers are refused. The scanner is a heuristic, not a guarantee. Data minimization is the boundary; the tool does not sanitize descriptions or schemas or promise anonymity.
Build writes report.json, report.md and a completion marker last. It checks output paths and links, and --force only permits a nonempty unmarked directory; it does not remove unrelated files or bypass security checks. Individual file writes are atomic, but the set is not transactional: a failed build can leave partial files, and filesystem races remain possible. See CLI, security and limitations.
Install with npm install -g github:dbdefault/joons-mcp-context-budget#v0.1.0. This command-line tool is not a supported library; src/ is internal. Use top to rank tools, measure to inspect all tools, validate to check a snapshot, check to compare a budget, and build to write artifacts. For CI, run joons-mcp-context-budget check examples/snapshot.json --max-tokens 1000: exit 0 is within budget, 1 exceeds it, 2 is an input or internal error, 3 is usage and 4 is output failure.
These numbers are ESTIMATES. A human must review outputs before sharing them. Description and schema text is never emitted. --details may reveal internal tool names.
To compare multiple servers, pass both synthetic files: joons-mcp-context-budget measure examples/snapshot.json examples/second.json --format json. Each input represents one server; repeated paths represent separate snapshots.
Identifier screening heuristically refuses common AWS access-key ID, GitHub, GitLab, sk-/live key, Slack, Google AIza/ya29, SendGrid, npm, Bearer, JWT and private-key header shapes, including supported percent and base64 forms. Bearer needs one non-space value character. A certificate header alone is accepted. This list is not a guarantee that a name is safe.