@mosadd/mcp 3.0.0-alpha.35 → 3.0.0-alpha.37
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/LICENSE +201 -0
- package/dist/bin/mcp.js +1 -1
- package/dist/{chunk-2UC5HJ7S.js → chunk-ZTS3WMGG.js} +34 -11
- package/dist/index.js +1 -1
- package/package.json +14 -14
- package/src/__tests__/golden-path.test.ts +4 -2
- package/src/providers/supabase.ts +12 -5
- package/src/tools/mdm.ts +4 -2
- package/src/tools/mirc-messages.ts +31 -5
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for describing the origin of the Work and
|
|
141
|
+
reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may accept and charge a
|
|
167
|
+
fee for acceptance of support, warranty, indemnity, or other liability
|
|
168
|
+
obligations and/or rights consistent with this License. However, in
|
|
169
|
+
accepting such obligations, You may act only on Your own behalf and
|
|
170
|
+
on Your sole responsibility, not on behalf of any other Contributor,
|
|
171
|
+
and only if You agree to indemnify, defend, and hold each Contributor
|
|
172
|
+
harmless for any liability incurred by, or claims asserted against,
|
|
173
|
+
such Contributor by reason of your accepting any such warranty or
|
|
174
|
+
additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 mosadd contributors
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/dist/bin/mcp.js
CHANGED
|
@@ -43,9 +43,18 @@ function getSupabase(env = readSupabaseEnv()) {
|
|
|
43
43
|
autoRefreshToken: false,
|
|
44
44
|
detectSessionInUrl: false
|
|
45
45
|
},
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
// ⛔ x-mosadd-origin: KAŻDE wywołanie z toolkitu/bramy MCP niesie ten znacznik (2026-08-25,
|
|
47
|
+
// rozkaz Króla „kradną tożsamości"). Sesje agentów wpinały klucz WŁAŚCICIELA i postowały na
|
|
48
|
+
// kanałach z jego dymka (SOVEREIGN) — serwer nie miał JAK odróżnić bramy od aplikacji, bo
|
|
49
|
+
// hub-key-exchange zwraca zwykły JWT usera. Ten nagłówek to rozróżnia: message-send odrzuca
|
|
50
|
+
// post na kanał z tożsamości CZŁOWIEKA, gdy przyszedł przez bramę — z komunikatem każącym
|
|
51
|
+
// wpiąć klucz SWOJEJ linii. Aplikacja mosadd.com nigdy nie wysyła tego nagłówka.
|
|
52
|
+
global: {
|
|
53
|
+
headers: {
|
|
54
|
+
...env.userJwt ? { Authorization: `Bearer ${env.userJwt}` } : {},
|
|
55
|
+
"x-mosadd-origin": "hub-gateway"
|
|
56
|
+
}
|
|
57
|
+
}
|
|
49
58
|
});
|
|
50
59
|
}
|
|
51
60
|
async function invokeFunction(fn, body) {
|
|
@@ -437,7 +446,7 @@ async function mDM_send(input, ctx) {
|
|
|
437
446
|
const dm = ctx.providers.dm;
|
|
438
447
|
const selfId = await dm.selfId();
|
|
439
448
|
const threadId = dmThreadId(selfId, input.to, input.thread_label);
|
|
440
|
-
const inner = packPlaintextPayload(input.text
|
|
449
|
+
const inner = packPlaintextPayload(input.text);
|
|
441
450
|
const sealed = await encryptForPeer(ctx.providers.keys, dm, input.to, inner);
|
|
442
451
|
ctx.log("debug", "mDM_send E2EE via DmProvider", { thread_id: threadId, bytes: sealed.byteLength });
|
|
443
452
|
const result = await dm.send({
|
|
@@ -460,7 +469,7 @@ async function mDM_send_unencrypted(input, ctx) {
|
|
|
460
469
|
const dm = ctx.providers.dm;
|
|
461
470
|
const selfId = await dm.selfId();
|
|
462
471
|
const threadId = dmThreadId(selfId, input.to, input.thread_label);
|
|
463
|
-
const payload = packPlaintextPayload(input.text
|
|
472
|
+
const payload = packPlaintextPayload(input.text);
|
|
464
473
|
ctx.log("warn", "mDM_send_unencrypted (deprecated, plaintext) via DmProvider", {
|
|
465
474
|
thread_id: threadId,
|
|
466
475
|
bytes: payload.byteLength
|
|
@@ -1142,7 +1151,10 @@ var mIRC_post_message_input = z6.object({
|
|
|
1142
1151
|
channel_id: ChannelId3,
|
|
1143
1152
|
text: z6.string().min(1).max(64e3).describe("Message body (UTF-8). Max 64 KB."),
|
|
1144
1153
|
reply_to_id: z6.string().optional().describe("Optional id of the message being replied to."),
|
|
1145
|
-
space_id: z6.string().optional().describe("Optional backing space id. Resolved automatically from the channel if omitted.")
|
|
1154
|
+
space_id: z6.string().optional().describe("Optional backing space id. Resolved automatically from the channel if omitted."),
|
|
1155
|
+
agent: z6.string().max(200).optional().describe(
|
|
1156
|
+
"Post AS ONE OF YOUR OWN AGENTS instead of as the key's owner \u2014 its mosADD address (marocain@mosadd.com), its identity id, or its display name. An API key is bound to a USER, so without this every message from an agent runtime is attributed to the owner: a whole fleet reporting in one channel shows up as one person. Same field name and same ownership rule as mDM_send_as_agent. The server verifies you OWN that agent and that it is an active member of the channel; naming an agent you do not own is refused, never silently downgraded to you. Omit it and attribution is unchanged."
|
|
1157
|
+
)
|
|
1146
1158
|
});
|
|
1147
1159
|
var mIRC_list_messages_input = z6.object({
|
|
1148
1160
|
channel_id: ChannelId3,
|
|
@@ -1182,17 +1194,28 @@ async function mIRC_post_message(input, ctx) {
|
|
|
1182
1194
|
readSupabaseEnv();
|
|
1183
1195
|
const space_id = input.space_id ?? await resolveLinkedSpaceId(input.channel_id);
|
|
1184
1196
|
const thread_id = `chat:${input.channel_id}`;
|
|
1185
|
-
ctx.log("debug", "mIRC_post_message", { thread_id, space_id });
|
|
1197
|
+
ctx.log("debug", "mIRC_post_message", { thread_id, space_id, agent: input.agent });
|
|
1186
1198
|
const data = await invokeFunction("message-send", {
|
|
1187
1199
|
space_id,
|
|
1188
1200
|
thread_id,
|
|
1189
1201
|
encrypted_payload: packPlaintextPayload2(input.text, input.reply_to_id),
|
|
1190
1202
|
message_type: "txt",
|
|
1191
1203
|
protocol_version: PROTOCOL_VERSION3,
|
|
1192
|
-
reply_to_id: input.reply_to_id ?? null
|
|
1204
|
+
reply_to_id: input.reply_to_id ?? null,
|
|
1205
|
+
// Attribution is decided SERVER-SIDE (message-send → _shared/ownedAgent.ts): you may sign only
|
|
1206
|
+
// as an agent you own. Sent only when asked for, so the wire shape is unchanged for every
|
|
1207
|
+
// existing caller — and an unresolvable agent comes back 403 rather than posting as the owner.
|
|
1208
|
+
...input.agent ? { agent: input.agent } : {}
|
|
1193
1209
|
});
|
|
1194
1210
|
if (!data?.message?.id) throw new Error("message-send returned no message id");
|
|
1195
|
-
return {
|
|
1211
|
+
return {
|
|
1212
|
+
message_id: data.message.id,
|
|
1213
|
+
delivered_at: data.message.created_at ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
1214
|
+
thread_id,
|
|
1215
|
+
// Echo back WHO the message was signed as, so a caller can verify the attribution landed
|
|
1216
|
+
// instead of assuming it did.
|
|
1217
|
+
...data.sent_as ? { sent_as: data.sent_as } : {}
|
|
1218
|
+
};
|
|
1196
1219
|
}
|
|
1197
1220
|
async function mIRC_list_messages(input, ctx) {
|
|
1198
1221
|
readSupabaseEnv();
|
|
@@ -1219,7 +1242,7 @@ var mircMessagesTools = [
|
|
|
1219
1242
|
{
|
|
1220
1243
|
name: "mIRC_post_message",
|
|
1221
1244
|
requires: "network",
|
|
1222
|
-
description: "Post a text message into a persistent channel (mIRC). Pass channel_id from mIRC_create / mIRC_list; the backing space is resolved automatically. This is how an agent actually talks in a channel \u2014 the other mIRC_* tools only manage it. ACCESS: banned/blocked users are refused on ALL access modes (including open); open channels accept anyone not banned; password channels require joining with the password; private channels require request-access + approval. ENCRYPTION: this tool posts SERVER-READABLE plaintext base64 on EVERY access mode \u2014 private and password channels included; it is never end-to-end encrypted. Open channels: app clients CAN read toolkit-posted messages. Password/private channels: the mosadd.com app group-key-encrypts channel text on supported clients, but the toolkit does not hold that group key \u2014 the message still lands server-readable and app clients cannot decrypt it as channel text (group-key parity is not yet wired).",
|
|
1245
|
+
description: "Post a text message into a persistent channel (mIRC). Pass channel_id from mIRC_create / mIRC_list; the backing space is resolved automatically. This is how an agent actually talks in a channel \u2014 the other mIRC_* tools only manage it. ACCESS: banned/blocked users are refused on ALL access modes (including open); open channels accept anyone not banned; password channels require joining with the password; private channels require request-access + approval. ATTRIBUTION: by default the message is signed with the identity behind the API key \u2014 and a key belongs to a USER, so an agent runtime using its owner's key posts as the OWNER. Pass `agent` to sign as one of your own agents instead; the server verifies you own it and that it is in the channel. ENCRYPTION: this tool posts SERVER-READABLE plaintext base64 on EVERY access mode \u2014 private and password channels included; it is never end-to-end encrypted. Open channels: app clients CAN read toolkit-posted messages. Password/private channels: the mosadd.com app group-key-encrypts channel text on supported clients, but the toolkit does not hold that group key \u2014 the message still lands server-readable and app clients cannot decrypt it as channel text (group-key parity is not yet wired).",
|
|
1223
1246
|
inputSchema: mIRC_post_message_input,
|
|
1224
1247
|
handler: mIRC_post_message
|
|
1225
1248
|
},
|
|
@@ -2910,7 +2933,7 @@ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
|
2910
2933
|
// package.json
|
|
2911
2934
|
var package_default = {
|
|
2912
2935
|
name: "@mosadd/mcp",
|
|
2913
|
-
version: "3.0.0-alpha.
|
|
2936
|
+
version: "3.0.0-alpha.36",
|
|
2914
2937
|
mcpName: "io.github.hei33enberg/mosadd-mcp",
|
|
2915
2938
|
description: "Model Context Protocol server for mosadd. Exposes 4 modules (mDM, mIRC, mURL, mAYL) and capabilities (mTALK, mRAG) plus comms agent-actions \u2014 84 tools \u2014 to any agent runtime (Claude Code, Cursor, Windsurf, Cline, ChatGPT Apps, Lovable, Bolt, Goose, Manus, custom).",
|
|
2916
2939
|
homepage: "https://github.com/Hei33enberg/mosADD-OS/tree/main/packages/mcp",
|
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.37",
|
|
4
4
|
"mcpName": "io.github.hei33enberg/mosadd-mcp",
|
|
5
5
|
"description": "Model Context Protocol server for mosadd. Exposes 4 modules (mDM, mIRC, mURL, mAYL) and capabilities (mTALK, mRAG) plus comms agent-actions — 84 tools — to any agent runtime (Claude Code, Cursor, Windsurf, Cline, ChatGPT Apps, Lovable, Bolt, Goose, Manus, custom).",
|
|
6
6
|
"homepage": "https://github.com/Hei33enberg/mosADD-OS/tree/main/packages/mcp",
|
|
@@ -34,21 +34,14 @@
|
|
|
34
34
|
"publishConfig": {
|
|
35
35
|
"access": "public"
|
|
36
36
|
},
|
|
37
|
-
"scripts": {
|
|
38
|
-
"build": "tsup src/index.ts src/bin/mcp.ts src/bin/login.ts --format esm --dts --clean --shims",
|
|
39
|
-
"dev": "tsx src/bin/mcp.ts",
|
|
40
|
-
"test": "vitest run",
|
|
41
|
-
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
42
|
-
"clean": "rm -rf dist .turbo"
|
|
43
|
-
},
|
|
44
37
|
"dependencies": {
|
|
45
38
|
"@modelcontextprotocol/sdk": "^1.0.4",
|
|
46
|
-
"@mosadd/crypto": "workspace:*",
|
|
47
|
-
"@mosadd/protocol": "workspace:*",
|
|
48
|
-
"@mosadd/providers": "workspace:*",
|
|
49
|
-
"@mosadd/threat-engine": "workspace:*",
|
|
50
39
|
"@supabase/supabase-js": "^2.48.0",
|
|
51
|
-
"zod": "^4.3.6"
|
|
40
|
+
"zod": "^4.3.6",
|
|
41
|
+
"@mosadd/crypto": "3.0.0-alpha.27",
|
|
42
|
+
"@mosadd/providers": "3.0.0-alpha.27",
|
|
43
|
+
"@mosadd/threat-engine": "3.0.0-alpha.28",
|
|
44
|
+
"@mosadd/protocol": "3.0.0-alpha.28"
|
|
52
45
|
},
|
|
53
46
|
"devDependencies": {
|
|
54
47
|
"tsup": "^8.3.5",
|
|
@@ -69,5 +62,12 @@
|
|
|
69
62
|
],
|
|
70
63
|
"engines": {
|
|
71
64
|
"node": ">=18"
|
|
65
|
+
},
|
|
66
|
+
"scripts": {
|
|
67
|
+
"build": "tsup src/index.ts src/bin/mcp.ts src/bin/login.ts --format esm --dts --clean --shims",
|
|
68
|
+
"dev": "tsx src/bin/mcp.ts",
|
|
69
|
+
"test": "vitest run",
|
|
70
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
71
|
+
"clean": "rm -rf dist .turbo"
|
|
72
72
|
}
|
|
73
|
-
}
|
|
73
|
+
}
|
|
@@ -111,8 +111,10 @@ describe("golden path — host injects transport under mDM", () => {
|
|
|
111
111
|
expect(result.message_id).toBe("radio-1");
|
|
112
112
|
|
|
113
113
|
// The payload is opaque to the provider but carries our text under the hood.
|
|
114
|
-
|
|
115
|
-
|
|
114
|
+
// 2026-08-25: plaintext lane is RAW utf8 text (native app format), not a JSON
|
|
115
|
+
// envelope — packPlaintextPayload change, unpack tolerates both shapes.
|
|
116
|
+
const decoded = Buffer.from(radio.sent[0]!.payload).toString("utf8");
|
|
117
|
+
expect(decoded).toBe("rendezvous at grid 4471, 0600");
|
|
116
118
|
});
|
|
117
119
|
|
|
118
120
|
it("step 5: mDM_list round-trips the message back through the same provider", async () => {
|
|
@@ -85,11 +85,18 @@ export function getSupabase(env: SupabaseEnv = readSupabaseEnv()): SupabaseClien
|
|
|
85
85
|
autoRefreshToken: false,
|
|
86
86
|
detectSessionInUrl: false,
|
|
87
87
|
},
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
88
|
+
// ⛔ x-mosadd-origin: KAŻDE wywołanie z toolkitu/bramy MCP niesie ten znacznik (2026-08-25,
|
|
89
|
+
// rozkaz Króla „kradną tożsamości"). Sesje agentów wpinały klucz WŁAŚCICIELA i postowały na
|
|
90
|
+
// kanałach z jego dymka (SOVEREIGN) — serwer nie miał JAK odróżnić bramy od aplikacji, bo
|
|
91
|
+
// hub-key-exchange zwraca zwykły JWT usera. Ten nagłówek to rozróżnia: message-send odrzuca
|
|
92
|
+
// post na kanał z tożsamości CZŁOWIEKA, gdy przyszedł przez bramę — z komunikatem każącym
|
|
93
|
+
// wpiąć klucz SWOJEJ linii. Aplikacja mosadd.com nigdy nie wysyła tego nagłówka.
|
|
94
|
+
global: {
|
|
95
|
+
headers: {
|
|
96
|
+
...(env.userJwt ? { Authorization: `Bearer ${env.userJwt}` } : {}),
|
|
97
|
+
"x-mosadd-origin": "hub-gateway",
|
|
98
|
+
},
|
|
99
|
+
},
|
|
93
100
|
});
|
|
94
101
|
}
|
|
95
102
|
|
package/src/tools/mdm.ts
CHANGED
|
@@ -150,7 +150,9 @@ async function mDM_send(
|
|
|
150
150
|
const selfId = await dm.selfId();
|
|
151
151
|
const threadId = dmThreadId(selfId, input.to, input.thread_label);
|
|
152
152
|
|
|
153
|
-
|
|
153
|
+
// reply-linkage jedzie w dm.send({replyToId}) — surowy tekst nie ma koperty, w którą
|
|
154
|
+
// można by go wpakować (zmiana formatu 2026-08-25, patrz packPlaintextPayload).
|
|
155
|
+
const inner = packPlaintextPayload(input.text);
|
|
154
156
|
const sealed = await encryptForPeer(ctx.providers.keys, dm, input.to, inner);
|
|
155
157
|
|
|
156
158
|
ctx.log("debug", "mDM_send E2EE via DmProvider", { thread_id: threadId, bytes: sealed.byteLength });
|
|
@@ -187,7 +189,7 @@ async function mDM_send_unencrypted(
|
|
|
187
189
|
const dm = ctx.providers.dm;
|
|
188
190
|
const selfId = await dm.selfId();
|
|
189
191
|
const threadId = dmThreadId(selfId, input.to, input.thread_label);
|
|
190
|
-
const payload = packPlaintextPayload(input.text
|
|
192
|
+
const payload = packPlaintextPayload(input.text);
|
|
191
193
|
|
|
192
194
|
ctx.log("warn", "mDM_send_unencrypted (deprecated, plaintext) via DmProvider", {
|
|
193
195
|
thread_id: threadId,
|
|
@@ -24,6 +24,19 @@ const mIRC_post_message_input = z.object({
|
|
|
24
24
|
.string()
|
|
25
25
|
.optional()
|
|
26
26
|
.describe("Optional backing space id. Resolved automatically from the channel if omitted."),
|
|
27
|
+
agent: z
|
|
28
|
+
.string()
|
|
29
|
+
.max(200)
|
|
30
|
+
.optional()
|
|
31
|
+
.describe(
|
|
32
|
+
"Post AS ONE OF YOUR OWN AGENTS instead of as the key's owner — its mosADD address " +
|
|
33
|
+
"(marocain@mosadd.com), its identity id, or its display name. An API key is bound to a USER, " +
|
|
34
|
+
"so without this every message from an agent runtime is attributed to the owner: a whole fleet " +
|
|
35
|
+
"reporting in one channel shows up as one person. Same field name and same ownership rule as " +
|
|
36
|
+
"mDM_send_as_agent. The server verifies you OWN that agent and that it is an active member of " +
|
|
37
|
+
"the channel; naming an agent you do not own is refused, never silently downgraded to you. " +
|
|
38
|
+
"Omit it and attribution is unchanged.",
|
|
39
|
+
),
|
|
27
40
|
});
|
|
28
41
|
|
|
29
42
|
const mIRC_list_messages_input = z.object({
|
|
@@ -76,26 +89,39 @@ async function resolveLinkedSpaceId(channelId: string): Promise<string> {
|
|
|
76
89
|
return spaceId;
|
|
77
90
|
}
|
|
78
91
|
|
|
92
|
+
type SentAs = { identity_id: string; address: string | null; display_name: string | null };
|
|
93
|
+
|
|
79
94
|
async function mIRC_post_message(
|
|
80
95
|
input: z.infer<typeof mIRC_post_message_input>,
|
|
81
96
|
ctx: MosaddToolContext,
|
|
82
|
-
): Promise<{ message_id: string; delivered_at: string; thread_id: string }> {
|
|
97
|
+
): Promise<{ message_id: string; delivered_at: string; thread_id: string; sent_as?: SentAs }> {
|
|
83
98
|
readSupabaseEnv();
|
|
84
99
|
const space_id = input.space_id ?? (await resolveLinkedSpaceId(input.channel_id));
|
|
85
100
|
const thread_id = `chat:${input.channel_id}`;
|
|
86
|
-
ctx.log("debug", "mIRC_post_message", { thread_id, space_id });
|
|
101
|
+
ctx.log("debug", "mIRC_post_message", { thread_id, space_id, agent: input.agent });
|
|
87
102
|
|
|
88
|
-
const data = await invokeFunction<{ message?: { id: string; created_at: string } }>("message-send", {
|
|
103
|
+
const data = await invokeFunction<{ message?: { id: string; created_at: string }; sent_as?: SentAs }>("message-send", {
|
|
89
104
|
space_id,
|
|
90
105
|
thread_id,
|
|
91
106
|
encrypted_payload: packPlaintextPayload(input.text, input.reply_to_id),
|
|
92
107
|
message_type: "txt",
|
|
93
108
|
protocol_version: PROTOCOL_VERSION,
|
|
94
109
|
reply_to_id: input.reply_to_id ?? null,
|
|
110
|
+
// Attribution is decided SERVER-SIDE (message-send → _shared/ownedAgent.ts): you may sign only
|
|
111
|
+
// as an agent you own. Sent only when asked for, so the wire shape is unchanged for every
|
|
112
|
+
// existing caller — and an unresolvable agent comes back 403 rather than posting as the owner.
|
|
113
|
+
...(input.agent ? { agent: input.agent } : {}),
|
|
95
114
|
});
|
|
96
115
|
|
|
97
116
|
if (!data?.message?.id) throw new Error("message-send returned no message id");
|
|
98
|
-
return {
|
|
117
|
+
return {
|
|
118
|
+
message_id: data.message.id,
|
|
119
|
+
delivered_at: data.message.created_at ?? new Date().toISOString(),
|
|
120
|
+
thread_id,
|
|
121
|
+
// Echo back WHO the message was signed as, so a caller can verify the attribution landed
|
|
122
|
+
// instead of assuming it did.
|
|
123
|
+
...(data.sent_as ? { sent_as: data.sent_as } : {}),
|
|
124
|
+
};
|
|
99
125
|
}
|
|
100
126
|
|
|
101
127
|
async function mIRC_list_messages(
|
|
@@ -140,7 +166,7 @@ export const mircMessagesTools: MosaddTool[] = [
|
|
|
140
166
|
name: "mIRC_post_message",
|
|
141
167
|
requires: "network",
|
|
142
168
|
description:
|
|
143
|
-
"Post a text message into a persistent channel (mIRC). Pass channel_id from mIRC_create / mIRC_list; the backing space is resolved automatically. This is how an agent actually talks in a channel — the other mIRC_* tools only manage it. ACCESS: banned/blocked users are refused on ALL access modes (including open); open channels accept anyone not banned; password channels require joining with the password; private channels require request-access + approval. ENCRYPTION: this tool posts SERVER-READABLE plaintext base64 on EVERY access mode — private and password channels included; it is never end-to-end encrypted. Open channels: app clients CAN read toolkit-posted messages. Password/private channels: the mosadd.com app group-key-encrypts channel text on supported clients, but the toolkit does not hold that group key — the message still lands server-readable and app clients cannot decrypt it as channel text (group-key parity is not yet wired).",
|
|
169
|
+
"Post a text message into a persistent channel (mIRC). Pass channel_id from mIRC_create / mIRC_list; the backing space is resolved automatically. This is how an agent actually talks in a channel — the other mIRC_* tools only manage it. ACCESS: banned/blocked users are refused on ALL access modes (including open); open channels accept anyone not banned; password channels require joining with the password; private channels require request-access + approval. ATTRIBUTION: by default the message is signed with the identity behind the API key — and a key belongs to a USER, so an agent runtime using its owner's key posts as the OWNER. Pass `agent` to sign as one of your own agents instead; the server verifies you own it and that it is in the channel. ENCRYPTION: this tool posts SERVER-READABLE plaintext base64 on EVERY access mode — private and password channels included; it is never end-to-end encrypted. Open channels: app clients CAN read toolkit-posted messages. Password/private channels: the mosadd.com app group-key-encrypts channel text on supported clients, but the toolkit does not hold that group key — the message still lands server-readable and app clients cannot decrypt it as channel text (group-key parity is not yet wired).",
|
|
144
170
|
inputSchema: mIRC_post_message_input,
|
|
145
171
|
handler: mIRC_post_message as MosaddTool["handler"],
|
|
146
172
|
},
|