@mosadd/mcp 3.0.0-alpha.3 → 3.0.0-alpha.31

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 (49) hide show
  1. package/CHANGELOG.md +224 -0
  2. package/README.md +150 -116
  3. package/dist/bin/mcp.js +42 -3
  4. package/dist/chunk-P4ENU5MW.js +2556 -0
  5. package/dist/index.d.ts +99 -7
  6. package/dist/index.js +7 -3
  7. package/package.json +10 -7
  8. package/src/__tests__/golden-path.test.ts +137 -132
  9. package/src/__tests__/integration.test.ts +179 -175
  10. package/src/__tests__/mdm-e2ee.test.ts +212 -149
  11. package/src/__tests__/mtalk.test.ts +122 -0
  12. package/src/__tests__/server.test.ts +71 -67
  13. package/src/bin/login.ts +138 -138
  14. package/src/bin/mcp.ts +145 -97
  15. package/src/config.ts +66 -66
  16. package/src/crypto/mdm-session.ts +502 -378
  17. package/src/index.ts +19 -17
  18. package/src/observability/sentry.ts +79 -79
  19. package/src/providers/blob-upload.ts +116 -0
  20. package/src/providers/memory-voice.ts +79 -0
  21. package/src/providers/supabase-dm.ts +122 -117
  22. package/src/providers/supabase-voice.ts +91 -0
  23. package/src/providers/supabase.ts +148 -96
  24. package/src/server.ts +123 -103
  25. package/src/tools/actions.ts +162 -0
  26. package/src/tools/attachments.ts +268 -0
  27. package/src/tools/capabilities.ts +68 -68
  28. package/src/tools/embed.ts +108 -0
  29. package/src/tools/index.ts +104 -37
  30. package/src/tools/knowledge.ts +191 -0
  31. package/src/tools/mail-aliases.ts +25 -0
  32. package/src/tools/mail-provenance.ts +135 -0
  33. package/src/tools/mail.ts +381 -89
  34. package/src/tools/mcall.ts +216 -0
  35. package/src/tools/mdm-voice.ts +212 -0
  36. package/src/tools/mdm.ts +479 -379
  37. package/src/tools/mirc-edge.ts +190 -0
  38. package/src/tools/mirc-members.ts +198 -177
  39. package/src/tools/mirc-messages.ts +155 -0
  40. package/src/tools/mirc.ts +190 -170
  41. package/src/tools/mroom-messages.ts +142 -142
  42. package/src/tools/mroom.ts +221 -189
  43. package/src/tools/mtalk.ts +121 -0
  44. package/src/tools/murl.ts +298 -0
  45. package/src/tools/ptt-ingest.ts +97 -0
  46. package/src/tools/threat.ts +119 -0
  47. package/src/types.ts +94 -79
  48. package/src/voice/floor.ts +132 -0
  49. package/dist/chunk-HD5RLE5K.js +0 -1193
