@tokenzero/mcp 0.1.5 → 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 +38 -1
- package/package.json +1 -1
package/bin/tokenzero-mcp.mjs
CHANGED
|
@@ -684,7 +684,7 @@ function manifests(root) {
|
|
|
684
684
|
}
|
|
685
685
|
|
|
686
686
|
// mcp/src/main.ts
|
|
687
|
-
var VERSION = "0.1.
|
|
687
|
+
var VERSION = "0.1.6";
|
|
688
688
|
var BAKED_URL = true ? "https://tokenzero.sh" : "__TOKENZERO_DEFAULT_URL__";
|
|
689
689
|
var SUPPORTED = ["2026-07-28", "2025-11-25", "2025-06-18", "2025-03-26"];
|
|
690
690
|
var serviceUrl = () => (process.env.TOKENZERO_URL || (BAKED_URL.startsWith("http") ? BAKED_URL : "")).replace(/\/+$/, "");
|
|
@@ -703,6 +703,11 @@ var TOOLS = [
|
|
|
703
703
|
name: "optimize_prompt_payload",
|
|
704
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.",
|
|
705
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 }
|
|
706
711
|
}
|
|
707
712
|
];
|
|
708
713
|
async function callTool(name, args) {
|
|
@@ -731,6 +736,38 @@ async function callTool(name, args) {
|
|
|
731
736
|
if (j.result?.isError) throw new Error(j.result.content?.[0]?.text ?? "remote tool error");
|
|
732
737
|
return j.result?.structuredContent ?? j.result;
|
|
733
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
|
+
}
|
|
734
771
|
default:
|
|
735
772
|
throw new Error(`unknown tool ${name}`);
|
|
736
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",
|