@mosadd/mcp 3.0.0-alpha.2 → 3.0.0-alpha.20
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 +120 -0
- package/README.md +141 -116
- package/dist/bin/mcp.js +70 -3
- package/dist/chunk-FZNAGICW.js +2353 -0
- package/dist/index.d.ts +62 -4
- package/dist/index.js +5 -3
- package/package.json +10 -5
- package/src/__tests__/golden-path.test.ts +137 -132
- package/src/__tests__/integration.test.ts +178 -175
- package/src/__tests__/mdm-e2ee.test.ts +212 -149
- package/src/__tests__/mtalk.test.ts +122 -0
- package/src/__tests__/server.test.ts +71 -67
- package/src/bin/login.ts +138 -138
- package/src/bin/mcp.ts +145 -55
- package/src/config.ts +66 -66
- package/src/crypto/mdm-session.ts +403 -378
- package/src/index.ts +19 -17
- package/src/observability/sentry.ts +79 -79
- package/src/providers/blob-upload.ts +116 -0
- package/src/providers/memory-voice.ts +79 -0
- package/src/providers/supabase-dm.ts +122 -117
- package/src/providers/supabase-voice.ts +91 -0
- package/src/providers/supabase.ts +120 -96
- package/src/server.ts +123 -103
- package/src/tools/actions.ts +162 -0
- package/src/tools/attachments.ts +268 -0
- package/src/tools/capabilities.ts +68 -68
- package/src/tools/embed.ts +108 -0
- package/src/tools/index.ts +72 -37
- package/src/tools/knowledge.ts +191 -0
- package/src/tools/mail-provenance.ts +137 -0
- package/src/tools/mail.ts +378 -89
- package/src/tools/mcall.ts +216 -0
- package/src/tools/mdm-voice.ts +206 -0
- package/src/tools/mdm.ts +451 -379
- package/src/tools/mirc-edge.ts +190 -0
- package/src/tools/mirc-members.ts +188 -177
- package/src/tools/mirc-messages.ts +159 -0
- package/src/tools/mirc.ts +174 -170
- package/src/tools/mroom-messages.ts +142 -142
- package/src/tools/mroom.ts +221 -189
- package/src/tools/mtalk.ts +121 -0
- package/src/tools/murl.ts +195 -0
- package/src/tools/ptt-ingest.ts +91 -0
- package/src/tools/threat.ts +92 -0
- package/src/types.ts +94 -79
- package/src/voice/floor.ts +132 -0
- package/dist/chunk-HD5RLE5K.js +0 -1193
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
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
|
+
### Fixed
|
|
12
|
+
- **mIRC `reject_request` / `approve_request` field (LINEAR-3522):** the tools sent
|
|
13
|
+
`request_id` but `channel-members-manage` reads `target_identity_id` → 400 every
|
|
14
|
+
call. Renamed to `identity_id` (normalized to `target_identity_id`). `reject` now
|
|
15
|
+
works; `approve` of an E2EE channel still needs a wrapped group key (LINEAR-3523).
|
|
16
|
+
- **mDM / mIRC message pagination (LINEAR-3524):** `mDM_list` read `cursor`/`has_more`
|
|
17
|
+
but `message-list` history mode returns `next_before`, and `mIRC_list_messages`
|
|
18
|
+
sent `cursor` (ignored; EF reads `before`) and read `next_cursor` (never returned)
|
|
19
|
+
→ neither paged past page 1. Send `before`, read `next_before`.
|
|
20
|
+
|
|
21
|
+
## [3.0.0-alpha.19] — 2026-06-19
|
|
22
|
+
|
|
23
|
+
### Removed
|
|
24
|
+
- **BREAKING — mROOM module killed (LINEAR-3414):** the 11 `mROOM_*` tools
|
|
25
|
+
(`mROOM_create`, `mROOM_create_guest_link`, `mROOM_join`, `mROOM_leave`,
|
|
26
|
+
`mROOM_close`, `mROOM_list`, `mROOM_voice_join`, `mROOM_send_message`,
|
|
27
|
+
`mROOM_list_messages`, `mROOM_send_voice`, `mROOM_send_file`) are no longer
|
|
28
|
+
registered. Ephemeral private rooms are re-cut into private mIRC channels.
|
|
29
|
+
The source stays in `tools/mroom*.ts` (unregistered, like mURL/mCALL).
|
|
30
|
+
|
|
31
|
+
### Added
|
|
32
|
+
- **Defensive threat engine as MCP tools (LINEAR-3498):** `threat_catalog`
|
|
33
|
+
(list the canonical 160+ threat-event taxonomy) and `threat_classify`
|
|
34
|
+
(pure `evaluateEvent` decision → action/severity/reason). Wraps
|
|
35
|
+
`@mosadd/threat-engine`; deterministic, offline, `requires: "any"`.
|
|
36
|
+
|
|
37
|
+
Net: 70 → **64 callable tools** across 5 live modules + comms + threat.
|
|
38
|
+
|
|
39
|
+
### Changed
|
|
40
|
+
- **BREAKING — mail tool rename:** the 12 email MCP tools are renamed
|
|
41
|
+
`mAIL_*` → `mp0st_*` (`mp0st_list`, `mp0st_send`, `mp0st_view`, `mp0st_delete`,
|
|
42
|
+
`mp0st_stats`, `mp0st_events`, `mp0st_metrics`, `mp0st_revoke`,
|
|
43
|
+
`mp0st_audit_export`, `mp0st_consent`, `mp0st_notify`, `mp0st_send_as_agent`).
|
|
44
|
+
No aliases — the old `mAIL_*` names no longer resolve. Backend Edge Functions
|
|
45
|
+
(`mp0st-*`) are unchanged.
|
|
46
|
+
|
|
47
|
+
## [3.0.0-alpha.18] — 2026-06-18
|
|
48
|
+
|
|
49
|
+
### Added
|
|
50
|
+
- **`comms_embed_create`** — embed a LIVE mosadd channel into an app/site a builder-agent is
|
|
51
|
+
generating (Lovable / Bolt / Cursor / v0). Mints a publishable embed key (`m_pk_live_…`,
|
|
52
|
+
origin-scoped, via the `embed-keys` EF) and returns a paste-in widget snippet
|
|
53
|
+
(`<div>` + `<script src="https://embed.mosadd.com/v1.js" data-key=…>`). The widget exchanges
|
|
54
|
+
the publishable key for a short-lived channel-scoped JWT at runtime; the hub key never enters
|
|
55
|
+
the browser. Extends `mROOM_create_guest_link` (link → embeddable widget). CDN override via
|
|
56
|
+
`MOSADD_EMBED_CDN`. (Widget served from the dedicated `embed.mosadd.com` deploy.)
|
|
57
|
+
|
|
58
|
+
## [3.0.0-alpha.17] — 2026-06-18
|
|
59
|
+
|
|
60
|
+
### Added
|
|
61
|
+
- **Action Links — screen share.** `comms_action_create` gains a `screen_share` action
|
|
62
|
+
type, and a new `comms_action_frame_get` tool lets the creating agent read frames of the
|
|
63
|
+
recipient's shared screen (consent-gated, browser-sandbox only). Turns Action Links into
|
|
64
|
+
"remote-desktop-lite" — the agent sees what the human chooses to share.
|
|
65
|
+
|
|
66
|
+
### Changed
|
|
67
|
+
- **Durable `mosadd login`.** The saved session (`~/.mosadd/session.json`) is now refreshed
|
|
68
|
+
from its refresh token at server boot, so a single `mosadd login` keeps working across
|
|
69
|
+
restarts — no more re-login when the access token expires.
|
|
70
|
+
- Onboarding README restructured (recommended auth path — `mosadd login` — first; hub API
|
|
71
|
+
key second; DevTools JWT demoted), and the 61→70 / `mosadd.dev`→`mosadd.com` reconciliation
|
|
72
|
+
(first shipped on the published package with this release).
|
|
73
|
+
|
|
74
|
+
## [3.0.0-alpha.16] — 2026-06-17
|
|
75
|
+
|
|
76
|
+
### Fixed
|
|
77
|
+
- `mAIL_view` now calls the `mp0st-get` Edge Function (read a message by id,
|
|
78
|
+
owner-scoped) instead of `mp0st-view` (the tracking-pixel endpoint, which
|
|
79
|
+
returned "Missing tracking ID"). ([LINEAR-2917])
|
|
80
|
+
- CI publish drops `--provenance` — npm returned 422 because the source repo
|
|
81
|
+
(`mosadd-os`) is private, so provenance attestation is not available.
|
|
82
|
+
|
|
83
|
+
### Added (cumulative since alpha.4 — tool count 61 → 70)
|
|
84
|
+
- **Action links (Tier 1):** `comms_action_create` mints a one-link browser
|
|
85
|
+
action an agent can hand to a human (run-with-consent in the mosadd sandbox).
|
|
86
|
+
- **mAIL provenance:** `mAIL_send_as_agent` stamps agent/human provenance on the
|
|
87
|
+
message so the recipient sees who actually sent it.
|
|
88
|
+
- **File & voice attachments:** `mDM_send_voice` / `mDM_send_file`,
|
|
89
|
+
`mROOM_send_voice` / `mROOM_send_file`, `mIRC_send_voice` / `mIRC_send_file`
|
|
90
|
+
(reuse the existing `chat-files` bucket — no new transport).
|
|
91
|
+
- **mTALK → RAG:** `mTALK_ingest_ptt` feeds push-to-talk audio into the RAG index
|
|
92
|
+
(opt-in, gated server-side).
|
|
93
|
+
- **mROOM:** `mROOM_create_guest_link` (single-call, no-account guest links) and
|
|
94
|
+
`mROOM_voice_join`.
|
|
95
|
+
- **mIRC edge transport:** `mIRC_mint_channel_token`, `mIRC_send_edge`,
|
|
96
|
+
`mIRC_history_edge` — the low-latency path the agent-coordination skill rides.
|
|
97
|
+
|
|
98
|
+
### Changed
|
|
99
|
+
- README, `package.json`, and the plugin `marketplace.json` reconciled to the
|
|
100
|
+
current surface: **70 tools across 6 modules** + `comms_capabilities`
|
|
101
|
+
discovery (71 callable), version `alpha.16`, and `mosadd.dev` → `mosadd.com`
|
|
102
|
+
(the dev surface was consolidated into the main site). ([LINEAR-3391])
|
|
103
|
+
- `mCALL` (telephony, carrier-pending) and `mURL` (brand/consumer surface)
|
|
104
|
+
remain **unregistered** in `tools/index.ts` — an agent only ever discovers
|
|
105
|
+
tools that actually work.
|
|
106
|
+
|
|
107
|
+
## [3.0.0-alpha.4]
|
|
108
|
+
|
|
109
|
+
### Added
|
|
110
|
+
- Initial public alpha: **61 tools across 6 live modules** — mDM (incl. voice),
|
|
111
|
+
mIRC, mROOM, mAIL, mTALK, mRAG — plus the `comms_capabilities` discovery tool.
|
|
112
|
+
- BYOK mode: the server talks to your own mosadd Supabase backend via
|
|
113
|
+
`MOSADD_SUPABASE_URL` / `MOSADD_SUPABASE_ANON_KEY` / `MOSADD_USER_JWT`.
|
|
114
|
+
- Apache-2.0 license; tool names follow [RFC 0001] (`m<MODULE>_<operation>`).
|
|
115
|
+
|
|
116
|
+
[3.0.0-alpha.16]: https://github.com/Hei33enberg/mosadd-os/tree/main/packages/mcp
|
|
117
|
+
[3.0.0-alpha.4]: https://github.com/Hei33enberg/mosadd-os/tree/main/packages/mcp
|
|
118
|
+
[LINEAR-2917]: https://linear.app/ip-ra/issue/LINEAR-2917
|
|
119
|
+
[LINEAR-3391]: https://linear.app/ip-ra/issue/LINEAR-3391
|
|
120
|
+
[RFC 0001]: https://github.com/Hei33enberg/mosadd-os/blob/main/docs/rfcs/0001-module-naming.md
|
package/README.md
CHANGED
|
@@ -1,116 +1,141 @@
|
|
|
1
|
-
# @mosadd/mcp
|
|
2
|
-
|
|
3
|
-
MCP server for [mosadd](https://mosadd.
|
|
4
|
-
|
|
5
|
-
> **3.0.0-alpha** —
|
|
6
|
-
|
|
7
|
-
##
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
1
|
+
# @mosadd/mcp
|
|
2
|
+
|
|
3
|
+
MCP server for [mosadd](https://mosadd.com) — 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.16** — **64 live tools across 5 live modules** (mDM incl. voice + files, mIRC, mp0st incl. provenance, mTALK, mRAG) + agent→user action links + the `comms_capabilities` discovery tool + the defensive `threat_*` engine, 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
|
+
|
|
7
|
+
## Connect your agent
|
|
8
|
+
|
|
9
|
+
Three ways to authenticate, friendliest first — all three end with the same ~64 tools.
|
|
10
|
+
|
|
11
|
+
### 1. `mosadd login` — recommended (one command, stays logged in)
|
|
12
|
+
|
|
13
|
+
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.
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npx -y @mosadd/mcp@alpha login
|
|
17
|
+
# prompts for your Supabase URL + anon key (both public) and your mosadd email + password
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Then register the server with **no env block**:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
# Claude Code
|
|
24
|
+
claude mcp add mosadd -- npx -y @mosadd/mcp@alpha
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
```json
|
|
28
|
+
// Claude Desktop / Cursor / Cline / Windsurf — mcpServers config, no env needed
|
|
29
|
+
{
|
|
30
|
+
"mcpServers": {
|
|
31
|
+
"mosadd": { "command": "npx", "args": ["-y", "@mosadd/mcp@alpha"] }
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
`npx @mosadd/mcp@alpha whoami` shows who you're signed in as; `… logout` clears it.
|
|
37
|
+
|
|
38
|
+
### 2. `MOSADD_API_KEY` — headless / CI (one long-lived key)
|
|
39
|
+
|
|
40
|
+
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`.
|
|
41
|
+
|
|
42
|
+
```json
|
|
43
|
+
{
|
|
44
|
+
"mcpServers": {
|
|
45
|
+
"mosadd": {
|
|
46
|
+
"command": "npx",
|
|
47
|
+
"args": ["-y", "@mosadd/mcp@alpha"],
|
|
48
|
+
"env": { "MOSADD_API_KEY": "mosadd_sk_live_…" }
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Mint a key by POSTing to the `hub-keys` Edge Function with your user JWT (it returns the secret once). A one-click "API keys" screen on mosadd.com is the planned UX.
|
|
55
|
+
|
|
56
|
+
### 3. BYOK + `MOSADD_USER_JWT` — advanced / debugging
|
|
57
|
+
|
|
58
|
+
Bring your own Supabase URL + anon key + a raw session token. **The JWT expires (~1h)** — prefer option 1 or 2 for anything ongoing.
|
|
59
|
+
|
|
60
|
+
- `MOSADD_SUPABASE_URL` — your Supabase project URL (e.g. `https://abc.supabase.co`)
|
|
61
|
+
- `MOSADD_SUPABASE_ANON_KEY` — the public anon key from project settings
|
|
62
|
+
- `MOSADD_USER_JWT` — sign in to mosadd.com → DevTools → Application → Local Storage → `sb-<ref>-auth-token` → copy the `access_token` field
|
|
63
|
+
|
|
64
|
+
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.
|
|
65
|
+
|
|
66
|
+
## Tools shipped in alpha
|
|
67
|
+
|
|
68
|
+
**64 live tools across 5 live modules** (mDM, mIRC, mp0st, mTALK, mRAG) + agent→user action links + the `comms_capabilities` discovery tool + the defensive `threat_*` engine. Highlights per module:
|
|
69
|
+
|
|
70
|
+
| Module | Tools | What it does |
|
|
71
|
+
|---|---|---|
|
|
72
|
+
| **mDM** (14) | `mDM_list_contacts`, `mDM_send`, `mDM_send_unencrypted`, `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, X3DH / Double-Ratchet E2EE with sealed sender on `mDM_send` |
|
|
73
|
+
| **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 |
|
|
74
|
+
| **mp0st** (12) | `mp0st_send`, `mp0st_view`, `mp0st_list`, `mp0st_delete`, `mp0st_stats`, `mp0st_events`, `mp0st_metrics`, `mp0st_revoke`, `mp0st_audit_export`, `mp0st_consent`, `mp0st_notify`, `mp0st_send_as_agent` | Mail; every user gets `<id>@mosadd.com`. `mp0st_send_as_agent` stamps agent/human provenance; `mp0st_revoke` recalls secure-reader access; `mp0st_audit_export` emits an HMAC-SHA256-signed engagement audit; `mp0st_consent` manages recipient tracking opt-outs (GDPR); `mp0st_notify` pulls the inbound-mail feed |
|
|
75
|
+
| **mTALK** (6) | `mTALK_open`, `mTALK_join`, `mTALK_press`, `mTALK_release`, `mTALK_state`, `mTALK_ingest_ptt` | Half-duplex push-to-talk: one speaker, FIFO queue, anti-hog auto-release; `mTALK_ingest_ptt` feeds PTT audio to RAG |
|
|
76
|
+
| **mRAG** (4) | `mRAG_ingest`, `mRAG_search`, `mRAG_list_sources`, `mRAG_delete` | RAG recall over the user's own data (hybrid vector + BM25) |
|
|
77
|
+
| **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` builds an embeddable surface |
|
|
78
|
+
| **threat_** (2) | `threat_catalog`, `threat_classify` | Pure defensive threat-event classification engine — enumerate the catalog and classify an operation against it |
|
|
79
|
+
|
|
80
|
+
Counts by module prefix sum to **58 channel tools**; the 4 `comms_*` tools and 2 `threat_*` tools make **64 callable** in total. `mCALL` (telephony) tools exist in the source but are **not registered** — agents only ever see tools that actually work.
|
|
81
|
+
|
|
82
|
+
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.
|
|
83
|
+
|
|
84
|
+
## Try it (60-second demo)
|
|
85
|
+
|
|
86
|
+
In Claude Code with env vars set:
|
|
87
|
+
|
|
88
|
+
> List my mosadd contacts.
|
|
89
|
+
|
|
90
|
+
Claude calls `mDM_list_contacts` → you see your contact list.
|
|
91
|
+
|
|
92
|
+
> Send "hello from Claude" to <id> with thread label `notes`.
|
|
93
|
+
|
|
94
|
+
Claude calls `mDM_send({ to, text, thread_label: "notes" })` → message appears in your mosadd app under a `notes` thread.
|
|
95
|
+
|
|
96
|
+
## Architecture
|
|
97
|
+
|
|
98
|
+
```
|
|
99
|
+
Agent (Claude / Cursor / ...)
|
|
100
|
+
│
|
|
101
|
+
│ stdio MCP
|
|
102
|
+
▼
|
|
103
|
+
@mosadd/mcp server (this package)
|
|
104
|
+
│
|
|
105
|
+
│ supabase.functions.invoke('message-send', ...)
|
|
106
|
+
│ + Authorization: Bearer <MOSADD_USER_JWT>
|
|
107
|
+
▼
|
|
108
|
+
mosadd backend Edge Function
|
|
109
|
+
│
|
|
110
|
+
│ RLS-checked insert
|
|
111
|
+
▼
|
|
112
|
+
Postgres `messages` table
|
|
113
|
+
│
|
|
114
|
+
│ Realtime broadcast
|
|
115
|
+
▼
|
|
116
|
+
mosadd.com app (receiver)
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
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.
|
|
120
|
+
|
|
121
|
+
## Configuration via env vars
|
|
122
|
+
|
|
123
|
+
| Env | Description | Required |
|
|
124
|
+
|---|---|---|
|
|
125
|
+
| `MOSADD_SUPABASE_URL` | Supabase project URL — DM / IRC / mail / KB backend | yes (BYOK) |
|
|
126
|
+
| `MOSADD_SUPABASE_ANON_KEY` | Supabase anon key | yes (BYOK) |
|
|
127
|
+
| `MOSADD_USER_JWT` | User session token | yes (for tools that touch user data) |
|
|
128
|
+
| `MOSADD_RESEND_API_KEY` | Resend API key — enables `mp0st` outbound | no (mp0st disabled if unset) |
|
|
129
|
+
| `MOSADD_LIVEKIT_URL` | LiveKit `wss://…` URL — enables `mTALK` voice | no (voice disabled if unset) |
|
|
130
|
+
| `MOSADD_LIVEKIT_API_KEY` | LiveKit API key | no (with `…_URL` / `…_API_SECRET`) |
|
|
131
|
+
| `MOSADD_LIVEKIT_API_SECRET` | LiveKit API secret | no |
|
|
132
|
+
| `MOSADD_API_KEY` | Hub API key (Phase 2 hosted mode) | no |
|
|
133
|
+
| `MOSADD_HUB_URL` | Override hub url | no |
|
|
134
|
+
| `MOSADD_MODE` | `local` / `cloud` / `self-host` | no (auto-detected) |
|
|
135
|
+
| `MOSADD_LOG_LEVEL` | `debug` / `info` / `warn` / `error` | no (default `info`) |
|
|
136
|
+
|
|
137
|
+
Missing optional keys fail closed — that channel is simply absent from `comms_capabilities`.
|
|
138
|
+
|
|
139
|
+
## License
|
|
140
|
+
|
|
141
|
+
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,73 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
createMosaddServer
|
|
4
|
-
} from "../chunk-
|
|
5
|
-
import
|
|
4
|
+
} from "../chunk-FZNAGICW.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";
|
|
14
|
+
var DEFAULT_EXCHANGE = "https://rooffhgbxafyjcwmwpsy.supabase.co/functions/v1/hub-key-exchange";
|
|
15
|
+
async function bootstrapFromApiKey() {
|
|
16
|
+
const apiKey = process.env.MOSADD_API_KEY;
|
|
17
|
+
if (!apiKey || process.env.MOSADD_USER_JWT) return;
|
|
18
|
+
const endpoint = process.env.MOSADD_HUB_URL ? `${process.env.MOSADD_HUB_URL.replace(/\/$/, "")}/hub-key-exchange` : DEFAULT_EXCHANGE;
|
|
19
|
+
try {
|
|
20
|
+
const res = await fetch(endpoint, {
|
|
21
|
+
method: "POST",
|
|
22
|
+
headers: { Authorization: `Bearer ${apiKey}`, "Content-Type": "application/json" },
|
|
23
|
+
body: "{}"
|
|
24
|
+
});
|
|
25
|
+
if (!res.ok) {
|
|
26
|
+
process.stderr.write(
|
|
27
|
+
JSON.stringify({ level: "warn", msg: "mosadd hub key exchange failed", status: res.status }) + "\n"
|
|
28
|
+
);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const d = await res.json();
|
|
32
|
+
if (d.url) process.env.MOSADD_SUPABASE_URL = d.url;
|
|
33
|
+
if (d.anon_key) process.env.MOSADD_SUPABASE_ANON_KEY = d.anon_key;
|
|
34
|
+
if (d.access_token) process.env.MOSADD_USER_JWT = d.access_token;
|
|
35
|
+
} catch (err) {
|
|
36
|
+
process.stderr.write(
|
|
37
|
+
JSON.stringify({ level: "warn", msg: "mosadd hub unreachable", error: String(err) }) + "\n"
|
|
38
|
+
);
|
|
39
|
+
}
|
|
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
|
+
}
|
|
9
71
|
async function main() {
|
|
10
72
|
const sub = process.argv[2];
|
|
11
73
|
if (sub === "login" || sub === "logout" || sub === "whoami") {
|
|
@@ -13,11 +75,16 @@ async function main() {
|
|
|
13
75
|
await runAuthCommand(sub, process.argv.slice(3));
|
|
14
76
|
return;
|
|
15
77
|
}
|
|
78
|
+
await bootstrapFromApiKey();
|
|
79
|
+
await bootstrapFromSavedSession();
|
|
16
80
|
const server = createMosaddServer({
|
|
17
81
|
apiKey: process.env.MOSADD_API_KEY,
|
|
18
82
|
hubUrl: process.env.MOSADD_HUB_URL,
|
|
19
83
|
mode: process.env.MOSADD_MODE,
|
|
20
|
-
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
|
|
21
88
|
});
|
|
22
89
|
const transport = new StdioServerTransport();
|
|
23
90
|
await server.connect(transport);
|