@maelitop/mention-mcp-server 1.3.0 → 1.4.1

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 (100) hide show
  1. package/CHANGELOG.md +101 -0
  2. package/README.md +21 -19
  3. package/dist/api-client.js +17 -15
  4. package/dist/config.js +10 -4
  5. package/dist/index.js +1 -2
  6. package/dist/logger.js +20 -55
  7. package/dist/prompts/base.js +0 -1
  8. package/dist/prompts/build-boolean-query.js +0 -1
  9. package/dist/prompts/index.js +0 -1
  10. package/dist/tools/base.js +0 -1
  11. package/dist/tools/create_advanced_alert.js +0 -1
  12. package/dist/tools/create_basic_alert.js +0 -1
  13. package/dist/tools/fetch_alert_stats.js +94 -0
  14. package/dist/tools/fetch_mentions.js +5 -4
  15. package/dist/tools/get_account_info.js +0 -1
  16. package/dist/tools/get_alert.js +2 -2
  17. package/dist/tools/get_app_data.js +0 -1
  18. package/dist/tools/index.js +2 -1
  19. package/dist/tools/list_alerts.js +0 -1
  20. package/dist/tools/pause_alert.js +3 -3
  21. package/dist/tools/unpause_alert.js +3 -3
  22. package/dist/tools/update_alert.js +18 -18
  23. package/dist/types.js +74 -13
  24. package/package.json +9 -13
  25. package/dist/__tests__/api-client.test.d.ts +0 -2
  26. package/dist/__tests__/api-client.test.d.ts.map +0 -1
  27. package/dist/__tests__/api-client.test.js +0 -132
  28. package/dist/__tests__/api-client.test.js.map +0 -1
  29. package/dist/__tests__/config.test.d.ts +0 -2
  30. package/dist/__tests__/config.test.d.ts.map +0 -1
  31. package/dist/__tests__/config.test.js +0 -48
  32. package/dist/__tests__/config.test.js.map +0 -1
  33. package/dist/__tests__/tools.test.d.ts +0 -2
  34. package/dist/__tests__/tools.test.d.ts.map +0 -1
  35. package/dist/__tests__/tools.test.js +0 -228
  36. package/dist/__tests__/tools.test.js.map +0 -1
  37. package/dist/__tests__/types.test.d.ts +0 -2
  38. package/dist/__tests__/types.test.d.ts.map +0 -1
  39. package/dist/__tests__/types.test.js +0 -179
  40. package/dist/__tests__/types.test.js.map +0 -1
  41. package/dist/api-client.d.ts +0 -14
  42. package/dist/api-client.d.ts.map +0 -1
  43. package/dist/api-client.js.map +0 -1
  44. package/dist/config.d.ts +0 -10
  45. package/dist/config.d.ts.map +0 -1
  46. package/dist/config.js.map +0 -1
  47. package/dist/index.d.ts +0 -3
  48. package/dist/index.d.ts.map +0 -1
  49. package/dist/index.js.map +0 -1
  50. package/dist/logger.d.ts +0 -6
  51. package/dist/logger.d.ts.map +0 -1
  52. package/dist/logger.js.map +0 -1
  53. package/dist/prompts/base.d.ts +0 -25
  54. package/dist/prompts/base.d.ts.map +0 -1
  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.map +0 -1
  65. package/dist/tools/create_advanced_alert.d.ts +0 -3
  66. package/dist/tools/create_advanced_alert.d.ts.map +0 -1
  67. package/dist/tools/create_advanced_alert.js.map +0 -1
  68. package/dist/tools/create_basic_alert.d.ts +0 -3
  69. package/dist/tools/create_basic_alert.d.ts.map +0 -1
  70. package/dist/tools/create_basic_alert.js.map +0 -1
  71. package/dist/tools/fetch_mentions.d.ts +0 -3
  72. package/dist/tools/fetch_mentions.d.ts.map +0 -1
  73. package/dist/tools/fetch_mentions.js.map +0 -1
  74. package/dist/tools/get_account_info.d.ts +0 -3
  75. package/dist/tools/get_account_info.d.ts.map +0 -1
  76. package/dist/tools/get_account_info.js.map +0 -1
  77. package/dist/tools/get_alert.d.ts +0 -3
  78. package/dist/tools/get_alert.d.ts.map +0 -1
  79. package/dist/tools/get_alert.js.map +0 -1
  80. package/dist/tools/get_app_data.d.ts +0 -3
  81. package/dist/tools/get_app_data.d.ts.map +0 -1
  82. package/dist/tools/get_app_data.js.map +0 -1
  83. package/dist/tools/index.d.ts +0 -14
  84. package/dist/tools/index.d.ts.map +0 -1
  85. package/dist/tools/index.js.map +0 -1
  86. package/dist/tools/list_alerts.d.ts +0 -3
  87. package/dist/tools/list_alerts.d.ts.map +0 -1
  88. package/dist/tools/list_alerts.js.map +0 -1
  89. package/dist/tools/pause_alert.d.ts +0 -3
  90. package/dist/tools/pause_alert.d.ts.map +0 -1
  91. package/dist/tools/pause_alert.js.map +0 -1
  92. package/dist/tools/unpause_alert.d.ts +0 -3
  93. package/dist/tools/unpause_alert.d.ts.map +0 -1
  94. package/dist/tools/unpause_alert.js.map +0 -1
  95. package/dist/tools/update_alert.d.ts +0 -3
  96. package/dist/tools/update_alert.d.ts.map +0 -1
  97. package/dist/tools/update_alert.js.map +0 -1
  98. package/dist/types.d.ts +0 -389
  99. package/dist/types.d.ts.map +0 -1
  100. package/dist/types.js.map +0 -1
