@tokenzero/mcp 0.2.0 → 0.2.2

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.
@@ -754,7 +754,7 @@ function manifests(root) {
754
754
  }
755
755
 
756
756
  // mcp/src/main.ts
757
- var VERSION = "0.2.0";
757
+ var VERSION = "0.2.2";
758
758
  var BAKED_URL = true ? "https://tokenzero.sh" : "__TOKENZERO_DEFAULT_URL__";
759
759
  var SUPPORTED = [...MCP_LEGACY_VERSIONS];
760
760
  var SERVER = { name: "tokenzero", version: VERSION };
@@ -777,6 +777,11 @@ var TOOLS = [
777
777
  description: "Rewrite an OpenAI Chat/Responses or Anthropic Messages request body so its static prefix is provider-cacheable, and project the saving. Sends the body you pass to the TokenZero service (set TOKENZERO_URL); do not pass secrets in it.",
778
778
  inputSchema: { type: "object", properties: { body: { type: "object" }, endpoint: { type: "string", enum: ["/v1/chat/completions", "/v1/responses", "/v1/messages"] }, strategy: { type: "string", enum: ["static", "conversation"] } }, required: ["body"], additionalProperties: false }
779
779
  },
780
+ {
781
+ name: "workspace_metrics",
782
+ description: "Live value scorecard for a TokenZero workspace (GET /v1/workspaces/me/metrics): hard savings and net ROI per window, per-engine contribution, speed, parity, availability, privacy posture, per-model breakdown and one-click recommendations. Uses TOKENZERO_KEY unless a key is given; demo: true returns a labelled sample.",
783
+ inputSchema: { type: "object", properties: { key: { type: "string", description: "workspace key (tz_live_\u2026); defaults to TOKENZERO_KEY" }, window: { type: "string", enum: ["24h", "7d", "30d", "all"] }, demo: { type: "boolean" } } }
784
+ },
780
785
  {
781
786
  name: "provision_workspace",
782
787
  description: "Create a TokenZero workspace and key with no form (POST /v1/workspaces on the TokenZero service). Returns the key once, the base URLs that route through it, the one-click dashboard link (key in the URL fragment, never sent to the server) and the badge URL. Free up to the monthly free tier; nothing is billed.",
@@ -809,6 +814,19 @@ async function callTool(name, args) {
809
814
  if (j.result?.isError) throw new Error(j.result.content?.[0]?.text ?? "remote tool error");
810
815
  return j.result?.structuredContent ?? j.result;
811
816
  }
817
+ case "workspace_metrics": {
818
+ const base = serviceUrl();
819
+ if (!base) throw new Error("set TOKENZERO_URL to use this tool");
820
+ const key = typeof args?.key === "string" && args.key.trim() ? args.key.trim() : process.env.TOKENZERO_KEY ?? "";
821
+ const demo = args?.demo === true || !key;
822
+ const w = ["24h", "7d", "30d", "all"].includes(args?.window) ? args.window : "30d";
823
+ const r = await fetch(`${base}/v1/workspaces/me/metrics?${demo ? "demo=1" : `window=${w}`}`, { redirect: "manual", signal: AbortSignal.timeout(2e4), headers: { "user-agent": `tokenzero-mcp/${VERSION}`, ...demo ? {} : { "x-tokenzero-key": key } } }).catch((e) => {
824
+ throw new Error(`could not reach the TokenZero service at ${base} (${e?.cause?.code ?? e?.message ?? e})`);
825
+ });
826
+ const j = await r.json();
827
+ if (r.status !== 200) throw new Error(j?.error?.message ?? `HTTP ${r.status}`);
828
+ return demo && !args?.demo ? { ...j, note: (j.note ? j.note + " " : "") + "No key was given and TOKENZERO_KEY is unset, so this is the sample scorecard." } : j;
829
+ }
812
830
  case "provision_workspace": {
813
831
  const base = serviceUrl();
814
832
  if (!base) throw new Error("set TOKENZERO_URL to use this tool (workspaces live in the TokenZero service)");
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@tokenzero/mcp",
3
- "version": "0.2.0",
3
+ "mcpName": "sh.tokenzero/mcp",
4
+ "version": "0.2.2",
4
5
  "description": "TokenZero MCP server (stdio): audit LLM token waste in your project locally, price model alternatives, and make prompts cache-friendly from Claude Code, Cursor, Windsurf or Cline.",
5
6
  "type": "module",
6
7
  "license": "Apache-2.0",