@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.
Files changed (104) hide show
  1. package/CHANGELOG.md +124 -0
  2. package/README.md +21 -19
  3. package/dist/api-client.js +79 -33
  4. package/dist/config.js +17 -4
  5. package/dist/index.js +6 -58
  6. package/dist/logger.js +20 -55
  7. package/dist/prompts/build-boolean-query.js +16 -34
  8. package/dist/prompts/index.js +4 -3
  9. package/dist/server.js +17 -0
  10. package/dist/tools/create_advanced_alert.js +33 -62
  11. package/dist/tools/create_basic_alert.js +36 -53
  12. package/dist/tools/fetch_alert_stats.js +63 -90
  13. package/dist/tools/fetch_mentions.js +33 -53
  14. package/dist/tools/get_account_info.js +20 -44
  15. package/dist/tools/get_alert.js +15 -35
  16. package/dist/tools/get_app_data.js +20 -44
  17. package/dist/tools/index.js +24 -56
  18. package/dist/tools/list_alerts.js +20 -41
  19. package/dist/tools/pause_alert.js +21 -36
  20. package/dist/tools/unpause_alert.js +21 -36
  21. package/dist/tools/update_alert.js +44 -55
  22. package/dist/types.js +20 -21
  23. package/package.json +11 -16
  24. package/dist/__tests__/api-client.test.d.ts +0 -2
  25. package/dist/__tests__/api-client.test.d.ts.map +0 -1
  26. package/dist/__tests__/api-client.test.js +0 -132
  27. package/dist/__tests__/api-client.test.js.map +0 -1
  28. package/dist/__tests__/config.test.d.ts +0 -2
  29. package/dist/__tests__/config.test.d.ts.map +0 -1
  30. package/dist/__tests__/config.test.js +0 -48
  31. package/dist/__tests__/config.test.js.map +0 -1
  32. package/dist/__tests__/tools.test.d.ts +0 -2
  33. package/dist/__tests__/tools.test.d.ts.map +0 -1
  34. package/dist/__tests__/tools.test.js +0 -316
  35. package/dist/__tests__/tools.test.js.map +0 -1
  36. package/dist/__tests__/types.test.d.ts +0 -2
  37. package/dist/__tests__/types.test.d.ts.map +0 -1
  38. package/dist/__tests__/types.test.js +0 -179
  39. package/dist/__tests__/types.test.js.map +0 -1
  40. package/dist/api-client.d.ts +0 -14
  41. package/dist/api-client.d.ts.map +0 -1
  42. package/dist/api-client.js.map +0 -1
  43. package/dist/config.d.ts +0 -10
  44. package/dist/config.d.ts.map +0 -1
  45. package/dist/config.js.map +0 -1
  46. package/dist/index.d.ts +0 -3
  47. package/dist/index.d.ts.map +0 -1
  48. package/dist/index.js.map +0 -1
  49. package/dist/logger.d.ts +0 -6
  50. package/dist/logger.d.ts.map +0 -1
  51. package/dist/logger.js.map +0 -1
  52. package/dist/prompts/base.d.ts +0 -25
  53. package/dist/prompts/base.d.ts.map +0 -1
  54. package/dist/prompts/base.js +0 -2
  55. package/dist/prompts/base.js.map +0 -1
  56. package/dist/prompts/build-boolean-query.d.ts +0 -3
  57. package/dist/prompts/build-boolean-query.d.ts.map +0 -1
  58. package/dist/prompts/build-boolean-query.js.map +0 -1
  59. package/dist/prompts/index.d.ts +0 -2
  60. package/dist/prompts/index.d.ts.map +0 -1
  61. package/dist/prompts/index.js.map +0 -1
  62. package/dist/tools/base.d.ts +0 -19
  63. package/dist/tools/base.d.ts.map +0 -1
  64. package/dist/tools/base.js +0 -2
  65. package/dist/tools/base.js.map +0 -1
  66. package/dist/tools/create_advanced_alert.d.ts +0 -3
  67. package/dist/tools/create_advanced_alert.d.ts.map +0 -1
  68. package/dist/tools/create_advanced_alert.js.map +0 -1
  69. package/dist/tools/create_basic_alert.d.ts +0 -3
  70. package/dist/tools/create_basic_alert.d.ts.map +0 -1
  71. package/dist/tools/create_basic_alert.js.map +0 -1
  72. package/dist/tools/fetch_alert_stats.d.ts +0 -3
  73. package/dist/tools/fetch_alert_stats.d.ts.map +0 -1
  74. package/dist/tools/fetch_alert_stats.js.map +0 -1
  75. package/dist/tools/fetch_mentions.d.ts +0 -3
  76. package/dist/tools/fetch_mentions.d.ts.map +0 -1
  77. package/dist/tools/fetch_mentions.js.map +0 -1
  78. package/dist/tools/get_account_info.d.ts +0 -3
  79. package/dist/tools/get_account_info.d.ts.map +0 -1
  80. package/dist/tools/get_account_info.js.map +0 -1
  81. package/dist/tools/get_alert.d.ts +0 -3
  82. package/dist/tools/get_alert.d.ts.map +0 -1
  83. package/dist/tools/get_alert.js.map +0 -1
  84. package/dist/tools/get_app_data.d.ts +0 -3
  85. package/dist/tools/get_app_data.d.ts.map +0 -1
  86. package/dist/tools/get_app_data.js.map +0 -1
  87. package/dist/tools/index.d.ts +0 -14
  88. package/dist/tools/index.d.ts.map +0 -1
  89. package/dist/tools/index.js.map +0 -1
  90. package/dist/tools/list_alerts.d.ts +0 -3
  91. package/dist/tools/list_alerts.d.ts.map +0 -1
  92. package/dist/tools/list_alerts.js.map +0 -1
  93. package/dist/tools/pause_alert.d.ts +0 -3
  94. package/dist/tools/pause_alert.d.ts.map +0 -1
  95. package/dist/tools/pause_alert.js.map +0 -1
  96. package/dist/tools/unpause_alert.d.ts +0 -3
  97. package/dist/tools/unpause_alert.d.ts.map +0 -1
  98. package/dist/tools/unpause_alert.js.map +0 -1
  99. package/dist/tools/update_alert.d.ts +0 -3
  100. package/dist/tools/update_alert.d.ts.map +0 -1
  101. package/dist/tools/update_alert.js.map +0 -1
  102. package/dist/types.d.ts +0 -448
  103. package/dist/types.d.ts.map +0 -1
  104. package/dist/types.js.map +0 -1
