Skip to main content
Glama

get-zhihu-trending

get-zhihu-trending

Retrieve trending discussions from Zhihu, covering current affairs, social topics, technology updates, and entertainment news in Chinese.

Instructions

获取知乎热榜,包含时事热点、社会话题、科技动态、娱乐八卦等多领域的热门问答和讨论的中文资讯

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNo

Implementation Reference

  • Core handler function that proxies tool execution to remote API at https://mcp.xiaobenyang.com/api, using toolName ('get-zhihu-trending') as 'func' header and passing arguments as body.
    const calcXiaoBenYangApi = async function (fullArgs: Record<string, any>) {
        // 发起 POST 请求
        let response = await fetch('https://mcp.xiaobenyang.com/api', {
            method: 'POST',
            headers: {
                'XBY-APIKEY': apiKey,
                'func': fullArgs.toolName,
                'mcpid': mcpID
            },
            body: new URLSearchParams(fullArgs)
        });
        const apiResult = await response.text();
    
        return {
            content: [
                {
                    type: "text",
                    text: apiResult // 将字符串结果放入 content 中
                }
            ]
        } as { [x: string]: unknown; content: [{ type: "text"; text: string }] };
    };
  • Wrapper handler that prepares arguments with toolName and calls the core proxy function for tools like get-zhihu-trending.
    const handleXiaoBenYangApi = async (args: Record<string, any>, toolName: string) => {
        // 校验aid是否存在
        if (toolName === undefined || toolName === null) {
            throw new Error("缺少必要参数 'aid'");
        }
        // 合并参数
        const fullArgs = {...args, toolName: toolName};
        // 调用API
        return calcXiaoBenYangApi(fullArgs);
    };
  • src/mcp.ts:73-144 (registration)
    Dynamic registration function that fetches tool list from remote API (for mcpId 1777316659328003), builds Zod schemas, and registers each tool (including get-zhihu-trending if present) using server.registerTool.
    const getServer = async () => {
        console.log("getServer start.........")
        if(!isRegistered) {
            try {
                state.isLoading = true;
    
                const res = await fetch('https://mcp.xiaobenyang.com/getMcpDesc?mcpId=' + mcpID, {
                    method: 'GET',
                });
    
                if (!res.ok) {
                    throw new Error(`请求失败:${res.status}`);
                }
    
                const data = await res.json();
                const apiDescList = data.tools;
    
                for (const apiDesc of apiDescList) {
                    let inputSchema = JSON.parse(apiDesc.inputSchema);
                    const zodDict: Record<string, z.ZodTypeAny> = {};
    
                    Object.entries(inputSchema.properties).forEach(([name, propConfig]) => {
                        let zodType;
                        let pt = (propConfig as { type: string }).type;
                        switch (pt) {
                            case 'string':
                                zodType = z.string();
                                break;
                            case 'number':
                                zodType = z.number();
                                break;
                            case 'boolean':
                                zodType = z.boolean();
                                break;
                            case 'integer':
                                zodType = z.int32();
                                break;
                            case 'array':
                                zodType = z.array(z.any());
                                break;
                            case 'object':
                                zodType = z.object(z.any());
                                break;
                            default:
                                zodType = z.any();
                        }
    
                        if (inputSchema.required?.includes(name)) {
                            zodDict[name] = zodType;
                        } else {
                            zodDict[name] = zodType.optional();
                        }
                    });
    
    
                    addToolXiaoBenYangApi(
                        apiDesc.name,
                        apiDesc.description ? apiDesc.description : apiDesc.name,
                        zodDict);
                }
                isRegistered = true;
                state.isLoading = false;
                console.log("state.isLoading: " + state.isLoading)
                return server;
            } catch (error) {
                console.error("getServer 执行失败:", error);
                state.isLoading = false; // 异常时也需要重置加载状态
                throw error; // 抛出错误,让调用方捕获
            }
        } else {
            return server;
        }
  • Helper function to register a tool with schema and generic handler bound to the tool name.
    const addToolXiaoBenYangApi = function (
        name: string,
        desc: string,
        params: Record<string, ZodType>
    ) {
        server.registerTool(
            name,
            {
                title: name,
                description: desc,
                inputSchema: params,
            }
            ,
            async (args: Record<string, any>) => handleXiaoBenYangApi(args, name)
        )
    };
  • Dynamic schema construction from remote tool description JSON schema, mapping to Zod types for input validation.
    let inputSchema = JSON.parse(apiDesc.inputSchema);
    const zodDict: Record<string, z.ZodTypeAny> = {};
    
    Object.entries(inputSchema.properties).forEach(([name, propConfig]) => {
        let zodType;
        let pt = (propConfig as { type: string }).type;
        switch (pt) {
            case 'string':
                zodType = z.string();
                break;
            case 'number':
                zodType = z.number();
                break;
            case 'boolean':
                zodType = z.boolean();
                break;
            case 'integer':
                zodType = z.int32();
                break;
            case 'array':
                zodType = z.array(z.any());
                break;
            case 'object':
                zodType = z.object(z.any());
                break;
            default:
                zodType = z.any();
        }
    
        if (inputSchema.required?.includes(name)) {
            zodDict[name] = zodType;
        } else {
            zodDict[name] = zodType.optional();
        }
    });
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It describes what the tool does (retrieves trending content) but doesn't mention any behavioral traits like whether it's a read-only operation, rate limits, authentication needs, data freshness, or what the output format looks like. For a tool with zero annotation coverage, this leaves significant gaps in understanding its behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, well-structured sentence that efficiently conveys the tool's purpose and scope. It's appropriately sized and front-loaded with the core function, though it could potentially be more concise by removing some of the domain examples if they're redundant with '多领域' (multiple domains).

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (retrieving trending content from a specific platform), no annotations, no output schema, and incomplete parameter documentation (0% coverage), the description is insufficient. It explains what the tool does but lacks crucial details about behavior, output format, and parameter usage, making it incomplete for effective agent use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 1 parameter (limit) with 0% description coverage, and the tool description doesn't mention any parameters. With low schema coverage (<50%), the description doesn't compensate by explaining the parameter's purpose or usage. However, since there's only one parameter and it's optional (0 required parameters), the baseline is slightly higher than if there were multiple undocumented parameters.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: '获取知乎热榜' (get Zhihu trending) with specific details about the content it retrieves - '包含时事热点、社会话题、科技动态、娱乐八卦等多领域的热门问答和讨论的中文资讯' (includes Chinese information on trending Q&A and discussions across multiple domains like current events, social topics, tech trends, entertainment gossip). It distinguishes itself from siblings by specifying the Zhihu platform and the type of content (trending Q&A/discussions).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage context by mentioning the specific platform (Zhihu) and content type (trending Q&A/discussions in Chinese), which helps differentiate it from siblings that target other platforms like Weibo, Douyin, or news sources. However, it doesn't explicitly state when to use this tool versus alternatives or provide any exclusions or prerequisites.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/xiaobenyang-com/1777316659328003'

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