@mosadd/mcp 3.0.0-alpha.11 → 3.0.0-alpha.12
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 +5 -2
- package/dist/{chunk-NQ624SIP.js → chunk-GVHAKT62.js} +3 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +1 -1
- package/package.json +2 -2
- package/src/__tests__/mdm-e2ee.test.ts +34 -0
- package/src/bin/mcp.ts +3 -0
- package/src/server.ts +13 -1
- package/src/types.ts +9 -0
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-GVHAKT62.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);
|
|
@@ -2064,6 +2064,9 @@ function createMosaddServer(options = {}) {
|
|
|
2064
2064
|
}
|
|
2065
2065
|
}
|
|
2066
2066
|
};
|
|
2067
|
+
if (options.autoPublishKeys) {
|
|
2068
|
+
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) }));
|
|
2069
|
+
}
|
|
2067
2070
|
const server = new McpServer(
|
|
2068
2071
|
{
|
|
2069
2072
|
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;
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mosadd/mcp",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.12",
|
|
4
4
|
"description": "Model Context Protocol server for mosadd. Exposes the 7 live m* modules (mDM, mIRC, mROOM, mTALK, mAIL, mRAG, mURL) — 65 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/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/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 {
|