package/dist/server.js ADDED
@@ -0,0 +1,17 @@
1
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ import { registerPrompts } from "./prompts/index.js";
3
+ import { registerTools } from "./tools/index.js";
4
+ const alertAuthoringInstructions = [
5
+ "Call get_account_info first. Its groups give the group_id that create_basic_alert and create_advanced_alert require, and canCreateAdvancedAlert says whether the account can use create_advanced_alert; when it is false, use create_basic_alert.",
6
+ "get_app_data lists the language and source codes that alerts accept, and the country codes that update_alert accepts.",
7
+ ];
8
+ const listAlertsInstruction = "list_alerts returns the alert IDs that the other alert, mention and stats tools take.";
9
+ export function createServer(apiClient, version, { readOnly }) {
10
+ const instructions = readOnly
11
+ ? listAlertsInstruction
12
+ : [...alertAuthoringInstructions, listAlertsInstruction].join("\n");
13
+ const server = new McpServer({ name: "mention-mcp-server", version }, { instructions });
14
+ registerTools(server, apiClient, readOnly);
15
+ registerPrompts(server);
16
+ return server;
17
+ }
@@ -1,66 +1,37 @@
1
- import { zodToJsonSchema } from "zod-to-json-schema";
2
- import { logError, logInfo } from "../logger.js";
1
+ import { logInfo } from "../logger.js";
3
2
  import { CreateAdvancedAlertArgsSchema, CreateAlertResponseSchema } from "../types.js";
