@modly_public/mcp-server 0.1.0 → 0.2.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 +13 -58
- package/dist/index.js +1 -1
- package/dist/locales/en.js +54 -48
- package/dist/locales/en.js.map +1 -1
- package/dist/tools.js +104 -73
- package/dist/tools.js.map +1 -1
- package/package.json +20 -7
package/dist/tools.js
CHANGED
|
@@ -65,57 +65,12 @@ function getObj(args, key) {
|
|
|
65
65
|
throw new Error(`missing arg: ${key}`);
|
|
66
66
|
return v;
|
|
67
67
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
const apiKey = process.env["MODLY_API_KEY"];
|
|
71
|
-
if (!apiKey)
|
|
72
|
-
throw new Error("MODLY_API_KEY not set");
|
|
73
|
-
const url = `${client.baseUrl}/api/guilds/${client.guildId}${path}`;
|
|
74
|
-
const res = await fetch(url, {
|
|
75
|
-
method,
|
|
76
|
-
headers: {
|
|
77
|
-
"authorization": `Bearer ${apiKey}`,
|
|
78
|
-
...(body !== undefined ? { "content-type": "application/json" } : {}),
|
|
79
|
-
},
|
|
80
|
-
...(body !== undefined ? { body: JSON.stringify(body) } : {}),
|
|
81
|
-
});
|
|
82
|
-
if (!res.ok) {
|
|
83
|
-
let parsed = null;
|
|
84
|
-
try {
|
|
85
|
-
parsed = await res.json();
|
|
86
|
-
}
|
|
87
|
-
catch { /* ignore */ }
|
|
88
|
-
throw new Error(`http_${res.status}: ${JSON.stringify(parsed)}`);
|
|
89
|
-
}
|
|
90
|
-
if (res.status === 204)
|
|
91
|
-
return undefined;
|
|
92
|
-
return (await res.json());
|
|
68
|
+
function raw(client, method, path, body) {
|
|
69
|
+
return client.request(method, path, body);
|
|
93
70
|
}
|
|
94
|
-
// non-guild-scoped
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
if (!apiKey)
|
|
98
|
-
throw new Error("MODLY_API_KEY not set");
|
|
99
|
-
const url = `${client.baseUrl}${path}`;
|
|
100
|
-
const res = await fetch(url, {
|
|
101
|
-
method,
|
|
102
|
-
headers: {
|
|
103
|
-
"authorization": `Bearer ${apiKey}`,
|
|
104
|
-
...(body !== undefined ? { "content-type": "application/json" } : {}),
|
|
105
|
-
},
|
|
106
|
-
...(body !== undefined ? { body: JSON.stringify(body) } : {}),
|
|
107
|
-
});
|
|
108
|
-
if (!res.ok) {
|
|
109
|
-
let parsed = null;
|
|
110
|
-
try {
|
|
111
|
-
parsed = await res.json();
|
|
112
|
-
}
|
|
113
|
-
catch { /* ignore */ }
|
|
114
|
-
throw new Error(`http_${res.status}: ${JSON.stringify(parsed)}`);
|
|
115
|
-
}
|
|
116
|
-
if (res.status === 204)
|
|
117
|
-
return undefined;
|
|
118
|
-
return (await res.json());
|
|
71
|
+
// non-guild-scoped call (e.g. /api/me, /api/modules, /api/discovery)
|
|
72
|
+
function rawAbs(client, method, path, body) {
|
|
73
|
+
return client.request(method, path, body);
|
|
119
74
|
}
|
|
120
75
|
function qs(params) {
|
|
121
76
|
const u = new URLSearchParams();
|
|
@@ -140,7 +95,7 @@ export const TOOLS = [
|
|
|
140
95
|
name: "list_cases",
|
|
141
96
|
descriptionKey: "mcp.tools.list_cases.description",
|
|
142
97
|
inputSchema: { type: "object", properties: { userId: Sn, limit: Nn, type: Sn, cursor: Sn } },
|
|
143
|
-
handler: async (a, c) => raw(c, "GET", `/cases${qs({
|
|
98
|
+
handler: async (a, c) => raw(c, "GET", `/cases${qs({ user: getOptStr(a, "userId"), limit: getOptNum(a, "limit"), type: getOptStr(a, "type"), cursor: getOptStr(a, "cursor") })}`),
|
|
144
99
|
},
|
|
145
100
|
{
|
|
146
101
|
name: "get_case",
|
|
@@ -214,7 +169,7 @@ export const TOOLS = [
|
|
|
214
169
|
name: "list_active_punishments",
|
|
215
170
|
descriptionKey: "mcp.tools.list_active_punishments.description",
|
|
216
171
|
inputSchema: { type: "object", properties: { userId: Sn, limit: Nn } },
|
|
217
|
-
handler: async (a, c) => raw(c, "GET", `/cases${qs({
|
|
172
|
+
handler: async (a, c) => raw(c, "GET", `/cases${qs({ user: getOptStr(a, "userId"), limit: getOptNum(a, "limit"), active: true })}`),
|
|
218
173
|
},
|
|
219
174
|
{
|
|
220
175
|
name: "list_member_notes",
|
|
@@ -981,8 +936,8 @@ export const TOOLS = [
|
|
|
981
936
|
{
|
|
982
937
|
name: "list_scheduled_actions",
|
|
983
938
|
descriptionKey: "mcp.tools.list_scheduled_actions.description",
|
|
984
|
-
inputSchema: { type: "object", properties: { kind: Sn, limit: Nn } },
|
|
985
|
-
handler: async (a, c) => raw(c, "GET", `/scheduled-actions${qs({ kind: getOptStr(a, "kind"), limit: getOptNum(a, "limit") })}`),
|
|
939
|
+
inputSchema: { type: "object", properties: { kind: Sn, done: Bn, limit: Nn } },
|
|
940
|
+
handler: async (a, c) => raw(c, "GET", `/scheduled-actions${qs({ kind: getOptStr(a, "kind"), done: getOptBool(a, "done"), limit: getOptNum(a, "limit") })}`),
|
|
986
941
|
},
|
|
987
942
|
{
|
|
988
943
|
name: "get_scheduled_action",
|
|
@@ -993,11 +948,14 @@ export const TOOLS = [
|
|
|
993
948
|
{
|
|
994
949
|
name: "create_scheduled_action",
|
|
995
950
|
descriptionKey: "mcp.tools.create_scheduled_action.description",
|
|
996
|
-
inputSchema: {
|
|
951
|
+
inputSchema: {
|
|
952
|
+
type: "object",
|
|
953
|
+
properties: { kind: { type: "string", enum: ["channel_lock", "role_assign", "slowmode", "announce"] }, runAt: Sn, payload: On },
|
|
954
|
+
required: ["kind", "runAt"],
|
|
955
|
+
},
|
|
997
956
|
handler: async (a, c) => raw(c, "POST", `/scheduled-actions`, {
|
|
998
957
|
kind: getStr(a, "kind"),
|
|
999
|
-
runAt:
|
|
1000
|
-
cron: getOptStr(a, "cron"),
|
|
958
|
+
runAt: getStr(a, "runAt"),
|
|
1001
959
|
payload: getOptObj(a, "payload") ?? {},
|
|
1002
960
|
}),
|
|
1003
961
|
},
|
|
@@ -1800,8 +1758,62 @@ export const TOOLS = [
|
|
|
1800
1758
|
{
|
|
1801
1759
|
name: "save_embed_template",
|
|
1802
1760
|
descriptionKey: "mcp.tools.save_embed_template.description",
|
|
1803
|
-
inputSchema: { type: "object", properties: { name: Sn, json: On }, required: ["name", "json"] },
|
|
1804
|
-
handler: async (a, c) =>
|
|
1761
|
+
inputSchema: { type: "object", properties: { name: Sn, json: On, description: Sn, folder: Sn, tags: { type: "array", items: Sn } }, required: ["name", "json"] },
|
|
1762
|
+
handler: async (a, c) => {
|
|
1763
|
+
const description = getOptStr(a, "description");
|
|
1764
|
+
const folder = getOptStr(a, "folder");
|
|
1765
|
+
const tags = getOptStrArr(a, "tags");
|
|
1766
|
+
return c.embeds.save(getStr(a, "name"), getObj(a, "json"), {
|
|
1767
|
+
...(description !== undefined ? { description } : {}),
|
|
1768
|
+
...(folder !== undefined ? { folder } : {}),
|
|
1769
|
+
...(tags !== undefined ? { tags } : {}),
|
|
1770
|
+
});
|
|
1771
|
+
},
|
|
1772
|
+
},
|
|
1773
|
+
{
|
|
1774
|
+
name: "delete_embed_template",
|
|
1775
|
+
descriptionKey: "mcp.tools.delete_embed_template.description",
|
|
1776
|
+
inputSchema: { type: "object", properties: { name: Sn }, required: ["name"] },
|
|
1777
|
+
handler: async (a, c) => c.embeds.delete(getStr(a, "name")),
|
|
1778
|
+
},
|
|
1779
|
+
{
|
|
1780
|
+
name: "duplicate_embed_template",
|
|
1781
|
+
descriptionKey: "mcp.tools.duplicate_embed_template.description",
|
|
1782
|
+
inputSchema: { type: "object", properties: { name: Sn, newName: Sn, description: Sn, folder: Sn, tags: { type: "array", items: Sn } }, required: ["name", "newName"] },
|
|
1783
|
+
handler: async (a, c) => {
|
|
1784
|
+
const description = getOptStr(a, "description");
|
|
1785
|
+
const folder = getOptStr(a, "folder");
|
|
1786
|
+
const tags = getOptStrArr(a, "tags");
|
|
1787
|
+
return c.embeds.duplicate(getStr(a, "name"), {
|
|
1788
|
+
name: getStr(a, "newName"),
|
|
1789
|
+
...(description !== undefined ? { description } : {}),
|
|
1790
|
+
...(folder !== undefined ? { folder } : {}),
|
|
1791
|
+
...(tags !== undefined ? { tags } : {}),
|
|
1792
|
+
});
|
|
1793
|
+
},
|
|
1794
|
+
},
|
|
1795
|
+
{
|
|
1796
|
+
name: "list_embed_template_versions",
|
|
1797
|
+
descriptionKey: "mcp.tools.list_embed_template_versions.description",
|
|
1798
|
+
inputSchema: { type: "object", properties: { name: Sn }, required: ["name"] },
|
|
1799
|
+
handler: async (a, c) => c.embeds.versions(getStr(a, "name")),
|
|
1800
|
+
},
|
|
1801
|
+
{
|
|
1802
|
+
name: "restore_embed_template_version",
|
|
1803
|
+
descriptionKey: "mcp.tools.restore_embed_template_version.description",
|
|
1804
|
+
inputSchema: { type: "object", properties: { name: Sn, version: Nn }, required: ["name", "version"] },
|
|
1805
|
+
handler: async (a, c) => {
|
|
1806
|
+
const version = getOptNum(a, "version");
|
|
1807
|
+
if (version === undefined)
|
|
1808
|
+
throw new Error("missing arg: version");
|
|
1809
|
+
return c.embeds.restoreVersion(getStr(a, "name"), version);
|
|
1810
|
+
},
|
|
1811
|
+
},
|
|
1812
|
+
{
|
|
1813
|
+
name: "send_embed_template",
|
|
1814
|
+
descriptionKey: "mcp.tools.send_embed_template.description",
|
|
1815
|
+
inputSchema: { type: "object", properties: { name: Sn, channelId: Sn }, required: ["name", "channelId"] },
|
|
1816
|
+
handler: async (a, c) => c.embeds.sendToChannel(getStr(a, "name"), getStr(a, "channelId")),
|
|
1805
1817
|
},
|
|
1806
1818
|
// ═══════════════════════════════════════════════════════════════════════
|
|
1807
1819
|
// CHANNELS / ROLES / SERVER
|
|
@@ -2365,9 +2377,13 @@ export const TOOLS = [
|
|
|
2365
2377
|
name: "search_outbound_webhook_deliveries",
|
|
2366
2378
|
descriptionKey: "mcp.tools.search_outbound_webhook_deliveries.description",
|
|
2367
2379
|
inputSchema: { type: "object", properties: { hookId: Sn, event: Sn, status: Sn, limit: Nn }, required: ["hookId"] },
|
|
2368
|
-
handler: async (a, c) =>
|
|
2369
|
-
|
|
2370
|
-
|
|
2380
|
+
handler: async (a, c) => {
|
|
2381
|
+
const event = getOptStr(a, "event");
|
|
2382
|
+
const status = getOptStr(a, "status");
|
|
2383
|
+
const rows = (await c.webhooks.deliveries(getStr(a, "hookId"))).filter((d) => (!event || d.event === event) &&
|
|
2384
|
+
(!status || (status === "failed" ? d.statusCode === 0 || d.statusCode >= 400 : d.statusCode >= 200 && d.statusCode < 400)));
|
|
2385
|
+
return rows.slice(0, getOptNum(a, "limit") ?? 50);
|
|
2386
|
+
},
|
|
2371
2387
|
},
|
|
2372
2388
|
{
|
|
2373
2389
|
name: "replay_outbound_webhook_delivery",
|
|
@@ -2498,8 +2514,11 @@ export const TOOLS = [
|
|
|
2498
2514
|
{
|
|
2499
2515
|
name: "wb_duplicate_group",
|
|
2500
2516
|
descriptionKey: "mcp.tools.wb_duplicate_group.description",
|
|
2501
|
-
inputSchema: { type: "object", properties: { id: Sn }, required: ["id"] },
|
|
2502
|
-
handler: async (a, c) =>
|
|
2517
|
+
inputSchema: { type: "object", properties: { id: Sn, name: Sn }, required: ["id"] },
|
|
2518
|
+
handler: async (a, c) => {
|
|
2519
|
+
const name = getOptStr(a, "name");
|
|
2520
|
+
return c.broadcaster.groups.duplicate(getStr(a, "id"), name ? { name } : {});
|
|
2521
|
+
},
|
|
2503
2522
|
},
|
|
2504
2523
|
{
|
|
2505
2524
|
name: "wb_list_schedules",
|
|
@@ -2531,19 +2550,31 @@ export const TOOLS = [
|
|
|
2531
2550
|
inputSchema: {
|
|
2532
2551
|
type: "object",
|
|
2533
2552
|
properties: {
|
|
2534
|
-
targetIds: { type: "array", items: Sn
|
|
2553
|
+
targetIds: { type: "array", items: Sn },
|
|
2554
|
+
groupIds: { type: "array", items: Sn },
|
|
2555
|
+
webhookUrl: Sn,
|
|
2535
2556
|
embedTemplateName: Sn, content: Sn,
|
|
2557
|
+
embeds: { type: "array", items: On },
|
|
2558
|
+
usernameOverride: Sn, avatarUrlOverride: Sn,
|
|
2559
|
+
variables: On,
|
|
2536
2560
|
},
|
|
2537
|
-
|
|
2561
|
+
},
|
|
2562
|
+
handler: async (a, c) => c.broadcaster.send(a),
|
|
2563
|
+
},
|
|
2564
|
+
{
|
|
2565
|
+
name: "wb_copy_group_targets",
|
|
2566
|
+
descriptionKey: "mcp.tools.wb_copy_group_targets.description",
|
|
2567
|
+
inputSchema: {
|
|
2568
|
+
type: "object",
|
|
2569
|
+
properties: { id: Sn, targetGroupId: Sn, targetIds: { type: "array", items: Sn, minItems: 1 }, mode: { type: "string", enum: ["merge", "replace"] } },
|
|
2570
|
+
required: ["id", "targetGroupId", "targetIds"],
|
|
2538
2571
|
},
|
|
2539
2572
|
handler: async (a, c) => {
|
|
2540
|
-
const
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
...(embedTemplateName !== undefined ? { embedTemplateName } : {}),
|
|
2546
|
-
...(content !== undefined ? { content } : {}),
|
|
2573
|
+
const mode = getOptStr(a, "mode");
|
|
2574
|
+
return c.broadcaster.groups.copyTargets(getStr(a, "id"), {
|
|
2575
|
+
targetGroupId: getStr(a, "targetGroupId"),
|
|
2576
|
+
targetIds: getStrArr(a, "targetIds"),
|
|
2577
|
+
...(mode ? { mode } : {}),
|
|
2547
2578
|
});
|
|
2548
2579
|
},
|
|
2549
2580
|
},
|