@mosadd/mcp 3.0.0-alpha.1 → 3.0.0-alpha.10

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.
Files changed (41) hide show
  1. package/README.md +127 -116
  2. package/dist/bin/login.js +4 -4
  3. package/dist/bin/mcp.js +29 -1
  4. package/dist/chunk-6EPYADVR.js +2095 -0
  5. package/dist/index.d.ts +46 -4
  6. package/dist/index.js +5 -3
  7. package/package.json +8 -5
  8. package/src/__tests__/golden-path.test.ts +137 -132
  9. package/src/__tests__/integration.test.ts +178 -175
  10. package/src/__tests__/mdm-e2ee.test.ts +178 -149
  11. package/src/__tests__/mtalk.test.ts +122 -0
  12. package/src/__tests__/server.test.ts +67 -67
  13. package/src/bin/login.ts +138 -127
  14. package/src/bin/mcp.ts +97 -55
  15. package/src/config.ts +66 -66
  16. package/src/crypto/mdm-session.ts +403 -378
  17. package/src/index.ts +19 -17
  18. package/src/observability/sentry.ts +79 -79
  19. package/src/providers/memory-voice.ts +79 -0
  20. package/src/providers/supabase-dm.ts +117 -117
  21. package/src/providers/supabase-voice.ts +91 -0
  22. package/src/providers/supabase.ts +120 -89
  23. package/src/server.ts +105 -103
  24. package/src/tools/capabilities.ts +68 -68
  25. package/src/tools/index.ts +53 -37
  26. package/src/tools/knowledge.ts +191 -0
  27. package/src/tools/mail.ts +371 -89
  28. package/src/tools/mcall.ts +216 -0
  29. package/src/tools/mdm-voice.ts +206 -0
  30. package/src/tools/mdm.ts +448 -379
  31. package/src/tools/mirc-edge.ts +190 -0
  32. package/src/tools/mirc-members.ts +177 -177
  33. package/src/tools/mirc-messages.ts +156 -0
  34. package/src/tools/mirc.ts +170 -170
  35. package/src/tools/mroom-messages.ts +142 -142
  36. package/src/tools/mroom.ts +221 -189
  37. package/src/tools/mtalk.ts +121 -0
  38. package/src/tools/murl.ts +141 -0
  39. package/src/types.ts +85 -79
  40. package/src/voice/floor.ts +132 -0
  41. package/dist/chunk-6IA4QVAJ.js +0 -1191
