Skip to main content
Glama
Selenium39

Weibo MCP Server

get_hot_search

Retrieve trending topics from Weibo's hot search list to monitor current discussions and viral content on the platform.

Instructions

获取当前微博热搜榜的热门话题列表

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitYes返回的最大热搜条目数量

Implementation Reference

  • src/server.ts:68-79 (registration)
    Registration of the MCP tool 'get_hot_search' including input schema (limit: number) and thin handler that calls WeiboCrawler.getHotSearchList
    server.tool("get_hot_search",
      "获取当前微博热搜榜的热门话题列表",
      { 
        limit: z.number().describe("返回的最大热搜条目数量")
      },
      async ({ limit }) => {
        const hotSearchList = await crawler.getHotSearchList(limit);
        return {
          content: [{ type: "text", text: JSON.stringify(hotSearchList) }]
        };
      }
    );
  • Core handler function getHotSearchList that fetches and parses Weibo hot search list from API into HotSearchItem array
    async getHotSearchList(limit: number): Promise<HotSearchItem[]> {
      try {
        const response = await axios.get(HOT_SEARCH_URL, {
          headers: DEFAULT_HEADERS
        });
        
        const data = response.data;
        const cards = data?.data?.cards || [];
        
        if (cards.length === 0) {
          return [];
        }
        
        // 查找包含热搜数据的card
        let hotSearchCard = null;
        for (const card of cards) {
          if (card.card_group && Array.isArray(card.card_group)) {
            hotSearchCard = card;
            break;
          }
        }
        
        if (!hotSearchCard || !hotSearchCard.card_group) {
          return [];
        }
        
        // 转换热搜数据为HotSearchItem格式
        const hotSearchItems: HotSearchItem[] = [];
        let rank = 1;
        
        for (const item of hotSearchCard.card_group) {
          if (item.desc && rank <= limit) {
            const hotSearchItem: HotSearchItem = {
              keyword: item.desc,
              rank: rank,
              hotValue: parseInt(item.desc_extr || '0', 10),
              tag: item.icon ? item.icon.slice(item.icon.lastIndexOf('/') + 1).replace('.png', '') : undefined,
              url: item.scheme
            };
            
            hotSearchItems.push(hotSearchItem);
            rank++;
          }
        }
        
        return hotSearchItems;
      } catch (error) {
        console.error('无法获取微博热搜榜', error);
        return [];
      }
    }
  • TypeScript interface HotSearchItem defining the output structure for hot search items returned by the tool.
    export interface HotSearchItem {
      /**
       * 热搜关键词
       */
      keyword: string;
      
      /**
       * 热搜排名
       */
      rank: number;
      
      /**
       * 热搜热度
       */
      hotValue: number;
      
      /**
       * 标签类型(如新、热、爆等)
       */
      tag?: string;
      
      /**
       * 搜索链接
       */
      url?: string;
    }

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/Selenium39/mcp-server-weibo'

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