Skip to main content
Glama

get-front-page

Retrieve trending posts from the HackerNews front page with pagination support to access popular stories sorted by ranking algorithm.

Instructions

Retrieve posts currently on the HackerNews front page.

Returns stories sorted by HackerNews ranking algorithm. The front page typically contains the most popular and trending stories.

Supports:

  • Pagination to view beyond the first page

  • Customizable results per page (default: 30)

  • All posts are tagged with 'front_page'

Examples:

  • Get first page: { }

  • Get with custom page size: { "hitsPerPage": 50 }

  • Get second page: { "page": 1 }

Returns the same structure as search results with hits, pagination info, and metadata.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pageNo
hitsPerPageNo

Implementation Reference

  • Generic handler function for all dynamically registered XiaoBenYang API tools, including "get-front-page". It validates the toolName, merges arguments, and proxies the call to the remote API via calcXiaoBenYangApi.
    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:89-133 (registration)
    Dynamic tool registration loop that fetches tool descriptions from remote API (https://mcp.xiaobenyang.com/getMcpDesc), builds Zod schemas, and registers each tool (including "get-front-page") using addToolXiaoBenYangApi.
    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;
  • Dynamic construction of Zod input schema for each tool based on fetched JSON schema, mapping JSON types to Zod types and handling required/optional fields.
    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(); } });
  • Helper function that performs the actual HTTP POST to the remote XiaoBenYang API endpoint, using the toolName (e.g., 'get-front-page') as 'func' header, and formats the response as MCP tool content.
    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 }] }; };
  • Helper function to register a tool on the MCP server, wiring the generic handleXiaoBenYangApi as the execution handler, passing 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) ) };

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/HackerNews-Search'

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