@tokenzero/mcp 0.1.4 → 0.1.6
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/bin/tokenzero-mcp.mjs +58 -4
- package/package.json +1 -1
package/bin/tokenzero-mcp.mjs
CHANGED
|
@@ -68,7 +68,18 @@ var PRICES = {
|
|
|
68
68
|
"gemini-3-flash": P("gemini", "fast", 0.5, 3, 0.05),
|
|
69
69
|
"gemini-2.5-pro": P("gemini", "frontier", 1.25, 10, 0.125, void 0, { longCtxAt: 2e5, longCtx: { input: 2.5, output: 15, cachedInput: 0.25 } }),
|
|
70
70
|
"gemini-2.5-flash": P("gemini", "fast", 0.3, 2.5, 0.03),
|
|
71
|
-
"gemini-2.5-flash-lite": P("gemini", "fast", 0.1, 0.4, 0.01)
|
|
71
|
+
"gemini-2.5-flash-lite": P("gemini", "fast", 0.1, 0.4, 0.01),
|
|
72
|
+
// ---- xAI Grok ----
|
|
73
|
+
"grok-4": P("xai", "frontier", 3, 15, 0.75),
|
|
74
|
+
"grok-4-fast": P("xai", "fast", 0.2, 0.8, 0.05),
|
|
75
|
+
"grok-4-mini": P("xai", "fast", 0.2, 0.8, 0.05),
|
|
76
|
+
"grok-3": P("xai", "mid", 3, 15, 0.75),
|
|
77
|
+
"grok-3-mini": P("xai", "fast", 0.3, 0.5, 0.075),
|
|
78
|
+
// ---- DeepSeek ----
|
|
79
|
+
"deepseek-v3": P("deepseek", "fast", 0.27, 1.1, 0.07),
|
|
80
|
+
"deepseek-chat": P("deepseek", "fast", 0.27, 1.1, 0.07),
|
|
81
|
+
"deepseek-r1": P("deepseek", "mid", 0.55, 2.19, 0.14),
|
|
82
|
+
"deepseek-reasoner": P("deepseek", "mid", 0.55, 2.19, 0.14)
|
|
72
83
|
};
|
|
73
84
|
var CASCADE_TARGET = {
|
|
74
85
|
"gpt-6-astra": "gpt-6.1-sol",
|
|
@@ -99,13 +110,19 @@ var CASCADE_TARGET = {
|
|
|
99
110
|
"gemini-3.1-pro": "gemini-3.8-flash",
|
|
100
111
|
"gemini-3.8-flash": "gemini-3.5-flash-lite",
|
|
101
112
|
"gemini-2.5-pro": "gemini-2.5-flash",
|
|
102
|
-
"gemini-2.5-flash": "gemini-2.5-flash-lite"
|
|
113
|
+
"gemini-2.5-flash": "gemini-2.5-flash-lite",
|
|
114
|
+
"grok-4": "grok-4-fast",
|
|
115
|
+
"grok-3": "grok-3-mini",
|
|
116
|
+
"deepseek-r1": "deepseek-v3",
|
|
117
|
+
"deepseek-reasoner": "deepseek-chat"
|
|
103
118
|
};
|
|
104
119
|
var KEYS_BY_LENGTH = Object.keys(PRICES).sort((a, b) => b.length - a.length);
|
|
105
120
|
function normalizeModel(model) {
|
|
106
121
|
if (typeof model !== "string" || !model) return null;
|
|
107
122
|
let m = model.toLowerCase().trim();
|
|
108
|
-
m = m.replace(/^(openai|anthropic|google|models|vertex_ai)\//, "");
|
|
123
|
+
m = m.replace(/^(openai|anthropic|google|gemini|x-ai|xai|deepseek|bedrock|models|vertex_ai)\//, "");
|
|
124
|
+
m = m.replace(/^(?:us\.|eu\.|apac\.)?anthropic\./, "");
|
|
125
|
+
m = m.replace(/-v\d+:\d+$/, "");
|
|
109
126
|
m = m.replace(/@\d{8}$/, "");
|
|
110
127
|
m = m.replace(/-(\d{8}|\d{4}-\d{2}-\d{2})$/, "");
|
|
111
128
|
m = m.replace(/-(latest|preview|customtools|thinking)$/, "");
|
|
@@ -667,7 +684,7 @@ function manifests(root) {
|
|
|
667
684
|
}
|
|
668
685
|
|
|
669
686
|
// mcp/src/main.ts
|
|
670
|
-
var VERSION = "0.1.
|
|
687
|
+
var VERSION = "0.1.6";
|
|
671
688
|
var BAKED_URL = true ? "https://tokenzero.sh" : "__TOKENZERO_DEFAULT_URL__";
|
|
672
689
|
var SUPPORTED = ["2026-07-28", "2025-11-25", "2025-06-18", "2025-03-26"];
|
|
673
690
|
var serviceUrl = () => (process.env.TOKENZERO_URL || (BAKED_URL.startsWith("http") ? BAKED_URL : "")).replace(/\/+$/, "");
|
|
@@ -686,6 +703,11 @@ var TOOLS = [
|
|
|
686
703
|
name: "optimize_prompt_payload",
|
|
687
704
|
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.",
|
|
688
705
|
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 }
|
|
706
|
+
},
|
|
707
|
+
{
|
|
708
|
+
name: "provision_workspace",
|
|
709
|
+
description: "Zero-click autonomous workspace and API key provisioning on TokenZero (POST /v1/workspaces). Returns a live tz_live_... API key, workspace_id, 1-click auto-unlock dashboard URL, gateway base URLs, and badge SVG URL with zero signup form required.",
|
|
710
|
+
inputSchema: { type: "object", properties: { name: { type: "string", description: "Optional workspace name (defaults to mcp-agent)" } }, additionalProperties: false }
|
|
689
711
|
}
|
|
690
712
|
];
|
|
691
713
|
async function callTool(name, args) {
|
|
@@ -714,6 +736,38 @@ async function callTool(name, args) {
|
|
|
714
736
|
if (j.result?.isError) throw new Error(j.result.content?.[0]?.text ?? "remote tool error");
|
|
715
737
|
return j.result?.structuredContent ?? j.result;
|
|
716
738
|
}
|
|
739
|
+
case "provision_workspace": {
|
|
740
|
+
const base = serviceUrl();
|
|
741
|
+
if (!base) throw new Error("set TOKENZERO_URL to use this tool");
|
|
742
|
+
const wsName = typeof args?.name === "string" && args.name.trim() ? args.name.trim() : "mcp-agent";
|
|
743
|
+
const r = await fetch(base + "/v1/workspaces", {
|
|
744
|
+
method: "POST",
|
|
745
|
+
redirect: "manual",
|
|
746
|
+
signal: AbortSignal.timeout(15e3),
|
|
747
|
+
headers: { "content-type": "application/json", "user-agent": `tokenzero-mcp/${VERSION}` },
|
|
748
|
+
body: JSON.stringify({ name: wsName })
|
|
749
|
+
}).catch((e) => {
|
|
750
|
+
throw new Error(`could not reach the TokenZero service at ${base} (${e?.cause?.code ?? e?.message ?? e}); set TOKENZERO_URL to use a different one`);
|
|
751
|
+
});
|
|
752
|
+
if (r.status >= 300 && r.status < 400) throw new Error(`${base} is not publicly reachable yet (redirected)`);
|
|
753
|
+
const j = await r.json();
|
|
754
|
+
if (r.status >= 400) throw new Error(j?.error?.message ?? `HTTP ${r.status}`);
|
|
755
|
+
const id = j.workspace?.id ?? j.workspace_id ?? j.id;
|
|
756
|
+
const key = j.key ?? j.api_key;
|
|
757
|
+
return {
|
|
758
|
+
workspace_id: id,
|
|
759
|
+
api_key: key,
|
|
760
|
+
name: wsName,
|
|
761
|
+
dashboard_url: `${base}/dashboard?workspace=${id}`,
|
|
762
|
+
one_click_dashboard_url: `${base}/dashboard?workspace=${id}#key=${key}`,
|
|
763
|
+
gateway_base_url: `${base}/v1`,
|
|
764
|
+
anthropic_base_url: base,
|
|
765
|
+
gemini_base_url: `${base}/gemini`,
|
|
766
|
+
zero_code_base_url: `${base}/w/${key}/v1`,
|
|
767
|
+
mcp_url: `${base}/mcp`,
|
|
768
|
+
badge_svg_url: `${base}/v1/badge/${id}.svg`
|
|
769
|
+
};
|
|
770
|
+
}
|
|
717
771
|
default:
|
|
718
772
|
throw new Error(`unknown tool ${name}`);
|
|
719
773
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tokenzero/mcp",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"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
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|