@mosadd/mcp 3.0.0-alpha.2 → 3.0.0-alpha.3

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/bin/mcp.js CHANGED
@@ -6,6 +6,33 @@ import "../chunk-Z7WR52GE.js";
6
6
 
7
7
  // src/bin/mcp.ts
8
8
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
9
+ var DEFAULT_EXCHANGE = "https://rooffhgbxafyjcwmwpsy.supabase.co/functions/v1/hub-key-exchange";
10
+ async function bootstrapFromApiKey() {
11
+ const apiKey = process.env.MOSADD_API_KEY;
12
+ if (!apiKey || process.env.MOSADD_USER_JWT) return;
13
+ const endpoint = process.env.MOSADD_HUB_URL ? `${process.env.MOSADD_HUB_URL.replace(/\/$/, "")}/hub-key-exchange` : DEFAULT_EXCHANGE;
14
+ try {
15
+ const res = await fetch(endpoint, {
16
+ method: "POST",
17
+ headers: { Authorization: `Bearer ${apiKey}`, "Content-Type": "application/json" },
18
+ body: "{}"
19
+ });
20
+ if (!res.ok) {
21
+ process.stderr.write(
22
+ JSON.stringify({ level: "warn", msg: "mosadd hub key exchange failed", status: res.status }) + "\n"
23
+ );
24
+ return;
25
+ }
26
+ const d = await res.json();
27
+ if (d.url) process.env.MOSADD_SUPABASE_URL = d.url;
28
+ if (d.anon_key) process.env.MOSADD_SUPABASE_ANON_KEY = d.anon_key;
29
+ if (d.access_token) process.env.MOSADD_USER_JWT = d.access_token;
30
+ } catch (err) {
31
+ process.stderr.write(
32
+ JSON.stringify({ level: "warn", msg: "mosadd hub unreachable", error: String(err) }) + "\n"
33
+ );
34
+ }
35
+ }
9
36
  async function main() {
10
37
  const sub = process.argv[2];
11
38
  if (sub === "login" || sub === "logout" || sub === "whoami") {
@@ -13,6 +40,7 @@ async function main() {
13
40
  await runAuthCommand(sub, process.argv.slice(3));
14
41
  return;
15
42
  }
43
+ await bootstrapFromApiKey();
16
44
  const server = createMosaddServer({
17
45
  apiKey: process.env.MOSADD_API_KEY,
18
46
  hubUrl: process.env.MOSADD_HUB_URL,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mosadd/mcp",
3
- "version": "3.0.0-alpha.2",
3
+ "version": "3.0.0-alpha.3",
4
4
  "description": "Model Context Protocol server for mosadd. Exposes m* OS modules (mDM, mTALK, mAIL, mCALL, mIRC, mIRL, mROOM, and bridges) as MCP tools to any agent runtime (Claude Code, Cursor, Windsurf, Cline, ChatGPT Apps, Lovable, Bolt, Goose, Manus, custom).",
5
5
  "homepage": "https://github.com/Hei33enberg/mosadd-os/tree/main/packages/mcp",
6
6
  "repository": {
@@ -36,8 +36,8 @@
36
36
  "@modelcontextprotocol/sdk": "^1.0.4",
37
37
  "@supabase/supabase-js": "^2.48.0",
38
38
  "zod": "^4.3.6",
39
- "@mosadd/providers": "3.0.0-alpha.0",
40
39
  "@mosadd/crypto": "3.0.0-alpha.0",
40
+ "@mosadd/providers": "3.0.0-alpha.0",
41
41
  "@mosadd/protocol": "3.0.0-alpha.0"
42
42
  },
43
43
  "devDependencies": {
@@ -57,6 +57,9 @@
57
57
  "communication",
58
58
  "messaging"
59
59
  ],
60
+ "engines": {
61
+ "node": ">=18"
62
+ },
60
63
  "scripts": {
61
64
  "build": "tsup src/index.ts src/bin/mcp.ts src/bin/login.ts --format esm --dts --clean --shims",
62
65
  "dev": "tsx src/bin/mcp.ts",
package/src/bin/mcp.ts CHANGED
@@ -12,6 +12,45 @@
12
12
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
13
13
  import { createMosaddServer } from "../server.js";
14
14
 
15
+ const DEFAULT_EXCHANGE =
16
+ "https://rooffhgbxafyjcwmwpsy.supabase.co/functions/v1/hub-key-exchange";
17
+
18
+ /**
19
+ * Hosted-hub path: when MOSADD_API_KEY is set, exchange it for a short-lived
20
+ * session (URL + anon key + access token) so the tools act as the key's owner.
21
+ * Removes the DevTools-JWT wall — paste one stable key, done. Falls through
22
+ * silently if the key is unset or the exchange is unreachable (so BYOK/self-host
23
+ * keep working).
24
+ */
25
+ async function bootstrapFromApiKey(): Promise<void> {
26
+ const apiKey = process.env.MOSADD_API_KEY;
27
+ if (!apiKey || process.env.MOSADD_USER_JWT) return;
28
+ const endpoint = process.env.MOSADD_HUB_URL
29
+ ? `${process.env.MOSADD_HUB_URL.replace(/\/$/, "")}/hub-key-exchange`
30
+ : DEFAULT_EXCHANGE;
31
+ try {
32
+ const res = await fetch(endpoint, {
33
+ method: "POST",
34
+ headers: { Authorization: `Bearer ${apiKey}`, "Content-Type": "application/json" },
35
+ body: "{}",
36
+ });
37
+ if (!res.ok) {
38
+ process.stderr.write(
39
+ JSON.stringify({ level: "warn", msg: "mosadd hub key exchange failed", status: res.status }) + "\n",
40
+ );
41
+ return;
42
+ }
43
+ const d = (await res.json()) as { url?: string; anon_key?: string; access_token?: string };
44
+ if (d.url) process.env.MOSADD_SUPABASE_URL = d.url;
45
+ if (d.anon_key) process.env.MOSADD_SUPABASE_ANON_KEY = d.anon_key;
46
+ if (d.access_token) process.env.MOSADD_USER_JWT = d.access_token;
47
+ } catch (err) {
48
+ process.stderr.write(
49
+ JSON.stringify({ level: "warn", msg: "mosadd hub unreachable", error: String(err) }) + "\n",
50
+ );
51
+ }
52
+ }
53
+
15
54
  async function main(): Promise<void> {
16
55
  // Auth subcommands: `mosadd login | logout | whoami`. Everything else starts the server.
17
56
  const sub = process.argv[2];
@@ -21,6 +60,9 @@ async function main(): Promise<void> {
21
60
  return;
22
61
  }
23
62
 
63
+ // Hosted: trade MOSADD_API_KEY for a live session before the server reads env.
64
+ await bootstrapFromApiKey();
65
+
24
66
  const server = createMosaddServer({
25
67
  apiKey: process.env.MOSADD_API_KEY,
26
68
  hubUrl: process.env.MOSADD_HUB_URL,