@maelitop/mention-mcp-server 1.4.1 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +23 -0
- package/README.md +1 -0
- package/dist/api-client.js +62 -18
- package/dist/config.js +7 -0
- package/dist/index.js +6 -57
- package/dist/prompts/build-boolean-query.js +16 -33
- package/dist/prompts/index.js +4 -2
- package/dist/server.js +17 -0
- package/dist/tools/create_advanced_alert.js +33 -61
- package/dist/tools/create_basic_alert.js +36 -52
- package/dist/tools/fetch_alert_stats.js +63 -88
- package/dist/tools/fetch_mentions.js +32 -53
- package/dist/tools/get_account_info.js +20 -43
- package/dist/tools/get_alert.js +14 -34
- package/dist/tools/get_app_data.js +20 -43
- package/dist/tools/index.js +24 -55
- package/dist/tools/list_alerts.js +20 -40
- package/dist/tools/pause_alert.js +20 -35
- package/dist/tools/unpause_alert.js +20 -35
- package/dist/tools/update_alert.js +43 -54
- package/dist/types.js +9 -17
- package/package.json +3 -4
- package/dist/prompts/base.js +0 -1
- package/dist/tools/base.js +0 -1
|
@@ -1,94 +1,69 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { logError, logInfo } from "../logger.js";
|
|
1
|
+
import { logInfo } from "../logger.js";
|
|
3
2
|
import { FetchAlertStatsArgsSchema } from "../types.js";
|
|
4
|
-
function
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
for (const
|
|
43
|
-
|
|
44
|
-
for (const value of values) {
|
|
45
|
-
searchParams.append(key, String(value));
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
// Handle special country_stats parameter
|
|
50
|
-
if (validated.country_stats !== undefined) {
|
|
51
|
-
if (typeof validated.country_stats === "boolean") {
|
|
52
|
-
searchParams.append("country_stats", validated.country_stats ? "10" : "0");
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
searchParams.append("country_stats", String(validated.country_stats));
|
|
56
|
-
}
|
|
3
|
+
export function registerFetchAlertStatsTool(server, apiClient) {
|
|
4
|
+
server.registerTool("fetch_alert_stats", {
|
|
5
|
+
title: "Fetch Alert Stats",
|
|
6
|
+
description: "Retrieve comprehensive statistics for one or more alerts including mentions per interval, tones, influencers, geographical data, and reach metrics. Supports flexible date ranges, filtering, and aggregation options.",
|
|
7
|
+
inputSchema: FetchAlertStatsArgsSchema.shape,
|
|
8
|
+
annotations: { readOnlyHint: true, openWorldHint: true },
|
|
9
|
+
}, async (args) => {
|
|
10
|
+
const accountId = await apiClient.getAccountId();
|
|
11
|
+
const searchParams = new URLSearchParams();
|
|
12
|
+
for (const alertId of args.alerts) {
|
|
13
|
+
searchParams.append("alerts[]", alertId);
|
|
14
|
+
}
|
|
15
|
+
searchParams.append("from", args.from);
|
|
16
|
+
searchParams.append("to", args.to);
|
|
17
|
+
searchParams.append("interval", args.interval);
|
|
18
|
+
const optionalParams = {
|
|
19
|
+
timezone: args.timezone,
|
|
20
|
+
favorite: args.favorite,
|
|
21
|
+
week_day_stats: args.week_day_stats,
|
|
22
|
+
week_day_by_hour_stats: args.week_day_by_hour_stats,
|
|
23
|
+
influencers: args.influencers,
|
|
24
|
+
reach_per_interval_stats: args.reach_per_interval_stats,
|
|
25
|
+
"author_influence.score": args["author_influence.score"],
|
|
26
|
+
};
|
|
27
|
+
for (const [key, value] of Object.entries(optionalParams)) {
|
|
28
|
+
if (value !== undefined && value !== null) {
|
|
29
|
+
searchParams.append(key, String(value));
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
const arrayParams = {
|
|
33
|
+
"tones[]": args.tones,
|
|
34
|
+
"languages[]": args.languages,
|
|
35
|
+
"sources[]": args.sources,
|
|
36
|
+
"countries[]": args.countries,
|
|
37
|
+
"tags[]": args.tags,
|
|
38
|
+
};
|
|
39
|
+
for (const [key, values] of Object.entries(arrayParams)) {
|
|
40
|
+
if (values && Array.isArray(values)) {
|
|
41
|
+
for (const value of values) {
|
|
42
|
+
searchParams.append(key, String(value));
|
|
57
43
|
}
|
|
58
|
-
const queryString = searchParams.toString();
|
|
59
|
-
const endpoint = `/accounts/${accountId}/stats${queryString ? `?${queryString}` : ""}`;
|
|
60
|
-
const data = await apiClient.makeRequest(endpoint);
|
|
61
|
-
logInfo("Alert statistics fetched successfully", {
|
|
62
|
-
accountId,
|
|
63
|
-
alertIds: validated.alerts,
|
|
64
|
-
endpoint,
|
|
65
|
-
from: validated.from,
|
|
66
|
-
to: validated.to,
|
|
67
|
-
partial: data?.partial || false,
|
|
68
|
-
});
|
|
69
|
-
return {
|
|
70
|
-
content: [
|
|
71
|
-
{
|
|
72
|
-
type: "text",
|
|
73
|
-
text: JSON.stringify(data, null, 2),
|
|
74
|
-
},
|
|
75
|
-
],
|
|
76
|
-
};
|
|
77
44
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
45
|
+
}
|
|
46
|
+
if (args.country_stats !== undefined) {
|
|
47
|
+
if (typeof args.country_stats === "boolean") {
|
|
48
|
+
searchParams.append("country_stats", args.country_stats ? "10" : "0");
|
|
81
49
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
|
|
50
|
+
else {
|
|
51
|
+
searchParams.append("country_stats", String(args.country_stats));
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
const queryString = searchParams.toString();
|
|
55
|
+
const endpoint = `/accounts/${accountId}/stats${queryString ? `?${queryString}` : ""}`;
|
|
56
|
+
const data = await apiClient.makeRequest(endpoint);
|
|
57
|
+
logInfo("Alert statistics fetched successfully", {
|
|
58
|
+
accountId,
|
|
59
|
+
alertIds: args.alerts,
|
|
60
|
+
endpoint,
|
|
61
|
+
from: args.from,
|
|
62
|
+
to: args.to,
|
|
63
|
+
partial: data?.partial || false,
|
|
64
|
+
});
|
|
87
65
|
return {
|
|
88
|
-
|
|
89
|
-
description: "Retrieve comprehensive statistics for one or more alerts including mentions per interval, tones, influencers, geographical data, and reach metrics. Supports flexible date ranges, filtering, and aggregation options.",
|
|
90
|
-
inputSchema: zodToJsonSchema(FetchAlertStatsArgsSchema),
|
|
66
|
+
content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
|
|
91
67
|
};
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
};
|
|
68
|
+
});
|
|
69
|
+
}
|
|
@@ -1,60 +1,39 @@
|
|
|
1
|
-
import { zodToJsonSchema } from "zod-to-json-schema";
|
|
2
1
|
import { apiPath } from "../api-client.js";
|
|
3
|
-
import {
|
|
2
|
+
import { logInfo } from "../logger.js";
|
|
4
3
|
import { FetchMentionsArgsSchema } from "../types.js";
|
|
5
|
-
function
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
else {
|
|
21
|
-
searchParams.append(key, String(value));
|
|
22
|
-
}
|
|
4
|
+
export function registerFetchMentionsTool(server, apiClient) {
|
|
5
|
+
server.registerTool("fetch_mentions", {
|
|
6
|
+
title: "Fetch Mentions",
|
|
7
|
+
description: "Retrieve mentions associated with a specific alert. Supports various filters like source, folder, tone, countries, and advanced search queries.",
|
|
8
|
+
inputSchema: FetchMentionsArgsSchema.shape,
|
|
9
|
+
annotations: { readOnlyHint: true, openWorldHint: true },
|
|
10
|
+
}, async ({ alert_id, ...queryParams }) => {
|
|
11
|
+
const accountId = await apiClient.getAccountId();
|
|
12
|
+
const searchParams = new URLSearchParams();
|
|
13
|
+
for (const [key, value] of Object.entries(queryParams)) {
|
|
14
|
+
if (value !== undefined && value !== null) {
|
|
15
|
+
if (Array.isArray(value)) {
|
|
16
|
+
for (const item of value) {
|
|
17
|
+
searchParams.append(`${key}[]`, String(item));
|
|
23
18
|
}
|
|
24
19
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const data = await apiClient.makeRequest(endpoint);
|
|
29
|
-
logInfo("Mentions fetched successfully", {
|
|
30
|
-
accountId,
|
|
31
|
-
alertId: alert_id,
|
|
32
|
-
endpoint,
|
|
33
|
-
mentionCount: data?.mentions?.length || 0,
|
|
34
|
-
});
|
|
35
|
-
return {
|
|
36
|
-
content: [
|
|
37
|
-
{
|
|
38
|
-
type: "text",
|
|
39
|
-
text: JSON.stringify(data, null, 2),
|
|
40
|
-
},
|
|
41
|
-
],
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
catch (error) {
|
|
45
|
-
logError("Failed to fetch mentions", error);
|
|
46
|
-
throw error;
|
|
20
|
+
else {
|
|
21
|
+
searchParams.append(key, String(value));
|
|
22
|
+
}
|
|
47
23
|
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
|
|
24
|
+
}
|
|
25
|
+
const queryString = searchParams.toString();
|
|
26
|
+
const path = apiPath `/accounts/${accountId}/alerts/${alert_id}/mentions`;
|
|
27
|
+
const endpoint = queryString ? `${path}?${queryString}` : path;
|
|
28
|
+
const data = await apiClient.makeRequest(endpoint);
|
|
29
|
+
logInfo("Mentions fetched successfully", {
|
|
30
|
+
accountId,
|
|
31
|
+
alertId: alert_id,
|
|
32
|
+
endpoint,
|
|
33
|
+
mentionCount: data?.mentions?.length || 0,
|
|
34
|
+
});
|
|
53
35
|
return {
|
|
54
|
-
|
|
55
|
-
description: "Retrieve mentions associated with a specific alert. Supports various filters like source, folder, tone, countries, and advanced search queries.",
|
|
56
|
-
inputSchema: zodToJsonSchema(FetchMentionsArgsSchema),
|
|
36
|
+
content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
|
|
57
37
|
};
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
};
|
|
38
|
+
});
|
|
39
|
+
}
|
|
@@ -1,45 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
function
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
{
|
|
19
|
-
type: "text",
|
|
20
|
-
text: JSON.stringify(filteredResponse, null, 2),
|
|
21
|
-
},
|
|
22
|
-
],
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
catch (error) {
|
|
26
|
-
logError("Failed to get account info", error);
|
|
27
|
-
throw error;
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
export const getAccountInfoTool = {
|
|
33
|
-
getDefinition() {
|
|
1
|
+
import { logInfo } from "../logger.js";
|
|
2
|
+
export function registerGetAccountInfoTool(server, apiClient) {
|
|
3
|
+
server.registerTool("get_account_info", {
|
|
4
|
+
title: "Get Account Info",
|
|
5
|
+
description: "Get the current account's ID, its groups, and whether it can create advanced alerts (canCreateAdvancedAlert).",
|
|
6
|
+
annotations: { readOnlyHint: true, openWorldHint: true },
|
|
7
|
+
}, async () => {
|
|
8
|
+
const data = await apiClient.getAccountInfo();
|
|
9
|
+
const filteredResponse = {
|
|
10
|
+
accountId: data.account.id,
|
|
11
|
+
canCreateAdvancedAlert: data.account.subscription.advanced_query_access,
|
|
12
|
+
groups: data.account.groups?.map((group) => ({
|
|
13
|
+
id: group.id,
|
|
14
|
+
name: group.name,
|
|
15
|
+
})) || [],
|
|
16
|
+
};
|
|
17
|
+
logInfo("Account info retrieved", { accountId: data.account.id });
|
|
34
18
|
return {
|
|
35
|
-
|
|
36
|
-
description: "Get current account information including subscription plan, account ID, and capabilities. This tool should be called first to understand account limitations and determine which alert creation tools are available.",
|
|
37
|
-
inputSchema: {
|
|
38
|
-
type: "object",
|
|
39
|
-
properties: {},
|
|
40
|
-
required: [],
|
|
41
|
-
},
|
|
19
|
+
content: [{ type: "text", text: JSON.stringify(filteredResponse, null, 2) }],
|
|
42
20
|
};
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
};
|
|
21
|
+
});
|
|
22
|
+
}
|
package/dist/tools/get_alert.js
CHANGED
|
@@ -1,38 +1,18 @@
|
|
|
1
|
-
import { zodToJsonSchema } from "zod-to-json-schema";
|
|
2
1
|
import { apiPath } from "../api-client.js";
|
|
3
|
-
import {
|
|
2
|
+
import { logInfo } from "../logger.js";
|
|
4
3
|
import { GetAlertArgsSchema } from "../types.js";
|
|
5
|
-
function
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
{
|
|
16
|
-
type: "text",
|
|
17
|
-
text: JSON.stringify(data, null, 2),
|
|
18
|
-
},
|
|
19
|
-
],
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
catch (error) {
|
|
23
|
-
logError("Failed to get alert", error);
|
|
24
|
-
throw error;
|
|
25
|
-
}
|
|
26
|
-
},
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
export const getAlertTool = {
|
|
30
|
-
getDefinition() {
|
|
4
|
+
export function registerGetAlertTool(server, apiClient) {
|
|
5
|
+
server.registerTool("get_alert", {
|
|
6
|
+
title: "Get Alert",
|
|
7
|
+
description: "Get detailed information about a specific alert by its ID.",
|
|
8
|
+
inputSchema: GetAlertArgsSchema.shape,
|
|
9
|
+
annotations: { readOnlyHint: true, openWorldHint: true },
|
|
10
|
+
}, async ({ alert_id }) => {
|
|
11
|
+
const accountId = await apiClient.getAccountId();
|
|
12
|
+
const data = await apiClient.makeRequest(apiPath `/accounts/${accountId}/alerts/${alert_id}`);
|
|
13
|
+
logInfo("Alert retrieved", { accountId, alertId: alert_id });
|
|
31
14
|
return {
|
|
32
|
-
|
|
33
|
-
description: "Get detailed information about a specific alert by its ID.",
|
|
34
|
-
inputSchema: zodToJsonSchema(GetAlertArgsSchema),
|
|
15
|
+
content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
|
|
35
16
|
};
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
};
|
|
17
|
+
});
|
|
18
|
+
}
|
|
@@ -1,46 +1,23 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { logInfo } from "../logger.js";
|
|
2
2
|
import { AppDataResponseSchema } from "../types.js";
|
|
3
|
-
function
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
{
|
|
20
|
-
type: "text",
|
|
21
|
-
text: JSON.stringify(filteredResponse, null, 2),
|
|
22
|
-
},
|
|
23
|
-
],
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
catch (error) {
|
|
27
|
-
logError("Failed to get app data", error);
|
|
28
|
-
throw error;
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
export const getAppDataTool = {
|
|
34
|
-
getDefinition() {
|
|
3
|
+
export function registerGetAppDataTool(server, apiClient) {
|
|
4
|
+
server.registerTool("get_app_data", {
|
|
5
|
+
title: "Get Languages, Countries and Sources",
|
|
6
|
+
description: "Get application configuration data including available languages, countries, sources, colors, and other metadata needed for creating alerts.",
|
|
7
|
+
annotations: { readOnlyHint: true, openWorldHint: true },
|
|
8
|
+
}, async () => {
|
|
9
|
+
const rawData = await apiClient.makeRequest("/app/data");
|
|
10
|
+
const data = AppDataResponseSchema.parse(rawData);
|
|
11
|
+
const filteredResponse = {
|
|
12
|
+
languages: Object.keys(data.alert_languages || {}),
|
|
13
|
+
countries: Object.keys(data.alert_countries || {}),
|
|
14
|
+
sources: Object.entries(data.alert_sources || {})
|
|
15
|
+
.filter(([_, source]) => !source.hidden)
|
|
16
|
+
.map(([code]) => code),
|
|
17
|
+
};
|
|
18
|
+
logInfo("App data retrieved");
|
|
35
19
|
return {
|
|
36
|
-
|
|
37
|
-
description: "Get application configuration data including available languages, countries, sources, colors, and other metadata needed for creating alerts.",
|
|
38
|
-
inputSchema: {
|
|
39
|
-
type: "object",
|
|
40
|
-
properties: {},
|
|
41
|
-
required: [],
|
|
42
|
-
},
|
|
20
|
+
content: [{ type: "text", text: JSON.stringify(filteredResponse, null, 2) }],
|
|
43
21
|
};
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
};
|
|
22
|
+
});
|
|
23
|
+
}
|
package/dist/tools/index.js
CHANGED
|
@@ -1,57 +1,26 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
unpauseAlertTool,
|
|
24
|
-
fetchMentionsTool,
|
|
25
|
-
fetchAlertStatsTool,
|
|
26
|
-
];
|
|
27
|
-
export function getToolDefinitions() {
|
|
28
|
-
return tools.map((tool) => tool.getDefinition());
|
|
29
|
-
}
|
|
30
|
-
export class ToolHandlers {
|
|
31
|
-
apiClient;
|
|
32
|
-
handlers;
|
|
33
|
-
constructor(apiClient) {
|
|
34
|
-
this.apiClient = apiClient;
|
|
35
|
-
this.handlers = new Map();
|
|
36
|
-
for (const tool of tools) {
|
|
37
|
-
const handler = tool.createHandler(apiClient);
|
|
38
|
-
this.handlers.set(tool.getDefinition().name, handler);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
async handleTool(name, args) {
|
|
42
|
-
const handler = this.handlers.get(name);
|
|
43
|
-
if (!handler) {
|
|
44
|
-
throw new McpError(ErrorCode.MethodNotFound, `Unknown tool: ${name}`);
|
|
45
|
-
}
|
|
46
|
-
logInfo("Tool call started", { tool: name });
|
|
47
|
-
try {
|
|
48
|
-
const result = await handler.handle(args);
|
|
49
|
-
logInfo("Tool call completed", { tool: name });
|
|
50
|
-
return result;
|
|
51
|
-
}
|
|
52
|
-
catch (error) {
|
|
53
|
-
logError("Tool call failed", error, { tool: name, args });
|
|
54
|
-
throw error;
|
|
55
|
-
}
|
|
1
|
+
import { registerCreateAdvancedAlertTool } from "./create_advanced_alert.js";
|
|
2
|
+
import { registerCreateBasicAlertTool } from "./create_basic_alert.js";
|
|
3
|
+
import { registerFetchAlertStatsTool } from "./fetch_alert_stats.js";
|
|
4
|
+
import { registerFetchMentionsTool } from "./fetch_mentions.js";
|
|
5
|
+
import { registerGetAccountInfoTool } from "./get_account_info.js";
|
|
6
|
+
import { registerGetAlertTool } from "./get_alert.js";
|
|
7
|
+
import { registerGetAppDataTool } from "./get_app_data.js";
|
|
8
|
+
import { registerListAlertsTool } from "./list_alerts.js";
|
|
9
|
+
import { registerPauseAlertTool } from "./pause_alert.js";
|
|
10
|
+
import { registerUnpauseAlertTool } from "./unpause_alert.js";
|
|
11
|
+
import { registerUpdateAlertTool } from "./update_alert.js";
|
|
12
|
+
export function registerTools(server, apiClient, readOnly) {
|
|
13
|
+
registerGetAccountInfoTool(server, apiClient);
|
|
14
|
+
registerGetAppDataTool(server, apiClient);
|
|
15
|
+
registerListAlertsTool(server, apiClient);
|
|
16
|
+
registerGetAlertTool(server, apiClient);
|
|
17
|
+
if (!readOnly) {
|
|
18
|
+
registerCreateBasicAlertTool(server, apiClient);
|
|
19
|
+
registerCreateAdvancedAlertTool(server, apiClient);
|
|
20
|
+
registerUpdateAlertTool(server, apiClient);
|
|
21
|
+
registerPauseAlertTool(server, apiClient);
|
|
22
|
+
registerUnpauseAlertTool(server, apiClient);
|
|
56
23
|
}
|
|
24
|
+
registerFetchMentionsTool(server, apiClient);
|
|
25
|
+
registerFetchAlertStatsTool(server, apiClient);
|
|
57
26
|
}
|
|
@@ -1,43 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { logError, logInfo } from "../logger.js";
|
|
1
|
+
import { logInfo } from "../logger.js";
|
|
3
2
|
import { ListAlertsArgsSchema } from "../types.js";
|
|
4
|
-
function
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
{
|
|
21
|
-
type: "text",
|
|
22
|
-
text: JSON.stringify(data, null, 2),
|
|
23
|
-
},
|
|
24
|
-
],
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
catch (error) {
|
|
28
|
-
logError("Failed to list alerts", error);
|
|
29
|
-
throw error;
|
|
30
|
-
}
|
|
31
|
-
},
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
export const listAlertsTool = {
|
|
35
|
-
getDefinition() {
|
|
3
|
+
export function registerListAlertsTool(server, apiClient) {
|
|
4
|
+
server.registerTool("list_alerts", {
|
|
5
|
+
title: "List Alerts",
|
|
6
|
+
description: "List all monitoring alerts for the current account with pagination support.",
|
|
7
|
+
inputSchema: ListAlertsArgsSchema.shape,
|
|
8
|
+
annotations: { readOnlyHint: true, openWorldHint: true },
|
|
9
|
+
}, async ({ limit, cursor }) => {
|
|
10
|
+
const accountId = await apiClient.getAccountId();
|
|
11
|
+
const queryParams = new URLSearchParams();
|
|
12
|
+
if (limit)
|
|
13
|
+
queryParams.append("limit", limit.toString());
|
|
14
|
+
if (cursor)
|
|
15
|
+
queryParams.append("cursor", cursor);
|
|
16
|
+
const endpoint = `/accounts/${accountId}/alerts${queryParams.toString() ? `?${queryParams.toString()}` : ""}`;
|
|
17
|
+
const data = await apiClient.makeRequest(endpoint);
|
|
18
|
+
logInfo("Alerts listed", { accountId, limit, cursor });
|
|
36
19
|
return {
|
|
37
|
-
|
|
38
|
-
description: "List all monitoring alerts for the current account with pagination support.",
|
|
39
|
-
inputSchema: zodToJsonSchema(ListAlertsArgsSchema),
|
|
20
|
+
content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
|
|
40
21
|
};
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
};
|
|
22
|
+
});
|
|
23
|
+
}
|