Skip to main content
Glama
baranwang

Trends Hub

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
NameRequiredDescriptionDefault
page_sizeNo

Implementation Reference

  • 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,
          };
        });
    },
  • 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),
    });
  • 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,
            };
          });
      },
    });

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/baranwang/mcp-trends-hub'

If you have feedback or need assistance with the MCP directory API, please join our Discord server