实时数据/虎嗅热榜
Access trending news and articles from Huxiu's hot topics list to stay informed about current events and popular discussions in Chinese media.
Instructions
实时数据/虎嗅热榜
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/test_stdio_list.js:152-157 (registration)Dynamically registers tools from the fetched apiDescList. Each tool uses apiDesc.title as the name (e.g., "实时数据/虎嗅热榜"), apiDesc.apiId as the internal aid, converted params as schema, and a wrapper around calcXiaoBenYangApi as handler.
for (const apiDesc of apiDescList) { addToolXiaoBenYangApi(apiDesc.apiId.toString(), apiDesc.title, apiDesc.description ? apiDesc.description : apiDesc.title, convertParamsToZ(apiDesc.params)); } - src/test_stdio_list.js:6-17 (handler)Core handler logic for all dynamic tools: sends POST request to https://xiaobenyang.com/api with API key, aid (tool-specific), and user args.
const calcXiaoBenYangApi = async function (fullArgs) { // 发起 GET 请求 let response = await fetch('https://xiaobenyang.com/api', { method: 'POST', headers: { 'APIKEY': process.env.API_KEY, 'aid': fullArgs.aid }, body: new URLSearchParams(fullArgs) }); return await response.text(); } - src/test_stdio_list.js:139-150 (registration)Registers a specific tool on the MCP server with given name/title (e.g., "实时数据/虎嗅热榜"), description, parameters schema, and execute handler that injects the tool's aid.
const addToolXiaoBenYangApi = function (aid, title, desc, params) { server.addTool({ name: title, description: desc, parameters: params, execute: async (args) => { // 合并用户输入 args 和工具专属 aid const fullArgs = {...args, aid: aid}; return calcXiaoBenYangApi(fullArgs); } }); } - src/test_stdio_list.js:109-123 (schema)Converts Java-style parameter descriptions (from API) to Zod schema objects used in tool parameters.
const convertParamsToZ = function (params) { let zParams = {}; for (const param of params) { let zodType = convertJavaTypeToZod(param.type) if (param.description) { zodType = zodType.describe(param.name); } if (param.required) { zodType = zodType.optional(); } zParams[param.name] = zodType; } return z.object(zParams); } - src/test_stdio_list.js:126-133 (helper)Fetches the list of tools descriptions from the remote API, populating apiDescList with titles like "实时数据/虎嗅热榜" for dynamic registration.
fetch('https://xiaobenyang.com/api/' + process.env.MCP_ID, { method: 'GET', }).then((res) => { if (!res.ok) throw new Error(`请求失败:${res.status}`); return res.json(); // 解析响应体为 JSON(假设返回 { apiDescList: [...] }) }) .then((data) => { const apiDescList = data.tools;