@maelitop/mention-mcp-server 1.4.0 → 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 +124 -0
- package/README.md +21 -19
- package/dist/api-client.js +79 -33
- package/dist/config.js +17 -4
- package/dist/index.js +6 -58
- package/dist/logger.js +20 -55
- package/dist/prompts/build-boolean-query.js +16 -34
- package/dist/prompts/index.js +4 -3
- package/dist/server.js +17 -0
- package/dist/tools/create_advanced_alert.js +33 -62
- package/dist/tools/create_basic_alert.js +36 -53
- package/dist/tools/fetch_alert_stats.js +63 -90
- package/dist/tools/fetch_mentions.js +33 -53
- package/dist/tools/get_account_info.js +20 -44
- package/dist/tools/get_alert.js +15 -35
- package/dist/tools/get_app_data.js +20 -44
- package/dist/tools/index.js +24 -56
- package/dist/tools/list_alerts.js +20 -41
- package/dist/tools/pause_alert.js +21 -36
- package/dist/tools/unpause_alert.js +21 -36
- package/dist/tools/update_alert.js +44 -55
- package/dist/types.js +20 -21
- package/package.json +11 -16
- package/dist/__tests__/api-client.test.d.ts +0 -2
- package/dist/__tests__/api-client.test.d.ts.map +0 -1
- package/dist/__tests__/api-client.test.js +0 -132
- package/dist/__tests__/api-client.test.js.map +0 -1
- package/dist/__tests__/config.test.d.ts +0 -2
- package/dist/__tests__/config.test.d.ts.map +0 -1
- package/dist/__tests__/config.test.js +0 -48
- package/dist/__tests__/config.test.js.map +0 -1
- package/dist/__tests__/tools.test.d.ts +0 -2
- package/dist/__tests__/tools.test.d.ts.map +0 -1
- package/dist/__tests__/tools.test.js +0 -316
- package/dist/__tests__/tools.test.js.map +0 -1
- package/dist/__tests__/types.test.d.ts +0 -2
- package/dist/__tests__/types.test.d.ts.map +0 -1
- package/dist/__tests__/types.test.js +0 -179
- package/dist/__tests__/types.test.js.map +0 -1
- package/dist/api-client.d.ts +0 -14
- package/dist/api-client.d.ts.map +0 -1
- package/dist/api-client.js.map +0 -1
- package/dist/config.d.ts +0 -10
- package/dist/config.d.ts.map +0 -1
- package/dist/config.js.map +0 -1
- package/dist/index.d.ts +0 -3
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/logger.d.ts +0 -6
- package/dist/logger.d.ts.map +0 -1
- package/dist/logger.js.map +0 -1
- package/dist/prompts/base.d.ts +0 -25
- package/dist/prompts/base.d.ts.map +0 -1
- package/dist/prompts/base.js +0 -2
- package/dist/prompts/base.js.map +0 -1
- package/dist/prompts/build-boolean-query.d.ts +0 -3
- package/dist/prompts/build-boolean-query.d.ts.map +0 -1
- package/dist/prompts/build-boolean-query.js.map +0 -1
- package/dist/prompts/index.d.ts +0 -2
- package/dist/prompts/index.d.ts.map +0 -1
- package/dist/prompts/index.js.map +0 -1
- package/dist/tools/base.d.ts +0 -19
- package/dist/tools/base.d.ts.map +0 -1
- package/dist/tools/base.js +0 -2
- package/dist/tools/base.js.map +0 -1
- package/dist/tools/create_advanced_alert.d.ts +0 -3
- package/dist/tools/create_advanced_alert.d.ts.map +0 -1
- package/dist/tools/create_advanced_alert.js.map +0 -1
- package/dist/tools/create_basic_alert.d.ts +0 -3
- package/dist/tools/create_basic_alert.d.ts.map +0 -1
- package/dist/tools/create_basic_alert.js.map +0 -1
- package/dist/tools/fetch_alert_stats.d.ts +0 -3
- package/dist/tools/fetch_alert_stats.d.ts.map +0 -1
- package/dist/tools/fetch_alert_stats.js.map +0 -1
- package/dist/tools/fetch_mentions.d.ts +0 -3
- package/dist/tools/fetch_mentions.d.ts.map +0 -1
- package/dist/tools/fetch_mentions.js.map +0 -1
- package/dist/tools/get_account_info.d.ts +0 -3
- package/dist/tools/get_account_info.d.ts.map +0 -1
- package/dist/tools/get_account_info.js.map +0 -1
- package/dist/tools/get_alert.d.ts +0 -3
- package/dist/tools/get_alert.d.ts.map +0 -1
- package/dist/tools/get_alert.js.map +0 -1
- package/dist/tools/get_app_data.d.ts +0 -3
- package/dist/tools/get_app_data.d.ts.map +0 -1
- package/dist/tools/get_app_data.js.map +0 -1
- package/dist/tools/index.d.ts +0 -14
- package/dist/tools/index.d.ts.map +0 -1
- package/dist/tools/index.js.map +0 -1
- package/dist/tools/list_alerts.d.ts +0 -3
- package/dist/tools/list_alerts.d.ts.map +0 -1
- package/dist/tools/list_alerts.js.map +0 -1
- package/dist/tools/pause_alert.d.ts +0 -3
- package/dist/tools/pause_alert.d.ts.map +0 -1
- package/dist/tools/pause_alert.js.map +0 -1
- package/dist/tools/unpause_alert.d.ts +0 -3
- package/dist/tools/unpause_alert.d.ts.map +0 -1
- package/dist/tools/unpause_alert.js.map +0 -1
- package/dist/tools/update_alert.d.ts +0 -3
- package/dist/tools/update_alert.d.ts.map +0 -1
- package/dist/tools/update_alert.js.map +0 -1
- package/dist/types.d.ts +0 -448
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js.map +0 -1
|
@@ -1,47 +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
|
-
};
|
|
47
|
-
//# sourceMappingURL=get_app_data.js.map
|
|
22
|
+
});
|
|
23
|
+
}
|
package/dist/tools/index.js
CHANGED
|
@@ -1,58 +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
|
}
|
|
58
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1,44 +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
|
-
};
|
|
44
|
-
//# sourceMappingURL=list_alerts.js.map
|
|
22
|
+
});
|
|
23
|
+
}
|
|
@@ -1,40 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { apiPath } from "../api-client.js";
|
|
2
|
+
import { logInfo } from "../logger.js";
|
|
3
3
|
import { PauseAlertArgsSchema } from "../types.js";
|
|
4
|
-
function
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return {
|
|
15
|
-
content: [
|
|
16
|
-
{
|
|
17
|
-
type: "text",
|
|
18
|
-
text: JSON.stringify(data, null, 2),
|
|
19
|
-
},
|
|
20
|
-
],
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
catch (error) {
|
|
24
|
-
logError("Failed to pause alert", error);
|
|
25
|
-
throw error;
|
|
26
|
-
}
|
|
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,
|
|
27
14
|
},
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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 });
|
|
32
21
|
return {
|
|
33
|
-
|
|
34
|
-
description: "Temporarily pause monitoring for a specific alert.",
|
|
35
|
-
inputSchema: zodToJsonSchema(PauseAlertArgsSchema),
|
|
22
|
+
content: [{ type: "text", text: `Alert ${alert_id} paused.` }],
|
|
36
23
|
};
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
};
|
|
40
|
-
//# sourceMappingURL=pause_alert.js.map
|
|
24
|
+
});
|
|
25
|
+
}
|
|
@@ -1,40 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { apiPath } from "../api-client.js";
|
|
2
|
+
import { logInfo } from "../logger.js";
|
|
3
3
|
import { UnpauseAlertArgsSchema } from "../types.js";
|
|
4
|
-
function
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return {
|
|
15
|
-
content: [
|
|
16
|
-
{
|
|
17
|
-
type: "text",
|
|
18
|
-
text: JSON.stringify(data, null, 2),
|
|
19
|
-
},
|
|
20
|
-
],
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
catch (error) {
|
|
24
|
-
logError("Failed to unpause alert", error);
|
|
25
|
-
throw error;
|
|
26
|
-
}
|
|
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,
|
|
27
14
|
},
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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 });
|
|
32
21
|
return {
|
|
33
|
-
|
|
34
|
-
description: "Resume monitoring for a previously paused alert.",
|
|
35
|
-
inputSchema: zodToJsonSchema(UnpauseAlertArgsSchema),
|
|
22
|
+
content: [{ type: "text", text: `Alert ${alert_id} unpaused.` }],
|
|
36
23
|
};
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
};
|
|
40
|
-
//# sourceMappingURL=unpause_alert.js.map
|
|
24
|
+
});
|
|
25
|
+
}
|
|
@@ -1,59 +1,48 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { apiPath } from "../api-client.js";
|
|
2
|
+
import { logInfo } from "../logger.js";
|
|
3
3
|
import { UpdateAlertArgsSchema } from "../types.js";
|
|
4
|
-
function
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
requestBody.query = {
|
|
15
|
-
type: "basic",
|
|
16
|
-
included_keywords,
|
|
17
|
-
required_keywords,
|
|
18
|
-
excluded_keywords,
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
else if (query_type === "advanced") {
|
|
22
|
-
requestBody.query = {
|
|
23
|
-
type: "advanced",
|
|
24
|
-
query_string,
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
const data = await apiClient.makeRequest(`/accounts/${accountId}/alerts/${alert_id}`, {
|
|
29
|
-
method: "PUT",
|
|
30
|
-
body: JSON.stringify(requestBody),
|
|
31
|
-
});
|
|
32
|
-
logInfo("Alert updated", { accountId, alertId: alert_id });
|
|
33
|
-
return {
|
|
34
|
-
content: [
|
|
35
|
-
{
|
|
36
|
-
type: "text",
|
|
37
|
-
text: JSON.stringify(data, null, 2),
|
|
38
|
-
},
|
|
39
|
-
],
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
catch (error) {
|
|
43
|
-
logError("Failed to update alert", error);
|
|
44
|
-
throw error;
|
|
45
|
-
}
|
|
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,
|
|
46
14
|
},
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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 });
|
|
51
44
|
return {
|
|
52
|
-
|
|
53
|
-
description: "Update an existing alert with new criteria or settings.",
|
|
54
|
-
inputSchema: zodToJsonSchema(UpdateAlertArgsSchema),
|
|
45
|
+
content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
|
|
55
46
|
};
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
};
|
|
59
|
-
//# sourceMappingURL=update_alert.js.map
|
|
47
|
+
});
|
|
48
|
+
}
|
package/dist/types.js
CHANGED
|
@@ -84,7 +84,6 @@ export const CreateBasicAlertArgsSchema = z.object({
|
|
|
84
84
|
.array(z.string())
|
|
85
85
|
.optional()
|
|
86
86
|
.describe("An array of blocked sites from which you don't want mentions to be tracked."),
|
|
87
|
-
noise_detection: z.boolean().default(false).optional(),
|
|
88
87
|
});
|
|
89
88
|
export const CreateAdvancedAlertArgsSchema = z.object({
|
|
90
89
|
group_id: z
|
|
@@ -115,7 +114,6 @@ export const CreateAdvancedAlertArgsSchema = z.object({
|
|
|
115
114
|
.array(z.string())
|
|
116
115
|
.optional()
|
|
117
116
|
.describe("An array of blocked sites from which you don't want mentions to be tracked."),
|
|
118
|
-
noise_detection: z.boolean().default(false).optional(),
|
|
119
117
|
});
|
|
120
118
|
export const UpdateAlertArgsSchema = z.object({
|
|
121
119
|
alert_id: z.string().describe("The alert ID to update"),
|
|
@@ -130,28 +128,29 @@ export const UpdateAlertArgsSchema = z.object({
|
|
|
130
128
|
.regex(/^#[0-9a-fA-F]{6}$/)
|
|
131
129
|
.optional()
|
|
132
130
|
.describe("New alert color code"),
|
|
133
|
-
query_type: z.enum(["basic", "advanced"]).optional().describe("Type of query to update"),
|
|
134
131
|
included_keywords: z
|
|
135
132
|
.array(z.string())
|
|
136
133
|
.optional()
|
|
137
|
-
.describe("Keywords to include
|
|
134
|
+
.describe("Keywords to include. Basic alerts only. Replaces the alert's list; leave out to keep it."),
|
|
138
135
|
required_keywords: z
|
|
139
136
|
.array(z.string())
|
|
140
137
|
.optional()
|
|
141
|
-
.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."),
|
|
142
139
|
excluded_keywords: z
|
|
143
140
|
.array(z.string())
|
|
144
141
|
.optional()
|
|
145
|
-
.describe("Excluded keywords
|
|
146
|
-
query_string: z
|
|
142
|
+
.describe("Excluded keywords. Basic alerts only. Replaces the alert's list; leave out to keep it."),
|
|
143
|
+
query_string: z
|
|
144
|
+
.string()
|
|
145
|
+
.optional()
|
|
146
|
+
.describe("Advanced query string. Advanced alerts only. Cannot be combined with included_keywords, required_keywords or excluded_keywords."),
|
|
147
147
|
languages: z.array(z.string()).max(5).optional().describe("Language codes to monitor (max 5)"),
|
|
148
148
|
countries: z.array(z.string()).optional().describe("Country codes to monitor"),
|
|
149
149
|
sources: z
|
|
150
|
-
.array(z.
|
|
150
|
+
.array(z.string())
|
|
151
151
|
.optional()
|
|
152
|
-
.describe("Sources to monitor"),
|
|
152
|
+
.describe("Sources to monitor. List available sources using get_app_data tool."),
|
|
153
153
|
blocked_sites: z.array(z.string()).optional().describe("Domains to exclude from monitoring"),
|
|
154
|
-
noise_detection: z.boolean().optional().describe("Enable noise detection"),
|
|
155
154
|
});
|
|
156
155
|
export const PauseAlertArgsSchema = z.object({
|
|
157
156
|
alert_id: z.string().describe("The alert ID to pause"),
|
|
@@ -217,31 +216,32 @@ export const FetchMentionsArgsSchema = z.object({
|
|
|
217
216
|
])
|
|
218
217
|
.optional()
|
|
219
218
|
.describe("Sort by field"),
|
|
220
|
-
languages: z
|
|
221
|
-
.array(z.string())
|
|
222
|
-
.optional()
|
|
223
|
-
.describe("Filter by language codes. Multiple values allowed."),
|
|
224
219
|
timezone: z.string().optional().describe("Timezone for parsing date values in q parameter"),
|
|
225
220
|
q: z.string().optional().describe("Advanced keyword-based filtering"),
|
|
226
221
|
cursor: z.string().optional().describe("Pagination cursor for navigating results"),
|
|
227
222
|
});
|
|
223
|
+
// The stats endpoint rejects a Z, an offset, or a date-time without fractional seconds.
|
|
224
|
+
function statsDateTime(timeIfDateOnly) {
|
|
225
|
+
return z
|
|
226
|
+
.string()
|
|
227
|
+
.regex(/^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}:\d{2}(\.\d+)?Z?)?$/, "Expected a date (2026-11-01) or a date-time (2026-11-01T08:00:00), optionally ending in Z")
|
|
228
|
+
.transform((value) => `${value.slice(0, 10)}T${value.slice(11, 19) || timeIfDateOnly}.0`);
|
|
229
|
+
}
|
|
228
230
|
export const FetchAlertStatsArgsSchema = z.object({
|
|
229
231
|
alerts: z
|
|
230
232
|
.array(z.string())
|
|
231
233
|
.min(1)
|
|
232
234
|
.describe("One or more alert IDs to fetch statistics for (required)"),
|
|
233
|
-
from:
|
|
234
|
-
to:
|
|
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."),
|
|
235
237
|
timezone: z
|
|
236
238
|
.string()
|
|
237
239
|
.optional()
|
|
238
|
-
.describe("Timezone
|
|
240
|
+
.describe("Timezone in which from and to are read and buckets start, e.g. 'Europe/Berlin'. Defaults to UTC."),
|
|
239
241
|
interval: z
|
|
240
242
|
.enum(["P1D", "P1W", "P1M"])
|
|
241
|
-
.
|
|
242
|
-
.describe("Aggregation interval: P1D (daily), P1W (weekly), P1M (monthly)"),
|
|
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."),
|
|
243
244
|
favorite: z.boolean().optional().describe("Only include statistics based on favorite mentions"),
|
|
244
|
-
important: z.boolean().optional().describe("Only include statistics based on important mentions"),
|
|
245
245
|
tones: z
|
|
246
246
|
.array(z.number().int().min(-1).max(1))
|
|
247
247
|
.optional()
|
|
@@ -279,4 +279,3 @@ export const FetchAlertStatsArgsSchema = z.object({
|
|
|
279
279
|
.optional()
|
|
280
280
|
.describe("Filter by author influence score range. Format: 'min:max' (e.g., '50:100', ':90', '30:')"),
|
|
281
281
|
});
|
|
282
|
-
//# sourceMappingURL=types.js.map
|
package/package.json
CHANGED
|
@@ -1,29 +1,28 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@maelitop/mention-mcp-server",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
5
|
"bin": {
|
|
7
6
|
"mention-mcp-server": "dist/index.js"
|
|
8
7
|
},
|
|
9
|
-
"files": ["dist/**/*"],
|
|
8
|
+
"files": ["dist/**/*", "CHANGELOG.md"],
|
|
9
|
+
"engines": {
|
|
10
|
+
"node": ">=22"
|
|
11
|
+
},
|
|
10
12
|
"scripts": {
|
|
11
|
-
"build": "tsc",
|
|
13
|
+
"build": "node -e \"fs.rmSync('dist', { recursive: true, force: true })\" && tsc -p tsconfig.build.json",
|
|
12
14
|
"start": "node dist/index.js",
|
|
13
15
|
"dev": "tsx src/index.ts",
|
|
14
16
|
"prepublishOnly": "npm run build",
|
|
15
17
|
"test": "vitest",
|
|
16
18
|
"test:run": "vitest run",
|
|
17
|
-
"test:coverage": "vitest run --coverage",
|
|
18
19
|
"lint": "biome lint .",
|
|
19
20
|
"lint:fix": "biome lint --write .",
|
|
20
21
|
"format": "biome format --write .",
|
|
21
|
-
"check": "biome check .",
|
|
22
|
+
"check": "biome check . && tsc --noEmit",
|
|
22
23
|
"check:fix": "biome check --write .",
|
|
23
|
-
"ci": "npm run check && npm run build",
|
|
24
|
-
"version
|
|
25
|
-
"version:minor": "npm version minor",
|
|
26
|
-
"version:major": "npm version major"
|
|
24
|
+
"ci": "npm run check && npm run build && npm run test:run",
|
|
25
|
+
"version": "biome format --write package.json"
|
|
27
26
|
},
|
|
28
27
|
"keywords": ["mcp", "mention", "monitoring", "api", "agorapulse"],
|
|
29
28
|
"author": "MaelitoP",
|
|
@@ -38,16 +37,12 @@
|
|
|
38
37
|
},
|
|
39
38
|
"homepage": "https://github.com/MaelitoP/mention-mcp-server#readme",
|
|
40
39
|
"dependencies": {
|
|
41
|
-
"@modelcontextprotocol/sdk": "^1.
|
|
42
|
-
"
|
|
43
|
-
"pino-pretty": "^13.0.0",
|
|
44
|
-
"zod": "^3.25.56",
|
|
45
|
-
"zod-to-json-schema": "^3.24.5"
|
|
40
|
+
"@modelcontextprotocol/sdk": "^1.32.2",
|
|
41
|
+
"zod": "^3.25.56"
|
|
46
42
|
},
|
|
47
43
|
"devDependencies": {
|
|
48
44
|
"@biomejs/biome": "^1.9.4",
|
|
49
45
|
"@types/node": "^22.15.30",
|
|
50
|
-
"@vitest/ui": "^3.2.4",
|
|
51
46
|
"tsx": "^4.19.4",
|
|
52
47
|
"typescript": "^5.8.3",
|
|
53
48
|
"vitest": "^3.2.4"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"api-client.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/api-client.test.ts"],"names":[],"mappings":""}
|