@mosadd/mcp 3.0.0-alpha.7 → 3.0.0
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 +410 -0
- package/README.md +79 -40
- package/dist/bin/mcp.js +132 -8
- package/dist/chunk-VMMJJYXF.js +4233 -0
- package/dist/index.d.ts +110 -6
- package/dist/index.js +3 -1
- package/package.json +19 -16
- package/src/__tests__/blob-upload.test.ts +93 -0
- package/src/__tests__/channel-e2ee.test.ts +62 -0
- package/src/__tests__/cli.test.ts +47 -0
- package/src/__tests__/flota-jawnie.test.ts +244 -0
- package/src/__tests__/golden-path.test.ts +4 -2
- package/src/__tests__/integration.test.ts +50 -11
- package/src/__tests__/knowledge-ingest.test.ts +114 -0
- package/src/__tests__/label-room-owner.test.ts +22 -0
- package/src/__tests__/mdm-e2ee.test.ts +35 -1
- package/src/__tests__/mdm-mcp-readable.test.ts +390 -0
- package/src/__tests__/mirc-invite.test.ts +112 -0
- package/src/__tests__/mrag-search-answer.test.ts +42 -0
- package/src/__tests__/no-dead-host.test.ts +37 -0
- package/src/__tests__/presence.test.ts +199 -0
- package/src/__tests__/server.test.ts +11 -7
- package/src/__tests__/serverJsonVersion.test.ts +45 -0
- package/src/__tests__/tool-count-consistency.test.ts +259 -0
- package/src/__tests__/voice-fields.test.ts +24 -0
- package/src/bin/mcp.ts +71 -6
- package/src/cli.ts +100 -0
- package/src/crypto/channel-e2ee.ts +288 -0
- package/src/crypto/mdm-session.ts +476 -37
- package/src/index.ts +2 -2
- package/src/providers/blob-upload.ts +162 -0
- package/src/providers/supabase-dm.ts +102 -7
- package/src/providers/supabase-voice.ts +13 -1
- package/src/providers/supabase.ts +121 -10
- package/src/server.ts +102 -12
- package/src/tools/__tests__/ragDeleteFoldsSourceId.test.ts +67 -0
- package/src/tools/actions.ts +166 -0
- package/src/tools/attachments.ts +276 -0
- package/src/tools/capabilities.ts +2 -0
- package/src/tools/channel-payload.ts +69 -0
- package/src/tools/embed.ts +110 -0
- package/src/tools/index.ts +136 -6
- package/src/tools/knowledge-graph.ts +186 -0
- package/src/tools/knowledge.ts +351 -191
- package/src/tools/mail-agentbox.ts +155 -0
- package/src/tools/mail-aliases.ts +25 -0
- package/src/tools/mail-provenance.ts +137 -0
- package/src/tools/mail.ts +214 -60
- package/src/tools/mdm-as-agent.ts +138 -0
- package/src/tools/mdm-voice.ts +17 -3
- package/src/tools/mdm.ts +303 -57
- package/src/tools/mirc-edge.ts +8 -2
- package/src/tools/mirc-members.ts +130 -20
- package/src/tools/mirc-messages.ts +80 -35
- package/src/tools/mirc.ts +149 -11
- package/src/tools/mroom-messages.ts +4 -12
- package/src/tools/mtalk.ts +11 -1
- package/src/tools/murl.ts +314 -0
- package/src/tools/presence.ts +442 -0
- package/src/tools/ptt-ingest.ts +99 -0
- package/src/tools/threat.ts +123 -0
- package/src/tools/voice-format.ts +43 -0
- package/src/types.ts +36 -0
- package/src/version.ts +8 -0
- package/LICENSE +0 -201
- package/dist/chunk-EFTB743G.js +0 -1924
package/dist/bin/mcp.js
CHANGED
|
@@ -1,12 +1,90 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
|
+
PKG_VERSION,
|
|
4
|
+
allTools,
|
|
3
5
|
createMosaddServer
|
|
4
|
-
} from "../chunk-
|
|
5
|
-
import
|
|
6
|
+
} from "../chunk-VMMJJYXF.js";
|
|
7
|
+
import {
|
|
8
|
+
isSessionExpired,
|
|
9
|
+
loadSession,
|
|
10
|
+
saveSession
|
|
11
|
+
} from "../chunk-Z7WR52GE.js";
|
|
6
12
|
|
|
7
13
|
// src/bin/mcp.ts
|
|
8
14
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
9
|
-
|
|
15
|
+
import { createClient } from "@supabase/supabase-js";
|
|
16
|
+
|
|
17
|
+
// src/cli.ts
|
|
18
|
+
function parseCli(args) {
|
|
19
|
+
const first = args[0];
|
|
20
|
+
if (args.includes("--version") || args.includes("-v") || first === "version") return { kind: "version" };
|
|
21
|
+
if (args.includes("--help") || args.includes("-h") || first === "help") return { kind: "help" };
|
|
22
|
+
if (first === "tools") return { kind: "tools" };
|
|
23
|
+
if (first === "login" || first === "logout" || first === "whoami") return { kind: "auth", sub: first, rest: args.slice(1) };
|
|
24
|
+
return { kind: "serve" };
|
|
25
|
+
}
|
|
26
|
+
function renderVersion(version) {
|
|
27
|
+
return `${version}
|
|
28
|
+
`;
|
|
29
|
+
}
|
|
30
|
+
function renderHelp(version) {
|
|
31
|
+
return [
|
|
32
|
+
`mosadd-mcp ${version} \u2014 mosADD MCP server (stdio)`,
|
|
33
|
+
``,
|
|
34
|
+
`Usage:`,
|
|
35
|
+
` npx @mosadd/mcp [command] [options]`,
|
|
36
|
+
``,
|
|
37
|
+
`Commands:`,
|
|
38
|
+
` (none) start the MCP server over stdio (what your agent runtime runs)`,
|
|
39
|
+
` login sign in and save a session on this machine`,
|
|
40
|
+
` logout delete the saved session`,
|
|
41
|
+
` whoami show which identity the saved session / MOSADD_API_KEY resolves to`,
|
|
42
|
+
` tools list every tool this server registers, grouped by module, and exit`,
|
|
43
|
+
``,
|
|
44
|
+
`Options:`,
|
|
45
|
+
` -v, --version print the version and exit`,
|
|
46
|
+
` -h, --help print this help and exit`,
|
|
47
|
+
``,
|
|
48
|
+
`Environment:`,
|
|
49
|
+
` MOSADD_API_KEY hub API key \u2014 exchanged for a short-lived session at boot (hosted mode)`,
|
|
50
|
+
` MOSADD_HUB_URL override the hub url`,
|
|
51
|
+
` MOSADD_MODE local | cloud`,
|
|
52
|
+
` MOSADD_LOG_LEVEL debug | info | warn | error (default info)`,
|
|
53
|
+
` See the README for the full list (Supabase BYOK, Resend, LiveKit).`,
|
|
54
|
+
``
|
|
55
|
+
].join("\n");
|
|
56
|
+
}
|
|
57
|
+
function moduleOf(toolName) {
|
|
58
|
+
const i = toolName.indexOf("_");
|
|
59
|
+
return i > 0 ? toolName.slice(0, i) : toolName;
|
|
60
|
+
}
|
|
61
|
+
function groupTools(tools) {
|
|
62
|
+
const by = /* @__PURE__ */ new Map();
|
|
63
|
+
for (const t of tools) {
|
|
64
|
+
const m = moduleOf(t.name);
|
|
65
|
+
by.set(m, [...by.get(m) ?? [], t]);
|
|
66
|
+
}
|
|
67
|
+
return [...by.entries()].map(([module, list]) => ({ module, tools: [...list].sort((a, b) => a.name.localeCompare(b.name)) })).sort((a, b) => b.tools.length - a.tools.length || a.module.localeCompare(b.module));
|
|
68
|
+
}
|
|
69
|
+
var oneLine = (s, max = 90) => {
|
|
70
|
+
const t = String(s ?? "").replace(/\s+/g, " ").trim();
|
|
71
|
+
const dot = t.search(/[.!?](\s|$)/);
|
|
72
|
+
const first = dot > 0 ? t.slice(0, dot + 1) : t;
|
|
73
|
+
return first.length > max ? `${first.slice(0, max - 1)}\u2026` : first;
|
|
74
|
+
};
|
|
75
|
+
function renderTools(tools) {
|
|
76
|
+
const groups = groupTools(tools);
|
|
77
|
+
const lines = [`${tools.length} tools in ${groups.length} groups`, ``];
|
|
78
|
+
for (const g of groups) {
|
|
79
|
+
lines.push(`${g.module} (${g.tools.length})`);
|
|
80
|
+
for (const t of g.tools) lines.push(` ${t.name}${t.description ? ` \u2014 ${oneLine(t.description)}` : ""}`);
|
|
81
|
+
lines.push(``);
|
|
82
|
+
}
|
|
83
|
+
return lines.join("\n");
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// src/bin/mcp.ts
|
|
87
|
+
var DEFAULT_EXCHANGE = "https://api.mosadd.com/functions/v1/hub-key-exchange";
|
|
10
88
|
async function bootstrapFromApiKey() {
|
|
11
89
|
const apiKey = process.env.MOSADD_API_KEY;
|
|
12
90
|
if (!apiKey || process.env.MOSADD_USER_JWT) return;
|
|
@@ -33,19 +111,65 @@ async function bootstrapFromApiKey() {
|
|
|
33
111
|
);
|
|
34
112
|
}
|
|
35
113
|
}
|
|
114
|
+
async function bootstrapFromSavedSession() {
|
|
115
|
+
if (process.env.MOSADD_USER_JWT) return;
|
|
116
|
+
const session = loadSession();
|
|
117
|
+
if (!session?.refreshToken) return;
|
|
118
|
+
if (!isSessionExpired(session)) return;
|
|
119
|
+
try {
|
|
120
|
+
const client = createClient(session.url, session.anonKey, {
|
|
121
|
+
auth: { persistSession: false, autoRefreshToken: false, detectSessionInUrl: false }
|
|
122
|
+
});
|
|
123
|
+
const { data, error } = await client.auth.refreshSession({ refresh_token: session.refreshToken });
|
|
124
|
+
if (error || !data.session) {
|
|
125
|
+
process.stderr.write(
|
|
126
|
+
JSON.stringify({ level: "warn", msg: "mosadd session refresh failed \u2014 run `mosadd login`", error: error?.message }) + "\n"
|
|
127
|
+
);
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
saveSession({
|
|
131
|
+
url: session.url,
|
|
132
|
+
anonKey: session.anonKey,
|
|
133
|
+
accessToken: data.session.access_token,
|
|
134
|
+
refreshToken: data.session.refresh_token ?? session.refreshToken,
|
|
135
|
+
expiresAt: data.session.expires_at,
|
|
136
|
+
email: data.user?.email ?? session.email
|
|
137
|
+
});
|
|
138
|
+
} catch (err) {
|
|
139
|
+
process.stderr.write(
|
|
140
|
+
JSON.stringify({ level: "warn", msg: "mosadd session refresh error \u2014 run `mosadd login`", error: String(err) }) + "\n"
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
36
144
|
async function main() {
|
|
37
|
-
const
|
|
38
|
-
if (
|
|
145
|
+
const action = parseCli(process.argv.slice(2));
|
|
146
|
+
if (action.kind === "version") {
|
|
147
|
+
process.stdout.write(renderVersion(PKG_VERSION));
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
if (action.kind === "help") {
|
|
151
|
+
process.stdout.write(renderHelp(PKG_VERSION));
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
if (action.kind === "tools") {
|
|
155
|
+
process.stdout.write(renderTools(allTools));
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
if (action.kind === "auth") {
|
|
39
159
|
const { runAuthCommand } = await import("./login.js");
|
|
40
|
-
await runAuthCommand(sub,
|
|
160
|
+
await runAuthCommand(action.sub, action.rest);
|
|
41
161
|
return;
|
|
42
162
|
}
|
|
43
163
|
await bootstrapFromApiKey();
|
|
164
|
+
await bootstrapFromSavedSession();
|
|
44
165
|
const server = createMosaddServer({
|
|
45
166
|
apiKey: process.env.MOSADD_API_KEY,
|
|
46
167
|
hubUrl: process.env.MOSADD_HUB_URL,
|
|
47
168
|
mode: process.env.MOSADD_MODE,
|
|
48
|
-
logLevel: process.env.MOSADD_LOG_LEVEL
|
|
169
|
+
logLevel: process.env.MOSADD_LOG_LEVEL,
|
|
170
|
+
// stdio is single-tenant: the session lives in env (set by bootstrapFromApiKey
|
|
171
|
+
// above), so auto-publish this identity's prekeys on boot → mDM is reachable.
|
|
172
|
+
autoPublishKeys: true
|
|
49
173
|
});
|
|
50
174
|
const transport = new StdioServerTransport();
|
|
51
175
|
await server.connect(transport);
|
|
@@ -53,7 +177,7 @@ async function main() {
|
|
|
53
177
|
JSON.stringify({
|
|
54
178
|
level: "info",
|
|
55
179
|
msg: "mosadd MCP server ready",
|
|
56
|
-
version:
|
|
180
|
+
version: PKG_VERSION,
|
|
57
181
|
ts: (/* @__PURE__ */ new Date()).toISOString()
|
|
58
182
|
}) + "\n"
|
|
59
183
|
);
|