@cubedot/cli 0.1.0 → 0.1.1
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/cli.js +26 -4
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -108,7 +108,7 @@ function writeMcpJson(cwd, mcpUrl, projectId, key) {
|
|
|
108
108
|
cubedot: {
|
|
109
109
|
type: "http",
|
|
110
110
|
url: `${mcpUrl}?project=${encodeURIComponent(projectId)}`,
|
|
111
|
-
headers: {
|
|
111
|
+
headers: { Authorization: `ApiKey ${key}` }
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
114
|
};
|
|
@@ -202,6 +202,23 @@ function writeHashes(cwd, hashes) {
|
|
|
202
202
|
if (!existsSync(dir)) mkdirSync(dir, { recursive: true });
|
|
203
203
|
writeFileSync(join(dir, "hashes.json"), JSON.stringify(hashes, null, 2) + "\n", "utf8");
|
|
204
204
|
}
|
|
205
|
+
function enableMcpServerInSettings(cwd, serverName = "cubedot") {
|
|
206
|
+
const dir = join(cwd, ".claude");
|
|
207
|
+
if (!existsSync(dir)) mkdirSync(dir, { recursive: true });
|
|
208
|
+
const path = join(dir, "settings.json");
|
|
209
|
+
let settings = {};
|
|
210
|
+
if (existsSync(path)) {
|
|
211
|
+
try {
|
|
212
|
+
settings = JSON.parse(readFileSync(path, "utf8"));
|
|
213
|
+
} catch {
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
const cur = Array.isArray(settings["enabledMcpjsonServers"]) ? settings["enabledMcpjsonServers"] : [];
|
|
217
|
+
if (!cur.includes(serverName)) {
|
|
218
|
+
settings["enabledMcpjsonServers"] = [...cur, serverName];
|
|
219
|
+
}
|
|
220
|
+
writeFileSync(path, JSON.stringify(settings, null, 2) + "\n", "utf8");
|
|
221
|
+
}
|
|
205
222
|
function readLinks(cwd) {
|
|
206
223
|
const path = join(cwd, ".cubedot", "links.json");
|
|
207
224
|
if (!existsSync(path)) return {};
|
|
@@ -466,6 +483,7 @@ async function initCommand(opts) {
|
|
|
466
483
|
await client.close();
|
|
467
484
|
}
|
|
468
485
|
writeMcpJson(cwd, mcpUrl, projectId, key);
|
|
486
|
+
enableMcpServerInSettings(cwd);
|
|
469
487
|
writeCubedotConfig(cwd, {
|
|
470
488
|
projectId,
|
|
471
489
|
mcpUrl,
|
|
@@ -804,10 +822,12 @@ async function readKeyFromMcpJson(cwd) {
|
|
|
804
822
|
throw new Error(".mcp.json not found. Run `cubedot init` first.");
|
|
805
823
|
}
|
|
806
824
|
const mcp = JSON.parse(readFileSync5(mcpPath, "utf8"));
|
|
807
|
-
const
|
|
825
|
+
const headers = mcp.mcpServers?.["cubedot"]?.headers ?? {};
|
|
826
|
+
const authHeader = headers["Authorization"] ?? headers["authorization"] ?? "";
|
|
827
|
+
const key = authHeader.replace(/^ApiKey\s+/i, "").trim();
|
|
808
828
|
if (!key) {
|
|
809
829
|
throw new Error(
|
|
810
|
-
".mcp.json is missing the cubedot
|
|
830
|
+
".mcp.json is missing the cubedot Authorization header. Re-run `cubedot init`."
|
|
811
831
|
);
|
|
812
832
|
}
|
|
813
833
|
return key;
|
|
@@ -843,7 +863,9 @@ async function statusCommand() {
|
|
|
843
863
|
} else {
|
|
844
864
|
try {
|
|
845
865
|
const mcp = JSON.parse(readFileSync6(mcpPath, "utf8"));
|
|
846
|
-
const
|
|
866
|
+
const headers = mcp.mcpServers?.["cubedot"]?.headers ?? {};
|
|
867
|
+
const authHeader = headers["Authorization"] ?? headers["authorization"] ?? "";
|
|
868
|
+
const keyRaw = authHeader.replace(/^ApiKey\s+/i, "").trim();
|
|
847
869
|
const keyTail = keyRaw ? keyRaw.slice(-8) : "(empty)";
|
|
848
870
|
console.log(pc3.green("\u2713") + ` .mcp.json \u2014 key tail: \u2026${keyTail}`);
|
|
849
871
|
} catch {
|