caelario-mcp 0.1.6 → 0.1.7

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 CHANGED
@@ -10,16 +10,26 @@ The official local server gives Codex and Claude Code typed tools for capability
10
10
  discovery, immediate and durable extraction, result pagination, and credit
11
11
  estimates.
12
12
 
13
+ ## New to Caelario?
14
+
15
+ [Open the guided setup](https://app.caelario.com/connect). Create a free account
16
+ with Google or email, choose Codex or Claude Code, and create a connection key.
17
+ The page shows each step and helps you check the connection. New accounts start
18
+ with 200 free credits.
19
+
20
+ The installer opens this setup page automatically when you do not already have
21
+ a key. Paste the key only into its secure terminal prompt, never into AI chat.
22
+
13
23
  ## Install for Codex
14
24
 
15
25
  ```bash
16
- npx -y caelario-mcp install codex
26
+ npx -y caelario-mcp@latest install codex
17
27
  ```
18
28
 
19
29
  ## Install for Claude Code
20
30
 
21
31
  ```bash
22
- npx -y caelario-mcp install claude
32
+ npx -y caelario-mcp@latest install claude
23
33
  ```
24
34
 
25
35
  The installer prompts for a Caelario workspace API key and registers the stdio
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "caelario-mcp",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
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,18 +9,18 @@
9
9
  "source": "github",
10
10
  "id": "1346708115"
11
11
  },