package/README.md CHANGED
@@ -1,116 +1,127 @@
1
- # @mosadd/mcp
2
-
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
-
5
- > **3.0.0-alpha** — `mDM` only, wired to the m0ssad-3 Supabase backend as a strangler-fig step. Phase 1 full will add mTALK / mAIL / mCALL / mIRC / mIRL / mROOM + bridges. Phase 2 routes through the hosted gateway at `mcp.mosadd.com` with the 167-event radar in front.
6
-
7
- ## Install
8
-
9
- ### Claude Code
10
-
11
- ```bash
12
- claude mcp add mosadd npx -- -y @mosadd/mcp
13
- ```
14
-
15
- ### Cursor
16
-
17
- `~/.cursor/mcp.json`:
18
-
19
- ```json
20
- {
21
- "mcpServers": {
22
- "mosadd": {
23
- "command": "npx",
24
- "args": ["-y", "@mosadd/mcp"],
25
- "env": {
26
- "M0SSAD_SUPABASE_URL": "https://<your-project>.supabase.co",
27
- "M0SSAD_SUPABASE_ANON_KEY": "<anon key>",
28
- "M0SSAD_USER_JWT": "<your session JWT>"
29
- }
30
- }
31
- }
32
- }
33
- ```
34
-
35
- ### Standalone
36
-
37
- ```bash
38
- M0SSAD_SUPABASE_URL=... M0SSAD_SUPABASE_ANON_KEY=... M0SSAD_USER_JWT=... npx @mosadd/mcp
39
- ```
40
-
41
- ## BYOK — get your env values
42
-
43
- While the hosted gateway is in development, the alpha runs in **local BYOK mode** — you supply your own Supabase credentials to talk to your own m0ssad-3 backend.
44
-
45
- - `M0SSAD_SUPABASE_URL` — your Supabase project URL (e.g. `https://abc.supabase.co`)
46
- - `M0SSAD_SUPABASE_ANON_KEY` — the public anon key from project settings
47
- - `M0SSAD_USER_JWT` — a Supabase session token for your mosadd user. Get it from the browser:
48
- 1. Sign in to mosadd.com
49
- 2. Open DevTools → Application → Local Storage → `sb-<ref>-auth-token`
50
- 3. Copy the `access_token` field
51
-
52
- In Phase 2, run `mosadd login` to OAuth into hub.mosadd.com — no JWT-juggling required.
53
-
54
- ## Tools shipped in alpha
55
-
56
- | Tool | Description |
57
- |---|---|
58
- | `mDM_list_contacts` | List your mosadd contacts (returns `identity_id` to use elsewhere) |
59
- | `mDM_send` | Send a DM. `{ to: identity_id, text, thread_label?, reply_to_id? }` |
60
- | `mDM_list` | Read DM thread |
61
- | `mDM_respond_request` | Accept/reject incoming DM request |
62
-
63
- 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.
64
-
65
- ## Try it (60-second demo)
66
-
67
- In Claude Code with env vars set:
68
-
69
- > List my mosadd contacts.
70
-
71
- Claude calls `mDM_list_contacts` → you see your contact list.
72
-
73
- > Send "hello from Claude" to <id> with thread label `notes`.
74
-
75
- Claude calls `mDM_send({ to, text, thread_label: "notes" })` → message appears in your mosadd app under a `notes` thread.
76
-
77
- ## Architecture
78
-
79
- ```
80
- Agent (Claude / Cursor / ...)
81
- │
82
- │ stdio MCP
83
- ▼
84
- @mosadd/mcp server (this package)
85
- │
86
- │ supabase.functions.invoke('message-send', ...)
87
- │ + Authorization: Bearer <M0SSAD_USER_JWT>
88
- ▼
89
- m0ssad-3 Edge Function
90
- │
91
- │ RLS-checked insert
92
- ▼
93
- Postgres `messages` table
94
- │
95
- │ Realtime broadcast
96
- ▼
97
- mosadd.com app (receiver)
98
- ```
99
-
100
- For PTT / CALL / ROOM (real-time media), the architecture separates **control plane** (MCP) from **data plane** (WebRTC daemon). See [docs/architecture/control-data-plane.md](https://github.com/Hei33enberg/mosadd-os/blob/main/docs/architecture/control-data-plane.md) when it lands.
101
-
102
- ## Configuration via env vars
103
-
104
- | Env | Description | Required |
105
- |---|---|---|
106
- | `M0SSAD_SUPABASE_URL` | Supabase project URL | yes |
107
- | `M0SSAD_SUPABASE_ANON_KEY` | Supabase anon key | yes |
108
- | `M0SSAD_USER_JWT` | User session token | yes (for tools that touch user data) |
109
- | `MOSADD_API_KEY` | Hub API key (Phase 2 hosted mode) | no |
110
- | `MOSADD_HUB_URL` | Override hub url | no |
111
- | `MOSADD_MODE` | `local` / `cloud` / `self-host` | no (auto-detected) |
112
- | `MOSADD_LOG_LEVEL` | `debug` / `info` / `warn` / `error` | no (default `info`) |
113
-
114
- ## License
115
-
116
- Apache-2.0. See repo [LICENSE](https://github.com/Hei33enberg/mosadd-os/blob/main/LICENSE) and [NOTICE](https://github.com/Hei33enberg/mosadd-os/blob/main/NOTICE).
1
+ # @mosadd/mcp
2
+
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
+
5
+ > **3.0.0-alpha.4** — **64 live tools across 7 live modules** (mDM incl. voice, mIRC, mROOM, mAIL, mTALK, mRAG, mURL) + 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 167-event radar in front.
6
+
7
+ ## Install
8
+
9
+ ### Claude Code
10
+
11
+ ```bash
12
+ claude mcp add mosadd -- npx -y @mosadd/mcp@alpha
13
+ ```
14
+
15
+ ### Cursor
16
+
17
+ `~/.cursor/mcp.json`:
18
+
19
+ ```json
20
+ {
21
+ "mcpServers": {
22
+ "mosadd": {
23
+ "command": "npx",
24
+ "args": ["-y", "@mosadd/mcp@alpha"],
25
+ "env": {
26
+ "MOSADD_SUPABASE_URL": "https://<your-project>.supabase.co",
27
+ "MOSADD_SUPABASE_ANON_KEY": "<anon key>",
28
+ "MOSADD_USER_JWT": "<your session JWT>"
29
+ }
30
+ }
31
+ }
32
+ }
33
+ ```
34
+
35
+ ### Standalone
36
+
37
+ ```bash
38
+ MOSADD_SUPABASE_URL=... MOSADD_SUPABASE_ANON_KEY=... MOSADD_USER_JWT=... npx @mosadd/mcp@alpha
39
+ ```
40
+
41
+ ## BYOK — get your env values
42
+
43
+ While the hosted gateway is in development, the alpha runs in **local BYOK mode** — you supply your own Supabase credentials to talk to your own mosadd backend.
44
+
45
+ - `MOSADD_SUPABASE_URL` — your Supabase project URL (e.g. `https://abc.supabase.co`)
46
+ - `MOSADD_SUPABASE_ANON_KEY` — the public anon key from project settings
47
+ - `MOSADD_USER_JWT` — a Supabase session token for your mosadd user. Get it from the browser:
48
+ 1. Sign in to mosadd.com
49
+ 2. Open DevTools → Application → Local Storage → `sb-<ref>-auth-token`
50
+ 3. Copy the `access_token` field
51
+
52
+ In Phase 2, run `mosadd login` to OAuth into hub.mosadd.com — no JWT-juggling required.
53
+
54
+ ## Tools shipped in alpha
55
+
56
+ **64 live tools across 7 live modules** (mDM, mIRC, mROOM, mAIL, mTALK, mRAG, mURL) + the `comms_capabilities` discovery tool. Highlights per module:
57
+
58
+ | Module | Tools | What it does |
59
+ |---|---|---|
60
+ | **mDM** (12) | `mDM_list_contacts`, `mDM_send`, `mDM_send_unencrypted`, `mDM_edit`, `mDM_delete`, `mDM_list`, `mDM_publish_keys`, `mDM_respond_request` + 4 voice ops | 1:1 text + voice. Multi-thread per contact, X3DH / Double-Ratchet E2EE on `mDM_send` |
61
+ | **mIRC** (20) | `mIRC_create/list/get/update/delete`, member RBAC ops, `mIRC_post_message`, `mIRC_list_messages` + admin | Persistent Discord/Slack-style channels |
62
+ | **mROOM** (9) | `mROOM_create`, **`mROOM_create_guest_link`**, `mROOM_join/leave/close/list`, `mROOM_send_message`, `mROOM_list_messages` | Ephemeral rooms + single-call no-account guest links |
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
+ | **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
+ | **mRAG** (4) | `mRAG_ingest`, `mRAG_search`, `mRAG_list_sources`, `mRAG_delete` | RAG recall over the user's own data (hybrid vector + BM25) |
66
+ | **mURL** (3) | `mURL_read_channel`, `mURL_post`, `mURL_presence` | 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
+
68
+ 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
+
70
+ ## Try it (60-second demo)
71
+
72
+ In Claude Code with env vars set:
73
+
74
+ > List my mosadd contacts.
75
+
76
+ Claude calls `mDM_list_contacts` → you see your contact list.
77
+
78
+ > Send "hello from Claude" to <id> with thread label `notes`.
79
+
80
+ Claude calls `mDM_send({ to, text, thread_label: "notes" })` → message appears in your mosadd app under a `notes` thread.
81
+
82
+ ## Architecture
83
+
84
+ ```
85
+ Agent (Claude / Cursor / ...)
86
+ │
87
+ │ stdio MCP
88
+ ▼
89
+ @mosadd/mcp server (this package)
90
+ │
91
+ │ supabase.functions.invoke('message-send', ...)
92
+ │ + Authorization: Bearer <MOSADD_USER_JWT>
93
+ ▼
94
+ mosadd backend Edge Function
95
+ │
96
+ │ RLS-checked insert
97
+ ▼
98
+ Postgres `messages` table
99
+ │
100
+ │ Realtime broadcast
101
+ ▼
102
+ mosadd.com app (receiver)
103
+ ```
104
+
105
+ For PTT / CALL / ROOM (real-time media), the architecture separates **control plane** (MCP) from **data plane** (WebRTC daemon). See [docs/architecture/control-data-plane.md](https://github.com/Hei33enberg/mosadd-os/blob/main/docs/architecture/control-data-plane.md) when it lands.
106
+
107
+ ## Configuration via env vars
108
+
109
+ | Env | Description | Required |
110
+ |---|---|---|
111
+ | `MOSADD_SUPABASE_URL` | Supabase project URL — DM / IRC / ROOM / KB backend | yes (BYOK) |
112
+ | `MOSADD_SUPABASE_ANON_KEY` | Supabase anon key | yes (BYOK) |
113
+ | `MOSADD_USER_JWT` | User session token | yes (for tools that touch user data) |
114
+ | `MOSADD_RESEND_API_KEY` | Resend API key — enables `mAIL` outbound | no (mAIL disabled if unset) |
115
+ | `MOSADD_LIVEKIT_URL` | LiveKit `wss://…` URL — enables `mTALK` / `mROOM` voice | no (voice disabled if unset) |
116
+ | `MOSADD_LIVEKIT_API_KEY` | LiveKit API key | no (with `…_URL` / `…_API_SECRET`) |
117
+ | `MOSADD_LIVEKIT_API_SECRET` | LiveKit API secret | no |
118
+ | `MOSADD_API_KEY` | Hub API key (Phase 2 hosted mode) | no |
119
+ | `MOSADD_HUB_URL` | Override hub url | no |
120
+ | `MOSADD_MODE` | `local` / `cloud` / `self-host` | no (auto-detected) |
121
+ | `MOSADD_LOG_LEVEL` | `debug` / `info` / `warn` / `error` | no (default `info`) |
122
+
123
+ Missing optional keys fail closed — that channel is simply absent from `comms_capabilities`.
124
+
125
+ ## License
126
+
127
+ Apache-2.0. See repo [LICENSE](https://github.com/Hei33enberg/mosadd-os/blob/main/LICENSE) and [NOTICE](https://github.com/Hei33enberg/mosadd-os/blob/main/NOTICE).
package/dist/bin/login.js CHANGED
@@ -45,10 +45,10 @@ function prompt(question, hidden = false) {
45
45
  async function login(args) {
46
46
  const flags = parseFlags(args);
47
47
  const prev = loadSession();
48
- const url = flags.url || process.env.M0SSAD_SUPABASE_URL || prev?.url || await prompt("Supabase URL: ");
49
- const anonKey = flags.anon || process.env.M0SSAD_SUPABASE_ANON_KEY || prev?.anonKey || await prompt("Supabase anon key: ");
50
- const email = flags.email || process.env.MOSADD_EMAIL || await prompt("Email: ");
51
- const password = flags.password || process.env.MOSADD_PASSWORD || await prompt("Password: ", true);
48
+ const url = flags.url || process.env.MOSADD_SUPABASE_URL || process.env.M0SSAD_SUPABASE_URL || prev?.url || await prompt("Supabase URL: ");
49
+ const anonKey = flags.anon || process.env.MOSADD_SUPABASE_ANON_KEY || process.env.M0SSAD_SUPABASE_ANON_KEY || prev?.anonKey || await prompt("Supabase anon key: ");
50
+ const email = flags.email || process.env.MOSADD_EMAIL || process.env.M0SSAD_EMAIL || await prompt("Email: ");
51
+ const password = flags.password || process.env.MOSADD_PASSWORD || process.env.M0SSAD_PASSWORD || await prompt("Password: ", true);
52
52
  if (!url || !anonKey || !email || !password) {
53
53
  console.error("\nmosadd login: need Supabase URL, anon key, email and password.");
54
54
  process.exit(1);
package/dist/bin/mcp.js CHANGED
@@ -1,11 +1,38 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  createMosaddServer
4
- } from "../chunk-6IA4QVAJ.js";
4
+ } from "../chunk-6EPYADVR.js";
5
5
  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,