4
- function createAdvancedAlertHandler(apiClient) {
5
- return {
6
- async handle(args) {
7
- try {
8
- const validated = CreateAdvancedAlertArgsSchema.parse(args);
9
- const accountId = await apiClient.getAccountId();
10
- const { query_string, ...requestData } = validated;
11
- const requestBody = {
12
- ...requestData,
13
- query: {
14
- type: "advanced",
15
- query_string,
16
- },
17
- };
18
- const rawData = await apiClient.makeRequest(`/accounts/${accountId}/alerts`, {
19
- method: "POST",
20
- body: JSON.stringify(requestBody),
21
- });
22
- const data = CreateAlertResponseSchema.parse(rawData);
23
- logInfo("Advanced alert created", {
24
- accountId,
25
- alertName: validated.name,
26
- alertId: data.alert.id,
27
- });
28
- return {
29
- content: [
30
- {
31
- type: "text",
32
- text: data.alert.id,
33
- },
34
- ],
35
- };
36
- }
37
- catch (error) {
38
- // Check if this is a boolean query validation error
39
- if (error instanceof Error && error.message.includes("boolean_errors")) {
40
- logError("Boolean query validation failed", error);
41
- throw new Error(`Boolean query validation failed. Common issues:
42
- - Use url:domain.com instead of domain.com for websites
43
- - Ensure proper boolean operators (AND, OR, NOT)
44
- - Use quotes for phrases: "cold email"
45
- - Max 1700 characters
46
- - Example: (Lemlist OR url:lemlist.com OR "cold email") AND -spam
47
-
48
- Original error: ${error.message}`);
49
- }
50
- logError("Failed to create advanced alert", error);
51
- throw error;
52
- }
3
+ export function registerCreateAdvancedAlertTool(server, apiClient) {
4
+ server.registerTool("create_advanced_alert", {
5
+ title: "Create Advanced Alert",
6
+ description: "Create a new advanced monitoring alert with boolean query syntax. Advanced alerts use complex query strings with boolean operators like AND, OR, NOT.",
7
+ inputSchema: CreateAdvancedAlertArgsSchema.shape,
8
+ annotations: {
9
+ readOnlyHint: false,
10
+ destructiveHint: false,
11
+ idempotentHint: false,
12
+ openWorldHint: true,
53
13
  },
54
- };
55
- }
56
- export const createAdvancedAlertTool = {
57
- getDefinition() {
14
+ }, async ({ query_string, ...requestData }) => {
15
+ const accountId = await apiClient.getAccountId();
16
+ const requestBody = {
17
+ ...requestData,
18
+ query: {
19
+ type: "advanced",
20
+ query_string,
21
+ },
22
+ };
23
+ const rawData = await apiClient.makeRequest(`/accounts/${accountId}/alerts`, {
24
+ method: "POST",
25
+ body: JSON.stringify(requestBody),
26
+ });
27
+ const data = CreateAlertResponseSchema.parse(rawData);
28
+ logInfo("Advanced alert created", {
29
+ accountId,
30
+ alertName: requestData.name,
31
+ alertId: data.alert.id,
32
+ });
58
33
  return {
59
- name: "create_advanced_alert",
60
- description: "Create a new advanced monitoring alert with boolean query syntax. Advanced alerts use complex query strings with boolean operators like AND, OR, NOT.",
61
- inputSchema: zodToJsonSchema(CreateAdvancedAlertArgsSchema),
34
+ content: [{ type: "text", text: data.alert.id }],
62
35
  };
63
- },
64
- createHandler: createAdvancedAlertHandler,
65
- };
66
- //# sourceMappingURL=create_advanced_alert.js.map
36
+ });
37
+ }
@@ -1,57 +1,40 @@
1
- import { zodToJsonSchema } from "zod-to-json-schema";
2
- import { logError, logInfo } from "../logger.js";
1
+ import { logInfo } from "../logger.js";
3
2
  import { CreateAlertResponseSchema, CreateBasicAlertArgsSchema } from "../types.js";
4
- function createBasicAlertHandler(apiClient) {
5
- return {
6
- async handle(args) {
7
- try {
8
- const validated = CreateBasicAlertArgsSchema.parse(args);
9
- const accountId = await apiClient.getAccountId();
10
- const { included_keywords, required_keywords, excluded_keywords, monitored_website, ...requestData } = validated;
11
- const requestBody = {
12
- ...requestData,
13
- query: {
14
- type: "basic",
15
- included_keywords,
16
- required_keywords,
17
- excluded_keywords,
18
- monitored_website,
19
- },
20
- };
21
- const rawData = await apiClient.makeRequest(`/accounts/${accountId}/alerts`, {
22
- method: "POST",
23
- body: JSON.stringify(requestBody),
24
- });
25
- const data = CreateAlertResponseSchema.parse(rawData);
26
- logInfo("Basic alert created", {
27
- accountId,
28
- alertName: validated.name,
29
- alertId: data.alert.id,
30
- });
31
- return {
32
- content: [
33
- {
34
- type: "text",
35
- text: data.alert.id,
36
- },
37
- ],
38
- };
39
- }
40
- catch (error) {
41
- logError("Failed to create basic alert", error);
42
- throw error;
43
- }
3
+ export function registerCreateBasicAlertTool(server, apiClient) {
4
+ server.registerTool("create_basic_alert", {
5
+ title: "Create Basic Alert",
6
+ description: "Create a new basic monitoring alert. Basic alerts use simple keyword matching with included_keywords, required_keywords, and excluded_keywords arrays.",
7
+ inputSchema: CreateBasicAlertArgsSchema.shape,
8
+ annotations: {
9
+ readOnlyHint: false,
10
+ destructiveHint: false,
11
+ idempotentHint: false,
12
+ openWorldHint: true,
44
13
  },
45
- };
46
- }
47
- export const createBasicAlertTool = {
48
- getDefinition() {
14
+ }, async ({ included_keywords, required_keywords, excluded_keywords, monitored_website, ...requestData }) => {
15
+ const accountId = await apiClient.getAccountId();
16
+ const requestBody = {
17
+ ...requestData,
18
+ query: {
19
+ type: "basic",
20
+ included_keywords,
21
+ required_keywords,
22
+ excluded_keywords,
23
+ monitored_website,
24
+ },
25
+ };
26
+ const rawData = await apiClient.makeRequest(`/accounts/${accountId}/alerts`, {
27
+ method: "POST",
28
+ body: JSON.stringify(requestBody),
29
+ });
30
+ const data = CreateAlertResponseSchema.parse(rawData);
31
+ logInfo("Basic alert created", {
32
+ accountId,
33
+ alertName: requestData.name,
34
+ alertId: data.alert.id,
35
+ });
49
36
  return {
50
- name: "create_basic_alert",
51
- description: "Create a new basic monitoring alert. Basic alerts use simple keyword matching with included_keywords, required_keywords, and excluded_keywords arrays.",
52
- inputSchema: zodToJsonSchema(CreateBasicAlertArgsSchema),
37
+ content: [{ type: "text", text: data.alert.id }],
53
38
  };
54
- },
55
- createHandler: createBasicAlertHandler,
56
- };
57
- //# sourceMappingURL=create_basic_alert.js.map
39
+ });
40
+ }
@@ -1,96 +1,69 @@
1
- import { zodToJsonSchema } from "zod-to-json-schema";
2
- import { logError, logInfo } from "../logger.js";
1
+ import { logInfo } from "../logger.js";
3
2
  import { FetchAlertStatsArgsSchema } from "../types.js";
4
- function createFetchAlertStatsHandler(apiClient) {
5
- return {
6
- async handle(args) {
7
- try {
8
- const validated = FetchAlertStatsArgsSchema.parse(args);
9
- const accountId = await apiClient.getAccountId();
10
- // Build query parameters
11
- const searchParams = new URLSearchParams();
12
- // Handle the required alerts array
13
- for (const alertId of validated.alerts) {
14
- searchParams.append("alerts[]", alertId);
15
- }
16
- // Handle optional parameters
17
- const optionalParams = {
18
- from: validated.from,
19
- to: validated.to,
20
- timezone: validated.timezone,
21
- interval: validated.interval,
22
- favorite: validated.favorite,
23
- important: validated.important,
24
- week_day_stats: validated.week_day_stats,
25
- week_day_by_hour_stats: validated.week_day_by_hour_stats,
26
- influencers: validated.influencers,
27
- reach_per_interval_stats: validated.reach_per_interval_stats,
28
- "author_influence.score": validated["author_influence.score"],
29
- };
30
- for (const [key, value] of Object.entries(optionalParams)) {
31
- if (value !== undefined && value !== null) {
32
- searchParams.append(key, String(value));
33
- }
34
- }
35
- // Handle array parameters
36
- const arrayParams = {
37
- "tones[]": validated.tones,
38
- "languages[]": validated.languages,
39
- "sources[]": validated.sources,
40
- "countries[]": validated.countries,
41
- "tags[]": validated.tags,
42
- };
43
- for (const [key, values] of Object.entries(arrayParams)) {
44
- if (values && Array.isArray(values)) {
45
- for (const value of values) {
46
- searchParams.append(key, String(value));
47
- }
48
- }
49
- }
50
- // Handle special country_stats parameter
51
- if (validated.country_stats !== undefined) {
52
- if (typeof validated.country_stats === "boolean") {
53
- searchParams.append("country_stats", validated.country_stats ? "10" : "0");
54
- }
55
- else {
56
- searchParams.append("country_stats", String(validated.country_stats));
57
- }
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));
58
43
  }
59
- const queryString = searchParams.toString();
60
- const endpoint = `/accounts/${accountId}/stats${queryString ? `?${queryString}` : ""}`;
61
- const data = await apiClient.makeRequest(endpoint);
62
- logInfo("Alert statistics fetched successfully", {
63
- accountId,
64
- alertIds: validated.alerts,
65
- endpoint,
66
- from: validated.from,
67
- to: validated.to,
68
- partial: data?.partial || false,
69
- });
70
- return {
71
- content: [
72
- {
73
- type: "text",
74
- text: JSON.stringify(data, null, 2),
75
- },
76
- ],
77
- };
78
44
  }
79
- catch (error) {
80
- logError("Failed to fetch alert statistics", error);
81
- throw error;
45
+ }
46
+ if (args.country_stats !== undefined) {
47
+ if (typeof args.country_stats === "boolean") {
48
+ searchParams.append("country_stats", args.country_stats ? "10" : "0");
82
49
  }
83
- },
84
- };
85
- }
86
- export const fetchAlertStatsTool = {
87
- getDefinition() {
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
+ });
88
65
  return {
89
- name: "fetch_alert_stats",
90
- 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.",
91
- inputSchema: zodToJsonSchema(FetchAlertStatsArgsSchema),
66
+ content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
92
67
  };
93
- },
94
- createHandler: createFetchAlertStatsHandler,
95
- };
96
- //# sourceMappingURL=fetch_alert_stats.js.map
68
+ });
69
+ }
@@ -1,59 +1,39 @@
1
- import { zodToJsonSchema } from "zod-to-json-schema";
2
- import { logError, logInfo } from "../logger.js";
1
+ import { apiPath } from "../api-client.js";
2
+ import { logInfo } from "../logger.js";
3
3
  import { FetchMentionsArgsSchema } from "../types.js";