@@ -1,4 +1,5 @@
1
1
  import { zodToJsonSchema } from "zod-to-json-schema";
2
+ import { apiPath } from "../api-client.js";
2
3
  import { logError, logInfo } from "../logger.js";
3
4
  import { UnpauseAlertArgsSchema } from "../types.js";
4
5
  function createUnpauseAlertHandler(apiClient) {
@@ -7,7 +8,7 @@ function createUnpauseAlertHandler(apiClient) {
7
8
  try {
8
9
  const { alert_id } = UnpauseAlertArgsSchema.parse(args);
9
10
  const accountId = await apiClient.getAccountId();
10
- const data = await apiClient.makeRequest(`/accounts/${accountId}/alerts/${alert_id}/unpause`, {
11
+ await apiClient.makeRequest(apiPath `/accounts/${accountId}/alerts/${alert_id}/unpause`, {
11
12
  method: "POST",
12
13
  });
13
14
  logInfo("Alert unpaused", { accountId, alertId: alert_id });
@@ -15,7 +16,7 @@ function createUnpauseAlertHandler(apiClient) {
15
16
  content: [
16
17
  {
17
18
  type: "text",
18
- text: JSON.stringify(data, null, 2),
19
+ text: `Alert ${alert_id} unpaused.`,
19
20
  },
20
21
  ],
21
22
  };
@@ -37,4 +38,3 @@ export const unpauseAlertTool = {
37
38
  },
38
39
  createHandler: createUnpauseAlertHandler,
39
40
  };
40
- //# sourceMappingURL=unpause_alert.js.map
@@ -1,4 +1,5 @@
1
1
  import { zodToJsonSchema } from "zod-to-json-schema";
2
+ import { apiPath } from "../api-client.js";
2
3
  import { logError, logInfo } from "../logger.js";
3
4
  import { UpdateAlertArgsSchema } from "../types.js";
4
5
  function createUpdateAlertHandler(apiClient) {
@@ -6,26 +7,26 @@ function createUpdateAlertHandler(apiClient) {
6
7
  async handle(args) {
7
8
  try {
8
9
  const validated = UpdateAlertArgsSchema.parse(args);
9
- const { alert_id, query_type, included_keywords, required_keywords, excluded_keywords, query_string, ...updateData } = validated;
10
+ const { alert_id, included_keywords, required_keywords, excluded_keywords, query_string, ...updateData } = validated;
10
11
  const accountId = await apiClient.getAccountId();
11
12
  const requestBody = { ...updateData };
12
- if (query_type) {
13
- if (query_type === "basic") {
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
- }
13
+ if (query_string !== undefined) {
14
+ requestBody.query = {
15
+ type: "advanced",
16
+ query_string,
17
+ };
27
18
  }
28
- const data = await apiClient.makeRequest(`/accounts/${accountId}/alerts/${alert_id}`, {
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}`, {
29
30
  method: "PUT",
30
31
  body: JSON.stringify(requestBody),
31
32
  });
@@ -56,4 +57,3 @@ export const updateAlertTool = {
56
57
  },
57
58
  createHandler: createUpdateAlertHandler,
58
59
  };
59
- //# sourceMappingURL=update_alert.js.map
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,9 +114,9 @@ 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
- export const UpdateAlertArgsSchema = z.object({
118
+ export const UpdateAlertArgsSchema = z
119
+ .object({
121
120
  alert_id: z.string().describe("The alert ID to update"),
122
121
  name: z.string().min(1).max(255).optional().describe("New alert name (1-255 characters)"),
123
122
  description: z
@@ -130,7 +129,6 @@ export const UpdateAlertArgsSchema = z.object({
130
129
  .regex(/^#[0-9a-fA-F]{6}$/)
131
130
  .optional()
132
131
  .describe("New alert color code"),
133
- query_type: z.enum(["basic", "advanced"]).optional().describe("Type of query to update"),
134
132
  included_keywords: z
135
133
  .array(z.string())
136
134
  .optional()
@@ -143,15 +141,24 @@ export const UpdateAlertArgsSchema = z.object({
143
141
  .array(z.string())
144
142
  .optional()
145
143
  .describe("Excluded keywords (for basic queries)"),
146
- query_string: z.string().optional().describe("Advanced query string (for advanced queries)"),
144
+ query_string: z
145
+ .string()
146
+ .optional()
147
+ .describe("Advanced query string (for advanced queries). Cannot be combined with included_keywords, required_keywords or excluded_keywords."),
147
148
  languages: z.array(z.string()).max(5).optional().describe("Language codes to monitor (max 5)"),
148
149
  countries: z.array(z.string()).optional().describe("Country codes to monitor"),
149
150
  sources: z
150
- .array(z.enum(["twitter", "news", "web", "blogs", "videos", "forums", "images", "facebook"]))
151
+ .array(z.string())
151
152
  .optional()
152
- .describe("Sources to monitor"),
153
+ .describe("Sources to monitor. List available sources using get_app_data tool."),
153
154
  blocked_sites: z.array(z.string()).optional().describe("Domains to exclude from monitoring"),
154
- noise_detection: z.boolean().optional().describe("Enable noise detection"),
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"],
155
162
  });
156
163
  export const PauseAlertArgsSchema = z.object({
157
164
  alert_id: z.string().describe("The alert ID to pause"),
@@ -217,12 +224,66 @@ export const FetchMentionsArgsSchema = z.object({
217
224
  ])
218
225
  .optional()
219
226
  .describe("Sort by field"),
220
- languages: z
221
- .array(z.string())
222
- .optional()
223
- .describe("Filter by language codes. Multiple values allowed."),
224
227
  timezone: z.string().optional().describe("Timezone for parsing date values in q parameter"),
225
228
  q: z.string().optional().describe("Advanced keyword-based filtering"),
226
229
  cursor: z.string().optional().describe("Pagination cursor for navigating results"),
227
230
  });
228
- //# sourceMappingURL=types.js.map
231
+ // The stats endpoint rejects a Z, an offset, or a date-time without fractional seconds.
232
+ function statsDateTime(timeIfDateOnly) {
233
+ return z
234
+ .string()
235
+ .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")
236
+ .transform((value) => `${value.slice(0, 10)}T${value.slice(11, 19) || timeIfDateOnly}.0`);
237
+ }
238
+ export const FetchAlertStatsArgsSchema = z.object({
239
+ alerts: z
240
+ .array(z.string())
241
+ .min(1)
242
+ .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."),
245
+ timezone: z
246
+ .string()
247
+ .optional()
248
+ .describe("Timezone used for from/to dates (e.g., 'Europe/Berlin', 'UTC')"),
249
+ interval: z
250
+ .enum(["P1D", "P1W", "P1M"])
251
+ .describe("Aggregation interval: P1D (daily), P1W (weekly), P1M (monthly)"),
252
+ favorite: z.boolean().optional().describe("Only include statistics based on favorite mentions"),
253
+ tones: z
254
+ .array(z.number().int().min(-1).max(1))
255
+ .optional()
256
+ .describe("Filter stats by tone: -1 (negative), 0 (neutral), 1 (positive)"),
257
+ languages: z.array(z.string()).optional().describe("Filter stats by language codes"),
258
+ sources: z
259
+ .array(z.string())
260
+ .optional()
261
+ .describe("Filter stats by source types (e.g., 'twitter', 'web', 'news')"),
262
+ countries: z
263
+ .array(z.string().length(2))
264
+ .optional()
265
+ .describe("Filter stats by country ISO codes (2-letter format)"),
266
+ tags: z.array(z.string()).optional().describe("Filter stats by specific tags"),
267
+ week_day_stats: z
268
+ .boolean()
269
+ .optional()
270
+ .describe("Group stats by week day (cannot be combined with week_day_by_hour_stats)"),
271
+ week_day_by_hour_stats: z
272
+ .boolean()
273
+ .optional()
274
+ .describe("Group stats by hour per weekday (cannot be combined with week_day_stats)"),
275
+ country_stats: z
276
+ .union([z.boolean(), z.number().int().min(0).max(100)])
277
+ .optional()
278
+ .describe("Return top N countries"),
279
+ influencers: z.boolean().optional().describe("Include top 10 influencers per alert"),
280
+ reach_per_interval_stats: z
281
+ .boolean()
282
+ .optional()
283
+ .describe("Include direct, cumulative, and domain reach per interval"),
284
+ "author_influence.score": z
285
+ .string()
286
+ .regex(/^(\d+)?:(\d+)?$/)
287
+ .optional()
288
+ .describe("Filter by author influence score range. Format: 'min:max' (e.g., '50:100', ':90', '30:')"),
289
+ });
package/package.json CHANGED
@@ -1,29 +1,28 @@
1
1
  {
2
2
  "name": "@maelitop/mention-mcp-server",
3
- "version": "1.3.0",
3
+ "version": "1.4.1",
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:patch": "npm version patch",
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",
@@ -39,15 +38,12 @@
39
38
  "homepage": "https://github.com/MaelitoP/mention-mcp-server#readme",
40
39
  "dependencies": {
41
40
  "@modelcontextprotocol/sdk": "^1.12.1",
42
- "pino": "^9.7.0",
43
- "pino-pretty": "^13.0.0",
44
41
  "zod": "^3.25.56",
45
42
  "zod-to-json-schema": "^3.24.5"
46
43
  },
47
44
  "devDependencies": {
48
45
  "@biomejs/biome": "^1.9.4",
49
46
  "@types/node": "^22.15.30",
50
- "@vitest/ui": "^3.2.4",
51
47
  "tsx": "^4.19.4",
52
48
  "typescript": "^5.8.3",
53
49
  "vitest": "^3.2.4"
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=api-client.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"api-client.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/api-client.test.ts"],"names":[],"mappings":""}
@@ -1,132 +0,0 @@
1
- import { ErrorCode, McpError } from "@modelcontextprotocol/sdk/types.js";
2
- import { beforeEach, describe, expect, it, vi } from "vitest";
3
- import { MentionAPIClient } from "../api-client.js";
4
- const mockFetch = vi.fn();
5
- global.fetch = mockFetch;
6
- vi.mock("../logger.js", () => ({
7
- logError: vi.fn(),
8
- logDebug: vi.fn(),
9
- }));
10
- describe("MentionAPIClient", () => {
11
- let client;
12
- let config;
13
- beforeEach(() => {
14
- config = {
15
- apiKey: "test-api-key",
16
- apiBaseUrl: "https://api.test.com",
17
- logLevel: "info",
18
- enableConsoleLogging: false,
19
- requestTimeout: 5000,
20
- maxRetries: 3,
21
- };
22
- client = new MentionAPIClient(config);
23
- mockFetch.mockReset();
24
- });
25
- describe("makeRequest", () => {
26
- it("should make successful API request", async () => {
27
- const mockResponse = { ok: true, json: vi.fn().mockResolvedValue({ data: "test" }) };
28
- mockFetch.mockResolvedValue(mockResponse);
29
- const result = await client.makeRequest("/test");
30
- expect(mockFetch).toHaveBeenCalledWith("https://api.test.com/test", expect.objectContaining({
31
- headers: expect.objectContaining({
32
- Authorization: "Bearer test-api-key",
33
- "Content-Type": "application/json",
34
- "User-Agent": "mention-mcp-server/1.0.0",
35
- }),
36
- }));
37
- expect(result).toEqual({ data: "test" });
38
- });
39
- it("should handle 401 error properly", async () => {
40
- const mockResponse = {
41
- ok: false,
42
- status: 401,
43
- json: vi.fn().mockResolvedValue({
44
- error: { code: 401, message: "Unauthorized" },
45
- }),
46
- };
47
- mockFetch.mockResolvedValue(mockResponse);
48
- await expect(client.makeRequest("/test")).rejects.toThrow(new McpError(ErrorCode.InvalidRequest, "Invalid API key"));
49
- });
50
- it("should handle 403 error properly", async () => {
51
- const mockResponse = {
52
- ok: false,
53
- status: 403,
54
- json: vi.fn().mockResolvedValue({
55
- error: { code: 403, message: "Forbidden" },
56
- }),
57
- };
58
- mockFetch.mockResolvedValue(mockResponse);
59
- await expect(client.makeRequest("/test")).rejects.toThrow(new McpError(ErrorCode.InvalidRequest, "Access denied"));
60
- });
61
- it("should handle 429 rate limit error properly", async () => {
62
- const mockResponse = {
63
- ok: false,
64
- status: 429,
65
- json: vi.fn().mockResolvedValue({
66
- error: { code: 429, message: "Rate limit exceeded" },
67
- }),
68
- };
69
- mockFetch.mockResolvedValue(mockResponse);
70
- await expect(client.makeRequest("/test")).rejects.toThrow(new McpError(ErrorCode.InternalError, "Rate limit exceeded - please try again later"));
71
- });
72
- it("should handle network errors", async () => {
73
- mockFetch.mockRejectedValue(new Error("Network error"));
74
- await expect(client.makeRequest("/test")).rejects.toThrow(new McpError(ErrorCode.InternalError, "Network request failed: Network error"));
75
- });
76
- it("should handle timeout", async () => {
77
- const abortError = new Error("The operation was aborted");
78
- abortError.name = "AbortError";
79
- mockFetch.mockRejectedValue(abortError);
80
- await expect(client.makeRequest("/test")).rejects.toThrow(new McpError(ErrorCode.InternalError, "Request timeout"));
81
- });
82
- });
83
- describe("getAccountInfo", () => {
84
- it("should cache account info", async () => {
85
- const mockAccountData = {
86
- account: {
87
- id: "test-account",
88
- subscription: { advanced_query_access: true },
89
- groups: [{ id: "group1", name: "Test Group" }],
90
- },
91
- };
92
- const mockResponse = { ok: true, json: vi.fn().mockResolvedValue(mockAccountData) };
93
- mockFetch.mockResolvedValue(mockResponse);
94
- const result1 = await client.getAccountInfo();
95
- expect(result1).toEqual(mockAccountData);
96
- expect(mockFetch).toHaveBeenCalledTimes(1);
97
- const result2 = await client.getAccountInfo();
98
- expect(result2).toEqual(mockAccountData);
99
- expect(mockFetch).toHaveBeenCalledTimes(1);
100
- });
101
- it("should refresh cache after expiry", async () => {
102
- const mockAccountData = {
103
- account: {
104
- id: "test-account",
105
- subscription: { advanced_query_access: true },
106
- },
107
- };
108
- const mockResponse = { ok: true, json: vi.fn().mockResolvedValue(mockAccountData) };
109
- mockFetch.mockResolvedValue(mockResponse);
110
- await client.getAccountInfo();
111
- expect(mockFetch).toHaveBeenCalledTimes(1);
112
- client.clearAccountCache();
113
- await client.getAccountInfo();
114
- expect(mockFetch).toHaveBeenCalledTimes(2);
115
- });
116
- });
117
- describe("getAccountId", () => {
118
- it("should return account ID from account info", async () => {
119
- const mockAccountData = {
120
- account: {
121
- id: "test-account-id",
122
- subscription: { advanced_query_access: true },
123
- },
124
- };
125
- const mockResponse = { ok: true, json: vi.fn().mockResolvedValue(mockAccountData) };
126
- mockFetch.mockResolvedValue(mockResponse);
127
- const accountId = await client.getAccountId();
128
- expect(accountId).toBe("test-account-id");
129
- });
130
- });
131
- });
132
- //# sourceMappingURL=api-client.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"api-client.test.js","sourceRoot":"","sources":["../../src/__tests__/api-client.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,EAAuB,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AACnF,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAGpD,MAAM,SAAS,GAAG,EAAE,CAAC,EAAE,EAAkC,CAAC;AAC1D,MAAM,CAAC,KAAK,GAAG,SAAS,CAAC;AAEzB,EAAE,CAAC,IAAI,CAAC,cAAc,EAAE,GAAG,EAAE,CAAC,CAAC;IAC7B,QAAQ,EAAE,EAAE,CAAC,EAAE,EAAE;IACjB,QAAQ,EAAE,EAAE,CAAC,EAAE,EAAE;CAClB,CAAC,CAAC,CAAC;AAEJ,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;IAChC,IAAI,MAAwB,CAAC;IAC7B,IAAI,MAAc,CAAC;IAEnB,UAAU,CAAC,GAAG,EAAE;QACd,MAAM,GAAG;YACP,MAAM,EAAE,cAAc;YACtB,UAAU,EAAE,sBAAsB;YA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AAQ,CAAC,cAAc,EAAE,GAAG,EAAE;QAC5B,EAAE,CAAC,4CAA4C,EAAE,KAAK,IAAI,EAAE;YAC1D,MAAM,eAAe,GAAG;gBACtB,OAAO,EAAE;oBACP,EAAE,EAAE,iBAAiB;oBACrB,YAAY,EAAE,EAAE,qBAAqB,EAAE,IAAI,EAAE;iBAC9C;aACF,CAAC;YAEF,MAAM,YAAY,GAAG,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC,eAAe,CAAC,EAAE,CAAC;YACpF,SAAS,CAAC,iBAAiB,CAAC,YAAmB,CAAC,CAAC;YAEjD,MAAM,SAAS,GAAG,MAAM,MAAM,CAAC,YAAY,EAAE,CAAC;YAC9C,MAAM,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;QAC5C,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=config.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"config.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/config.test.ts"],"names":[],"mappings":""}
@@ -1,48 +0,0 @@
1
- import { afterEach, beforeEach, describe, expect, it } from "vitest";
2
- import { loadConfig } from "../config.js";
3
- describe("Config", () => {
4
- const originalEnv = process.env;
5
- beforeEach(() => {
6
- process.env = { ...originalEnv };
7
- });
8
- afterEach(() => {
9
- process.env = originalEnv;
10
- });
11
- it("should load config with required API key", () => {
12
- process.env.MENTION_API_KEY = "test-api-key";
13
- const config = loadConfig();
14
- expect(config.apiKey).toBe("test-api-key");
15
- expect(config.apiBaseUrl).toBe("https://web.mention.com/api");
16
- expect(config.logLevel).toBe("info");
17
- expect(config.enableConsoleLogging).toBe(false);
18
- expect(config.requestTimeout).toBe(30000);
19
- expect(config.maxRetries).toBe(3);
20
- });
21
- it("should throw error when API key is missing", () => {
22
- process.env.MENTION_API_KEY = undefined;
23
- expect(() => loadConfig()).toThrow("MENTION_API_KEY environment variable is required");
24
- });
25
- it("should use custom environment variables", () => {
26
- process.env.MENTION_API_KEY = "test-api-key";
27
- process.env.MENTION_API_BASE_URL = "https://custom.api.com";
28
- process.env.MCP_LOG_LEVEL = "debug";
29
- process.env.MCP_CONSOLE_LOGGING = "true";
30
- process.env.MCP_REQUEST_TIMEOUT = "60000";
31
- process.env.MCP_MAX_RETRIES = "5";
32
- const config = loadConfig();
33
- expect(config.apiBaseUrl).toBe("https://custom.api.com");
34
- expect(config.logLevel).toBe("debug");
35
- expect(config.enableConsoleLogging).toBe(true);
36
- expect(config.requestTimeout).toBe(60000);
37
- expect(config.maxRetries).toBe(5);
38
- });
39
- it("should handle invalid number values gracefully", () => {
40
- process.env.MENTION_API_KEY = "test-api-key";
41
- process.env.MCP_REQUEST_TIMEOUT = "invalid";
42
- process.env.MCP_MAX_RETRIES = "not-a-number";
43
- const config = loadConfig();
44
- expect(config.requestTimeout).toBe(Number.NaN);
45
- expect(config.maxRetries).toBe(Number.NaN);
46
- });
47
- });
48
- //# sourceMappingURL=config.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"config.test.js","sourceRoot":"","sources":["../../src/__tests__/config.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AACrE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,QAAQ,CAAC,QAAQ,EAAE,GAAG,EAAE;IACtB,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC;IAEhC,UAAU,CAAC,GAAG,EAAE;QACd,OAAO,CAAC,GAAG,GAAG,EAAE,GAAG,WAAW,EAAE,CAAC;IACnC,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC,GAAG,EAAE;QACb,OAAO,CAAC,GAAG,GAAG,WAAW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