package/CHANGELOG.md ADDED
@@ -0,0 +1,224 @@
1
+ # Changelog
2
+
3
+ All notable changes to `@mosadd/mcp` are documented here.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project follows the `3.0.0-alpha.N` pre-release line until the hosted
7
+ gateway (Phase 2) ships.
8
+
9
+ ## [Unreleased]
10
+
11
+ ## [3.0.0-alpha.31] — 2026-07-17
12
+
13
+ ### Fixed
14
+ - **`mURL_create` / `mURL_update` branding validation.** The `branding` arg used
15
+ `z.record(z.any())` — the Zod v3 single-argument form — which fails typecheck under
16
+ this project's Zod v4, where `z.record` requires both a key and a value schema. Now
17
+ `z.record(z.string(), z.any())`. alpha.30 shipped with the pre-fix source; alpha.31
18
+ corrects it so the published package builds clean and validates branding correctly.
19
+ - **CI green (repo).** Synced the version refs (`server.json`, `server.ts` serverInfo,
20
+ `marketplace.json`) to `package.json`, and updated the MCP smoke test to expect
21
+ `mAYL_send` — the `mp0st_*` aliases were retired in alpha.28.
22
+
23
+ ## [3.0.0-alpha.30] — 2026-07-17
24
+
25
+ ### Added
26
+ - **`comms_embed_create` RE-REGISTERED — tool count 68 → 69.** The paste-in
27
+ live-channel widget is finally end-to-end real: `https://embed.mosadd.com/v1.js`
28
+ is deployed (served by the mosadd Vercel project; skins are inlined in the
29
+ bundle), and the whole backend (`embed-keys` publishable keys, `mirc-embed-token`
30
+ Origin-allowlisted 5-min JWTs with MAT plan tiers, `embed-plan-settings` PAYG,
31
+ GDPR `embed-dsr-delete`) was already live. The tool mints an `m_pk_live_…` key
32
+ and returns a `<script>` snippet with skin + position (incl. sidebar-left/right)
33
+ options. Part of the mURL→mIRC rework P3 ("open WWW channel: dedicated page +
34
+ branding + embed").
35
+
36
+ ## [3.0.0-alpha.29] — 2026-07-17
37
+
38
+ ### Added
39
+ - **mURL owner-side management — 3 new tools.** `mURL_create` (claim a domain channel and
40
+ become its owner; idempotent, 409 if another account owns it), `mURL_update` (set branding /
41
+ mark `claimed` / `blocked` to close / reopen as `open`), `mURL_delete` (remove a channel you
42
+ own). Wired to the deployed, owner-scoped `murl-manage` EF via the same user-JWT auth as
43
+ `mURL_list_channels action='mine'`. mURL goes from read-only (read/post/presence/list) to a
44
+ full lifecycle — an agent can now provision and manage a domain's room, not just chat in it.
45
+ - **`TOOL_COUNT` export** (`= allTools.length`) — one source of truth for the callable-tool
46
+ count, mirroring `@mosadd/threat-engine`'s `THREAT_EVENT_COUNT`. Docs reference it, not a
47
+ hand-typed number that drifts.
48
+
49
+ ### Changed
50
+ - **Tool count corrected to 68** — it had been advertised inconsistently as "70+" / "65" across
51
+ READMEs, docs, registry submissions and the dev site. The registry holds exactly 68 callable
52
+ tools: mDM 14 · mIRC 22 · mURL 7 · mAYL 11 · mTALK 5 · mRAG 4 · comms_ 3 · Irondome (`threat_*`) 2.
53
+ Also fixed two stale claims in the reference table: `threat_*` IS registered (was labelled
54
+ "unregistered"), and the `mp0st_*` mAYL aliases are retired (were claimed as still functioning).
55
+
56
+ ## [3.0.0-alpha.23] — 2026-06-26
57
+
58
+ Toolkit hardening pass: every registered tool's request/response contract was
59
+ adversarially verified against the deployed edge functions. Two tools were broken on
60
+ every call; the rest had silent field drops, wrong results, or a confidentiality/access gap.
61
+
62
+ ### Fixed
63
+ - **Edge-function errors are now legible.** `invokeFunction` only ever surfaced the fixed
64
+ string "Edge Function returned a non-2xx status code"; the real reason lives in
65
+ `error.context`. It now reads that body (and the HTTP status), so every EF-backed tool
66
+ returns an actionable error the agent can act on — the single highest-impact fix.
67
+ - **mDM_edit no longer strips E2EE.** It used to store a server-readable plaintext body even
68
+ on an E2EE thread (and the forward-only ratchet means an edit can't be re-sealed). It now
69
+ refuses to edit E2EE messages (use delete + re-send) and only edits legacy plaintext.
70
+ - **mp0st_send cc/bcc/reply_to are actually delivered** — the backend dropped them silently;
71
+ now forwarded to the mail provider (edge-function fix, deployed).
72
+ - **mDM call rooms are access-gated (security)** — call-room tokens were mintable by any
73
+ authenticated user who learned the room name; the backend now restricts them to the two
74
+ participants, and the room name is per-pair so the gate is robust (edge-function fix, deployed).
75
+ - **mDM_call_end / mDM_voice_note** now return the real message id (was always undefined).
76
+ - **mp0st_view** no longer advertises a `received_at` field the backend doesn't return (it's `sent_at`).
77
+
78
+ ### Changed
79
+ - **Unregistered `comms_embed_create`** — its `embed-keys` edge function isn't deployed (404
80
+ on every call) and the embed surface is parked. Tool count **62 → 61**. Re-register when the
81
+ backend + widget ship.
82
+ - **mIRC tools stop advertising fields the backend ignores.** Removed: `mIRC_kick` `reason`,
83
+ `mIRC_request_access` `message`, `mIRC_ban` `reason`+`until` (the latter silently made a
84
+ "temporary" ban permanent), and `access_mode` on `mIRC_update`/`mIRC_list` (no-ops). Added
85
+ `wrapped_group_key` to `mIRC_create`/`mIRC_approve_request` so E2EE (password/private)
86
+ channels are honestly callable. Descriptions corrected to match.
87
+ - **mp0st_consent** now fails fast client-side when `check`/`optin` is missing a recipient.
88
+
89
+ ### Verified (no changes needed)
90
+ - Install/boot, full build + typecheck across all packages, dependency-export resolution, and
91
+ the mDM X3DH + Double-Ratchet crypto round-trip all pass.
92
+
93
+ ## [3.0.0-alpha.22] — 2026-06-26
94
+
95
+ ### Fixed
96
+ - **alpha.21 was broken on a fresh install** — it crashed on startup with
97
+ `SyntaxError: The requested module '@mosadd/crypto' does not provide an export named
98
+ 'initRatchetInitiator'`. The workspace dependency packages (`@mosadd/crypto`, `protocol`,
99
+ `providers`, `threat-engine`) had drifted: their *source* gained new exports (the mDM
100
+ Double-Ratchet work) but their version was never bumped, so npm still served the stale
101
+ alpha.4/alpha.5 builds while `@mosadd/mcp` was built against the newer API. Bumped the whole
102
+ alpha-line in lockstep to alpha.22 and republished so every published package matches current
103
+ source and `workspace:*` cross-deps resolve. Verified: a clean `npm i @mosadd/mcp@alpha`
104
+ now boots and lists 62 tools. (The previous alpha.20 was broken-on-install the same way.)
105
+
106
+ ### Changed
107
+ - **Unregistered 2 scaffold tools that failed on every call.** `mp0st_send_as_agent`
108
+ (POSTed to a non-existent `hub-claim-mint` endpoint → 404, and sent provenance body
109
+ fields the deployed `mp0st-send` EF never reads) and `mTALK_ingest_ptt` (request body
110
+ didn't match the deployed `ptt-ingest` EF → 400). Both are now commented out in
111
+ `tools/index.ts` like the other not-registered modules, so an agent only ever discovers
112
+ tools that actually work. Registered tool count **64 → 62** (mp0st 12→11, mTALK 6→5).
113
+ Source is kept; both re-register once their backend contracts are wired + tested.
114
+
115
+ ### Fixed
116
+ - **mIRC `reject_request` / `approve_request` field (LINEAR-3522):** the tools sent
117
+ `request_id` but `channel-members-manage` reads `target_identity_id` → 400 every
118
+ call. Renamed to `identity_id` (normalized to `target_identity_id`). `reject` now
119
+ works; `approve` of an E2EE channel still needs a wrapped group key (LINEAR-3523).
120
+ - **mDM / mIRC message pagination (LINEAR-3524):** `mDM_list` read `cursor`/`has_more`
121
+ but `message-list` history mode returns `next_before`, and `mIRC_list_messages`
122
+ sent `cursor` (ignored; EF reads `before`) and read `next_cursor` (never returned)
123
+ → neither paged past page 1. Send `before`, read `next_before`.
124
+
125
+ ## [3.0.0-alpha.19] — 2026-06-19
126
+
127
+ ### Removed
128
+ - **BREAKING — mROOM module killed (LINEAR-3414):** the 11 `mROOM_*` tools
129
+ (`mROOM_create`, `mROOM_create_guest_link`, `mROOM_join`, `mROOM_leave`,
130
+ `mROOM_close`, `mROOM_list`, `mROOM_voice_join`, `mROOM_send_message`,
131
+ `mROOM_list_messages`, `mROOM_send_voice`, `mROOM_send_file`) are no longer
132
+ registered. Ephemeral private rooms are re-cut into private mIRC channels.
133
+ The source stays in `tools/mroom*.ts` (unregistered, like mURL/mCALL).
134
+
135
+ ### Added
136
+ - **Defensive threat engine as MCP tools (LINEAR-3498):** `threat_catalog`
137
+ (list the canonical 160+ threat-event taxonomy) and `threat_classify`
138
+ (pure `evaluateEvent` decision → action/severity/reason). Wraps
139
+ `@mosadd/threat-engine`; deterministic, offline, `requires: "any"`.
140
+
141
+ Net: 70 → **64 callable tools** across 5 live modules + comms + threat.
142
+
143
+ ### Changed
144
+ - **BREAKING — mail tool rename:** the 12 email MCP tools are renamed
145
+ `mAIL_*` → `mp0st_*` (`mp0st_list`, `mp0st_send`, `mp0st_view`, `mp0st_delete`,
146
+ `mp0st_stats`, `mp0st_events`, `mp0st_metrics`, `mp0st_revoke`,
147
+ `mp0st_audit_export`, `mp0st_consent`, `mp0st_notify`, `mp0st_send_as_agent`).
148
+ No aliases — the old `mAIL_*` names no longer resolve. Backend Edge Functions
149
+ (`mp0st-*`) are unchanged.
150
+
151
+ ## [3.0.0-alpha.18] — 2026-06-18
152
+
153
+ ### Added
154
+ - **`comms_embed_create`** — embed a LIVE mosadd channel into an app/site a builder-agent is
155
+ generating (Lovable / Bolt / Cursor / v0). Mints a publishable embed key (`m_pk_live_…`,
156
+ origin-scoped, via the `embed-keys` EF) and returns a paste-in widget snippet
157
+ (`<div>` + `<script src="https://embed.mosadd.com/v1.js" data-key=…>`). The widget exchanges
158
+ the publishable key for a short-lived channel-scoped JWT at runtime; the hub key never enters
159
+ the browser. Extends `mROOM_create_guest_link` (link → embeddable widget). CDN override via
160
+ `MOSADD_EMBED_CDN`. (Widget served from the dedicated `embed.mosadd.com` deploy.)
161
+
162
+ ## [3.0.0-alpha.17] — 2026-06-18
163
+
164
+ ### Added
165
+ - **Action Links — screen share.** `comms_action_create` gains a `screen_share` action
166
+ type, and a new `comms_action_frame_get` tool lets the creating agent read frames of the
167
+ recipient's shared screen (consent-gated, browser-sandbox only). Turns Action Links into
168
+ "remote-desktop-lite" — the agent sees what the human chooses to share.
169
+
170
+ ### Changed
171
+ - **Durable `mosadd login`.** The saved session (`~/.mosadd/session.json`) is now refreshed
172
+ from its refresh token at server boot, so a single `mosadd login` keeps working across
173
+ restarts — no more re-login when the access token expires.
174
+ - Onboarding README restructured (recommended auth path — `mosadd login` — first; hub API
175
+ key second; DevTools JWT demoted), and the 61→70 / `mosadd.dev`→`mosadd.com` reconciliation
176
+ (first shipped on the published package with this release).
177
+
178
+ ## [3.0.0-alpha.16] — 2026-06-17
179
+
180
+ ### Fixed
181
+ - `mAIL_view` now calls the `mp0st-get` Edge Function (read a message by id,
182
+ owner-scoped) instead of `mp0st-view` (the tracking-pixel endpoint, which
183
+ returned "Missing tracking ID"). ([LINEAR-2917])
184
+ - CI publish drops `--provenance` — npm returned 422 because the source repo
185
+ (`mosadd-os`) is private, so provenance attestation is not available.
186
+
187
+ ### Added (cumulative since alpha.4 — tool count 61 → 70)
188
+ - **Action links (Tier 1):** `comms_action_create` mints a one-link browser
189
+ action an agent can hand to a human (run-with-consent in the mosadd sandbox).
190
+ - **mAIL provenance:** `mAIL_send_as_agent` stamps agent/human provenance on the
191
+ message so the recipient sees who actually sent it.
192
+ - **File & voice attachments:** `mDM_send_voice` / `mDM_send_file`,
193
+ `mROOM_send_voice` / `mROOM_send_file`, `mIRC_send_voice` / `mIRC_send_file`
194
+ (reuse the existing `chat-files` bucket — no new transport).
195
+ - **mTALK → RAG:** `mTALK_ingest_ptt` feeds push-to-talk audio into the RAG index
196
+ (opt-in, gated server-side).
197
+ - **mROOM:** `mROOM_create_guest_link` (single-call, no-account guest links) and
198
+ `mROOM_voice_join`.
199
+ - **mIRC edge transport:** `mIRC_mint_channel_token`, `mIRC_send_edge`,
200
+ `mIRC_history_edge` — the low-latency path the agent-coordination skill rides.
201
+
202
+ ### Changed
203
+ - README, `package.json`, and the plugin `marketplace.json` reconciled to the
204
+ current surface: **70 tools across 6 modules** + `comms_capabilities`
205
+ discovery (71 callable), version `alpha.16`, and `mosadd.dev` → `mosadd.com`
206
+ (the dev surface was consolidated into the main site). ([LINEAR-3391])
207
+ - `mCALL` (telephony, carrier-pending) and `mURL` (brand/consumer surface)
208
+ remain **unregistered** in `tools/index.ts` — an agent only ever discovers
209
+ tools that actually work.
210
+
211
+ ## [3.0.0-alpha.4]
212
+
213
+ ### Added
214
+ - Initial public alpha: **61 tools across 6 live modules** — mDM (incl. voice),
215
+ mIRC, mROOM, mAIL, mTALK, mRAG — plus the `comms_capabilities` discovery tool.
216
+ - BYOK mode: the server talks to your own mosadd Supabase backend via
217
+ `MOSADD_SUPABASE_URL` / `MOSADD_SUPABASE_ANON_KEY` / `MOSADD_USER_JWT`.
218
+ - Apache-2.0 license; tool names follow [RFC 0001] (`m<MODULE>_<operation>`).
219
+
220
+ [3.0.0-alpha.16]: https://github.com/Hei33enberg/mosadd-os/tree/main/packages/mcp
221
+ [3.0.0-alpha.4]: https://github.com/Hei33enberg/mosadd-os/tree/main/packages/mcp
222
+ [LINEAR-2917]: https://linear.app/ip-ra/issue/LINEAR-2917
223
+ [LINEAR-3391]: https://linear.app/ip-ra/issue/LINEAR-3391
224
+ [RFC 0001]: https://github.com/Hei33enberg/mosadd-os/blob/main/docs/rfcs/0001-module-naming.md
package/README.md CHANGED
@@ -1,116 +1,150 @@
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
- "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
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
- - `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
- | 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 <MOSADD_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
- | `MOSADD_SUPABASE_URL` | Supabase project URL | yes |
107
- | `MOSADD_SUPABASE_ANON_KEY` | Supabase anon key | yes |
108
- | `MOSADD_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
+ **They're apps. We're the layer.** The MCP server for [mosADD](https://mosadd.com) — the omnichannel comms layer for humans, agents, and robots. It exposes the OS modules (m\*) — **mDM (1:1 E2EE), mIRC (in-app channels), mURL (open/embeddable rooms), and mAYL (email 3.0)** — as Model Context Protocol tools, so any agent runtime becomes a first-class contact your team can message and direct: Claude Code, Cursor, Windsurf, Cline, ChatGPT Apps, Lovable, Bolt, Goose, Manus, or your own.
4
+
5
+ One key, one server, 69 tools — MCP-native, no SDK to wire up. **Encrypted where it counts, honest where it isn't:** only mDM is end-to-end (Signal X3DH + Double Ratchet, keys on-device, never on our servers); every other channel is server-readable and labeled as such.
6
+
7
+ > **69 tools** across **4 modules** (mDM, mIRC, mURL, mAYL) + cross-cutting capabilities (mTALK voice, mRAG search, comms agent-actions) + agent→user action links + 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`.
8
+
9
+ ## Connect your agent
10
+
11
+ Three ways to authenticate, friendliest first — all three end with the same 69 tools.
12
+
13
+ ### 1. `mosadd login` — recommended (one command, stays logged in)
14
+
15
+ Sign in once; the session is saved to `~/.mosadd/session.json` and **refreshed automatically on every server start** (from its refresh token), so a single login keeps working — no env vars, no expiring-token dance.
16
+
17
+ ```bash
18
+ npx -y @mosadd/mcp@alpha login
19
+ # prompts for your Supabase URL + anon key (both public) and your mosADD email + password
20
+ ```
21
+
22
+ Then register the server with **no env block**:
23
+
24
+ ```bash
25
+ # Claude Code
26
+ claude mcp add mosadd -- npx -y @mosadd/mcp@alpha
27
+ ```
28
+
29
+ ```json
30
+ // Claude Desktop / Cursor / Cline / Windsurf — mcpServers config, no env needed
31
+ {
32
+ "mcpServers": {
33
+ "mosadd": { "command": "npx", "args": ["-y", "@mosadd/mcp@alpha"] }
34
+ }
35
+ }
36
+ ```
37
+
38
+ `npx @mosadd/mcp@alpha whoami` shows who you're signed in as; `… logout` clears it.
39
+
40
+ ### 2. `MOSADD_API_KEY` — headless / CI (one long-lived key)
41
+
42
+ A `mosadd_sk_live_…` hub key does not expire; the server exchanges it for a fresh session on every start. Best for servers, cron, and our own `mosadd-agent`.
43
+
44
+ ```json
45
+ {
46
+ "mcpServers": {
47
+ "mosadd": {
48
+ "command": "npx",
49
+ "args": ["-y", "@mosadd/mcp@alpha"],
50
+ "env": { "MOSADD_API_KEY": "mosadd_sk_live_…" }
51
+ }
52
+ }
53
+ }
54
+ ```
55
+
56
+ Mint a key at **[mosadd.com/keys](https://mosadd.com/keys)** — the hub shows it once, in the `mosadd_sk_live_…` format above. You can also use it as a Bearer token against the hosted MCP gateway at `https://mcp.mosadd.com/mcp`.
57
+
58
+ ### 3. BYOK + `MOSADD_USER_JWT` — advanced / debugging
59
+
60
+ Bring your own Supabase URL + anon key + a raw session token. **The JWT expires (~1h)** — prefer option 1 or 2 for anything ongoing.
61
+
62
+ - `MOSADD_SUPABASE_URL` — your Supabase project URL (e.g. `https://abc.supabase.co`)
63
+ - `MOSADD_SUPABASE_ANON_KEY` — the public anon key from project settings
64
+ - `MOSADD_USER_JWT` — sign in to mosadd.com → DevTools → Application → Local Storage → `sb-<ref>-auth-token` → copy the `access_token` field
65
+
66
+ In Phase 2 the hosted gateway at `mcp.mosadd.com` removes even this — add a URL + key once, server-side, and the broker holds the credentials.
67
+
68
+ ## Tools shipped in alpha
69
+
70
+ **69 tools** — 4 modules (mDM, mIRC, mURL, mAYL) + capabilities (mTALK voice, mRAG search, comms agent-actions) + the `comms_capabilities` discovery tool. Highlights per module:
71
+
72
+ | Module | Tools | What it does |
73
+ |---|---|---|
74
+ | **mDM** (14) | `mDM_list_contacts`, `mDM_send`, `mDM_send_unencrypted` (DEPRECATED — migration-window fallback, only when the peer hasn't published keys), `mDM_edit`, `mDM_delete`, `mDM_list`, `mDM_publish_keys`, `mDM_respond_request`, `mDM_call_start/answer/end`, `mDM_voice_note`, `mDM_send_voice`, `mDM_send_file` | 1:1 text, voice notes, calls + file/voice attachments. Multi-thread per contact. `mDM_send` is end-to-end encrypted by default (X3DH / Double Ratchet, `mosadd.e2ee.v2`); the operator cannot read message content |
75
+ | **mIRC** (22) | `mIRC_create/list/get/update/delete`, member RBAC (`mIRC_join/leave/kick/ban/unban/set_role/set_ptt/approve_request/reject_request/request_access`), `mIRC_post_message`, `mIRC_list_messages`, edge (`mIRC_mint_channel_token`, `mIRC_send_edge`, `mIRC_history_edge`), `mIRC_send_voice/file` | Persistent Discord/Slack-style channels + the agent-coordination edge transport |
76
+ | **mURL** (7) | `mURL_read_channel`, `mURL_post`, `mURL_presence`, `mURL_list_channels`, `mURL_create`, `mURL_update`, `mURL_delete` | IRC-for-URLs — open-web text rooms, agent-native. Read/post/presence/discovery with a hub key, PLUS owner-side lifecycle: `mURL_create` (claim a domain), `mURL_update` (branding + open/claimed/blocked), `mURL_delete` (`murl-manage` EF, owner-scoped via your login session). Transport-encrypted, server-readable/public by design |
77
+ | **mAYL** (11) | `mAYL_send`, `mAYL_view`, `mAYL_list`, `mAYL_delete`, `mAYL_stats`, `mAYL_events`, `mAYL_metrics`, `mAYL_revoke`, `mAYL_audit_export`, `mAYL_consent`, `mAYL_notify` | Mail; every user gets `<id>@mosadd.com`. Transport + at-rest encrypted (server-readable), NOT E2EE. `mAYL_revoke` recalls secure-reader access; `mAYL_audit_export` emits an HMAC-SHA256-signed engagement audit; `mAYL_consent` manages recipient tracking opt-outs (GDPR); `mAYL_notify` pulls the inbound-mail feed. (Was the mp0st codename; the `mp0st_*` aliases are retired — mAYL is the one name) |
78
+ | **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 |
79
+ | **mRAG** (4) | `mRAG_ingest`, `mRAG_search`, `mRAG_list_sources`, `mRAG_delete` | RAG recall over the user's own data (hybrid vector + BM25) |
80
+ | **comms_** (4) | `comms_action_create`, `comms_action_frame_get`, `comms_capabilities`, `comms_embed_create` | `comms_action_create` mints an agent→user one-link browser action (Tier 1); `comms_action_frame_get` fetches a framed action; `comms_capabilities` is one-call discovery of every tool's transport `requires` flag; `comms_embed_create` mints a publishable embed key + a paste-in `<script>` snippet that drops a live mIRC channel into any website (`embed.mosadd.com/v1.js`, skins + sidebar/launcher modes) |
81
+ | **Irondome** (2) | `threat_catalog`, `threat_classify` | On-device defensive classification over the 166-event threat taxonomy — pure, offline, no backend and no surveillance. The engine decides, the caller acts |
82
+
83
+ Module tools: mDM (14) + mIRC (22) + mURL (7) + mAYL (11) = 54; capabilities: mTALK (5) + mRAG (4) + comms_ (4, incl. the `comms_capabilities` discovery tool and `comms_embed_create` — re-registered 2026-07-17 now that `embed.mosadd.com/v1.js` is live) + Irondome (2) = 15 — **69 callable tools** in total. The exact live number is exported as `TOOL_COUNT` (`= allTools.length`) — reference that, never a hand-typed figure. mDM and mIRC each include their two attachment tools (`*_send_voice` / `*_send_file`). Not registered (so agents only ever see tools that actually work): `mCALL` (telephony, carrier-pending), `mROOM` (folded into ephemeral private mIRC), the retired `mp0st_*` mAYL aliases, and the `mAYL_send_as_agent` / `mTALK_ingest_ptt` scaffolds.
84
+
85
+ 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.
86
+
87
+ ## Try it (60-second demo)
88
+
89
+ In Claude Code with env vars set:
90
+
91
+ > List my mosadd contacts.
92
+
93
+ Claude calls `mDM_list_contacts` → you see your contact list.
94
+
95
+ > Send "hello from Claude" to <id> with thread label `notes`.
96
+
97
+ Claude calls `mDM_send({ to, text, thread_label: "notes" })` → message appears in your mosADD app under a `notes` thread.
98
+
99
+ ## Architecture
100
+
101
+ ```
102
+ Agent (Claude / Cursor / ...)
103
+ │
104
+ │ stdio MCP
105
+ ▼
106
+ @mosadd/mcp server (this package)
107
+ │
108
+ │ supabase.functions.invoke('message-send', ...)
109
+ │ + Authorization: Bearer <MOSADD_USER_JWT>
110
+ ▼
111
+ mosADD backend Edge Function
112
+ │
113
+ │ RLS-checked insert
114
+ ▼
115
+ Postgres `messages` table
116
+ │
117
+ │ Realtime broadcast
118
+ ▼
119
+ mosadd.com app (receiver)
120
+ ```
121
+
122
+ For PTT / CALL (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.
123
+
124
+ ## Configuration via env vars
125
+
126
+ | Env | Description | Required |
127
+ |---|---|---|
128
+ | `MOSADD_SUPABASE_URL` | Supabase project URL — DM / IRC / mail / KB backend | yes (BYOK) |
129
+ | `MOSADD_SUPABASE_ANON_KEY` | Supabase anon key | yes (BYOK) |
130
+ | `MOSADD_USER_JWT` | User session token | yes (for tools that touch user data) |
131
+ | `MOSADD_RESEND_API_KEY` | Resend API key — enables `mAYL` outbound mail (deprecated `mp0st_*` aliases still function) | no (mAYL disabled if unset) |
132
+ | `MOSADD_LIVEKIT_URL` | LiveKit `wss://…` URL — enables `mTALK` voice | no (voice disabled if unset) |
133
+ | `MOSADD_LIVEKIT_API_KEY` | LiveKit API key | no (with `…_URL` / `…_API_SECRET`) |
134
+ | `MOSADD_LIVEKIT_API_SECRET` | LiveKit API secret | no |
135
+ | `MOSADD_API_KEY` | Hub API key (Phase 2 hosted mode) | no |
136
+ | `MOSADD_HUB_URL` | Override hub url | no |
137
+ | `MOSADD_MODE` | `local` / `cloud` / `self-host` | no (auto-detected) |
138
+ | `MOSADD_LOG_LEVEL` | `debug` / `info` / `warn` / `error` | no (default `info`) |
139
+
140
+ Missing optional keys fail closed — that channel is simply absent from `comms_capabilities`.
141
+
142
+ ## Links
143
+
144
+ - **Mint a key + docs** — [mosadd.com/keys](https://mosadd.com/keys) · [mosadd.com/docs](https://mosadd.com/docs) · [mosadd.com/mcp](https://mosadd.com/mcp)
145
+ - **Hosted gateway** — `https://mcp.mosadd.com/mcp` (BYOK key broker, zero-install for remote agents)
146
+ - **Source + self-host** — [github.com/Hei33enberg/mosADD-OS](https://github.com/Hei33enberg/mosADD-OS) (Apache-2.0)
147
+
148
+ ## License
149
+
150
+ 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/mcp.js CHANGED
@@ -1,11 +1,16 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  createMosaddServer
4
- } from "../chunk-HD5RLE5K.js";
5
- import "../chunk-Z7WR52GE.js";
4
+ } from "../chunk-P4ENU5MW.js";
5
+ import {
6
+ isSessionExpired,
7
+ loadSession,
8
+ saveSession
9
+ } from "../chunk-Z7WR52GE.js";
6
10
 
7
11
  // src/bin/mcp.ts
8
12
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
13
+ import { createClient } from "@supabase/supabase-js";
9
14
  var DEFAULT_EXCHANGE = "https://rooffhgbxafyjcwmwpsy.supabase.co/functions/v1/hub-key-exchange";
10
15
  async function bootstrapFromApiKey() {
11
16
  const apiKey = process.env.MOSADD_API_KEY;
@@ -33,6 +38,36 @@ async function bootstrapFromApiKey() {
33
38
  );
34
39
  }
35
40
  }
41
+ async function bootstrapFromSavedSession() {
42
+ if (process.env.MOSADD_USER_JWT) return;
43
+ const session = loadSession();
44
+ if (!session?.refreshToken) return;
45
+ if (!isSessionExpired(session)) return;
46
+ try {
47
+ const client = createClient(session.url, session.anonKey, {
48
+ auth: { persistSession: false, autoRefreshToken: false, detectSessionInUrl: false }
49
+ });
50
+ const { data, error } = await client.auth.refreshSession({ refresh_token: session.refreshToken });
51
+ if (error || !data.session) {
52
+ process.stderr.write(
53
+ JSON.stringify({ level: "warn", msg: "mosadd session refresh failed \u2014 run `mosadd login`", error: error?.message }) + "\n"
54
+ );
55
+ return;
56
+ }
57
+ saveSession({
58
+ url: session.url,
59
+ anonKey: session.anonKey,
60
+ accessToken: data.session.access_token,
61
+ refreshToken: data.session.refresh_token ?? session.refreshToken,
62
+ expiresAt: data.session.expires_at,
63
+ email: data.user?.email ?? session.email
64
+ });
65
+ } catch (err) {
66
+ process.stderr.write(
67
+ JSON.stringify({ level: "warn", msg: "mosadd session refresh error \u2014 run `mosadd login`", error: String(err) }) + "\n"
68
+ );
69
+ }
70
+ }
36
71
  async function main() {
37
72
  const sub = process.argv[2];
38
73
  if (sub === "login" || sub === "logout" || sub === "whoami") {
@@ -41,11 +76,15 @@ async function main() {
41
76
  return;
42
77
  }
43
78
  await bootstrapFromApiKey();
79
+ await bootstrapFromSavedSession();
44
80
  const server = createMosaddServer({
45
81
  apiKey: process.env.MOSADD_API_KEY,
46
82
  hubUrl: process.env.MOSADD_HUB_URL,
47
83
  mode: process.env.MOSADD_MODE,
48
- logLevel: process.env.MOSADD_LOG_LEVEL
84
+ logLevel: process.env.MOSADD_LOG_LEVEL,
85
+ // stdio is single-tenant: the session lives in env (set by bootstrapFromApiKey
86
+ // above), so auto-publish this identity's prekeys on boot → mDM is reachable.
87
+ autoPublishKeys: true
49
88
  });
50
89
  const transport = new StdioServerTransport();
51
90
  await server.connect(transport);