@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,40 +1,25 @@
|
|
|
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 { PauseAlertArgsSchema } from "../types.js";
|
|
5
|
-
function
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
return {
|
|
16
|
-
content: [
|
|
17
|
-
{
|
|
18
|
-
type: "text",
|
|
19
|
-
text: `Alert ${alert_id} paused.`,
|
|
20
|
-
},
|
|
21
|
-
],
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
catch (error) {
|
|
25
|
-
logError("Failed to pause alert", error);
|
|
26
|
-
throw error;
|
|
27
|
-
}
|
|
4
|
+
export function registerPauseAlertTool(server, apiClient) {
|
|
5
|
+
server.registerTool("pause_alert", {
|
|
6
|
+
title: "Pause Alert",
|
|
7
|
+
description: "Temporarily pause monitoring for a specific alert.",
|
|
8
|
+
inputSchema: PauseAlertArgsSchema.shape,
|
|
9
|
+
annotations: {
|
|
10
|
+
readOnlyHint: false,
|
|
11
|
+
destructiveHint: false,
|
|
12
|
+
idempotentHint: true,
|
|
13
|
+
openWorldHint: true,
|
|
28
14
|
},
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
15
|
+
}, async ({ alert_id }) => {
|
|
16
|
+
const accountId = await apiClient.getAccountId();
|
|
17
|
+
await apiClient.makeRequest(apiPath `/accounts/${accountId}/alerts/${alert_id}/pause`, {
|
|
18
|
+
method: "POST",
|
|
19
|
+
});
|
|
20
|
+
logInfo("Alert paused", { accountId, alertId: alert_id });
|
|
33
21
|
return {
|
|
34
|
-
|
|
35
|
-
description: "Temporarily pause monitoring for a specific alert.",
|
|
36
|
-
inputSchema: zodToJsonSchema(PauseAlertArgsSchema),
|
|
22
|
+
content: [{ type: "text", text: `Alert ${alert_id} paused.` }],
|
|
37
23
|
};
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
};
|
|
24
|
+
});
|
|
25
|
+
}
|
|
@@ -1,40 +1,25 @@
|
|
|
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 { UnpauseAlertArgsSchema } from "../types.js";
|
|
5
|
-
function
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
return {
|
|
16
|
-
content: [
|
|
17
|
-
{
|
|
18
|
-
type: "text",
|
|
19
|
-
text: `Alert ${alert_id} unpaused.`,
|
|
20
|
-
},
|
|
21
|
-
],
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
catch (error) {
|
|
25
|
-
logError("Failed to unpause alert", error);
|
|
26
|
-
throw error;
|
|
27
|
-
}
|
|
4
|
+
export function registerUnpauseAlertTool(server, apiClient) {
|
|
5
|
+
server.registerTool("unpause_alert", {
|
|
6
|
+
title: "Unpause Alert",
|
|
7
|
+
description: "Resume monitoring for a previously paused alert.",
|
|
8
|
+
inputSchema: UnpauseAlertArgsSchema.shape,
|
|
9
|
+
annotations: {
|
|
10
|
+
readOnlyHint: false,
|
|
11
|
+
destructiveHint: false,
|
|
12
|
+
idempotentHint: true,
|
|
13
|
+
openWorldHint: true,
|
|
28
14
|
},
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
15
|
+
}, async ({ alert_id }) => {
|
|
16
|
+
const accountId = await apiClient.getAccountId();
|
|
17
|
+
await apiClient.makeRequest(apiPath `/accounts/${accountId}/alerts/${alert_id}/unpause`, {
|
|
18
|
+
method: "POST",
|
|
19
|
+
});
|
|
20
|
+
logInfo("Alert unpaused", { accountId, alertId: alert_id });
|
|
33
21
|
return {
|
|
34
|
-
|
|
35
|
-
description: "Resume monitoring for a previously paused alert.",
|
|
36
|
-
inputSchema: zodToJsonSchema(UnpauseAlertArgsSchema),
|
|
22
|
+
content: [{ type: "text", text: `Alert ${alert_id} unpaused.` }],
|
|
37
23
|
};
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
};
|
|
24
|
+
});
|
|
25
|
+
}
|
|
@@ -1,59 +1,48 @@
|
|
|
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 { UpdateAlertArgsSchema } from "../types.js";
|
|
5
|
-
function
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
type: "advanced",
|
|
16
|
-
query_string,
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
else if (included_keywords !== undefined ||
|
|
20
|
-
required_keywords !== undefined ||
|
|
21
|
-
excluded_keywords !== undefined) {
|
|
22
|
-
requestBody.query = {
|
|
23
|
-
type: "basic",
|
|
24
|
-
included_keywords,
|
|
25
|
-
required_keywords,
|
|
26
|
-
excluded_keywords,
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
const data = await apiClient.makeRequest(apiPath `/accounts/${accountId}/alerts/${alert_id}`, {
|
|
30
|
-
method: "PUT",
|
|
31
|
-
body: JSON.stringify(requestBody),
|
|
32
|
-
});
|
|
33
|
-
logInfo("Alert updated", { accountId, alertId: alert_id });
|
|
34
|
-
return {
|
|
35
|
-
content: [
|
|
36
|
-
{
|
|
37
|
-
type: "text",
|
|
38
|
-
text: JSON.stringify(data, null, 2),
|
|
39
|
-
},
|
|
40
|
-
],
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
catch (error) {
|
|
44
|
-
logError("Failed to update alert", error);
|
|
45
|
-
throw error;
|
|
46
|
-
}
|
|
4
|
+
export function registerUpdateAlertTool(server, apiClient) {
|
|
5
|
+
server.registerTool("update_alert", {
|
|
6
|
+
title: "Update Alert",
|
|
7
|
+
description: "Update an existing alert with new criteria or settings. An alert's query type is fixed at creation: included_keywords, required_keywords and excluded_keywords apply only to basic alerts, and query_string only to advanced alerts. Sending a field of the other type rejects the whole update; to change the query type, create a new alert with create_basic_alert or create_advanced_alert.",
|
|
8
|
+
inputSchema: UpdateAlertArgsSchema.shape,
|
|
9
|
+
annotations: {
|
|
10
|
+
readOnlyHint: false,
|
|
11
|
+
destructiveHint: true,
|
|
12
|
+
idempotentHint: true,
|
|
13
|
+
openWorldHint: true,
|
|
47
14
|
},
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
15
|
+
}, async ({ alert_id, included_keywords, required_keywords, excluded_keywords, query_string, ...updateData }) => {
|
|
16
|
+
const hasKeywords = included_keywords !== undefined ||
|
|
17
|
+
required_keywords !== undefined ||
|
|
18
|
+
excluded_keywords !== undefined;
|
|
19
|
+
// Not a .refine: McpServer lists a zod v3 ZodEffects input schema as an object without properties.
|
|
20
|
+
if (query_string !== undefined && hasKeywords) {
|
|
21
|
+
throw new Error("query_string cannot be combined with included_keywords, required_keywords or excluded_keywords");
|
|
22
|
+
}
|
|
23
|
+
const accountId = await apiClient.getAccountId();
|
|
24
|
+
const requestBody = { ...updateData };
|
|
25
|
+
if (query_string !== undefined) {
|
|
26
|
+
requestBody.query = {
|
|
27
|
+
type: "advanced",
|
|
28
|
+
query_string,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
else if (hasKeywords) {
|
|
32
|
+
requestBody.query = {
|
|
33
|
+
type: "basic",
|
|
34
|
+
included_keywords,
|
|
35
|
+
required_keywords,
|
|
36
|
+
excluded_keywords,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
const data = await apiClient.makeRequest(apiPath `/accounts/${accountId}/alerts/${alert_id}`, {
|
|
40
|
+
method: "PUT",
|
|
41
|
+
body: JSON.stringify(requestBody),
|
|
42
|
+
});
|
|
43
|
+
logInfo("Alert updated", { accountId, alertId: alert_id });
|
|
52
44
|
return {
|
|
53
|
-
|
|
54
|
-
description: "Update an existing alert with new criteria or settings.",
|
|
55
|
-
inputSchema: zodToJsonSchema(UpdateAlertArgsSchema),
|
|
45
|
+
content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
|
|
56
46
|
};
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
};
|
|
47
|
+
});
|
|
48
|
+
}
|
package/dist/types.js
CHANGED
|
@@ -115,8 +115,7 @@ export const CreateAdvancedAlertArgsSchema = z.object({
|
|
|
115
115
|
.optional()
|
|
116
116
|
.describe("An array of blocked sites from which you don't want mentions to be tracked."),
|
|
117
117
|
});
|
|
118
|
-
export const UpdateAlertArgsSchema = z
|
|
119
|
-
.object({
|
|
118
|
+
export const UpdateAlertArgsSchema = z.object({
|
|
120
119
|
alert_id: z.string().describe("The alert ID to update"),
|
|
121
120
|
name: z.string().min(1).max(255).optional().describe("New alert name (1-255 characters)"),
|
|
122
121
|
description: z
|
|
@@ -132,19 +131,19 @@ export const UpdateAlertArgsSchema = z
|
|
|
132
131
|
included_keywords: z
|
|
133
132
|
.array(z.string())
|
|
134
133
|
.optional()
|
|
135
|
-
.describe("Keywords to include
|
|
134
|
+
.describe("Keywords to include. Basic alerts only. Replaces the alert's list; leave out to keep it."),
|
|
136
135
|
required_keywords: z
|
|
137
136
|
.array(z.string())
|
|
138
137
|
.optional()
|
|
139
|
-
.describe("Required keywords
|
|
138
|
+
.describe("Required keywords. Basic alerts only. Replaces the alert's list; leave out to keep it, or send an empty list to clear it."),
|
|
140
139
|
excluded_keywords: z
|
|
141
140
|
.array(z.string())
|
|
142
141
|
.optional()
|
|
143
|
-
.describe("Excluded keywords
|
|
142
|
+
.describe("Excluded keywords. Basic alerts only. Replaces the alert's list; leave out to keep it."),
|
|
144
143
|
query_string: z
|
|
145
144
|
.string()
|
|
146
145
|
.optional()
|
|
147
|
-
.describe("Advanced query string
|
|
146
|
+
.describe("Advanced query string. Advanced alerts only. Cannot be combined with included_keywords, required_keywords or excluded_keywords."),
|
|
148
147
|
languages: z.array(z.string()).max(5).optional().describe("Language codes to monitor (max 5)"),
|
|
149
148
|
countries: z.array(z.string()).optional().describe("Country codes to monitor"),
|
|
150
149
|
sources: z
|
|
@@ -152,13 +151,6 @@ export const UpdateAlertArgsSchema = z
|
|
|
152
151
|
.optional()
|
|
153
152
|
.describe("Sources to monitor. List available sources using get_app_data tool."),
|
|
154
153
|
blocked_sites: z.array(z.string()).optional().describe("Domains to exclude from monitoring"),
|
|
155
|
-
})
|
|
156
|
-
.refine((args) => args.query_string === undefined ||
|
|
157
|
-
(args.included_keywords === undefined &&
|
|
158
|
-
args.required_keywords === undefined &&
|
|
159
|
-
args.excluded_keywords === undefined), {
|
|
160
|
-
message: "query_string cannot be combined with included_keywords, required_keywords or excluded_keywords",
|
|
161
|
-
path: ["query_string"],
|
|
162
154
|
});
|
|
163
155
|
export const PauseAlertArgsSchema = z.object({
|
|
164
156
|
alert_id: z.string().describe("The alert ID to pause"),
|
|
@@ -240,15 +232,15 @@ export const FetchAlertStatsArgsSchema = z.object({
|
|
|
240
232
|
.array(z.string())
|
|
241
233
|
.min(1)
|
|
242
234
|
.describe("One or more alert IDs to fetch statistics for (required)"),
|
|
243
|
-
from: statsDateTime("00:00:00").describe("
|
|
244
|
-
to: statsDateTime("23:59:59").describe("
|
|
235
|
+
from: statsDateTime("00:00:00").describe("First day to include, in timezone, e.g. 2026-11-01. Any time of day, fractional seconds or trailing Z is ignored."),
|
|
236
|
+
to: statsDateTime("23:59:59").describe("Last day to include, in timezone, e.g. 2026-11-30 to end on 30 November, not 2026-12-01. Any time of day, fractional seconds or trailing Z is ignored."),
|
|
245
237
|
timezone: z
|
|
246
238
|
.string()
|
|
247
239
|
.optional()
|
|
248
|
-
.describe("Timezone
|
|
240
|
+
.describe("Timezone in which from and to are read and buckets start, e.g. 'Europe/Berlin'. Defaults to UTC."),
|
|
249
241
|
interval: z
|
|
250
242
|
.enum(["P1D", "P1W", "P1M"])
|
|
251
|
-
.describe("
|
|
243
|
+
.describe("Bucket size: P1D (day), P1W (week, Monday to Sunday) or P1M (month). P1W and P1M widen the range to whole weeks or whole months."),
|
|
252
244
|
favorite: z.boolean().optional().describe("Only include statistics based on favorite mentions"),
|
|
253
245
|
tones: z
|
|
254
246
|
.array(z.number().int().min(-1).max(1))
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@maelitop/mention-mcp-server",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"mention-mcp-server": "dist/index.js"
|
|
@@ -37,9 +37,8 @@
|
|
|
37
37
|
},
|
|
38
38
|
"homepage": "https://github.com/MaelitoP/mention-mcp-server#readme",
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@modelcontextprotocol/sdk": "^1.
|
|
41
|
-
"zod": "^3.25.56"
|
|
42
|
-
"zod-to-json-schema": "^3.24.5"
|
|
40
|
+
"@modelcontextprotocol/sdk": "^1.32.2",
|
|
41
|
+
"zod": "^3.25.56"
|
|
43
42
|
},
|
|
44
43
|
"devDependencies": {
|
|
45
44
|
"@biomejs/biome": "^1.9.4",
|
package/dist/prompts/base.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/tools/base.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|