@socialproof/memory-mcp 0.1.1
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/README.md +189 -0
- package/dist/bin/memory-mcp.d.ts +2 -0
- package/dist/bin/memory-mcp.js +3 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +61 -0
- package/dist/credentials.d.ts +21 -0
- package/dist/credentials.js +157 -0
- package/dist/errors.d.ts +26 -0
- package/dist/errors.js +57 -0
- package/dist/hosted.d.ts +15 -0
- package/dist/hosted.js +108 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +20 -0
- package/dist/oauth.d.ts +25 -0
- package/dist/oauth.js +104 -0
- package/dist/provisioning.d.ts +19 -0
- package/dist/provisioning.js +70 -0
- package/dist/server.d.ts +3 -0
- package/dist/server.js +28 -0
- package/dist/signers.d.ts +119 -0
- package/dist/signers.js +323 -0
- package/dist/social-gateway.d.ts +195 -0
- package/dist/social-gateway.js +671 -0
- package/dist/tools.d.ts +29 -0
- package/dist/tools.js +1089 -0
- package/dist/version.d.ts +3 -0
- package/dist/version.js +12 -0
- package/package.json +42 -0
package/dist/tools.js
ADDED
|
@@ -0,0 +1,1089 @@
|
|
|
1
|
+
import { SOCIAL_ACTION_IDS } from "@socialproof/social";
|
|
2
|
+
import { McpRuntimeError, toStructuredMcpError } from "./errors.js";
|
|
3
|
+
export const TOOL_OAUTH_SCOPES = Object.freeze({
|
|
4
|
+
memory_remember: "memory:write",
|
|
5
|
+
memory_recall: "memory:read",
|
|
6
|
+
memory_health: "memory:read",
|
|
7
|
+
chain_get_action_status: "chain:read",
|
|
8
|
+
chain_list_actions: "chain:read",
|
|
9
|
+
social_create_post: "social:publish",
|
|
10
|
+
social_create_comment: "social:publish",
|
|
11
|
+
social_react_post: "social:write",
|
|
12
|
+
social_react_comment: "social:write",
|
|
13
|
+
social_create_repost: "social:publish",
|
|
14
|
+
social_remove_post_reaction: "social:write",
|
|
15
|
+
social_remove_comment_reaction: "social:write",
|
|
16
|
+
social_edit_post: "social:publish",
|
|
17
|
+
social_edit_comment: "social:publish",
|
|
18
|
+
social_remove_repost: "social:publish",
|
|
19
|
+
social_follow_profile: "social:write",
|
|
20
|
+
social_unfollow_profile: "social:write",
|
|
21
|
+
social_block_profile: "social:write",
|
|
22
|
+
social_unblock_profile: "social:write",
|
|
23
|
+
messaging_send_message: "social:write",
|
|
24
|
+
messaging_create_group: "social:write",
|
|
25
|
+
messaging_list_inbox: "messaging:read",
|
|
26
|
+
messaging_wait_for_message: "messaging:read",
|
|
27
|
+
organization_get_control: "organization:read",
|
|
28
|
+
organization_create: "organization:admin",
|
|
29
|
+
organization_update_metadata: "organization:admin",
|
|
30
|
+
organization_update_category: "organization:admin",
|
|
31
|
+
organization_deactivate: "organization:admin",
|
|
32
|
+
organization_ensure_memory_group: "organization:admin",
|
|
33
|
+
organization_define_role: "organization:admin",
|
|
34
|
+
organization_assign_role: "organization:admin",
|
|
35
|
+
organization_revoke_role: "organization:admin",
|
|
36
|
+
organization_create_invitation: "organization:admin",
|
|
37
|
+
organization_accept_invitation: "organization:admin",
|
|
38
|
+
organization_decline_invitation: "organization:admin",
|
|
39
|
+
agent_provision_signer: "agent:provision",
|
|
40
|
+
agent_register_root: "organization:admin",
|
|
41
|
+
agent_register_child: "organization:admin",
|
|
42
|
+
agent_update_child: "organization:admin",
|
|
43
|
+
agent_deactivate_child: "organization:admin",
|
|
44
|
+
agent_revoke_child: "organization:admin",
|
|
45
|
+
social_delete_post: "social:destructive",
|
|
46
|
+
social_delete_comment: "social:destructive",
|
|
47
|
+
chain_request_action_approval: "social:write",
|
|
48
|
+
chain_approve_action: "social:approve",
|
|
49
|
+
chain_prepare_approved_action: "social:approve",
|
|
50
|
+
chain_submit_approved_action: "social:approve",
|
|
51
|
+
});
|
|
52
|
+
const OUTPUT_SCHEMA = {
|
|
53
|
+
type: "object",
|
|
54
|
+
properties: {
|
|
55
|
+
ok: { type: "boolean" },
|
|
56
|
+
data: {},
|
|
57
|
+
error: {
|
|
58
|
+
type: "object",
|
|
59
|
+
properties: {
|
|
60
|
+
code: { type: "string" },
|
|
61
|
+
message: { type: "string" },
|
|
62
|
+
retryable: { type: "boolean" },
|
|
63
|
+
approvalRequired: { type: "boolean" },
|
|
64
|
+
actionId: { type: "string" },
|
|
65
|
+
digest: { type: "string" },
|
|
66
|
+
},
|
|
67
|
+
required: ["code", "message", "retryable", "approvalRequired"],
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
required: ["ok"],
|
|
71
|
+
};
|
|
72
|
+
function annotations(title, options) {
|
|
73
|
+
return {
|
|
74
|
+
title,
|
|
75
|
+
readOnlyHint: options.readOnly,
|
|
76
|
+
destructiveHint: options.destructive,
|
|
77
|
+
idempotentHint: options.idempotent,
|
|
78
|
+
openWorldHint: options.openWorld ?? true,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
const MEMORY_TOOLS = [
|
|
82
|
+
{
|
|
83
|
+
name: "memory_remember",
|
|
84
|
+
description: "Store text in encrypted agent memory and wait for the asynchronous job to finish.",
|
|
85
|
+
inputSchema: {
|
|
86
|
+
type: "object",
|
|
87
|
+
properties: {
|
|
88
|
+
text: { type: "string", minLength: 1 },
|
|
89
|
+
subLabel: { type: "string", minLength: 1 },
|
|
90
|
+
},
|
|
91
|
+
required: ["text"],
|
|
92
|
+
additionalProperties: false,
|
|
93
|
+
},
|
|
94
|
+
outputSchema: OUTPUT_SCHEMA,
|
|
95
|
+
annotations: annotations("Remember encrypted text", {
|
|
96
|
+
readOnly: false,
|
|
97
|
+
destructive: false,
|
|
98
|
+
idempotent: false,
|
|
99
|
+
}),
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
name: "memory_recall",
|
|
103
|
+
description: "Run semantic recall against the authenticated agent's encrypted memory.",
|
|
104
|
+
inputSchema: {
|
|
105
|
+
type: "object",
|
|
106
|
+
properties: {
|
|
107
|
+
query: { type: "string", minLength: 1 },
|
|
108
|
+
limit: { type: "integer", minimum: 1, maximum: 100 },
|
|
109
|
+
},
|
|
110
|
+
required: ["query"],
|
|
111
|
+
additionalProperties: false,
|
|
112
|
+
},
|
|
113
|
+
outputSchema: OUTPUT_SCHEMA,
|
|
114
|
+
annotations: annotations("Recall encrypted memory", {
|
|
115
|
+
readOnly: true,
|
|
116
|
+
destructive: false,
|
|
117
|
+
idempotent: true,
|
|
118
|
+
}),
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
name: "memory_health",
|
|
122
|
+
description: "Check memory relayer health.",
|
|
123
|
+
inputSchema: { type: "object", properties: {}, additionalProperties: false },
|
|
124
|
+
outputSchema: OUTPUT_SCHEMA,
|
|
125
|
+
annotations: annotations("Check memory health", {
|
|
126
|
+
readOnly: true,
|
|
127
|
+
destructive: false,
|
|
128
|
+
idempotent: true,
|
|
129
|
+
}),
|
|
130
|
+
},
|
|
131
|
+
];
|
|
132
|
+
const ID_KEY = { type: "string", minLength: 8, maxLength: 128 };
|
|
133
|
+
const ID_STRING = { type: "string", minLength: 1 };
|
|
134
|
+
const DECIMAL_STRING = { type: "string", pattern: "^(0|[1-9][0-9]{0,19})$" };
|
|
135
|
+
const U8_INTEGER = { type: "integer", minimum: 0, maximum: 255 };
|
|
136
|
+
const ORG_TYPE_INTEGER = { type: "integer", minimum: 0, maximum: 13 };
|
|
137
|
+
const AGENT_POLICY_TOOL_PROPERTIES = {
|
|
138
|
+
publicKeyHex: { type: "string", pattern: "^[0-9a-f]{64}$" },
|
|
139
|
+
derivedAddress: ID_STRING,
|
|
140
|
+
label: ID_STRING,
|
|
141
|
+
identityClass: U8_INTEGER,
|
|
142
|
+
roleTags: DECIMAL_STRING,
|
|
143
|
+
capabilities: DECIMAL_STRING,
|
|
144
|
+
delegatableCaps: DECIMAL_STRING,
|
|
145
|
+
registerScope: U8_INTEGER,
|
|
146
|
+
approvalRequiredCaps: DECIMAL_STRING,
|
|
147
|
+
maxActionSpendMist: DECIMAL_STRING,
|
|
148
|
+
platformScope: ID_STRING,
|
|
149
|
+
expiresAtMs: DECIMAL_STRING,
|
|
150
|
+
};
|
|
151
|
+
const ADDITIONAL_TIER_1_TOOLS = [
|
|
152
|
+
["social_remove_post_reaction", "Remove post reaction", { postId: ID_STRING }],
|
|
153
|
+
["social_remove_comment_reaction", "Remove comment reaction", { commentId: ID_STRING }],
|
|
154
|
+
["social_edit_post", "Edit social post", {
|
|
155
|
+
postId: ID_STRING,
|
|
156
|
+
content: ID_STRING,
|
|
157
|
+
mediaUrls: { type: "array", items: ID_STRING },
|
|
158
|
+
mentions: { type: "array", items: ID_STRING },
|
|
159
|
+
metadataJson: { type: "string" },
|
|
160
|
+
}],
|
|
161
|
+
["social_edit_comment", "Edit social comment", {
|
|
162
|
+
commentId: ID_STRING,
|
|
163
|
+
content: ID_STRING,
|
|
164
|
+
mentions: { type: "array", items: ID_STRING },
|
|
165
|
+
}],
|
|
166
|
+
["social_remove_repost", "Remove social repost", {
|
|
167
|
+
originalPostId: ID_STRING,
|
|
168
|
+
repostId: ID_STRING,
|
|
169
|
+
}],
|
|
170
|
+
["social_follow_profile", "Follow profile", { targetOwner: ID_STRING }],
|
|
171
|
+
["social_unfollow_profile", "Unfollow profile", { targetOwner: ID_STRING }],
|
|
172
|
+
["social_block_profile", "Block profile", { targetOwner: ID_STRING }],
|
|
173
|
+
["social_unblock_profile", "Unblock profile", { targetOwner: ID_STRING }],
|
|
174
|
+
["messaging_send_message", "Send encrypted message", {
|
|
175
|
+
groupId: ID_STRING,
|
|
176
|
+
messageLogId: ID_STRING,
|
|
177
|
+
recipient: ID_STRING,
|
|
178
|
+
contentDigestHex: ID_STRING,
|
|
179
|
+
contentUri: ID_STRING,
|
|
180
|
+
dedupeKey: ID_STRING,
|
|
181
|
+
nonce: ID_STRING,
|
|
182
|
+
}],
|
|
183
|
+
].map(([name, title, actionProperties]) => {
|
|
184
|
+
const properties = { ...actionProperties, idempotencyKey: ID_KEY };
|
|
185
|
+
return {
|
|
186
|
+
name: name,
|
|
187
|
+
description: `${title} through the capability-authorized production registry.`,
|
|
188
|
+
inputSchema: {
|
|
189
|
+
type: "object",
|
|
190
|
+
properties,
|
|
191
|
+
required: [...Object.keys(actionProperties).filter((key) => !["mediaUrls", "mentions", "metadataJson"].includes(key)), "idempotencyKey"],
|
|
192
|
+
additionalProperties: false,
|
|
193
|
+
},
|
|
194
|
+
outputSchema: OUTPUT_SCHEMA,
|
|
195
|
+
annotations: annotations(title, {
|
|
196
|
+
readOnly: false,
|
|
197
|
+
destructive: false,
|
|
198
|
+
idempotent: true,
|
|
199
|
+
}),
|
|
200
|
+
};
|
|
201
|
+
});
|
|
202
|
+
const OWNER_APPROVAL_TOOL_DEFINITIONS = [
|
|
203
|
+
{
|
|
204
|
+
toolName: "organization_create",
|
|
205
|
+
title: "Create organization",
|
|
206
|
+
registryAction: "organization.create.v1",
|
|
207
|
+
properties: { orgType: ORG_TYPE_INTEGER, name: { type: "string" }, description: { type: "string" } },
|
|
208
|
+
required: ["orgType"],
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
toolName: "organization_update_metadata",
|
|
212
|
+
title: "Update organization metadata",
|
|
213
|
+
registryAction: "organization.update_metadata.v1",
|
|
214
|
+
properties: { organizationId: ID_STRING, name: { type: "string" }, description: { type: "string" } },
|
|
215
|
+
required: ["organizationId"],
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
toolName: "organization_update_category",
|
|
219
|
+
title: "Update organization category",
|
|
220
|
+
registryAction: "organization.update_category.v1",
|
|
221
|
+
properties: { organizationId: ID_STRING, orgType: ORG_TYPE_INTEGER },
|
|
222
|
+
required: ["organizationId", "orgType"],
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
toolName: "organization_deactivate",
|
|
226
|
+
title: "Deactivate organization",
|
|
227
|
+
registryAction: "organization.deactivate.v1",
|
|
228
|
+
properties: { organizationId: ID_STRING },
|
|
229
|
+
required: ["organizationId"],
|
|
230
|
+
destructive: true,
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
toolName: "organization_ensure_memory_group",
|
|
234
|
+
title: "Create organization memory group",
|
|
235
|
+
registryAction: "organization.ensure_memory_group.v1",
|
|
236
|
+
properties: { organizationId: ID_STRING },
|
|
237
|
+
required: ["organizationId"],
|
|
238
|
+
},
|
|
239
|
+
{
|
|
240
|
+
toolName: "organization_define_role",
|
|
241
|
+
title: "Define organization role",
|
|
242
|
+
registryAction: "organization.define_role.v1",
|
|
243
|
+
properties: {
|
|
244
|
+
organizationId: ID_STRING,
|
|
245
|
+
orgMemoryGroupId: ID_STRING,
|
|
246
|
+
roleName: ID_STRING,
|
|
247
|
+
permissionsMask: DECIMAL_STRING,
|
|
248
|
+
},
|
|
249
|
+
required: ["organizationId", "orgMemoryGroupId", "roleName", "permissionsMask"],
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
toolName: "organization_assign_role",
|
|
253
|
+
title: "Assign organization role",
|
|
254
|
+
registryAction: "organization.assign_role.v1",
|
|
255
|
+
properties: {
|
|
256
|
+
organizationId: ID_STRING,
|
|
257
|
+
orgMemoryGroupId: ID_STRING,
|
|
258
|
+
memberAddress: ID_STRING,
|
|
259
|
+
roleName: ID_STRING,
|
|
260
|
+
},
|
|
261
|
+
required: ["organizationId", "orgMemoryGroupId", "memberAddress", "roleName"],
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
toolName: "organization_revoke_role",
|
|
265
|
+
title: "Revoke organization role",
|
|
266
|
+
registryAction: "organization.revoke_role.v1",
|
|
267
|
+
properties: {
|
|
268
|
+
organizationId: ID_STRING,
|
|
269
|
+
orgMemoryGroupId: ID_STRING,
|
|
270
|
+
memberAddress: ID_STRING,
|
|
271
|
+
roleName: ID_STRING,
|
|
272
|
+
},
|
|
273
|
+
required: ["organizationId", "orgMemoryGroupId", "memberAddress", "roleName"],
|
|
274
|
+
destructive: true,
|
|
275
|
+
},
|
|
276
|
+
{
|
|
277
|
+
toolName: "organization_create_invitation",
|
|
278
|
+
title: "Create organization invitation",
|
|
279
|
+
registryAction: "organization.create_invitation.v1",
|
|
280
|
+
properties: {
|
|
281
|
+
organizationId: ID_STRING,
|
|
282
|
+
orgMemoryGroupId: ID_STRING,
|
|
283
|
+
invitee: ID_STRING,
|
|
284
|
+
roleName: { type: "string" },
|
|
285
|
+
permissionsMask: DECIMAL_STRING,
|
|
286
|
+
expiresAtMs: DECIMAL_STRING,
|
|
287
|
+
},
|
|
288
|
+
required: ["organizationId", "orgMemoryGroupId", "invitee", "permissionsMask"],
|
|
289
|
+
},
|
|
290
|
+
{
|
|
291
|
+
toolName: "agent_register_root",
|
|
292
|
+
title: "Register organization root agent",
|
|
293
|
+
registryAction: "agent.register_agent.v1",
|
|
294
|
+
properties: { organizationId: ID_STRING, ...AGENT_POLICY_TOOL_PROPERTIES },
|
|
295
|
+
required: ["organizationId", "publicKeyHex", "derivedAddress", "label"],
|
|
296
|
+
},
|
|
297
|
+
];
|
|
298
|
+
const OWNER_APPROVAL_ACTION_BY_TOOL = new Map(OWNER_APPROVAL_TOOL_DEFINITIONS.map((definition) => [definition.toolName, definition]));
|
|
299
|
+
const OWNER_APPROVAL_TOOLS = OWNER_APPROVAL_TOOL_DEFINITIONS.map((definition) => ({
|
|
300
|
+
name: definition.toolName,
|
|
301
|
+
description: `${definition.title}. Returns an exact-input approval intent that the account owner must sign before preparation and submission.`,
|
|
302
|
+
inputSchema: {
|
|
303
|
+
type: "object",
|
|
304
|
+
properties: {
|
|
305
|
+
...definition.properties,
|
|
306
|
+
idempotencyKey: ID_KEY,
|
|
307
|
+
expiresInSeconds: { type: "integer", minimum: 60, maximum: 900 },
|
|
308
|
+
},
|
|
309
|
+
required: [...definition.required, "idempotencyKey"],
|
|
310
|
+
additionalProperties: false,
|
|
311
|
+
},
|
|
312
|
+
outputSchema: OUTPUT_SCHEMA,
|
|
313
|
+
annotations: annotations(definition.title, {
|
|
314
|
+
readOnly: false,
|
|
315
|
+
destructive: definition.destructive ?? false,
|
|
316
|
+
idempotent: true,
|
|
317
|
+
}),
|
|
318
|
+
}));
|
|
319
|
+
const ORGANIZATION_AND_MESSAGING_TOOLS = [
|
|
320
|
+
{
|
|
321
|
+
name: "organization_get_control",
|
|
322
|
+
description: "Read the indexed organization, agents, roles, assignments, invitations, and messaging groups for the authenticated principal.",
|
|
323
|
+
inputSchema: {
|
|
324
|
+
type: "object",
|
|
325
|
+
properties: { organizationId: ID_STRING },
|
|
326
|
+
required: ["organizationId"],
|
|
327
|
+
additionalProperties: false,
|
|
328
|
+
},
|
|
329
|
+
outputSchema: OUTPUT_SCHEMA,
|
|
330
|
+
annotations: annotations("Read organization control state", {
|
|
331
|
+
readOnly: true, destructive: false, idempotent: true,
|
|
332
|
+
}),
|
|
333
|
+
},
|
|
334
|
+
{
|
|
335
|
+
name: "agent_provision_signer",
|
|
336
|
+
description: "Generate a new agent Ed25519 signer in the configured Keychain or KMS without returning private key material.",
|
|
337
|
+
inputSchema: {
|
|
338
|
+
type: "object",
|
|
339
|
+
properties: { label: { type: "string", minLength: 1, maxLength: 64 } },
|
|
340
|
+
required: ["label"],
|
|
341
|
+
additionalProperties: false,
|
|
342
|
+
},
|
|
343
|
+
outputSchema: OUTPUT_SCHEMA,
|
|
344
|
+
annotations: annotations("Provision agent signer", {
|
|
345
|
+
readOnly: false, destructive: false, idempotent: false,
|
|
346
|
+
}),
|
|
347
|
+
},
|
|
348
|
+
{
|
|
349
|
+
name: "messaging_create_group",
|
|
350
|
+
description: "Create an encrypted messaging group for the authenticated agent and human or agent peers.",
|
|
351
|
+
inputSchema: {
|
|
352
|
+
type: "object",
|
|
353
|
+
properties: {
|
|
354
|
+
name: ID_STRING,
|
|
355
|
+
uuid: ID_STRING,
|
|
356
|
+
encryptedDekHex: ID_STRING,
|
|
357
|
+
initialMembers: { type: "array", items: ID_STRING, minItems: 1, maxItems: 32 },
|
|
358
|
+
crossPrincipalPeerAccountId: ID_STRING,
|
|
359
|
+
idempotencyKey: ID_KEY,
|
|
360
|
+
},
|
|
361
|
+
required: ["name", "uuid", "encryptedDekHex", "initialMembers", "idempotencyKey"],
|
|
362
|
+
additionalProperties: false,
|
|
363
|
+
},
|
|
364
|
+
outputSchema: OUTPUT_SCHEMA,
|
|
365
|
+
annotations: annotations("Create messaging group", {
|
|
366
|
+
readOnly: false, destructive: false, idempotent: true,
|
|
367
|
+
}),
|
|
368
|
+
},
|
|
369
|
+
{
|
|
370
|
+
name: "messaging_list_inbox",
|
|
371
|
+
description: "List incoming encrypted message pointers for the authenticated agent.",
|
|
372
|
+
inputSchema: {
|
|
373
|
+
type: "object",
|
|
374
|
+
properties: {
|
|
375
|
+
limit: { type: "integer", minimum: 1, maximum: 100 },
|
|
376
|
+
offset: { type: "integer", minimum: 0 },
|
|
377
|
+
groupId: ID_STRING,
|
|
378
|
+
afterCreatedAtMs: { type: "integer", minimum: 0 },
|
|
379
|
+
afterSeq: { type: "integer", minimum: 0 },
|
|
380
|
+
},
|
|
381
|
+
additionalProperties: false,
|
|
382
|
+
},
|
|
383
|
+
outputSchema: OUTPUT_SCHEMA,
|
|
384
|
+
annotations: annotations("List agent inbox", {
|
|
385
|
+
readOnly: true, destructive: false, idempotent: true,
|
|
386
|
+
}),
|
|
387
|
+
},
|
|
388
|
+
{
|
|
389
|
+
name: "messaging_wait_for_message",
|
|
390
|
+
description: "Wait up to 20 seconds for a new incoming encrypted message pointer; use repeatedly for an agent response loop.",
|
|
391
|
+
inputSchema: {
|
|
392
|
+
type: "object",
|
|
393
|
+
properties: {
|
|
394
|
+
timeoutMs: { type: "integer", minimum: 250, maximum: 20000 },
|
|
395
|
+
groupId: ID_STRING,
|
|
396
|
+
afterCreatedAtMs: { type: "integer", minimum: 0 },
|
|
397
|
+
afterSeq: { type: "integer", minimum: 0 },
|
|
398
|
+
},
|
|
399
|
+
additionalProperties: false,
|
|
400
|
+
},
|
|
401
|
+
outputSchema: OUTPUT_SCHEMA,
|
|
402
|
+
annotations: annotations("Wait for agent message", {
|
|
403
|
+
readOnly: true, destructive: false, idempotent: true,
|
|
404
|
+
}),
|
|
405
|
+
},
|
|
406
|
+
...[
|
|
407
|
+
["organization_accept_invitation", "Accept organization invitation"],
|
|
408
|
+
["organization_decline_invitation", "Decline organization invitation"],
|
|
409
|
+
].map(([name, title]) => ({
|
|
410
|
+
name,
|
|
411
|
+
description: `${title} addressed to the authenticated agent.`,
|
|
412
|
+
inputSchema: {
|
|
413
|
+
type: "object",
|
|
414
|
+
properties: {
|
|
415
|
+
organizationAccountId: ID_STRING,
|
|
416
|
+
organizationId: ID_STRING,
|
|
417
|
+
orgMemoryGroupId: ID_STRING,
|
|
418
|
+
invitee: ID_STRING,
|
|
419
|
+
idempotencyKey: ID_KEY,
|
|
420
|
+
},
|
|
421
|
+
required: name === "organization_accept_invitation"
|
|
422
|
+
? ["organizationAccountId", "organizationId", "orgMemoryGroupId", "invitee", "idempotencyKey"]
|
|
423
|
+
: ["organizationAccountId", "organizationId", "invitee", "idempotencyKey"],
|
|
424
|
+
additionalProperties: false,
|
|
425
|
+
},
|
|
426
|
+
outputSchema: OUTPUT_SCHEMA,
|
|
427
|
+
annotations: annotations(title, {
|
|
428
|
+
readOnly: false, destructive: name === "organization_decline_invitation", idempotent: true,
|
|
429
|
+
}),
|
|
430
|
+
})),
|
|
431
|
+
{
|
|
432
|
+
name: "agent_register_child",
|
|
433
|
+
description: "Register a bounded child or peer agent beneath the authenticated agent.",
|
|
434
|
+
inputSchema: {
|
|
435
|
+
type: "object",
|
|
436
|
+
properties: {
|
|
437
|
+
registerRelation: U8_INTEGER,
|
|
438
|
+
...AGENT_POLICY_TOOL_PROPERTIES,
|
|
439
|
+
idempotencyKey: ID_KEY,
|
|
440
|
+
},
|
|
441
|
+
required: ["registerRelation", "publicKeyHex", "derivedAddress", "label", "idempotencyKey"],
|
|
442
|
+
additionalProperties: false,
|
|
443
|
+
},
|
|
444
|
+
outputSchema: OUTPUT_SCHEMA,
|
|
445
|
+
annotations: annotations("Register child agent", {
|
|
446
|
+
readOnly: false, destructive: false, idempotent: true,
|
|
447
|
+
}),
|
|
448
|
+
},
|
|
449
|
+
{
|
|
450
|
+
name: "agent_update_child",
|
|
451
|
+
description: "Update a managed descendant agent within on-chain non-escalation constraints.",
|
|
452
|
+
inputSchema: {
|
|
453
|
+
type: "object",
|
|
454
|
+
properties: {
|
|
455
|
+
agentObjectId: ID_STRING,
|
|
456
|
+
identityClass: U8_INTEGER,
|
|
457
|
+
roleTags: DECIMAL_STRING,
|
|
458
|
+
capabilities: DECIMAL_STRING,
|
|
459
|
+
delegatableCaps: DECIMAL_STRING,
|
|
460
|
+
registerScope: U8_INTEGER,
|
|
461
|
+
approvalRequiredCaps: DECIMAL_STRING,
|
|
462
|
+
maxActionSpendMist: DECIMAL_STRING,
|
|
463
|
+
platformScope: ID_STRING,
|
|
464
|
+
expiresAtMs: DECIMAL_STRING,
|
|
465
|
+
idempotencyKey: ID_KEY,
|
|
466
|
+
},
|
|
467
|
+
required: ["agentObjectId", "identityClass", "roleTags", "capabilities", "delegatableCaps", "registerScope", "approvalRequiredCaps", "idempotencyKey"],
|
|
468
|
+
additionalProperties: false,
|
|
469
|
+
},
|
|
470
|
+
outputSchema: OUTPUT_SCHEMA,
|
|
471
|
+
annotations: annotations("Update child agent", {
|
|
472
|
+
readOnly: false, destructive: false, idempotent: true,
|
|
473
|
+
}),
|
|
474
|
+
},
|
|
475
|
+
...[
|
|
476
|
+
["agent_deactivate_child", "Deactivate child agent"],
|
|
477
|
+
["agent_revoke_child", "Revoke child agent"],
|
|
478
|
+
].map(([name, title]) => ({
|
|
479
|
+
name,
|
|
480
|
+
description: `${title} within the authenticated agent's on-chain management scope.`,
|
|
481
|
+
inputSchema: {
|
|
482
|
+
type: "object",
|
|
483
|
+
properties: { agentObjectId: ID_STRING, idempotencyKey: ID_KEY },
|
|
484
|
+
required: ["agentObjectId", "idempotencyKey"],
|
|
485
|
+
additionalProperties: false,
|
|
486
|
+
},
|
|
487
|
+
outputSchema: OUTPUT_SCHEMA,
|
|
488
|
+
annotations: annotations(title, {
|
|
489
|
+
readOnly: false, destructive: true, idempotent: true,
|
|
490
|
+
}),
|
|
491
|
+
})),
|
|
492
|
+
];
|
|
493
|
+
const SOCIAL_TOOLS = [
|
|
494
|
+
{
|
|
495
|
+
name: "chain_list_actions",
|
|
496
|
+
description: "List the versioned production action catalog with tier, approval policy, implementation status, blockers, and permissions for this authenticated agent.",
|
|
497
|
+
inputSchema: { type: "object", properties: {}, additionalProperties: false },
|
|
498
|
+
outputSchema: OUTPUT_SCHEMA,
|
|
499
|
+
annotations: annotations("List available blockchain actions", {
|
|
500
|
+
readOnly: true,
|
|
501
|
+
destructive: false,
|
|
502
|
+
idempotent: true,
|
|
503
|
+
}),
|
|
504
|
+
},
|
|
505
|
+
...ADDITIONAL_TIER_1_TOOLS,
|
|
506
|
+
...OWNER_APPROVAL_TOOLS,
|
|
507
|
+
...ORGANIZATION_AND_MESSAGING_TOOLS,
|
|
508
|
+
{
|
|
509
|
+
name: "chain_request_action_approval",
|
|
510
|
+
description: "Create an exact-input owner approval request for a registered action.",
|
|
511
|
+
inputSchema: {
|
|
512
|
+
type: "object",
|
|
513
|
+
properties: {
|
|
514
|
+
registryAction: { type: "string", enum: [...SOCIAL_ACTION_IDS] },
|
|
515
|
+
parameters: { type: "object" },
|
|
516
|
+
idempotencyKey: { type: "string", minLength: 8, maxLength: 128 },
|
|
517
|
+
expiresInSeconds: { type: "integer", minimum: 60, maximum: 900 },
|
|
518
|
+
},
|
|
519
|
+
required: ["registryAction", "parameters", "idempotencyKey"],
|
|
520
|
+
additionalProperties: false,
|
|
521
|
+
},
|
|
522
|
+
outputSchema: OUTPUT_SCHEMA,
|
|
523
|
+
annotations: annotations("Request owner action approval", {
|
|
524
|
+
readOnly: false, destructive: false, idempotent: true,
|
|
525
|
+
}),
|
|
526
|
+
},
|
|
527
|
+
{
|
|
528
|
+
name: "chain_approve_action",
|
|
529
|
+
description: "Submit an owner wallet signature over a previously returned approval intent.",
|
|
530
|
+
inputSchema: {
|
|
531
|
+
type: "object",
|
|
532
|
+
properties: {
|
|
533
|
+
approvalId: { type: "string", minLength: 36, maxLength: 36 },
|
|
534
|
+
walletSignature: { type: "string", minLength: 80, maxLength: 4096 },
|
|
535
|
+
},
|
|
536
|
+
required: ["approvalId", "walletSignature"],
|
|
537
|
+
additionalProperties: false,
|
|
538
|
+
},
|
|
539
|
+
outputSchema: OUTPUT_SCHEMA,
|
|
540
|
+
annotations: annotations("Approve registered action", {
|
|
541
|
+
readOnly: false, destructive: false, idempotent: true,
|
|
542
|
+
}),
|
|
543
|
+
},
|
|
544
|
+
{
|
|
545
|
+
name: "chain_prepare_approved_action",
|
|
546
|
+
description: "Prepare, sponsor, and simulate an owner-approved registry action; returns bytes for wallet signing.",
|
|
547
|
+
inputSchema: {
|
|
548
|
+
type: "object",
|
|
549
|
+
properties: {
|
|
550
|
+
registryAction: { type: "string", enum: [...SOCIAL_ACTION_IDS] },
|
|
551
|
+
parameters: { type: "object" },
|
|
552
|
+
idempotencyKey: { type: "string", minLength: 8, maxLength: 128 },
|
|
553
|
+
approvalId: { type: "string", minLength: 36, maxLength: 36 },
|
|
554
|
+
},
|
|
555
|
+
required: ["registryAction", "parameters", "idempotencyKey", "approvalId"],
|
|
556
|
+
additionalProperties: false,
|
|
557
|
+
},
|
|
558
|
+
outputSchema: OUTPUT_SCHEMA,
|
|
559
|
+
annotations: annotations("Prepare owner-approved action", {
|
|
560
|
+
readOnly: false, destructive: true, idempotent: true,
|
|
561
|
+
}),
|
|
562
|
+
},
|
|
563
|
+
{
|
|
564
|
+
name: "chain_submit_approved_action",
|
|
565
|
+
description: "Submit the owner wallet signature for the exact sponsored transaction returned by preparation.",
|
|
566
|
+
inputSchema: {
|
|
567
|
+
type: "object",
|
|
568
|
+
properties: {
|
|
569
|
+
registryAction: { type: "string", enum: [...SOCIAL_ACTION_IDS] },
|
|
570
|
+
idempotencyKey: { type: "string", minLength: 8, maxLength: 128 },
|
|
571
|
+
approvalId: { type: "string", minLength: 36, maxLength: 36 },
|
|
572
|
+
digest: { type: "string", minLength: 43, maxLength: 44 },
|
|
573
|
+
walletSignature: { type: "string", minLength: 1 },
|
|
574
|
+
},
|
|
575
|
+
required: ["registryAction", "idempotencyKey", "approvalId", "digest", "walletSignature"],
|
|
576
|
+
additionalProperties: false,
|
|
577
|
+
},
|
|
578
|
+
outputSchema: OUTPUT_SCHEMA,
|
|
579
|
+
annotations: annotations("Submit owner-approved action", {
|
|
580
|
+
readOnly: false, destructive: true, idempotent: true,
|
|
581
|
+
}),
|
|
582
|
+
},
|
|
583
|
+
{
|
|
584
|
+
name: "chain_get_action_status",
|
|
585
|
+
description: "Read transaction finality from chain RPC and optional indexed enrichment.",
|
|
586
|
+
inputSchema: {
|
|
587
|
+
type: "object",
|
|
588
|
+
properties: { digest: { type: "string", minLength: 43, maxLength: 44 } },
|
|
589
|
+
required: ["digest"],
|
|
590
|
+
additionalProperties: false,
|
|
591
|
+
},
|
|
592
|
+
outputSchema: OUTPUT_SCHEMA,
|
|
593
|
+
annotations: annotations("Get blockchain action status", {
|
|
594
|
+
readOnly: true,
|
|
595
|
+
destructive: false,
|
|
596
|
+
idempotent: true,
|
|
597
|
+
}),
|
|
598
|
+
},
|
|
599
|
+
{
|
|
600
|
+
name: "social_create_post",
|
|
601
|
+
description: "Publish a post on MySocial. Requires CAP_POST_PUBLISH and platform scope.",
|
|
602
|
+
inputSchema: {
|
|
603
|
+
type: "object",
|
|
604
|
+
properties: {
|
|
605
|
+
content: { type: "string", minLength: 1 },
|
|
606
|
+
idempotencyKey: { type: "string", minLength: 8, maxLength: 128 },
|
|
607
|
+
},
|
|
608
|
+
required: ["content", "idempotencyKey"],
|
|
609
|
+
additionalProperties: false,
|
|
610
|
+
},
|
|
611
|
+
outputSchema: OUTPUT_SCHEMA,
|
|
612
|
+
annotations: annotations("Publish social post", {
|
|
613
|
+
readOnly: false,
|
|
614
|
+
destructive: false,
|
|
615
|
+
idempotent: true,
|
|
616
|
+
}),
|
|
617
|
+
},
|
|
618
|
+
{
|
|
619
|
+
name: "social_create_comment",
|
|
620
|
+
description: "Comment on a post. Requires CAP_COMMENT and platform scope.",
|
|
621
|
+
inputSchema: {
|
|
622
|
+
type: "object",
|
|
623
|
+
properties: {
|
|
624
|
+
postId: { type: "string", minLength: 1 },
|
|
625
|
+
content: { type: "string", minLength: 1 },
|
|
626
|
+
parentCommentId: { type: "string", minLength: 1 },
|
|
627
|
+
idempotencyKey: { type: "string", minLength: 8, maxLength: 128 },
|
|
628
|
+
},
|
|
629
|
+
required: ["postId", "content", "idempotencyKey"],
|
|
630
|
+
additionalProperties: false,
|
|
631
|
+
},
|
|
632
|
+
outputSchema: OUTPUT_SCHEMA,
|
|
633
|
+
annotations: annotations("Create social comment", {
|
|
634
|
+
readOnly: false,
|
|
635
|
+
destructive: false,
|
|
636
|
+
idempotent: true,
|
|
637
|
+
}),
|
|
638
|
+
},
|
|
639
|
+
{
|
|
640
|
+
name: "social_react_post",
|
|
641
|
+
description: "React to a post. Requires CAP_REACT and platform scope.",
|
|
642
|
+
inputSchema: {
|
|
643
|
+
type: "object",
|
|
644
|
+
properties: {
|
|
645
|
+
postId: { type: "string", minLength: 1 },
|
|
646
|
+
reaction: { type: "string", minLength: 1 },
|
|
647
|
+
idempotencyKey: { type: "string", minLength: 8, maxLength: 128 },
|
|
648
|
+
},
|
|
649
|
+
required: ["postId", "reaction", "idempotencyKey"],
|
|
650
|
+
additionalProperties: false,
|
|
651
|
+
},
|
|
652
|
+
outputSchema: OUTPUT_SCHEMA,
|
|
653
|
+
annotations: annotations("React to social post", {
|
|
654
|
+
readOnly: false,
|
|
655
|
+
destructive: false,
|
|
656
|
+
idempotent: true,
|
|
657
|
+
}),
|
|
658
|
+
},
|
|
659
|
+
{
|
|
660
|
+
name: "social_react_comment",
|
|
661
|
+
description: "React to a comment. Requires CAP_REACT and platform scope.",
|
|
662
|
+
inputSchema: {
|
|
663
|
+
type: "object",
|
|
664
|
+
properties: {
|
|
665
|
+
commentId: { type: "string", minLength: 1 },
|
|
666
|
+
reaction: { type: "string", minLength: 1 },
|
|
667
|
+
idempotencyKey: { type: "string", minLength: 8, maxLength: 128 },
|
|
668
|
+
},
|
|
669
|
+
required: ["commentId", "reaction", "idempotencyKey"],
|
|
670
|
+
additionalProperties: false,
|
|
671
|
+
},
|
|
672
|
+
outputSchema: OUTPUT_SCHEMA,
|
|
673
|
+
annotations: annotations("React to social comment", {
|
|
674
|
+
readOnly: false,
|
|
675
|
+
destructive: false,
|
|
676
|
+
idempotent: true,
|
|
677
|
+
}),
|
|
678
|
+
},
|
|
679
|
+
{
|
|
680
|
+
name: "social_create_repost",
|
|
681
|
+
description: "Repost or quote-repost. Requires CAP_POST_PUBLISH and platform scope.",
|
|
682
|
+
inputSchema: {
|
|
683
|
+
type: "object",
|
|
684
|
+
properties: {
|
|
685
|
+
originalPostId: { type: "string", minLength: 1 },
|
|
686
|
+
content: { type: "string", minLength: 1 },
|
|
687
|
+
idempotencyKey: { type: "string", minLength: 8, maxLength: 128 },
|
|
688
|
+
},
|
|
689
|
+
required: ["originalPostId", "idempotencyKey"],
|
|
690
|
+
additionalProperties: false,
|
|
691
|
+
},
|
|
692
|
+
outputSchema: OUTPUT_SCHEMA,
|
|
693
|
+
annotations: annotations("Create social repost", {
|
|
694
|
+
readOnly: false,
|
|
695
|
+
destructive: false,
|
|
696
|
+
idempotent: true,
|
|
697
|
+
}),
|
|
698
|
+
},
|
|
699
|
+
{
|
|
700
|
+
name: "social_delete_post",
|
|
701
|
+
description: "Request post deletion. Disabled until the owner approval and wallet-signing flow is available.",
|
|
702
|
+
inputSchema: {
|
|
703
|
+
type: "object",
|
|
704
|
+
properties: { postId: { type: "string", minLength: 1 } },
|
|
705
|
+
required: ["postId"],
|
|
706
|
+
additionalProperties: false,
|
|
707
|
+
},
|
|
708
|
+
outputSchema: OUTPUT_SCHEMA,
|
|
709
|
+
annotations: annotations("Delete social post", {
|
|
710
|
+
readOnly: false,
|
|
711
|
+
destructive: true,
|
|
712
|
+
idempotent: false,
|
|
713
|
+
}),
|
|
714
|
+
},
|
|
715
|
+
{
|
|
716
|
+
name: "social_delete_comment",
|
|
717
|
+
description: "Request comment deletion. Disabled until the owner approval and wallet-signing flow is available.",
|
|
718
|
+
inputSchema: {
|
|
719
|
+
type: "object",
|
|
720
|
+
properties: {
|
|
721
|
+
postId: { type: "string", minLength: 1 },
|
|
722
|
+
commentId: { type: "string", minLength: 1 },
|
|
723
|
+
},
|
|
724
|
+
required: ["postId", "commentId"],
|
|
725
|
+
additionalProperties: false,
|
|
726
|
+
},
|
|
727
|
+
outputSchema: OUTPUT_SCHEMA,
|
|
728
|
+
annotations: annotations("Delete social comment", {
|
|
729
|
+
readOnly: false,
|
|
730
|
+
destructive: true,
|
|
731
|
+
idempotent: false,
|
|
732
|
+
}),
|
|
733
|
+
},
|
|
734
|
+
];
|
|
735
|
+
export function createToolCatalog(socialToolNames = [], oauthScopes) {
|
|
736
|
+
const allowed = new Set(socialToolNames);
|
|
737
|
+
const scoped = (tool) => !oauthScopes || oauthScopes.has(TOOL_OAUTH_SCOPES[tool.name]);
|
|
738
|
+
return [
|
|
739
|
+
...MEMORY_TOOLS.filter(scoped),
|
|
740
|
+
...SOCIAL_TOOLS.filter((tool) => allowed.has(tool.name) && scoped(tool)),
|
|
741
|
+
];
|
|
742
|
+
}
|
|
743
|
+
function requireString(args, name) {
|
|
744
|
+
const value = args[name];
|
|
745
|
+
if (typeof value !== "string" || !value.trim()) {
|
|
746
|
+
throw new McpRuntimeError("INVALID_ARGUMENT", `${name} must be a non-empty string.`);
|
|
747
|
+
}
|
|
748
|
+
return value;
|
|
749
|
+
}
|
|
750
|
+
function optionalString(args, name) {
|
|
751
|
+
const value = args[name];
|
|
752
|
+
if (value === undefined)
|
|
753
|
+
return undefined;
|
|
754
|
+
return requireString(args, name);
|
|
755
|
+
}
|
|
756
|
+
function optionalStringArray(args, name) {
|
|
757
|
+
const value = args[name];
|
|
758
|
+
if (value === undefined)
|
|
759
|
+
return undefined;
|
|
760
|
+
if (!Array.isArray(value) || value.some((item) => typeof item !== "string" || !item.trim())) {
|
|
761
|
+
throw new McpRuntimeError("INVALID_ARGUMENT", `${name} must be an array of non-empty strings.`);
|
|
762
|
+
}
|
|
763
|
+
return value;
|
|
764
|
+
}
|
|
765
|
+
function requireObject(args, name) {
|
|
766
|
+
const value = args[name];
|
|
767
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
768
|
+
throw new McpRuntimeError("INVALID_ARGUMENT", `${name} must be an object.`);
|
|
769
|
+
}
|
|
770
|
+
return value;
|
|
771
|
+
}
|
|
772
|
+
function optionalInteger(args, name) {
|
|
773
|
+
const value = args[name];
|
|
774
|
+
if (value === undefined)
|
|
775
|
+
return undefined;
|
|
776
|
+
if (!Number.isSafeInteger(value)) {
|
|
777
|
+
throw new McpRuntimeError("INVALID_ARGUMENT", `${name} must be a safe integer.`);
|
|
778
|
+
}
|
|
779
|
+
return value;
|
|
780
|
+
}
|
|
781
|
+
function requireInteger(args, name) {
|
|
782
|
+
const value = optionalInteger(args, name);
|
|
783
|
+
if (value === undefined) {
|
|
784
|
+
throw new McpRuntimeError("INVALID_ARGUMENT", `${name} must be an integer.`);
|
|
785
|
+
}
|
|
786
|
+
return value;
|
|
787
|
+
}
|
|
788
|
+
function recallLimit(args) {
|
|
789
|
+
const value = args.limit ?? 5;
|
|
790
|
+
if (!Number.isInteger(value) || value < 1 || value > 100) {
|
|
791
|
+
throw new McpRuntimeError("INVALID_ARGUMENT", "limit must be an integer between 1 and 100.");
|
|
792
|
+
}
|
|
793
|
+
return value;
|
|
794
|
+
}
|
|
795
|
+
function requireSocial(dependencies) {
|
|
796
|
+
if (!dependencies.social) {
|
|
797
|
+
throw new McpRuntimeError("SOCIAL_GATEWAY_UNAVAILABLE", "Social tools are disabled for this MCP server.");
|
|
798
|
+
}
|
|
799
|
+
return dependencies.social;
|
|
800
|
+
}
|
|
801
|
+
function toStructuredValue(value) {
|
|
802
|
+
if (value === undefined)
|
|
803
|
+
return null;
|
|
804
|
+
return JSON.parse(JSON.stringify(value, (_key, nested) => typeof nested === "bigint" ? nested.toString() : nested));
|
|
805
|
+
}
|
|
806
|
+
export async function executeTool(name, args, dependencies) {
|
|
807
|
+
try {
|
|
808
|
+
const requiredScope = TOOL_OAUTH_SCOPES[name];
|
|
809
|
+
if (dependencies.oauthScopes && (!requiredScope || !dependencies.oauthScopes.has(requiredScope))) {
|
|
810
|
+
throw new McpRuntimeError("CAPABILITY_DENIED", `The OAuth token does not grant ${requiredScope ?? "this tool"}.`);
|
|
811
|
+
}
|
|
812
|
+
let result;
|
|
813
|
+
const ownerDefinition = OWNER_APPROVAL_ACTION_BY_TOOL.get(name);
|
|
814
|
+
if (ownerDefinition) {
|
|
815
|
+
const parameters = Object.fromEntries(Object.keys(ownerDefinition.properties)
|
|
816
|
+
.filter((key) => args[key] !== undefined)
|
|
817
|
+
.map((key) => [key, args[key]]));
|
|
818
|
+
result = await requireSocial(dependencies).requestActionApproval({
|
|
819
|
+
registryAction: ownerDefinition.registryAction,
|
|
820
|
+
parameters,
|
|
821
|
+
idempotencyKey: requireString(args, "idempotencyKey"),
|
|
822
|
+
expiresInSeconds: optionalInteger(args, "expiresInSeconds"),
|
|
823
|
+
});
|
|
824
|
+
return { ok: true, data: toStructuredValue(result) };
|
|
825
|
+
}
|
|
826
|
+
switch (name) {
|
|
827
|
+
case "memory_remember":
|
|
828
|
+
result = await dependencies.memory.rememberAndWait(requireString(args, "text"), optionalString(args, "subLabel"));
|
|
829
|
+
break;
|
|
830
|
+
case "memory_recall":
|
|
831
|
+
result = await dependencies.memory.recall(requireString(args, "query"), recallLimit(args));
|
|
832
|
+
break;
|
|
833
|
+
case "memory_health":
|
|
834
|
+
result = await dependencies.memory.health();
|
|
835
|
+
break;
|
|
836
|
+
case "chain_list_actions":
|
|
837
|
+
result = await requireSocial(dependencies).listActions();
|
|
838
|
+
break;
|
|
839
|
+
case "social_create_post":
|
|
840
|
+
result = await requireSocial(dependencies).createPost({
|
|
841
|
+
content: requireString(args, "content"),
|
|
842
|
+
idempotencyKey: requireString(args, "idempotencyKey"),
|
|
843
|
+
});
|
|
844
|
+
break;
|
|
845
|
+
case "social_create_comment":
|
|
846
|
+
result = await requireSocial(dependencies).createComment({
|
|
847
|
+
postId: requireString(args, "postId"),
|
|
848
|
+
content: requireString(args, "content"),
|
|
849
|
+
parentCommentId: optionalString(args, "parentCommentId"),
|
|
850
|
+
idempotencyKey: requireString(args, "idempotencyKey"),
|
|
851
|
+
});
|
|
852
|
+
break;
|
|
853
|
+
case "social_react_post":
|
|
854
|
+
result = await requireSocial(dependencies).reactToPost({
|
|
855
|
+
postId: requireString(args, "postId"),
|
|
856
|
+
reaction: requireString(args, "reaction"),
|
|
857
|
+
idempotencyKey: requireString(args, "idempotencyKey"),
|
|
858
|
+
});
|
|
859
|
+
break;
|
|
860
|
+
case "social_react_comment":
|
|
861
|
+
result = await requireSocial(dependencies).reactToComment({
|
|
862
|
+
commentId: requireString(args, "commentId"),
|
|
863
|
+
reaction: requireString(args, "reaction"),
|
|
864
|
+
idempotencyKey: requireString(args, "idempotencyKey"),
|
|
865
|
+
});
|
|
866
|
+
break;
|
|
867
|
+
case "social_create_repost":
|
|
868
|
+
result = await requireSocial(dependencies).createRepost({
|
|
869
|
+
originalPostId: requireString(args, "originalPostId"),
|
|
870
|
+
content: optionalString(args, "content"),
|
|
871
|
+
idempotencyKey: requireString(args, "idempotencyKey"),
|
|
872
|
+
});
|
|
873
|
+
break;
|
|
874
|
+
case "social_remove_post_reaction":
|
|
875
|
+
result = await requireSocial(dependencies).removePostReaction({
|
|
876
|
+
postId: requireString(args, "postId"),
|
|
877
|
+
idempotencyKey: requireString(args, "idempotencyKey"),
|
|
878
|
+
});
|
|
879
|
+
break;
|
|
880
|
+
case "social_remove_comment_reaction":
|
|
881
|
+
result = await requireSocial(dependencies).removeCommentReaction({
|
|
882
|
+
commentId: requireString(args, "commentId"),
|
|
883
|
+
idempotencyKey: requireString(args, "idempotencyKey"),
|
|
884
|
+
});
|
|
885
|
+
break;
|
|
886
|
+
case "social_edit_post":
|
|
887
|
+
result = await requireSocial(dependencies).editPost({
|
|
888
|
+
postId: requireString(args, "postId"),
|
|
889
|
+
content: requireString(args, "content"),
|
|
890
|
+
mediaUrls: optionalStringArray(args, "mediaUrls"),
|
|
891
|
+
mentions: optionalStringArray(args, "mentions"),
|
|
892
|
+
metadataJson: optionalString(args, "metadataJson"),
|
|
893
|
+
idempotencyKey: requireString(args, "idempotencyKey"),
|
|
894
|
+
});
|
|
895
|
+
break;
|
|
896
|
+
case "social_edit_comment":
|
|
897
|
+
result = await requireSocial(dependencies).editComment({
|
|
898
|
+
commentId: requireString(args, "commentId"),
|
|
899
|
+
content: requireString(args, "content"),
|
|
900
|
+
mentions: optionalStringArray(args, "mentions"),
|
|
901
|
+
idempotencyKey: requireString(args, "idempotencyKey"),
|
|
902
|
+
});
|
|
903
|
+
break;
|
|
904
|
+
case "social_remove_repost":
|
|
905
|
+
result = await requireSocial(dependencies).removeRepost({
|
|
906
|
+
originalPostId: requireString(args, "originalPostId"),
|
|
907
|
+
repostId: requireString(args, "repostId"),
|
|
908
|
+
idempotencyKey: requireString(args, "idempotencyKey"),
|
|
909
|
+
});
|
|
910
|
+
break;
|
|
911
|
+
case "social_follow_profile":
|
|
912
|
+
case "social_unfollow_profile":
|
|
913
|
+
case "social_block_profile":
|
|
914
|
+
case "social_unblock_profile": {
|
|
915
|
+
const input = {
|
|
916
|
+
targetOwner: requireString(args, "targetOwner"),
|
|
917
|
+
idempotencyKey: requireString(args, "idempotencyKey"),
|
|
918
|
+
};
|
|
919
|
+
const social = requireSocial(dependencies);
|
|
920
|
+
result = name === "social_follow_profile"
|
|
921
|
+
? await social.followProfile(input)
|
|
922
|
+
: name === "social_unfollow_profile"
|
|
923
|
+
? await social.unfollowProfile(input)
|
|
924
|
+
: name === "social_block_profile"
|
|
925
|
+
? await social.blockProfile(input)
|
|
926
|
+
: await social.unblockProfile(input);
|
|
927
|
+
break;
|
|
928
|
+
}
|
|
929
|
+
case "messaging_send_message":
|
|
930
|
+
result = await requireSocial(dependencies).sendMessage({
|
|
931
|
+
groupId: requireString(args, "groupId"),
|
|
932
|
+
messageLogId: requireString(args, "messageLogId"),
|
|
933
|
+
recipient: requireString(args, "recipient"),
|
|
934
|
+
contentDigestHex: requireString(args, "contentDigestHex"),
|
|
935
|
+
contentUri: requireString(args, "contentUri"),
|
|
936
|
+
dedupeKey: requireString(args, "dedupeKey"),
|
|
937
|
+
nonce: requireString(args, "nonce"),
|
|
938
|
+
idempotencyKey: requireString(args, "idempotencyKey"),
|
|
939
|
+
});
|
|
940
|
+
break;
|
|
941
|
+
case "messaging_create_group":
|
|
942
|
+
result = await requireSocial(dependencies).createMessagingGroup({
|
|
943
|
+
name: requireString(args, "name"),
|
|
944
|
+
uuid: requireString(args, "uuid"),
|
|
945
|
+
encryptedDekHex: requireString(args, "encryptedDekHex"),
|
|
946
|
+
initialMembers: optionalStringArray(args, "initialMembers") ?? [],
|
|
947
|
+
crossPrincipalPeerAccountId: optionalString(args, "crossPrincipalPeerAccountId"),
|
|
948
|
+
idempotencyKey: requireString(args, "idempotencyKey"),
|
|
949
|
+
});
|
|
950
|
+
break;
|
|
951
|
+
case "messaging_list_inbox":
|
|
952
|
+
result = await requireSocial(dependencies).listInbox({
|
|
953
|
+
limit: optionalInteger(args, "limit"),
|
|
954
|
+
offset: optionalInteger(args, "offset"),
|
|
955
|
+
groupId: optionalString(args, "groupId"),
|
|
956
|
+
afterCreatedAtMs: optionalInteger(args, "afterCreatedAtMs"),
|
|
957
|
+
afterSeq: optionalInteger(args, "afterSeq"),
|
|
958
|
+
});
|
|
959
|
+
break;
|
|
960
|
+
case "messaging_wait_for_message":
|
|
961
|
+
result = await requireSocial(dependencies).waitForMessage({
|
|
962
|
+
timeoutMs: optionalInteger(args, "timeoutMs"),
|
|
963
|
+
groupId: optionalString(args, "groupId"),
|
|
964
|
+
afterCreatedAtMs: optionalInteger(args, "afterCreatedAtMs"),
|
|
965
|
+
afterSeq: optionalInteger(args, "afterSeq"),
|
|
966
|
+
});
|
|
967
|
+
break;
|
|
968
|
+
case "organization_get_control":
|
|
969
|
+
result = await requireSocial(dependencies).getOrganizationControl(requireString(args, "organizationId"));
|
|
970
|
+
break;
|
|
971
|
+
case "agent_provision_signer":
|
|
972
|
+
if (!dependencies.agentProvisioner) {
|
|
973
|
+
throw new McpRuntimeError("SIGNER_UNAVAILABLE", "This MCP runtime does not have a Keychain or KMS agent provisioner.");
|
|
974
|
+
}
|
|
975
|
+
result = await dependencies.agentProvisioner.provision(requireString(args, "label"));
|
|
976
|
+
break;
|
|
977
|
+
case "organization_accept_invitation":
|
|
978
|
+
case "organization_decline_invitation": {
|
|
979
|
+
const input = {
|
|
980
|
+
organizationAccountId: requireString(args, "organizationAccountId"),
|
|
981
|
+
organizationId: requireString(args, "organizationId"),
|
|
982
|
+
orgMemoryGroupId: optionalString(args, "orgMemoryGroupId"),
|
|
983
|
+
invitee: requireString(args, "invitee"),
|
|
984
|
+
idempotencyKey: requireString(args, "idempotencyKey"),
|
|
985
|
+
};
|
|
986
|
+
const social = requireSocial(dependencies);
|
|
987
|
+
result = name === "organization_accept_invitation"
|
|
988
|
+
? await social.acceptOrganizationInvitation(input)
|
|
989
|
+
: await social.declineOrganizationInvitation(input);
|
|
990
|
+
break;
|
|
991
|
+
}
|
|
992
|
+
case "agent_register_child":
|
|
993
|
+
result = await requireSocial(dependencies).registerChildAgent({
|
|
994
|
+
parentAgentObjectId: optionalString(args, "parentAgentObjectId"),
|
|
995
|
+
registerRelation: requireInteger(args, "registerRelation"),
|
|
996
|
+
publicKeyHex: requireString(args, "publicKeyHex"),
|
|
997
|
+
derivedAddress: requireString(args, "derivedAddress"),
|
|
998
|
+
label: requireString(args, "label"),
|
|
999
|
+
identityClass: optionalInteger(args, "identityClass"),
|
|
1000
|
+
roleTags: optionalString(args, "roleTags"),
|
|
1001
|
+
capabilities: optionalString(args, "capabilities"),
|
|
1002
|
+
delegatableCaps: optionalString(args, "delegatableCaps"),
|
|
1003
|
+
registerScope: optionalInteger(args, "registerScope"),
|
|
1004
|
+
approvalRequiredCaps: optionalString(args, "approvalRequiredCaps"),
|
|
1005
|
+
maxActionSpendMist: optionalString(args, "maxActionSpendMist"),
|
|
1006
|
+
platformScope: optionalString(args, "platformScope"),
|
|
1007
|
+
expiresAtMs: optionalString(args, "expiresAtMs"),
|
|
1008
|
+
idempotencyKey: requireString(args, "idempotencyKey"),
|
|
1009
|
+
});
|
|
1010
|
+
break;
|
|
1011
|
+
case "agent_update_child":
|
|
1012
|
+
result = await requireSocial(dependencies).updateChildAgent({
|
|
1013
|
+
agentObjectId: requireString(args, "agentObjectId"),
|
|
1014
|
+
identityClass: requireInteger(args, "identityClass"),
|
|
1015
|
+
roleTags: requireString(args, "roleTags"),
|
|
1016
|
+
capabilities: requireString(args, "capabilities"),
|
|
1017
|
+
delegatableCaps: requireString(args, "delegatableCaps"),
|
|
1018
|
+
registerScope: requireInteger(args, "registerScope"),
|
|
1019
|
+
approvalRequiredCaps: requireString(args, "approvalRequiredCaps"),
|
|
1020
|
+
maxActionSpendMist: optionalString(args, "maxActionSpendMist"),
|
|
1021
|
+
platformScope: optionalString(args, "platformScope"),
|
|
1022
|
+
expiresAtMs: optionalString(args, "expiresAtMs"),
|
|
1023
|
+
idempotencyKey: requireString(args, "idempotencyKey"),
|
|
1024
|
+
});
|
|
1025
|
+
break;
|
|
1026
|
+
case "agent_deactivate_child":
|
|
1027
|
+
case "agent_revoke_child": {
|
|
1028
|
+
const input = {
|
|
1029
|
+
agentObjectId: requireString(args, "agentObjectId"),
|
|
1030
|
+
idempotencyKey: requireString(args, "idempotencyKey"),
|
|
1031
|
+
};
|
|
1032
|
+
const social = requireSocial(dependencies);
|
|
1033
|
+
result = name === "agent_deactivate_child"
|
|
1034
|
+
? await social.deactivateChildAgent(input)
|
|
1035
|
+
: await social.revokeChildAgent(input);
|
|
1036
|
+
break;
|
|
1037
|
+
}
|
|
1038
|
+
case "social_delete_post":
|
|
1039
|
+
result = await requireSocial(dependencies).deletePost(requireString(args, "postId"));
|
|
1040
|
+
break;
|
|
1041
|
+
case "social_delete_comment":
|
|
1042
|
+
result = await requireSocial(dependencies).deleteComment({
|
|
1043
|
+
postId: requireString(args, "postId"),
|
|
1044
|
+
commentId: requireString(args, "commentId"),
|
|
1045
|
+
});
|
|
1046
|
+
break;
|
|
1047
|
+
case "chain_get_action_status":
|
|
1048
|
+
result = await requireSocial(dependencies).getActionStatus(requireString(args, "digest"));
|
|
1049
|
+
break;
|
|
1050
|
+
case "chain_request_action_approval":
|
|
1051
|
+
result = await requireSocial(dependencies).requestActionApproval({
|
|
1052
|
+
registryAction: requireString(args, "registryAction"),
|
|
1053
|
+
parameters: requireObject(args, "parameters"),
|
|
1054
|
+
idempotencyKey: requireString(args, "idempotencyKey"),
|
|
1055
|
+
expiresInSeconds: optionalInteger(args, "expiresInSeconds"),
|
|
1056
|
+
});
|
|
1057
|
+
break;
|
|
1058
|
+
case "chain_approve_action":
|
|
1059
|
+
result = await requireSocial(dependencies).approveAction({
|
|
1060
|
+
approvalId: requireString(args, "approvalId"),
|
|
1061
|
+
walletSignature: requireString(args, "walletSignature"),
|
|
1062
|
+
});
|
|
1063
|
+
break;
|
|
1064
|
+
case "chain_prepare_approved_action":
|
|
1065
|
+
result = await requireSocial(dependencies).prepareApprovedAction({
|
|
1066
|
+
registryAction: requireString(args, "registryAction"),
|
|
1067
|
+
parameters: requireObject(args, "parameters"),
|
|
1068
|
+
idempotencyKey: requireString(args, "idempotencyKey"),
|
|
1069
|
+
approvalId: requireString(args, "approvalId"),
|
|
1070
|
+
});
|
|
1071
|
+
break;
|
|
1072
|
+
case "chain_submit_approved_action":
|
|
1073
|
+
result = await requireSocial(dependencies).submitApprovedAction({
|
|
1074
|
+
registryAction: requireString(args, "registryAction"),
|
|
1075
|
+
idempotencyKey: requireString(args, "idempotencyKey"),
|
|
1076
|
+
approvalId: requireString(args, "approvalId"),
|
|
1077
|
+
digest: requireString(args, "digest"),
|
|
1078
|
+
walletSignature: requireString(args, "walletSignature"),
|
|
1079
|
+
});
|
|
1080
|
+
break;
|
|
1081
|
+
default:
|
|
1082
|
+
throw new McpRuntimeError("UNKNOWN_TOOL", `Unknown tool: ${name}`);
|
|
1083
|
+
}
|
|
1084
|
+
return { ok: true, data: toStructuredValue(result) };
|
|
1085
|
+
}
|
|
1086
|
+
catch (error) {
|
|
1087
|
+
return { ok: false, error: toStructuredMcpError(error) };
|
|
1088
|
+
}
|
|
1089
|
+
}
|