@mosadd/mcp 3.0.0-alpha.11 → 3.0.0-alpha.13
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 +2 -3
- package/dist/bin/mcp.js +5 -2
- package/dist/{chunk-NQ624SIP.js → chunk-YLIPGVP7.js} +23 -132
- package/dist/index.d.ts +12 -1
- package/dist/index.js +1 -1
- package/package.json +3 -3
- package/src/__tests__/mdm-e2ee.test.ts +34 -0
- package/src/bin/mcp.ts +3 -0
- package/src/server.ts +13 -1
- package/src/tools/index.ts +5 -3
- package/src/tools/mirc-members.ts +12 -4
- package/src/types.ts +9 -0
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
MCP server for [mosadd](https://mosadd.dev) — exposes the OS modules (m\*) as Model Context Protocol tools so any agent runtime can talk to mosadd: Claude Code, Cursor, Windsurf, Cline, ChatGPT Apps, Lovable, Bolt, Goose, Manus, custom.
|
|
4
4
|
|
|
5
|
-
> **3.0.0-alpha.4** — **
|
|
5
|
+
> **3.0.0-alpha.4** — **61 live tools across 6 live modules** (mDM incl. voice, mIRC, mROOM, mAIL, mTALK, mRAG) + the `comms_capabilities` discovery tool, wired to the mosadd backend (BYOK) as a strangler-fig step. Phase 2 routes through the hosted gateway at `mcp.mosadd.com` with the 166-event radar in front.
|
|
6
6
|
|
|
7
7
|
## Install
|
|
8
8
|
|
|
@@ -53,7 +53,7 @@ In Phase 2, run `mosadd login` to OAuth into hub.mosadd.com — no JWT-juggling
|
|
|
53
53
|
|
|
54
54
|
## Tools shipped in alpha
|
|
55
55
|
|
|
56
|
-
**
|
|
56
|
+
**61 live tools across 6 live modules** (mDM, mIRC, mROOM, mAIL, mTALK, mRAG) + the `comms_capabilities` discovery tool. Highlights per module:
|
|
57
57
|
|
|
58
58
|
| Module | Tools | What it does |
|
|
59
59
|
|---|---|---|
|
|
@@ -63,7 +63,6 @@ In Phase 2, run `mosadd login` to OAuth into hub.mosadd.com — no JWT-juggling
|
|
|
63
63
|
| **mTALK** (5) | `mTALK_open`, `mTALK_join`, `mTALK_press`, `mTALK_release`, `mTALK_state` | Half-duplex push-to-talk: one speaker, FIFO queue, anti-hog auto-release |
|
|
64
64
|
| **mAIL** (11) | `mAIL_send`, `mAIL_view`, `mAIL_list`, `mAIL_delete`, `mAIL_stats`, `mAIL_events`, `mAIL_metrics`, `mAIL_revoke`, `mAIL_audit_export`, `mAIL_consent`, `mAIL_notify` | Mail; every user gets `<id>@mosadd.com`. `mAIL_revoke` recalls secure-reader access; `mAIL_audit_export` emits an HMAC-SHA256-signed engagement audit; `mAIL_consent` manages recipient tracking opt-outs (GDPR); `mAIL_notify` pulls the inbound-mail notification feed |
|
|
65
65
|
| **mRAG** (4) | `mRAG_ingest`, `mRAG_search`, `mRAG_list_sources`, `mRAG_delete` | RAG recall over the user's own data (hybrid vector + BM25) |
|
|
66
|
-
| **mURL** (4) | `mURL_read_channel`, `mURL_post`, `mURL_presence`, `mURL_list_channels` | Real-time chat attached to any web domain — agent-native ("IRC for URLs"). The per-domain room is never empty because agents read context + leave findings via MCP |
|
|
67
66
|
|
|
68
67
|
All tool names follow [RFC 0001](https://github.com/Hei33enberg/mosadd-os/blob/main/docs/rfcs/0001-module-naming.md) — `m<MODULE>_<operation>` snake_case.
|
|
69
68
|
|
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-
|
|
4
|
+
} from "../chunk-YLIPGVP7.js";
|
|
5
5
|
import "../chunk-Z7WR52GE.js";
|
|
6
6
|
|
|
7
7
|
// src/bin/mcp.ts
|
|
@@ -45,7 +45,10 @@ async function main() {
|
|
|
45
45
|
apiKey: process.env.MOSADD_API_KEY,
|
|
46
46
|
hubUrl: process.env.MOSADD_HUB_URL,
|
|
47
47
|
mode: process.env.MOSADD_MODE,
|
|
48
|
-
logLevel: process.env.MOSADD_LOG_LEVEL
|
|
48
|
+
logLevel: process.env.MOSADD_LOG_LEVEL,
|
|
49
|
+
// stdio is single-tenant: the session lives in env (set by bootstrapFromApiKey
|
|
50
|
+
// above), so auto-publish this identity's prekeys on boot → mDM is reachable.
|
|
51
|
+
autoPublishKeys: true
|
|
49
52
|
});
|
|
50
53
|
const transport = new StdioServerTransport();
|
|
51
54
|
await server.connect(transport);
|
|
@@ -790,7 +790,7 @@ var mircTools = [
|
|
|
790
790
|
import { z as z4 } from "zod";
|
|
791
791
|
var ChannelId2 = z4.string().min(1).max(120).describe("Channel id (UUID). From mIRC_list / mIRC_create.");
|
|
792
792
|
var MemberIdentity = z4.string().min(1).describe("Target user's identity id (UUID). From mDM_list_contacts or radar logs.");
|
|
793
|
-
var Role = z4.enum(["
|
|
793
|
+
var Role = z4.enum(["superadmin", "admin", "moderator", "member"]).describe("Role to assign. owner = channel creator (not assignable); promote up to one tier below your own.");
|
|
794
794
|
var mIRC_join_input = z4.object({
|
|
795
795
|
channel_id: ChannelId2,
|
|
796
796
|
password: z4.string().min(1).optional().describe("Required if the channel is access_mode=private.")
|
|
@@ -834,9 +834,22 @@ var mIRC_set_ptt_input = z4.object({
|
|
|
834
834
|
ptt_enabled: z4.boolean().describe("Allow this member to hold the PTT floor in voice mode.")
|
|
835
835
|
});
|
|
836
836
|
async function invokeChannelMembers(action, body, ctx) {
|
|
837
|
+
const b = { ...body };
|
|
838
|
+
if ("identity_id" in b) {
|
|
839
|
+
b.target_identity_id = b.identity_id;
|
|
840
|
+
delete b.identity_id;
|
|
841
|
+
}
|
|
842
|
+
if ("role" in b) {
|
|
843
|
+
b.new_role = b.role;
|
|
844
|
+
delete b.role;
|
|
845
|
+
}
|
|
846
|
+
if ("ptt_enabled" in b) {
|
|
847
|
+
b.can_ptt = b.ptt_enabled;
|
|
848
|
+
delete b.ptt_enabled;
|
|
849
|
+
}
|
|
837
850
|
readSupabaseEnv();
|
|
838
|
-
ctx.log("debug", `mIRC.${action}`,
|
|
839
|
-
return await invokeFunction("channel-members-manage", { action, ...
|
|
851
|
+
ctx.log("debug", `mIRC.${action}`, b);
|
|
852
|
+
return await invokeFunction("channel-members-manage", { action, ...b });
|
|
840
853
|
}
|
|
841
854
|
var mircMembersTools = [
|
|
842
855
|
{
|
|
@@ -1726,133 +1739,8 @@ var knowledgeTools = [
|
|
|
1726
1739
|
}
|
|
1727
1740
|
];
|
|
1728
1741
|
|
|
1729
|
-
// src/tools/murl.ts
|
|
1730
|
-
import { z as z12 } from "zod";
|
|
1731
|
-
var DEFAULT_EDGE_URL2 = "https://mosadd-edge.mr-brics-33.workers.dev";
|
|
1732
|
-
function edgeUrl2() {
|
|
1733
|
-
return process.env.MOSADD_EDGE_URL?.replace(/\/$/, "") ?? DEFAULT_EDGE_URL2;
|
|
1734
|
-
}
|
|
1735
|
-
function hubKey2() {
|
|
1736
|
-
const key = process.env.MOSADD_API_KEY ?? process.env.MOSADD_HUB_KEY ?? "";
|
|
1737
|
-
if (!key) throw new Error("MOSADD_API_KEY required for mURL tools (see `mosadd login` / hub-keys).");
|
|
1738
|
-
return key;
|
|
1739
|
-
}
|
|
1740
|
-
function domainToSlug(input) {
|
|
1741
|
-
let host = String(input).trim().toLowerCase();
|
|
1742
|
-
host = host.replace(/^[a-z]+:\/\//, "").replace(/[/?#].*$/, "").replace(/:\d+$/, "");
|
|
1743
|
-
if (host.startsWith("www.")) host = host.slice(4);
|
|
1744
|
-
if (!host || !/^[a-z0-9-]+(\.[a-z0-9-]+)+$/.test(host)) {
|
|
1745
|
-
throw new Error(`Invalid domain: "${input}" \u2014 pass a domain like "example.com" or a URL.`);
|
|
1746
|
-
}
|
|
1747
|
-
return { domain: host, slug: host.replace(/\./g, "-") };
|
|
1748
|
-
}
|
|
1749
|
-
var DomainArg = z12.string().min(3).max(255).describe("A domain (e.g. 'example.com') or a full URL \u2014 the channel is keyed to the domain.");
|
|
1750
|
-
var mURL_read_channel_input = z12.object({
|
|
1751
|
-
domain: DomainArg,
|
|
1752
|
-
limit: z12.number().int().min(1).max(100).optional().describe("Recent messages to return (max 100). Default 50.")
|
|
1753
|
-
});
|
|
1754
|
-
async function mURL_read_channel(input, ctx) {
|
|
1755
|
-
const { domain, slug: slug2 } = domainToSlug(input.domain);
|
|
1756
|
-
const limit = input.limit ?? 50;
|
|
1757
|
-
ctx.log("debug", "mURL_read_channel", { domain });
|
|
1758
|
-
const r = await fetch(`${edgeUrl2()}/c/${slug2}/history?limit=${limit}`, {
|
|
1759
|
-
headers: { Authorization: `Bearer ${hubKey2()}` }
|
|
1760
|
-
});
|
|
1761
|
-
if (!r.ok) {
|
|
1762
|
-
const e = await r.text().catch(() => "");
|
|
1763
|
-
throw new Error(`mosadd-edge ${r.status}: ${e.slice(0, 200)}`);
|
|
1764
|
-
}
|
|
1765
|
-
const data = await r.json();
|
|
1766
|
-
return {
|
|
1767
|
-
domain,
|
|
1768
|
-
messages: (data.messages ?? []).map((m) => ({ id: m.id, from: m.from ?? null, text: m.text, timestamp: m.ts }))
|
|
1769
|
-
};
|
|
1770
|
-
}
|
|
1771
|
-
var mURL_post_input = z12.object({
|
|
1772
|
-
domain: DomainArg,
|
|
1773
|
-
text: z12.string().min(1).max(2e3).describe("Message body (max 2000 chars, up to 3 lines \u2014 Worker-enforced)."),
|
|
1774
|
-
from: z12.string().max(120).optional().describe("Sender hint shown to others (defaults to the hub-key owner / your agent name).")
|
|
1775
|
-
});
|
|
1776
|
-
async function mURL_post(input, ctx) {
|
|
1777
|
-
const { domain, slug: slug2 } = domainToSlug(input.domain);
|
|
1778
|
-
ctx.log("debug", "mURL_post", { domain });
|
|
1779
|
-
const r = await fetch(`${edgeUrl2()}/c/${slug2}/send`, {
|
|
1780
|
-
method: "POST",
|
|
1781
|
-
headers: { "Content-Type": "application/json", Authorization: `Bearer ${hubKey2()}` },
|
|
1782
|
-
body: JSON.stringify({ text: input.text, from: input.from })
|
|
1783
|
-
});
|
|
1784
|
-
if (!r.ok) {
|
|
1785
|
-
const e = await r.text().catch(() => "");
|
|
1786
|
-
throw new Error(`mosadd-edge ${r.status}: ${e.slice(0, 200)}`);
|
|
1787
|
-
}
|
|
1788
|
-
const data = await r.json();
|
|
1789
|
-
if (!data?.id) throw new Error("mosadd-edge: send returned no id");
|
|
1790
|
-
return { domain, message_id: data.id, posted_at: data.ts ?? Date.now() };
|
|
1791
|
-
}
|
|
1792
|
-
var mURL_list_channels_input = z12.object({
|
|
1793
|
-
action: z12.enum(["trending", "list", "mine"]).optional().describe("'trending' (default) = most active domain channels in the last N hours; 'list' = paginated catalogue filtered by status; 'mine' = channels you own (DNS-verified)."),
|
|
1794
|
-
limit: z12.number().int().min(1).max(100).optional().describe("Max channels to return. Default 20."),
|
|
1795
|
-
hours: z12.number().int().min(1).max(168).optional().describe("Trending window in hours. Default 24, max 168 (7d)."),
|
|
1796
|
-
status: z12.enum(["open", "claimed", "blocked"]).optional().describe("For action='list': filter (default 'open')."),
|
|
1797
|
-
cursor: z12.string().optional().describe("For action='list': pagination \u2014 pass previous response's next_cursor (created_at ISO).")
|
|
1798
|
-
});
|
|
1799
|
-
async function mURL_list_channels(input, ctx) {
|
|
1800
|
-
readSupabaseEnv();
|
|
1801
|
-
const action = input.action ?? "trending";
|
|
1802
|
-
ctx.log("debug", "mURL_list_channels invoking murl-channels", { action });
|
|
1803
|
-
return await invokeFunction("murl-channels", {
|
|
1804
|
-
action,
|
|
1805
|
-
limit: input.limit ?? null,
|
|
1806
|
-
hours: input.hours ?? null,
|
|
1807
|
-
status: input.status ?? null,
|
|
1808
|
-
cursor: input.cursor ?? null
|
|
1809
|
-
});
|
|
1810
|
-
}
|
|
1811
|
-
var mURL_presence_input = z12.object({ domain: DomainArg });
|
|
1812
|
-
async function mURL_presence(input, ctx) {
|
|
1813
|
-
const { domain, slug: slug2 } = domainToSlug(input.domain);
|
|
1814
|
-
ctx.log("debug", "mURL_presence", { domain });
|
|
1815
|
-
const r = await fetch(`${edgeUrl2()}/c/${slug2}/presence`);
|
|
1816
|
-
if (!r.ok) {
|
|
1817
|
-
const e = await r.text().catch(() => "");
|
|
1818
|
-
throw new Error(`mosadd-edge ${r.status}: ${e.slice(0, 200)}`);
|
|
1819
|
-
}
|
|
1820
|
-
const data = await r.json();
|
|
1821
|
-
return { domain, count: data.count ?? 0, roster: data.roster ?? [], status: data.status ?? "open" };
|
|
1822
|
-
}
|
|
1823
|
-
var murlTools = [
|
|
1824
|
-
{
|
|
1825
|
-
name: "mURL_read_channel",
|
|
1826
|
-
requires: "network",
|
|
1827
|
-
description: "Read the live chat channel for a web DOMAIN (mURL \u2014 'IRC for URLs'). Returns the most recent messages humans and agents have posted about that domain. Use it to get real-time, crowd-sourced context before acting on a site \u2014 e.g. scam warnings, promo codes, outage reports, 'is this legit?'. The channel auto-exists for any domain. Auth: MOSADD_API_KEY (hub key).",
|
|
1828
|
-
inputSchema: mURL_read_channel_input,
|
|
1829
|
-
handler: mURL_read_channel
|
|
1830
|
-
},
|
|
1831
|
-
{
|
|
1832
|
-
name: "mURL_post",
|
|
1833
|
-
requires: "network",
|
|
1834
|
-
description: "Post a message into a web DOMAIN's mURL chat channel \u2014 leave context for the humans and agents who visit that site next (a finding, warning, tip, or coordination note). Sub-100ms global fan-out to everyone currently on the channel. Auth: MOSADD_API_KEY (hub key).",
|
|
1835
|
-
inputSchema: mURL_post_input,
|
|
1836
|
-
handler: mURL_post
|
|
1837
|
-
},
|
|
1838
|
-
{
|
|
1839
|
-
name: "mURL_presence",
|
|
1840
|
-
requires: "network",
|
|
1841
|
-
description: "Who is on a domain's mURL channel right now: live participant count + roster nicknames + channel status (open/claimed/blocked). Public (no key needed). Use it to gauge whether a domain has an active audience before posting.",
|
|
1842
|
-
inputSchema: mURL_presence_input,
|
|
1843
|
-
handler: mURL_presence
|
|
1844
|
-
},
|
|
1845
|
-
{
|
|
1846
|
-
name: "mURL_list_channels",
|
|
1847
|
-
requires: "network",
|
|
1848
|
-
description: "Discovery for mURL domain channels: 'trending' (most active in the last N hours, default 24) / 'list' (paginated catalogue, status-filtered) / 'mine' (channels you DNS-verified). Returns domain, slug, status, branding, verified_at + (for trending) messages_in_window. For who's-on-now, follow up with mURL_presence on the slug.",
|
|
1849
|
-
inputSchema: mURL_list_channels_input,
|
|
1850
|
-
handler: mURL_list_channels
|
|
1851
|
-
}
|
|
1852
|
-
];
|
|
1853
|
-
|
|
1854
1742
|
// src/tools/capabilities.ts
|
|
1855
|
-
import { z as
|
|
1743
|
+
import { z as z12 } from "zod";
|
|
1856
1744
|
var CONTRACT_VERSION = "1.0.0";
|
|
1857
1745
|
var ALL_REQUIREMENTS = ["any", "radio", "network"];
|
|
1858
1746
|
function buildCapabilityManifest(tools) {
|
|
@@ -1875,7 +1763,7 @@ function makeCapabilitiesTool(channelTools2) {
|
|
|
1875
1763
|
name: "comms_capabilities",
|
|
1876
1764
|
requires: "any",
|
|
1877
1765
|
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.",
|
|
1878
|
-
inputSchema:
|
|
1766
|
+
inputSchema: z12.object({}),
|
|
1879
1767
|
handler: async () => buildCapabilityManifest([...channelTools2, tool])
|
|
1880
1768
|
};
|
|
1881
1769
|
return tool;
|
|
@@ -1893,8 +1781,8 @@ var channelTools = [
|
|
|
1893
1781
|
...mroomMessagesTools,
|
|
1894
1782
|
...mailTools,
|
|
1895
1783
|
...mtalkTools,
|
|
1896
|
-
...knowledgeTools
|
|
1897
|
-
...murlTools
|
|
1784
|
+
...knowledgeTools
|
|
1785
|
+
// ...murlTools, // mURL: brand/consumer surface (murl.mosadd.com), not a dev product
|
|
1898
1786
|
// ...mcallTools, // mCALL: carrier-pending (no telephony carrier live) — re-register when a carrier is configured
|
|
1899
1787
|
// mirlTools,
|
|
1900
1788
|
// mmatrixTools, mdiscordTools, mtelegramTools, mslackTools, msignalTools,
|
|
@@ -2064,6 +1952,9 @@ function createMosaddServer(options = {}) {
|
|
|
2064
1952
|
}
|
|
2065
1953
|
}
|
|
2066
1954
|
};
|
|
1955
|
+
if (options.autoPublishKeys) {
|
|
1956
|
+
void publishOwnPrekeys(providers.keys, providers.dm).then((r) => ctx.log("debug", "auto-published mDM prekeys", { one_time_prekeys: r.oneTimePrekeyCount })).catch((err) => ctx.log("debug", "auto-publish mDM prekeys skipped", { error: String(err) }));
|
|
1957
|
+
}
|
|
2067
1958
|
const server = new McpServer(
|
|
2068
1959
|
{
|
|
2069
1960
|
name: "mosadd",
|
package/dist/index.d.ts
CHANGED
|
@@ -131,6 +131,15 @@ interface MosaddServerOptions {
|
|
|
131
131
|
* network adapter. A carrier-aware host supplies e.g. a radio DmProvider here.
|
|
132
132
|
*/
|
|
133
133
|
providers?: Partial<ProviderRegistry>;
|
|
134
|
+
/**
|
|
135
|
+
* When true, publish this identity's mDM prekey bundle once on startup
|
|
136
|
+
* (best-effort, non-fatal) so peers can open an E2EE session without the user
|
|
137
|
+
* manually running mDM_publish_keys first. Fixes the cold-start where mDM_send
|
|
138
|
+
* fails for every recipient because nobody has published keys. Used by the
|
|
139
|
+
* stdio binary; the hosted per-request transport leaves this off (it publishes
|
|
140
|
+
* per authenticated session instead).
|
|
141
|
+
*/
|
|
142
|
+
autoPublishKeys?: boolean;
|
|
134
143
|
}
|
|
135
144
|
interface MosaddToolContext {
|
|
136
145
|
options: Required<Pick<MosaddServerOptions, "mode" | "hubUrl">> & MosaddServerOptions;
|
|
@@ -186,7 +195,9 @@ declare function createMosaddServer(options?: MosaddServerOptions): McpServer;
|
|
|
186
195
|
/**
|
|
187
196
|
* Tool registry. Each m* module contributes a set of tools.
|
|
188
197
|
*
|
|
189
|
-
* Live modules (
|
|
198
|
+
* Live modules (6): mDM, mIRC, mROOM, mTALK, mAIL, mRAG — 61 tools + comms_capabilities.
|
|
199
|
+
* mURL is a consumer/brand surface (murl.mosadd.com), NOT a dev product — its tools
|
|
200
|
+
* live in tools/murl.ts but are NOT registered here (founder decision 2026-06-10).
|
|
190
201
|
* mCALL is carrier-pending (no telephony carrier live yet): its tools live in
|
|
191
202
|
* tools/mcall.ts but are NOT registered here, so an agent only ever discovers
|
|
192
203
|
* tools that actually work. Re-register the one line below when a carrier ships.
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mosadd/mcp",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
4
|
-
"description": "Model Context Protocol server for mosadd. Exposes the
|
|
3
|
+
"version": "3.0.0-alpha.13",
|
|
4
|
+
"description": "Model Context Protocol server for mosadd. Exposes the 6 live m* modules (mDM, mIRC, mROOM, mTALK, mAIL, mRAG) — 61 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": {
|
|
7
7
|
"type": "git",
|
|
@@ -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/protocol": "3.0.0-alpha.4",
|
|
40
39
|
"@mosadd/crypto": "3.0.0-alpha.4",
|
|
40
|
+
"@mosadd/protocol": "3.0.0-alpha.4",
|
|
41
41
|
"@mosadd/providers": "3.0.0-alpha.4"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
@@ -21,6 +21,7 @@ import type {
|
|
|
21
21
|
import { mdmTools } from "../tools/mdm.js";
|
|
22
22
|
import { InMemoryMdmKeyStore } from "../crypto/mdm-session.js";
|
|
23
23
|
import { InMemoryVoiceProvider } from "../providers/memory-voice.js";
|
|
24
|
+
import { createMosaddServer } from "../server.js";
|
|
24
25
|
import type { MosaddToolContext } from "../types.js";
|
|
25
26
|
|
|
26
27
|
/** Shared store: message log + key directory, both keyed in one place. */
|
|
@@ -176,3 +177,36 @@ describe("mDM E2EE golden path — X3DH handshake + ratchet, both directions", (
|
|
|
176
177
|
);
|
|
177
178
|
});
|
|
178
179
|
});
|
|
180
|
+
|
|
181
|
+
describe("auto-publish prekeys on startup (LINEAR-3104 cold-start fix)", () => {
|
|
182
|
+
it("publishes the local prekey bundle when autoPublishKeys is set", async () => {
|
|
183
|
+
const backend = new SharedBackend();
|
|
184
|
+
createMosaddServer({
|
|
185
|
+
mode: "local",
|
|
186
|
+
autoPublishKeys: true,
|
|
187
|
+
providers: {
|
|
188
|
+
dm: new ClientProvider(backend, "self-agent"),
|
|
189
|
+
keys: new InMemoryMdmKeyStore(),
|
|
190
|
+
voice: new InMemoryVoiceProvider("self-agent"),
|
|
191
|
+
},
|
|
192
|
+
});
|
|
193
|
+
// fire-and-forget; getOwnMaterial() does async key generation, so flush.
|
|
194
|
+
await new Promise((r) => setTimeout(r, 50));
|
|
195
|
+
expect(backend.bundles.has("self-agent")).toBe(true);
|
|
196
|
+
expect(backend.bundles.get("self-agent")!.byteLength).toBeGreaterThan(0);
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
it("does NOT publish when autoPublishKeys is unset (hosted/default)", async () => {
|
|
200
|
+
const backend = new SharedBackend();
|
|
201
|
+
createMosaddServer({
|
|
202
|
+
mode: "local",
|
|
203
|
+
providers: {
|
|
204
|
+
dm: new ClientProvider(backend, "quiet-agent"),
|
|
205
|
+
keys: new InMemoryMdmKeyStore(),
|
|
206
|
+
voice: new InMemoryVoiceProvider("quiet-agent"),
|
|
207
|
+
},
|
|
208
|
+
});
|
|
209
|
+
await new Promise((r) => setTimeout(r, 50));
|
|
210
|
+
expect(backend.bundles.has("quiet-agent")).toBe(false);
|
|
211
|
+
});
|
|
212
|
+
});
|
package/src/bin/mcp.ts
CHANGED
|
@@ -68,6 +68,9 @@ async function main(): Promise<void> {
|
|
|
68
68
|
hubUrl: process.env.MOSADD_HUB_URL,
|
|
69
69
|
mode: (process.env.MOSADD_MODE as "cloud" | "local" | "self-host" | undefined),
|
|
70
70
|
logLevel: (process.env.MOSADD_LOG_LEVEL as "debug" | "info" | "warn" | "error" | undefined),
|
|
71
|
+
// stdio is single-tenant: the session lives in env (set by bootstrapFromApiKey
|
|
72
|
+
// above), so auto-publish this identity's prekeys on boot → mDM is reachable.
|
|
73
|
+
autoPublishKeys: true,
|
|
71
74
|
});
|
|
72
75
|
|
|
73
76
|
const transport = new StdioServerTransport();
|
package/src/server.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
|
6
6
|
import { allTools } from "./tools/index.js";
|
|
7
7
|
import { SupabaseDmProvider } from "./providers/supabase-dm.js";
|
|
8
8
|
import { SupabaseVoiceProvider } from "./providers/supabase-voice.js";
|
|
9
|
-
import { InMemoryMdmKeyStore } from "./crypto/mdm-session.js";
|
|
9
|
+
import { InMemoryMdmKeyStore, publishOwnPrekeys } from "./crypto/mdm-session.js";
|
|
10
10
|
import type { MosaddServerOptions, MosaddToolContext, ProviderRegistry } from "./types.js";
|
|
11
11
|
|
|
12
12
|
/**
|
|
@@ -45,6 +45,18 @@ export function createMosaddServer(options: MosaddServerOptions = {}) {
|
|
|
45
45
|
},
|
|
46
46
|
};
|
|
47
47
|
|
|
48
|
+
// Cold-start fix: make this identity reachable for inbound E2EE DMs the moment
|
|
49
|
+
// the server is up, so mDM_send works without every recipient first running
|
|
50
|
+
// mDM_publish_keys. Best-effort and non-fatal — it needs an authenticated
|
|
51
|
+
// session, so it silently skips when there is none (BYOK without a JWT, offline,
|
|
52
|
+
// etc.) and never blocks startup. Uses the SAME keystore the tools use, so the
|
|
53
|
+
// published identity matches what mDM_send/encryptForPeer will use this process.
|
|
54
|
+
if (options.autoPublishKeys) {
|
|
55
|
+
void publishOwnPrekeys(providers.keys, providers.dm)
|
|
56
|
+
.then((r) => ctx.log("debug", "auto-published mDM prekeys", { one_time_prekeys: r.oneTimePrekeyCount }))
|
|
57
|
+
.catch((err) => ctx.log("debug", "auto-publish mDM prekeys skipped", { error: String(err) }));
|
|
58
|
+
}
|
|
59
|
+
|
|
48
60
|
const server = new McpServer(
|
|
49
61
|
{
|
|
50
62
|
name: "mosadd",
|
package/src/tools/index.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Tool registry. Each m* module contributes a set of tools.
|
|
3
3
|
*
|
|
4
|
-
* Live modules (
|
|
4
|
+
* Live modules (6): mDM, mIRC, mROOM, mTALK, mAIL, mRAG — 61 tools + comms_capabilities.
|
|
5
|
+
* mURL is a consumer/brand surface (murl.mosadd.com), NOT a dev product — its tools
|
|
6
|
+
* live in tools/murl.ts but are NOT registered here (founder decision 2026-06-10).
|
|
5
7
|
* mCALL is carrier-pending (no telephony carrier live yet): its tools live in
|
|
6
8
|
* tools/mcall.ts but are NOT registered here, so an agent only ever discovers
|
|
7
9
|
* tools that actually work. Re-register the one line below when a carrier ships.
|
|
@@ -20,7 +22,7 @@ import { mailTools } from "./mail.js";
|
|
|
20
22
|
import { mtalkTools } from "./mtalk.js";
|
|
21
23
|
// import { mcallTools } from "./mcall.js"; // mCALL: carrier-pending — not registered (see header note)
|
|
22
24
|
import { knowledgeTools } from "./knowledge.js";
|
|
23
|
-
import { murlTools } from "./murl.js";
|
|
25
|
+
// import { murlTools } from "./murl.js"; // mURL: brand/consumer surface, not a dev product — not registered
|
|
24
26
|
import { makeCapabilitiesTool } from "./capabilities.js";
|
|
25
27
|
|
|
26
28
|
/** The m* channel tools (everything except the meta discovery tool). */
|
|
@@ -36,7 +38,7 @@ const channelTools: MosaddTool[] = [
|
|
|
36
38
|
...mailTools,
|
|
37
39
|
...mtalkTools,
|
|
38
40
|
...knowledgeTools,
|
|
39
|
-
...murlTools,
|
|
41
|
+
// ...murlTools, // mURL: brand/consumer surface (murl.mosadd.com), not a dev product
|
|
40
42
|
// ...mcallTools, // mCALL: carrier-pending (no telephony carrier live) — re-register when a carrier is configured
|
|
41
43
|
// mirlTools,
|
|
42
44
|
// mmatrixTools, mdiscordTools, mtelegramTools, mslackTools, msignalTools,
|
|
@@ -28,8 +28,8 @@ const MemberIdentity = z
|
|
|
28
28
|
.describe("Target user's identity id (UUID). From mDM_list_contacts or radar logs.");
|
|
29
29
|
|
|
30
30
|
const Role = z
|
|
31
|
-
.enum(["
|
|
32
|
-
.describe("
|
|
31
|
+
.enum(["superadmin", "admin", "moderator", "member"])
|
|
32
|
+
.describe("Role to assign. owner = channel creator (not assignable); promote up to one tier below your own.");
|
|
33
33
|
|
|
34
34
|
const mIRC_join_input = z.object({
|
|
35
35
|
channel_id: ChannelId,
|
|
@@ -90,9 +90,17 @@ async function invokeChannelMembers(
|
|
|
90
90
|
body: Record<string, unknown>,
|
|
91
91
|
ctx: MosaddToolContext,
|
|
92
92
|
): Promise<unknown> {
|
|
93
|
+
// Map the toolkit's intuitive input field names to the exact ones the
|
|
94
|
+
// channel-members-manage Edge Function reads. Without this, kick/ban/unban/
|
|
95
|
+
// set-role/set-ptt all 400 ("target_identity_id required"), set-role is
|
|
96
|
+
// ignored, and set-ptt silently disables PTT (missing can_ptt → false).
|
|
97
|
+
const b: Record<string, unknown> = { ...body };
|
|
98
|
+
if ("identity_id" in b) { b.target_identity_id = b.identity_id; delete b.identity_id; }
|
|
99
|
+
if ("role" in b) { b.new_role = b.role; delete b.role; }
|
|
100
|
+
if ("ptt_enabled" in b) { b.can_ptt = b.ptt_enabled; delete b.ptt_enabled; }
|
|
93
101
|
readSupabaseEnv();
|
|
94
|
-
ctx.log("debug", `mIRC.${action}`,
|
|
95
|
-
return await invokeFunction("channel-members-manage", { action, ...
|
|
102
|
+
ctx.log("debug", `mIRC.${action}`, b);
|
|
103
|
+
return await invokeFunction("channel-members-manage", { action, ...b });
|
|
96
104
|
}
|
|
97
105
|
|
|
98
106
|
// ---- Registration ----
|
package/src/types.ts
CHANGED
|
@@ -43,6 +43,15 @@ export interface MosaddServerOptions {
|
|
|
43
43
|
* network adapter. A carrier-aware host supplies e.g. a radio DmProvider here.
|
|
44
44
|
*/
|
|
45
45
|
providers?: Partial<ProviderRegistry>;
|
|
46
|
+
/**
|
|
47
|
+
* When true, publish this identity's mDM prekey bundle once on startup
|
|
48
|
+
* (best-effort, non-fatal) so peers can open an E2EE session without the user
|
|
49
|
+
* manually running mDM_publish_keys first. Fixes the cold-start where mDM_send
|
|
50
|
+
* fails for every recipient because nobody has published keys. Used by the
|
|
51
|
+
* stdio binary; the hosted per-request transport leaves this off (it publishes
|
|
52
|
+
* per authenticated session instead).
|
|
53
|
+
*/
|
|
54
|
+
autoPublishKeys?: boolean;
|
|
46
55
|
}
|
|
47
56
|
|
|
48
57
|
export interface MosaddToolContext {
|