afpnews-mcp-server 1.3.4 → 1.3.7
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,7 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { textContent, toolError } from '../utils/format.js';
|
|
3
|
-
import { getTopicLabel } from '../utils/topics.js';
|
|
4
|
-
import { DEFAULT_FACET_SIZE } from '../utils/types.js';
|
|
5
3
|
import { formatErrorMessage, langEnum, listPresetEnum, } from './shared.js';
|
|
6
4
|
export const afpListFacetsTool = {
|
|
7
5
|
name: 'afp_list_facets',
|
|
@@ -37,18 +35,16 @@ Examples:
|
|
|
37
35
|
return toolError("Missing required parameter: facet (e.g. 'slug', 'genre', 'country'). Alternatively, use preset: 'trending-topics'.");
|
|
38
36
|
}
|
|
39
37
|
const params = isTrendingTopics
|
|
40
|
-
? { langs: [lang ?? 'fr'], product: ['news'], dateFrom: 'now-1d' }
|
|
41
|
-
: (lang ? { langs: [lang] } : {});
|
|
42
|
-
const
|
|
43
|
-
const rawResult = await apicore.list(resolvedFacet, params, resolvedSize);
|
|
38
|
+
? { langs: [lang ?? 'fr'], product: ['news'], dateFrom: 'now-1d', size: size ?? 10 }
|
|
39
|
+
: (lang ? { langs: [lang], size: size ?? 10 } : { size: size ?? 10 });
|
|
40
|
+
const rawResult = await apicore.list(resolvedFacet, params, 1);
|
|
44
41
|
const results = rawResult?.keywords ?? rawResult ?? [];
|
|
45
42
|
if (results.length === 0) {
|
|
46
43
|
return { content: [textContent(`No facet values found for "${resolvedFacet}".`)] };
|
|
47
44
|
}
|
|
48
45
|
const heading = isTrendingTopics ? 'Trending Topics' : `Facet: ${resolvedFacet}`;
|
|
49
46
|
const lines = results.map((item) => {
|
|
50
|
-
|
|
51
|
-
return `- **${label}** — ${item.count} articles`;
|
|
47
|
+
return `- **${item.name}** — ${item.count} articles`;
|
|
52
48
|
});
|
|
53
49
|
return { content: [textContent(`## ${heading}\n\n${lines.join('\n')}`)] };
|
|
54
50
|
}
|