@mosadd/mcp 3.0.0-alpha.17 → 3.0.0-alpha.18

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/CHANGELOG.md CHANGED
@@ -6,6 +6,17 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project follows the `3.0.0-alpha.N` pre-release line until the hosted
7
7
  gateway (Phase 2) ships.
8
8
 
9
+ ## [3.0.0-alpha.18] — 2026-06-18
10
+
11
+ ### Added
12
+ - **`comms_embed_create`** — embed a LIVE mosadd channel into an app/site a builder-agent is
13
+ generating (Lovable / Bolt / Cursor / v0). Mints a publishable embed key (`m_pk_live_…`,
14
+ origin-scoped, via the `embed-keys` EF) and returns a paste-in widget snippet
15
+ (`<div>` + `<script src="https://embed.mosadd.com/v1.js" data-key=…>`). The widget exchanges
16
+ the publishable key for a short-lived channel-scoped JWT at runtime; the hub key never enters
17
+ the browser. Extends `mROOM_create_guest_link` (link → embeddable widget). CDN override via
18
+ `MOSADD_EMBED_CDN`. (Widget served from the dedicated `embed.mosadd.com` deploy.)
19
+
9
20
  ## [3.0.0-alpha.17] — 2026-06-18
10
21
 
11
22
  ### Added
package/dist/bin/mcp.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  createMosaddServer
4
- } from "../chunk-5ZMJB5YU.js";
4
+ } from "../chunk-D2PH2HYY.js";
5
5
  import {
6
6
  isSessionExpired,
7
7
  loadSession,
@@ -2255,8 +2255,62 @@ var actionTools = [
2255
2255
  }
2256
2256
  ];
2257
2257
 
2258
- // src/tools/capabilities.ts
2258
+ // src/tools/embed.ts
2259
2259
  import { z as z16 } from "zod";
