caelario-mcp 0.1.7 → 0.1.8
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/README.md +7 -3
- package/package.json +1 -1
- package/server.json +2 -2
- package/src/client.js +52 -0
- package/src/install.js +48 -14
- package/src/onboarding.js +8 -1
package/README.md
CHANGED
|
@@ -18,7 +18,9 @@ The page shows each step and helps you check the connection. New accounts start
|
|
|
18
18
|
with 200 free credits.
|
|
19
19
|
|
|
20
20
|
The installer opens this setup page automatically when you do not already have
|
|
21
|
-
a key
|
|
21
|
+
a key, or when the key in your terminal environment is rejected. It lets you
|
|
22
|
+
replace a rejected or incomplete key without restarting the command. Paste the
|
|
23
|
+
key only into its secure terminal prompt, never into AI chat.
|
|
22
24
|
|
|
23
25
|
## Install for Codex
|
|
24
26
|
|
|
@@ -32,8 +34,10 @@ npx -y caelario-mcp@latest install codex
|
|
|
32
34
|
npx -y caelario-mcp@latest install claude
|
|
33
35
|
```
|
|
34
36
|
|
|
35
|
-
The installer
|
|
36
|
-
|
|
37
|
+
The installer finds your assistant before starting setup. On Windows it also
|
|
38
|
+
finds the Codex desktop app when `codex` is absent from your terminal PATH. It
|
|
39
|
+
prompts for a Caelario workspace API key and registers the stdio server at user
|
|
40
|
+
scope. It does not ask for Instagram, TikTok, YouTube, X, or
|
|
37
41
|
Facebook credentials; provider identities are managed by Caelario.
|
|
38
42
|
|
|
39
43
|
After installation, restart the client and ask:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "caelario-mcp",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
4
4
|
"mcpName": "io.github.chunkydonut21/caelario",
|
|
5
5
|
"description": "MCP server for social media data from Instagram, TikTok, YouTube, X and Facebook. Run extractions, batches, schedules, saved results and usage workflows through Caelario.",
|
|
6
6
|
"type": "module",
|
package/server.json
CHANGED
|
@@ -9,12 +9,12 @@
|
|
|
9
9
|
"source": "github",
|
|
10
10
|
"id": "1346708115"
|
|
11
11
|
},
|
|
12
|
-
"version": "0.1.
|
|
12
|
+
"version": "0.1.8",
|
|
13
13
|
"packages": [
|
|
14
14
|
{
|
|
15
15
|
"registryType": "npm",
|
|
16
16
|
"identifier": "caelario-mcp",
|
|
17
|
-
"version": "0.1.
|
|
17
|
+
"version": "0.1.8",
|
|
18
18
|
"transport": {
|
|
19
19
|
"type": "stdio"
|
|
20
20
|
},
|
package/src/client.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { spawnSync } from "node:child_process";
|
|
2
|
+
import { existsSync } from "node:fs";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
|
|
5
|
+
export function resolveClientExecutable(client, {
|
|
6
|
+
platform = process.platform,
|
|
7
|
+
env = process.env,
|
|
8
|
+
spawn = spawnSync,
|
|
9
|
+
exists = existsSync,
|
|
10
|
+
} = {}) {
|
|
11
|
+
if (!["codex", "claude"].includes(client)) throw new Error("client must be codex or claude");
|
|
12
|
+
const options = { encoding: "utf8", stdio: "pipe", windowsHide: true, timeout: 10_000 };
|
|
13
|
+
const usable = (path) => {
|
|
14
|
+
const shell = platform === "win32" && /\.(cmd|bat)$/i.test(path);
|
|
15
|
+
const command = shell ? `"${path}"` : path;
|
|
16
|
+
const result = spawn(command, ["--version"], { ...options, shell });
|
|
17
|
+
return !result.error && result.status === 0 ? { command, shell } : null;
|
|
18
|
+
};
|
|
19
|
+
if (platform !== "win32") {
|
|
20
|
+
const found = usable(client);
|
|
21
|
+
if (found) return found;
|
|
22
|
+
} else {
|
|
23
|
+
const located = spawn("where.exe", [client], options);
|
|
24
|
+
if (!located.error && located.status === 0) {
|
|
25
|
+
for (const path of (located.stdout || "").trim().split(/\r?\n/)) {
|
|
26
|
+
if (path && exists(path)) {
|
|
27
|
+
const found = usable(path);
|
|
28
|
+
if (found) return found;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
if (client === "codex") {
|
|
33
|
+
// Desktop installs include a CLI even when a normal terminal cannot find it.
|
|
34
|
+
const powershell = join(env.SystemRoot || "C:\\Windows", "System32", "WindowsPowerShell", "v1.0", "powershell.exe");
|
|
35
|
+
const app = spawn(powershell, ["-NoProfile", "-NonInteractive", "-Command",
|
|
36
|
+
"Get-AppxPackage -Name OpenAI.Codex -ErrorAction SilentlyContinue | ForEach-Object { Join-Path $_.InstallLocation 'app\\resources\\codex.exe' }",
|
|
37
|
+
], options);
|
|
38
|
+
const candidates = !app.error && app.status === 0 ? (app.stdout || "").trim().split(/\r?\n/) : [];
|
|
39
|
+
if (env.LOCALAPPDATA) candidates.push(join(env.LOCALAPPDATA, "Programs", "Codex", "resources", "codex.exe"));
|
|
40
|
+
if (env.ProgramFiles) candidates.push(join(env.ProgramFiles, "Codex", "resources", "codex.exe"));
|
|
41
|
+
for (const path of candidates) {
|
|
42
|
+
if (path && exists(path)) {
|
|
43
|
+
const found = usable(path);
|
|
44
|
+
if (found) return found;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
throw new Error(client === "codex"
|
|
50
|
+
? "Codex was not found. Install the Codex desktop app or Codex CLI, then run this command again."
|
|
51
|
+
: "Claude Code was not found. Install Claude Code, then run this command again.");
|
|
52
|
+
}
|
package/src/install.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { spawnSync } from "node:child_process";
|
|
2
2
|
import process from "node:process";
|
|
3
3
|
import readline from "node:readline";
|
|
4
|
-
import {
|
|
4
|
+
import { resolveClientExecutable } from "./client.js";
|
|
5
|
+
import { SETUP_URL, setupInstructions, openSetupPage, verifyWorkspaceKey, ConnectionKeyRejectedError } from "./onboarding.js";
|
|
5
6
|
|
|
6
7
|
const CLIENTS = new Set(["codex", "claude"]);
|
|
7
8
|
const KEY_PATTERN = /^[A-Za-z0-9._-]{16,256}$/;
|
|
@@ -41,6 +42,7 @@ export async function installClient(
|
|
|
41
42
|
apiUrl = process.env.CAELARIO_API_URL || "https://api.caelario.com",
|
|
42
43
|
platform = process.platform,
|
|
43
44
|
spawn = spawnSync,
|
|
45
|
+
resolveClient = resolveClientExecutable,
|
|
44
46
|
openBrowser = openSetupPage,
|
|
45
47
|
prompt = promptSecret,
|
|
46
48
|
verifyKey = verifyWorkspaceKey,
|
|
@@ -49,25 +51,57 @@ export async function installClient(
|
|
|
49
51
|
} = {},
|
|
50
52
|
) {
|
|
51
53
|
if (!CLIENTS.has(client)) throw new Error("client must be codex or claude");
|
|
54
|
+
write(`Finding ${client === "codex" ? "Codex" : "Claude Code"}...\n`);
|
|
55
|
+
const executable = resolveClient(client, { platform });
|
|
52
56
|
let key = apiKey?.trim();
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
57
|
+
let setupShown = false;
|
|
58
|
+
let registration;
|
|
59
|
+
if (key) write("Found CAELARIO_API_KEY in your environment.\n");
|
|
60
|
+
while (true) {
|
|
61
|
+
if (!key) {
|
|
62
|
+
if (!setupShown) {
|
|
63
|
+
write(`${setupInstructions(client)}\n\n`);
|
|
64
|
+
if (interactive) {
|
|
65
|
+
write("Opening your browser setup page...\n");
|
|
66
|
+
openBrowser();
|
|
67
|
+
}
|
|
68
|
+
setupShown = true;
|
|
69
|
+
}
|
|
70
|
+
if (!interactive) {
|
|
71
|
+
throw new Error(`Open ${SETUP_URL} to create your account and connection key. Run the installer in an interactive terminal, or set CAELARIO_API_KEY in your private MCP configuration.`);
|
|
72
|
+
}
|
|
73
|
+
key = (await prompt("Finish setup in your browser, then paste your connection key here: ")).trim();
|
|
74
|
+
}
|
|
75
|
+
if (!KEY_PATTERN.test(key)) {
|
|
76
|
+
if (!interactive) throw new Error(`The connection key format is invalid. Get your full key at ${SETUP_URL}.`);
|
|
77
|
+
write("That connection key is incomplete or has an invalid format. Paste the full key from browser setup.\n");
|
|
78
|
+
key = "";
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
// Validate the origin before sending a key, even when setup needs a retry.
|
|
82
|
+
registration = registrationCommand(client, key, apiUrl, platform);
|
|
83
|
+
write("Checking your Caelario connection key...\n");
|
|
84
|
+
try {
|
|
85
|
+
await verifyKey(key, apiUrl);
|
|
86
|
+
break;
|
|
87
|
+
} catch (error) {
|
|
88
|
+
if (!(error instanceof ConnectionKeyRejectedError) || !interactive) throw error;
|
|
89
|
+
write("Caelario did not accept that key. Let's connect with a current key from browser setup.\n");
|
|
90
|
+
key = "";
|
|
58
91
|
}
|
|
59
|
-
key = await prompt("Finish setup in your browser, then paste your connection key here: ");
|
|
60
92
|
}
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
const completed = spawn(registration.command, registration.args, {
|
|
65
|
-
stdio: "inherit",
|
|
93
|
+
const completed = spawn(executable.command, registration.args, {
|
|
94
|
+
stdio: "pipe",
|
|
95
|
+
encoding: "utf8",
|
|
66
96
|
windowsHide: true,
|
|
67
|
-
|
|
97
|
+
timeout: 30_000,
|
|
98
|
+
shell: executable.shell,
|
|
68
99
|
});
|
|
100
|
+
for (const output of [completed.stdout, completed.stderr]) {
|
|
101
|
+
if (output) write(output.replaceAll(key, "[redacted]"));
|
|
102
|
+
}
|
|
69
103
|
if (completed.error?.code === "ENOENT") {
|
|
70
|
-
throw new Error(`${client === "codex" ? "Codex" : "Claude Code"}
|
|
104
|
+
throw new Error(`${client === "codex" ? "Codex" : "Claude Code"} was not found. Reopen your terminal and run this command again.`);
|
|
71
105
|
}
|
|
72
106
|
if (completed.error) throw new Error("The assistant client could not be started. Check its installation and run this command again.");
|
|
73
107
|
if (completed.status !== 0) {
|
package/src/onboarding.js
CHANGED
|
@@ -27,6 +27,13 @@ export function openSetupPage() {
|
|
|
27
27
|
} catch { /* The printed URL remains usable when a browser cannot be opened. */ }
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
export class ConnectionKeyRejectedError extends Error {
|
|
31
|
+
constructor() {
|
|
32
|
+
super(`Caelario did not accept that key. Open ${SETUP_URL}, copy your full connection key and try again.`);
|
|
33
|
+
this.name = "ConnectionKeyRejectedError";
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
30
37
|
export async function verifyWorkspaceKey(apiKey, apiUrl) {
|
|
31
38
|
let response;
|
|
32
39
|
try {
|
|
@@ -39,7 +46,7 @@ export async function verifyWorkspaceKey(apiKey, apiUrl) {
|
|
|
39
46
|
throw new Error("Could not reach Caelario to check the key. Check your connection and run the installer again.");
|
|
40
47
|
}
|
|
41
48
|
if (response.status === 401 || response.status === 403) {
|
|
42
|
-
throw new
|
|
49
|
+
throw new ConnectionKeyRejectedError();
|
|
43
50
|
}
|
|
44
51
|
if (!response.ok) throw new Error("Caelario could not verify the key right now. Please try again shortly.");
|
|
45
52
|
const account = await response.json().catch(() => null);
|