12
- "version": "0.1.6",
12
+ "version": "0.1.7",
13
13
  "packages": [
14
14
  {
15
15
  "registryType": "npm",
16
16
  "identifier": "caelario-mcp",
17
- "version": "0.1.6",
17
+ "version": "0.1.7",
18
18
  "transport": {
19
19
  "type": "stdio"
20
20
  },
21
21
  "environmentVariables": [
22
22
  {
23
- "description": "A revocable Caelario workspace API key from the Developers page.",
23
+ "description": "Get your Caelario account and connection key at https://app.caelario.com/connect. The browser setup guides you through registration and connection.",
24
24
  "isRequired": true,
25
25
  "format": "string",
26
26
  "isSecret": true,
package/src/install.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { spawnSync } from "node:child_process";
2
2
  import process from "node:process";
3
3
  import readline from "node:readline";
4
+ import { SETUP_URL, setupInstructions, openSetupPage, verifyWorkspaceKey } from "./onboarding.js";
4
5
 
5
6
  const CLIENTS = new Set(["codex", "claude"]);
6
7
  const KEY_PATTERN = /^[A-Za-z0-9._-]{16,256}$/;
@@ -40,11 +41,26 @@ export async function installClient(
40
41
  apiUrl = process.env.CAELARIO_API_URL || "https://api.caelario.com",
41
42
  platform = process.platform,
42
43
  spawn = spawnSync,
44
+ openBrowser = openSetupPage,
45
+ prompt = promptSecret,
46
+ verifyKey = verifyWorkspaceKey,
47
+ write = (text) => process.stderr.write(text),
48
+ interactive = Boolean(process.stdin.isTTY && process.stderr.isTTY),
43
49
  } = {},
44
50
  ) {
45
51
  if (!CLIENTS.has(client)) throw new Error("client must be codex or claude");
46
- const key = apiKey?.trim() || await promptSecret("Paste your Caelario API key: ");
52
+ let key = apiKey?.trim();
53
+ if (!key) {
54
+ write(`${setupInstructions(client)}\n\n`);
55
+ if (interactive) {
56
+ write("Opening your browser setup page...\n");
57
+ openBrowser();
58
+ }
59
+ key = await prompt("Finish setup in your browser, then paste your connection key here: ");
60
+ }
47
61
  const registration = registrationCommand(client, key, apiUrl, platform);
62
+ write("Checking your Caelario connection key...\n");
63
+ await verifyKey(key, apiUrl);
48
64
  const completed = spawn(registration.command, registration.args, {
49
65
  stdio: "inherit",
50
66
  windowsHide: true,
@@ -53,16 +69,16 @@ export async function installClient(
53
69
  if (completed.error?.code === "ENOENT") {
54
70
  throw new Error(`${client === "codex" ? "Codex" : "Claude Code"} CLI was not found. Install it, then run this command again.`);
55
71
  }
56
- if (completed.error) throw completed.error;
72
+ if (completed.error) throw new Error("The assistant client could not be started. Check its installation and run this command again.");
57
73
  if (completed.status !== 0) {
58
74
  throw new Error(`${client === "codex" ? "Codex" : "Claude Code"} rejected the MCP registration (exit ${completed.status ?? "unknown"})`);
59
75
  }
60
- process.stderr.write(`Caelario is connected to ${client === "codex" ? "Codex" : "Claude Code"}. Restart the client, then ask it to use Caelario.\n`);
76
+ write(`Caelario is connected to ${client === "codex" ? "Codex" : "Claude Code"}. Restart the client, then ask it to use Caelario.\n`);
61
77
  }
62
78
 
63
79
  async function promptSecret(prompt) {
64
80
  if (!process.stdin.isTTY || !process.stderr.isTTY) {
65
- throw new Error("set CAELARIO_API_KEY when running the installer non-interactively");
81
+ 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.`);
66
82
  }
67
83
  process.stderr.write(prompt);
68
84
  process.stdin.setRawMode?.(true);
@@ -100,7 +116,7 @@ export function printHelp() {
100
116
  " npx -y caelario-mcp install claude Register for Claude Code (user-wide)",
101
117
  " npx -y caelario-mcp serve Run the stdio server",
102
118
  "",
103
- "The guided installer securely prompts for CAELARIO_API_KEY.",
119
+ setupInstructions(),
104
120
  ];
105
121
  readline.clearLine(process.stderr, 0);
106
122
  process.stderr.write(`${output.join("\n")}\n`);
@@ -0,0 +1,49 @@
1
+ import { spawn } from "node:child_process";
2
+
3
+ export const SETUP_URL = "https://app.caelario.com/connect";
4
+ export const SIGNUP_URL = "https://app.caelario.com/sign-up";
5
+
6
+ export function setupInstructions(client = "codex") {
7
+ const label = client === "claude" ? "Claude Code" : "Codex";
8
+ return [
9
+ "Caelario connects social media data to your AI assistant.",
10
+ "",
11
+ `1. Open ${SETUP_URL}`,
12
+ "2. Create a free account (or sign in), then create your connection key.",
13
+ `3. Return here, paste the key when asked, then restart ${label}.`,
14
+ "",
15
+ "The browser setup page guides you through every step. Keep the key out of chat.",
16
+ ].join("\n");
17
+ }
18
+
19
+ export function openSetupPage() {
20
+ const [command, args] = process.platform === "win32"
21
+ ? ["rundll32.exe", ["url.dll,FileProtocolHandler", SETUP_URL]]
22
+ : process.platform === "darwin" ? ["open", [SETUP_URL]] : ["xdg-open", [SETUP_URL]];
23
+ try {
24
+ const child = spawn(command, args, { detached: true, stdio: "ignore", windowsHide: true });
25
+ child.on("error", () => {});
26
+ child.unref();
27
+ } catch { /* The printed URL remains usable when a browser cannot be opened. */ }
28
+ }
29
+
30
+ export async function verifyWorkspaceKey(apiKey, apiUrl) {
31
+ let response;
32
+ try {
33
+ response = await fetch(new URL("/v1/account", apiUrl), {
34
+ headers: { "X-API-Key": apiKey, Accept: "application/json" },
35
+ redirect: "manual",
36
+ signal: AbortSignal.timeout(20_000),
37
+ });
38
+ } catch {
39
+ throw new Error("Could not reach Caelario to check the key. Check your connection and run the installer again.");
40
+ }
41
+ if (response.status === 401 || response.status === 403) {
42
+ throw new Error(`Caelario did not accept that key. Open ${SETUP_URL}, copy your full connection key and try again.`);
43
+ }
44
+ if (!response.ok) throw new Error("Caelario could not verify the key right now. Please try again shortly.");
45
+ const account = await response.json().catch(() => null);
46
+ if (!account || typeof account.organization_id !== "string") {
47
+ throw new Error("Caelario returned an unexpected response while checking the key. Please try again shortly.");
48
+ }
49
+ }
package/src/server.js CHANGED
@@ -4,6 +4,7 @@ import { readFileSync } from "node:fs";
4
4
  import { McpServer } from "@modelcontextprotocol/server";
5
5
  import { serveStdio } from "@modelcontextprotocol/server/stdio";
6
6
  import * as z from "zod/v4";
7
+ import { SETUP_URL } from "./onboarding.js";
7
8
 
8
9
  const VERSION = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8")).version;
9
10
  const TERMINAL = new Set(["completed", "failed", "cancelled"]);
@@ -13,7 +14,7 @@ const id = z.string().regex(/^[A-Za-z0-9_-]{1,128}$/);
13
14
 
14
15
  function apiConfiguration() {
15
16
  const apiKey = (process.env.CAELARIO_API_KEY || "").trim();
16
- if (!apiKey) throw new Error("CAELARIO_API_KEY is required; run `npx -y caelario-mcp install codex` or `install claude`");
17
+ if (!apiKey) throw new Error(`Create a free Caelario account and connection key at ${SETUP_URL}, then run npx -y caelario-mcp@latest install codex (or install claude). Paste the key into the installer, never into chat.`);
17
18
  const baseUrl = new URL(process.env.CAELARIO_API_URL || "https://api.caelario.com");
18
19
  if (!["https:", "http:"].includes(baseUrl.protocol)) throw new Error("CAELARIO_API_URL requires HTTP or HTTPS");
19
20
  if (baseUrl.protocol !== "https:" && !["localhost", "127.0.0.1", "[::1]"].includes(baseUrl.hostname)) {
@@ -55,6 +56,7 @@ async function api(method, path, { body, params, idempotencyKey } = {}) {
55
56
  Accept: "application/json",
56
57
  "Content-Type": "application/json",
57
58
  "X-API-Key": apiKey,
59
+ "User-Agent": `caelario-mcp/${VERSION}`,
58
60
  ...(idempotencyKey ? { "Idempotency-Key": idempotencyKey } : {}),
59
61
  },
60
62
  body: body === undefined ? undefined : JSON.stringify(body),
@@ -84,6 +86,7 @@ async function api(method, path, { body, params, idempotencyKey } = {}) {
84
86
  throw new ApiError(`Caelario API request failed (${response.status})${safeMessage ? `: ${safeMessage}` : ""}`, {
85
87
  error: typeof code === "string" && /^[a-z0-9_]{1,64}$/.test(code) ? code : "api_request_failed",
86
88
  status_code: response.status, retryable: Boolean(detail?.retryable),
89
+ ...([401, 403].includes(response.status) ? { setup_url: SETUP_URL } : {}),
87
90
  outcome_unknown: false, ...(jobId ? { job_id: jobId } : {}), ...recovery,
88
91
  });
89
92
  }
@@ -164,7 +167,7 @@ const extractionSchema = z.object({
164
167
  export function createServer() {
165
168
  const server = new McpServer(
166
169
  { name: "Caelario", version: VERSION },
167
- { instructions: "Use discover_platforms and get_operation_guide before unfamiliar or expensive work. Prefer extract_now for one bounded target. Use durable jobs or batches for larger work, then wait and page the result. Only a Caelario workspace API key is needed; never ask users for social-network credentials." },
170
+ { instructions: "For first-time setup or a missing connection key, direct the user to https://app.caelario.com/connect to create an account and follow the browser setup. Never ask them to paste the key into chat. Use discover_platforms and get_operation_guide before unfamiliar or expensive work. Prefer extract_now for one bounded target. Use durable jobs or batches for larger work, then wait and page the result. Only a Caelario workspace API key is needed; never ask users for social-network credentials." },
168
171
  );
169
172
  const tool = (name, description, inputSchema, handler) => server.registerTool(name, { description, inputSchema }, async (input) => {
170
173
  try {
@@ -186,6 +189,7 @@ export function createServer() {
186
189
  tool("estimate_credits", "Estimate the maximum reservation for one or many targets before starting work.", z.object({ platform, operation, limit: z.number().int().min(1).max(25_000).default(12), include_posts: z.number().int().min(0).max(200).default(0), target_count: z.number().int().min(1).max(100).default(1) }), async (input) => {
187
190
  const catalog = await api("GET", "/v1/platforms");
188
191
  const { definition, capability } = capabilityFor(catalog, input.platform, input.operation);
192
+ if (capability.available === false) throw new ApiError(capability.unavailable_reason || "This operation is temporarily unavailable.", { error: "operation_unavailable", retryable: false });
189
193
  const single = new Set(["profile", "post", "video", "transcript", "adlibrary_ad", "adlibrary_ad_transcript", "profile_analytics", "playlist"]);
190
194
  const fixedCollection = input.platform.toLowerCase() === "instagram" && new Set(["highlights", "highlight_items", "stories"]).has(input.operation);
191
195
  const normalizedLimit = single.has(input.operation) ? 1 : fixedCollection ? capability.max_results : input.limit;