@candledottv/mcp 0.6.2 → 0.6.4
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/dist/index.js +42 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -104,6 +104,43 @@ function percentOfBalance(balanceRaw, percent) {
|
|
|
104
104
|
|
|
105
105
|
// src/orchestrate.ts
|
|
106
106
|
import { randomUUID } from "node:crypto";
|
|
107
|
+
|
|
108
|
+
// src/version.ts
|
|
109
|
+
var SERVER_VERSION = "0.6.4";
|
|
110
|
+
|
|
111
|
+
// src/update-notice.ts
|
|
112
|
+
var PLAIN_VERSION = /^\d+\.\d+\.\d+$/;
|
|
113
|
+
var latestSeen = null;
|
|
114
|
+
var warned = false;
|
|
115
|
+
function newer(a, b) {
|
|
116
|
+
const [a1 = 0, a2 = 0, a3 = 0] = a.split(".").map(Number);
|
|
117
|
+
const [b1 = 0, b2 = 0, b3 = 0] = b.split(".").map(Number);
|
|
118
|
+
return a1 !== b1 ? a1 > b1 : a2 !== b2 ? a2 > b2 : a3 > b3;
|
|
119
|
+
}
|
|
120
|
+
function noteVersionHeaders(res) {
|
|
121
|
+
const headers = res?.headers;
|
|
122
|
+
const value = typeof headers?.get === "function" ? headers.get("x-candle-mcp-latest") : null;
|
|
123
|
+
if (!value || !PLAIN_VERSION.test(value))
|
|
124
|
+
return;
|
|
125
|
+
if (latestSeen !== null && !newer(value, latestSeen))
|
|
126
|
+
return;
|
|
127
|
+
latestSeen = value;
|
|
128
|
+
if (!warned && newer(value, SERVER_VERSION) && !process.env.CANDLE_NO_UPDATE_NOTIFIER) {
|
|
129
|
+
warned = true;
|
|
130
|
+
console.error(`@candledottv/mcp ${value} is available (running ${SERVER_VERSION}). Update: npm install -g @candledottv/mcp@latest`);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
function updateAvailable() {
|
|
134
|
+
if (latestSeen === null || !newer(latestSeen, SERVER_VERSION))
|
|
135
|
+
return null;
|
|
136
|
+
return {
|
|
137
|
+
current: SERVER_VERSION,
|
|
138
|
+
latest: latestSeen,
|
|
139
|
+
command: "npm install -g @candledottv/mcp@latest"
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// src/orchestrate.ts
|
|
107
144
|
function requireApiKey(cfg) {
|
|
108
145
|
if (!cfg.apiKey) {
|
|
109
146
|
throw new Error("CANDLE_AGENT_API_KEY is required for this tool. Set it in the environment or MCP client config.");
|
|
@@ -412,6 +449,7 @@ async function executionStatus(cfg, doFetch) {
|
|
|
412
449
|
const apiKey = requireApiKey(cfg);
|
|
413
450
|
const get = async (path) => {
|
|
414
451
|
const res = await doFetch(`${base(cfg)}${path}`, { method: "GET", headers: headers(apiKey) });
|
|
452
|
+
noteVersionHeaders(res);
|
|
415
453
|
const text = await res.text();
|
|
416
454
|
let body;
|
|
417
455
|
try {
|
|
@@ -431,10 +469,13 @@ async function executionStatus(cfg, doFetch) {
|
|
|
431
469
|
["tier", tier],
|
|
432
470
|
["limits", limits]
|
|
433
471
|
].filter(([, r]) => !r.ok);
|
|
472
|
+
const tierBody = tier.ok ? tier.body : undefined;
|
|
434
473
|
return {
|
|
435
474
|
text: JSON.stringify({
|
|
436
475
|
success: true,
|
|
437
476
|
ready: unreadable.length === 0 ? true : undefined,
|
|
477
|
+
notice: tierBody?.maxExpired ? tierBody.maxExpiredNotice : undefined,
|
|
478
|
+
updateAvailable: updateAvailable() ?? undefined,
|
|
438
479
|
unreadable: unreadable.length > 0 ? unreadable.map(([name]) => name) : undefined,
|
|
439
480
|
wallets: wallets.body,
|
|
440
481
|
tier: tier.body,
|
|
@@ -584,6 +625,7 @@ function buildRequest(name, args, cfg) {
|
|
|
584
625
|
async function callAndRelay(name, args, cfg) {
|
|
585
626
|
const { url, init } = buildRequest(name, args, cfg);
|
|
586
627
|
const res = await fetch(url, init);
|
|
628
|
+
noteVersionHeaders(res);
|
|
587
629
|
const text = await res.text();
|
|
588
630
|
return {
|
|
589
631
|
content: [{ type: "text", text }],
|
|
@@ -786,9 +828,6 @@ function registerTools(server, env = process.env) {
|
|
|
786
828
|
});
|
|
787
829
|
}
|
|
788
830
|
|
|
789
|
-
// src/version.ts
|
|
790
|
-
var SERVER_VERSION = "0.6.2";
|
|
791
|
-
|
|
792
831
|
// src/server.ts
|
|
793
832
|
function createCandleMcpServer(env = process.env) {
|
|
794
833
|
const server = new McpServer({ name: "candle-mcp", version: SERVER_VERSION });
|