4
- function createFetchMentionsHandler(apiClient) {
5
- return {
6
- async handle(args) {
7
- try {
8
- const validated = FetchMentionsArgsSchema.parse(args);
9
- const accountId = await apiClient.getAccountId();
10
- const { alert_id, ...queryParams } = validated;
11
- const searchParams = new URLSearchParams();
12
- for (const [key, value] of Object.entries(queryParams)) {
13
- if (value !== undefined && value !== null) {
14
- if (Array.isArray(value)) {
15
- for (const item of value) {
16
- searchParams.append(key, String(item));
17
- }
18
- }
19
- else {
20
- searchParams.append(key, String(value));
21
- }
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));
22
18
  }
23
19
  }
24
- const queryString = searchParams.toString();
25
- const endpoint = `/accounts/${accountId}/alerts/${alert_id}/mentions${queryString ? `?${queryString}` : ""}`;
26
- const data = await apiClient.makeRequest(endpoint);
27
- logInfo("Mentions fetched successfully", {
28
- accountId,
29
- alertId: alert_id,
30
- endpoint,
31
- mentionCount: data?.mentions?.length || 0,
32
- });
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 fetch mentions", error);
44
- throw error;
20
+ else {
21
+ searchParams.append(key, String(value));
22
+ }
45
23
  }
46
- },
47
- };
48
- }
49
- export const fetchMentionsTool = {
50
- getDefinition() {
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
+ });
51
35
  return {
52
- name: "fetch_mentions",
53
- description: "Retrieve mentions associated with a specific alert. Supports various filters like source, folder, tone, countries, languages, and advanced search queries.",
54
- inputSchema: zodToJsonSchema(FetchMentionsArgsSchema),
36
+ content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
55
37
  };
