实时数据/IT资讯热榜
Access trending IT news and real-time data updates to stay informed about current technology developments and industry insights.
Instructions
实时数据/IT资讯热榜
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/test_stdio_list.js:6-17 (handler)The shared handler function for all dynamically loaded tools. It sends a POST request to 'https://xiaobenyang.com/api' using the tool-specific 'aid' and input arguments, authenticating with API_KEY.
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)The function used to register each tool dynamically. Tool name is set to 'title' from the API response (which includes "实时数据/IT资讯热榜"), description, Zod parameters schema, and a wrapped execute handler that injects the tool-specific '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:152-157 (registration)Loop that registers all tools by calling addToolXiaoBenYangApi for each item in the fetched apiDescList (tools data from https://xiaobenyang.com/api/[MCP_ID]).
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:109-123 (schema)Converts the 'params' array from the API (Java-style type descriptions) into a Zod object schema used for the tool's input 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:89-106 (helper)Helper function that converts Java type strings (including generics) to corresponding Zod validators, used in schema generation.
function convertJavaTypeToZod(javaType) { // 解析泛型(如处理 "List<Integer>" 这种格式) const {base: baseType, generics} = parseGenericType(javaType); // 优先匹配全类名(如 "java.lang.String") if (JAVA_TO_ZOD_MAP[baseType]) { return JAVA_TO_ZOD_MAP[baseType](...generics); } // 若全类名未匹配,提取简单类名再匹配(如 "String" 从 "java.lang.String" 提取) const simpleTypeName = baseType.split('.').pop(); if (JAVA_TO_ZOD_MAP[simpleTypeName]) { return JAVA_TO_ZOD_MAP[simpleTypeName](...generics); } // 未匹配的类型默认视为自定义对象(返回 z.object(),需手动补充) return z.object({}); }