@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.
@@ -1,40 +1,25 @@
1
- import { zodToJsonSchema } from "zod-to-json-schema";
2
1
  import { apiPath } from "../api-client.js";
3
- import { logError, logInfo } from "../logger.js";
2
+ import { logInfo } from "../logger.js";
4
3
  import { PauseAlertArgsSchema } from "../types.js";
5
- function createPauseAlertHandler(apiClient) {
6
- return {
7
- async handle(args) {
8
- try {
9
- const { alert_id } = PauseAlertArgsSchema.parse(args);
10
- const accountId = await apiClient.getAccountId();
11
- await apiClient.makeRequest(apiPath `/accounts/${accountId}/alerts/${alert_id}/pause`, {
12
- method: "POST",
13
- });
14
- logInfo("Alert paused", { accountId, alertId: alert_id });
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
- export const pauseAlertTool = {
32
- getDefinition() {
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
- name: "pause_alert",
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
- createHandler: createPauseAlertHandler,
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 { logError, logInfo } from "../logger.js";
2
+ import { logInfo } from "../logger.js";
4
3
  import { UnpauseAlertArgsSchema } from "../types.js";
5
- function createUnpauseAlertHandler(apiClient) {
6
- return {
7
- async handle(args) {
8
- try {
9
- const { alert_id } = UnpauseAlertArgsSchema.parse(args);
10
- const accountId = await apiClient.getAccountId();
11
- await apiClient.makeRequest(apiPath `/accounts/${accountId}/alerts/${alert_id}/unpause`, {
12
- method: "POST",
13
- });
14
- logInfo("Alert unpaused", { accountId, alertId: alert_id });
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
- export const unpauseAlertTool = {
32
- getDefinition() {
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
- name: "unpause_alert",
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
- createHandler: createUnpauseAlertHandler,
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 { logError, logInfo } from "../logger.js";
2
+ import { logInfo } from "../logger.js";
4
3
  import { UpdateAlertArgsSchema } from "../types.js";
5
- function createUpdateAlertHandler(apiClient) {
6
- return {
7
- async handle(args) {
8
- try {
9
- const validated = UpdateAlertArgsSchema.parse(args);
10
- const { alert_id, included_keywords, required_keywords, excluded_keywords, query_string, ...updateData } = validated;
11
- const accountId = await apiClient.getAccountId();
12
- const requestBody = { ...updateData };
13
- if (query_string !== undefined) {
14
- requestBody.query = {
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
- export const updateAlertTool = {
51
- getDefinition() {
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
- name: "update_alert",
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
- createHandler: createUpdateAlertHandler,
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 (for basic queries)"),
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 (for basic queries)"),
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 (for basic queries)"),
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 (for advanced queries). Cannot be combined with included_keywords, required_keywords or excluded_keywords."),
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("Start of the range, inclusive, as local time in the timezone parameter: a date (2026-11-01, read as 00:00:00) or a date-time (2026-11-01T08:00:00). Fractional seconds and a trailing Z are ignored."),
244
- to: statsDateTime("23:59:59").describe("End of the range, inclusive, as local time in the timezone parameter: a date (2026-11-30, read as 23:59:59) or a date-time (2026-11-30T18:00:00). Fractional seconds and a trailing Z are ignored."),
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 used for from/to dates (e.g., 'Europe/Berlin', 'UTC')"),
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("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."),
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.4.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.12.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",
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};