get-tencent-news-trending
Retrieve trending news from Tencent's comprehensive Chinese news aggregator covering current affairs, social issues, finance, entertainment, and sports.
Instructions
获取腾讯新闻热点榜,包含国内外时事、社会热点、财经资讯、娱乐动态及体育赛事的综合性中文新闻资讯
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| page_size | No |
Implementation Reference
- src/tools/tencent-news.ts:12-40 (handler)The main handler function that parses input arguments, makes an HTTP GET request to the Tencent News trending API, processes the response by filtering and mapping the news items to a standardized format, and returns the list of trending news.func: async (args) => { const { page_size } = tencentNewsRequestSchema.parse(args); const resp = await http.get<{ ret: number; idlist: [{ newslist: any[] }]; }>('https://r.inews.qq.com/gw/event/hot_ranking_list', { params: { page_size, }, }); if (resp.data.ret !== 0 || !Array.isArray(resp.data.idlist?.[0].newslist)) { throw new Error('获取腾讯新闻热点榜失败'); } return resp.data.idlist[0].newslist .filter((_, index) => index !== 0) .map((item) => { return { title: item.title, description: item.abstract, cover: item.thumbnails?.[0], source: item.source, popularity: item.hotEvent.hotScore, publish_time: item.time, link: item.url, }; }); },
- src/tools/tencent-news.ts:4-6 (schema)Zod schema defining the input parameters for the tool, specifically an optional page_size parameter defaulting to 20.const tencentNewsRequestSchema = z.object({ page_size: z.number().int().optional().default(20), });
- src/tools/tencent-news.ts:8-41 (registration)The tool registration using defineToolConfig, specifying the name, description, input schema, and handler function.export default defineToolConfig({ name: 'get-tencent-news-trending', description: '获取腾讯新闻热点榜,包含国内外时事、社会热点、财经资讯、娱乐动态及体育赛事的综合性中文新闻资讯', zodSchema: tencentNewsRequestSchema, func: async (args) => { const { page_size } = tencentNewsRequestSchema.parse(args); const resp = await http.get<{ ret: number; idlist: [{ newslist: any[] }]; }>('https://r.inews.qq.com/gw/event/hot_ranking_list', { params: { page_size, }, }); if (resp.data.ret !== 0 || !Array.isArray(resp.data.idlist?.[0].newslist)) { throw new Error('获取腾讯新闻热点榜失败'); } return resp.data.idlist[0].newslist .filter((_, index) => index !== 0) .map((item) => { return { title: item.title, description: item.abstract, cover: item.thumbnails?.[0], source: item.source, popularity: item.hotEvent.hotScore, publish_time: item.time, link: item.url, }; }); }, });