2260
+ var EMBED_CDN = (process.env.MOSADD_EMBED_CDN ?? "https://embed.mosadd.com").replace(/\/+$/, "");
2261
+ var POSITIONS = ["inline", "sidebar-left", "sidebar-right", "floating-bl", "floating-br", "fullscreen"];
2262
+ var SKINS = ["default", "retro-irc-1990", "terminal", "minimal-dark", "minimal-light"];
2263
+ var embed_create_input = z16.object({
2264
+ channel: z16.string().min(1).max(128).regex(/^[A-Za-z0-9_-]+$/).describe("The mIRC channel id everyone on the embed shares (e.g. 'acme-support'). Auto-created on first message if new."),
2265
+ allowed_origins: z16.array(z16.string().min(1)).min(1).max(10).describe("REQUIRED. Domain(s) where the widget will be served \u2014 the key only works from these origins. Use the host(s) of the app you're building, e.g. ['app.acme.com','*.acme.com']. For local testing use mode:'test' and e.g. 'localhost:3000'."),
2266
+ name: z16.string().max(64).optional().describe("Label for the key in the owner's dashboard. Default 'embed: <channel>'."),
2267
+ position: z16.enum(POSITIONS).optional().describe("Where the widget renders. Default 'inline'."),
2268
+ skin: z16.enum(SKINS).optional().describe("Visual skin. Default 'default' (mosadd-branded retro mIRC)."),
2269
+ title: z16.string().max(60).optional().describe("Header title shown in the widget. Default 'mIRC'."),
2270
+ anon: z16.boolean().optional().describe("Allow visitors to join with just a nick (no mosadd account). Default true."),
2271
+ locale: z16.enum(["en", "pl"]).optional().describe("Widget UI language. Default 'en'."),
2272
+ mode: z16.enum(["live", "test"]).optional().describe("Key mode \u2014 'test' for local/dev origins, 'live' for production. Default 'live'.")
2273
+ });
2274
+ var attrSafe = (s) => s.replace(/["'<>]/g, "");
2275
+ function buildSnippet(input, key) {
2276
+ const attrs = [`data-channel="${attrSafe(input.channel)}"`, `data-position="${input.position ?? "inline"}"`];
2277
+ if (input.skin) attrs.push(`data-skin="${input.skin}"`);
2278
+ if (input.title) attrs.push(`data-title="${attrSafe(input.title)}"`);
2279
+ if (input.anon === false) attrs.push(`data-anon="false"`);
2280
+ if (input.locale) attrs.push(`data-locale="${input.locale}"`);
2281
+ return `<div id="mosadd-mirc" ${attrs.join(" ")}></div>
2282
+ <script src="${EMBED_CDN}/v1.js" data-key="${key}"></script>`;
2283
+ }
2284
+ async function embed_create(input, ctx) {
2285
+ readSupabaseEnv();
2286
+ ctx.log("debug", "comms_embed_create minting embed key", { channel: input.channel, origins: input.allowed_origins.length });
2287
+ const res = await invokeFunction("embed-keys", {
2288
+ name: input.name ?? `embed: ${input.channel}`,
2289
+ channels: [input.channel],
2290
+ allowed_origins: input.allowed_origins,
2291
+ mode: input.mode ?? "live"
2292
+ });
2293
+ if (res.error) throw new Error(res.error);
2294
+ if (!res.key) throw new Error("embed-keys returned no publishable key (missing `key`).");
2295
+ return {
2296
+ embed_key: res.key,
2297
+ channel: input.channel,
2298
+ allowed_origins: input.allowed_origins,
2299
+ snippet: buildSnippet(input, res.key)
2300
+ };
2301
+ }
2302
+ var embedTools = [
2303
+ {
2304
+ name: "comms_embed_create",
2305
+ requires: "network",
2306
+ description: "Embed a LIVE mosadd chat channel into an app/site you're building (great for builder-agents on Lovable/Bolt/Cursor/v0). Mints a publishable embed key scoped to a channel + the app's domain(s) and returns a ready-to-paste HTML snippet (a <div> + <script src=embed.mosadd.com/v1.js data-key=\u2026>). Visitors of the host page chat in real time (anonymous nick or mosadd login). REQUIRES `allowed_origins` \u2014 the domain(s) the app is served from (the key only works there). The publishable key is browser-safe (mints only channel-scoped JWTs); your hub key never leaves the server. Returns { embed_key, channel, allowed_origins, snippet }. Extends mROOM_create_guest_link (link \u2192 embeddable widget).",
2307
+ inputSchema: embed_create_input,
2308
+ handler: embed_create
2309
+ }
2310
+ ];
2311
+
2312
+ // src/tools/capabilities.ts
2313
+ import { z as z17 } from "zod";
2260
2314
  var CONTRACT_VERSION = "1.0.0";
2261
2315
  var ALL_REQUIREMENTS = ["any", "radio", "network"];
2262
2316
  function buildCapabilityManifest(tools) {
@@ -2279,7 +2333,7 @@ function makeCapabilitiesTool(channelTools2) {
2279
2333
  name: "comms_capabilities",
2280
2334
  requires: "any",
2281
2335
  description: "Discover which mosadd tools are available and what transport each requires (any | radio | network). Carrier-aware hosts (e.g. off-grid radio devices) call this once to gate the tool list to what the current carrier supports. Returns a manifest with per-tool requirements grouped by transport.",
2282
- inputSchema: z16.object({}),
2336
+ inputSchema: z17.object({}),
2283
2337
  handler: async () => buildCapabilityManifest([...channelTools2, tool])
2284
2338
  };
2285
2339
  return tool;
@@ -2301,8 +2355,10 @@ var channelTools = [
2301
2355
  ...attachmentTools,
2302
2356
  ...pttIngestTools,
2303
2357
  ...knowledgeTools,
2304
- ...actionTools
2358
+ ...actionTools,
2305
2359
  // Action links (Tier 1): agent → user one-link browser action via action-create EF
2360
+ ...embedTools
2361
+ // comms_embed_create: agent embeds a live channel into the app it builds (embed-keys EF + embed.mosadd.com widget)
2306
2362
  // ...murlTools, // mURL: brand/consumer surface (murl.mosadd.com), not a dev product
2307
2363
  // ...mcallTools, // mCALL: carrier-pending (no telephony carrier live) — re-register when a carrier is configured
2308
2364
  // mirlTools,
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  createMosaddServer,
4
4
  defaultProviders,
5
5
  runWithSupabaseEnv
6
- } from "./chunk-5ZMJB5YU.js";
6
+ } from "./chunk-D2PH2HYY.js";
7
7
  import "./chunk-Z7WR52GE.js";
8
8
  export {
9
9
  allTools,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mosadd/mcp",
3
- "version": "3.0.0-alpha.17",
3
+ "version": "3.0.0-alpha.18",
4
4
  "description": "Model Context Protocol server for mosadd. Exposes the 6 live m* modules (mDM, mIRC, mROOM, mTALK, mAIL, mRAG) — 70 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": {
@@ -38,8 +38,8 @@
38
38
  "@supabase/supabase-js": "^2.48.0",
39
39
  "zod": "^4.3.6",
40
40
  "@mosadd/crypto": "3.0.0-alpha.4",
41
- "@mosadd/providers": "3.0.0-alpha.4",
42
- "@mosadd/protocol": "3.0.0-alpha.4"
41
+ "@mosadd/protocol": "3.0.0-alpha.4",
42
+ "@mosadd/providers": "3.0.0-alpha.4"
43
43
  },
44
44
  "devDependencies": {
45
45
  "tsup": "^8.3.5",
@@ -0,0 +1,108 @@
1
+ /**
2
+ * comms_embed — let a builder-agent drop a LIVE mosadd channel into the app/site
3
+ * it is generating.
4
+ *
5
+ * Mints a publishable embed key (`m_pk_live_…`) scoped to a channel + the app's
6
+ * domain(s) via the `embed-keys` Edge Function, and returns a paste-in HTML
7
+ * snippet that loads the mosadd widget from the CDN (embed.mosadd.com/v1.js).
8
+ *
9
+ * Security: the publishable key is safe to ship in HTML — it can ONLY mint
10
+ * channel-scoped JWTs (the widget exchanges it at runtime via `mirc-embed-token`,
11
+ * validated against the key's origin allow-list). Your hub key (`mosadd_sk_live_…`)
12
+ * never enters the browser. The action is owned by the calling user (user-JWT
13
+ * scoped — `mosadd login` / MOSADD_USER_JWT / hub-key exchange).
14
+ *
15
+ * Reuses the shipped embed infra (apps/embed widget + embed-keys + mirc-embed-token).
16
+ * RFC 0001: channel-agnostic capability → `comms_` namespace (not an m<MODULE>_ prefix).
17
+ */
18
+
19
+ import { z } from "zod";
20
+ import type { MosaddTool, MosaddToolContext } from "../types.js";
21
+ import { invokeFunction, readSupabaseEnv } from "../providers/supabase.js";
22
+
23
+ /** Widget CDN base. Override with MOSADD_EMBED_CDN for self-host / dev. */
24
+ const EMBED_CDN = (process.env.MOSADD_EMBED_CDN ?? "https://embed.mosadd.com").replace(/\/+$/, "");
25
+
26
+ const POSITIONS = ["inline", "sidebar-left", "sidebar-right", "floating-bl", "floating-br", "fullscreen"] as const;
27
+ const SKINS = ["default", "retro-irc-1990", "terminal", "minimal-dark", "minimal-light"] as const;
28
+
29
+ const embed_create_input = z.object({
30
+ channel: z
31
+ .string().min(1).max(128).regex(/^[A-Za-z0-9_-]+$/)
32
+ .describe("The mIRC channel id everyone on the embed shares (e.g. 'acme-support'). Auto-created on first message if new."),
33
+ allowed_origins: z
34
+ .array(z.string().min(1)).min(1).max(10)
35
+ .describe("REQUIRED. Domain(s) where the widget will be served — the key only works from these origins. Use the host(s) of the app you're building, e.g. ['app.acme.com','*.acme.com']. For local testing use mode:'test' and e.g. 'localhost:3000'."),
36
+ name: z.string().max(64).optional().describe("Label for the key in the owner's dashboard. Default 'embed: <channel>'."),
37
+ position: z.enum(POSITIONS).optional().describe("Where the widget renders. Default 'inline'."),
38
+ skin: z.enum(SKINS).optional().describe("Visual skin. Default 'default' (mosadd-branded retro mIRC)."),
39
+ title: z.string().max(60).optional().describe("Header title shown in the widget. Default 'mIRC'."),
40
+ anon: z.boolean().optional().describe("Allow visitors to join with just a nick (no mosadd account). Default true."),
41
+ locale: z.enum(["en", "pl"]).optional().describe("Widget UI language. Default 'en'."),
42
+ mode: z.enum(["live", "test"]).optional().describe("Key mode — 'test' for local/dev origins, 'live' for production. Default 'live'."),
43
+ });
44
+
45
+ interface EmbedKeyResult {
46
+ id?: string;
47
+ key?: string;
48
+ pk_prefix?: string;
49
+ allowed_channels?: string[];
50
+ error?: string;
51
+ }
52
+
53
+ interface EmbedCreateResult {
54
+ embed_key: string;
55
+ channel: string;
56
+ allowed_origins: string[];
57
+ snippet: string;
58
+ }
59
+
60
+ /** HTML-attr-safe: drop quotes/angle brackets (inputs are already length-bounded). */
61
+ const attrSafe = (s: string): string => s.replace(/["'<>]/g, "");
62
+
63
+ function buildSnippet(input: z.infer<typeof embed_create_input>, key: string): string {
64
+ const attrs = [`data-channel="${attrSafe(input.channel)}"`, `data-position="${input.position ?? "inline"}"`];
65
+ if (input.skin) attrs.push(`data-skin="${input.skin}"`);
66
+ if (input.title) attrs.push(`data-title="${attrSafe(input.title)}"`);
67
+ if (input.anon === false) attrs.push(`data-anon="false"`);
68
+ if (input.locale) attrs.push(`data-locale="${input.locale}"`);
69
+ return (
70
+ `<div id="mosadd-mirc" ${attrs.join(" ")}></div>\n` +
71
+ `<script src="${EMBED_CDN}/v1.js" data-key="${key}"></script>`
72
+ );
73
+ }
74
+
75
+ async function embed_create(
76
+ input: z.infer<typeof embed_create_input>,
77
+ ctx: MosaddToolContext,
78
+ ): Promise<EmbedCreateResult> {
79
+ readSupabaseEnv();
80
+ ctx.log("debug", "comms_embed_create minting embed key", { channel: input.channel, origins: input.allowed_origins.length });
81
+
82
+ const res = await invokeFunction<EmbedKeyResult>("embed-keys", {
83
+ name: input.name ?? `embed: ${input.channel}`,
84
+ channels: [input.channel],
85
+ allowed_origins: input.allowed_origins,
86
+ mode: input.mode ?? "live",
87
+ });
88
+ if (res.error) throw new Error(res.error);
89
+ if (!res.key) throw new Error("embed-keys returned no publishable key (missing `key`).");
90
+
91
+ return {
92
+ embed_key: res.key,
93
+ channel: input.channel,
94
+ allowed_origins: input.allowed_origins,
95
+ snippet: buildSnippet(input, res.key),
96
+ };
97
+ }
98
+
99
+ export const embedTools: MosaddTool[] = [
100
+ {
101
+ name: "comms_embed_create",
102
+ requires: "network",
103
+ description:
104
+ "Embed a LIVE mosadd chat channel into an app/site you're building (great for builder-agents on Lovable/Bolt/Cursor/v0). Mints a publishable embed key scoped to a channel + the app's domain(s) and returns a ready-to-paste HTML snippet (a <div> + <script src=embed.mosadd.com/v1.js data-key=…>). Visitors of the host page chat in real time (anonymous nick or mosadd login). REQUIRES `allowed_origins` — the domain(s) the app is served from (the key only works there). The publishable key is browser-safe (mints only channel-scoped JWTs); your hub key never leaves the server. Returns { embed_key, channel, allowed_origins, snippet }. Extends mROOM_create_guest_link (link → embeddable widget).",
105
+ inputSchema: embed_create_input,
106
+ handler: embed_create as MosaddTool["handler"],
107
+ },
108
+ ];
@@ -28,6 +28,7 @@ import { pttIngestTools } from "./ptt-ingest.js";
28
28
  // import { mcallTools } from "./mcall.js"; // mCALL: carrier-pending — not registered (see header note)
29
29
  import { knowledgeTools } from "./knowledge.js";
30
30
  import { actionTools } from "./actions.js";
31
+ import { embedTools } from "./embed.js";
31
32
  // import { murlTools } from "./murl.js"; // mURL: brand/consumer surface, not a dev product — not registered
32
33
  import { makeCapabilitiesTool } from "./capabilities.js";
33
34
 
@@ -48,6 +49,7 @@ const channelTools: MosaddTool[] = [
48
49
  ...pttIngestTools,
49
50
  ...knowledgeTools,
50
51
  ...actionTools, // Action links (Tier 1): agent → user one-link browser action via action-create EF
52
+ ...embedTools, // comms_embed_create: agent embeds a live channel into the app it builds (embed-keys EF + embed.mosadd.com widget)
51
53
  // ...murlTools, // mURL: brand/consumer surface (murl.mosadd.com), not a dev product
52
54
  // ...mcallTools, // mCALL: carrier-pending (no telephony carrier live) — re-register when a carrier is configured
53
55
  // mirlTools,