56
- },
57
- createHandler: createFetchMentionsHandler,
58
- };
59
- //# sourceMappingURL=fetch_mentions.js.map
38
+ });
39
+ }
@@ -1,46 +1,22 @@
1
- import { logError, logInfo } from "../logger.js";
2
- function createGetAccountInfoHandler(apiClient) {
3
- return {
4
- async handle() {
5
- try {
6
- const data = await apiClient.getAccountInfo();
7
- const filteredResponse = {
8
- accountId: data.account.id,
9
- canCreateAdvancedAlert: data.account.subscription.advanced_query_access,
10
- groups: data.account.groups?.map((group) => ({
11
- id: group.id,
12
- name: group.name,
13
- })) || [],
14
- };
15
- logInfo("Account info retrieved", { accountId: data.account.id });
16
- return {
17
- content: [
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
- name: "get_account_info",
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
- createHandler: createGetAccountInfoHandler,
45
- };
46
- //# sourceMappingURL=get_account_info.js.map
21
+ });
22
+ }
@@ -1,38 +1,18 @@
1
- import { zodToJsonSchema } from "zod-to-json-schema";
2
- import { logError, logInfo } from "../logger.js";
1
+ import { apiPath } from "../api-client.js";
2
+ import { logInfo } from "../logger.js";
3
3
  import { GetAlertArgsSchema } from "../types.js";
4
- function createGetAlertHandler(apiClient) {
5
- return {
6
- async handle(args) {
7
- try {
8
- const { alert_id } = GetAlertArgsSchema.parse(args);
9
- const accountId = await apiClient.getAccountId();
10
- const data = await apiClient.makeRequest(`/accounts/${accountId}/alerts/${alert_id}`);
11
- logInfo("Alert retrieved", { accountId, alertId: alert_id });
12
- return {
13
- content: [
14
- {
15
- type: "text",
16
- text: JSON.stringify(data, null, 2),
17
- },
18
- ],
19
- };
20
- }
21
- catch (error) {
22
- logError("Failed to get alert", error);
23
- throw error;
24
- }
25
- },
26
- };
27
- }
28
- export const getAlertTool = {
29
- 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 });
30
14
  return {
31
- name: "get_alert",
32
- description: "Get detailed information about a specific alert by its ID.",
33
- inputSchema: zodToJsonSchema(GetAlertArgsSchema),
15
+ content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
34
16
  };
35
- },
36
- createHandler: createGetAlertHandler,
37
- };
38
- //# sourceMappingURL=get_alert.js.map
17
+ });
18
+ }