Skip to main content
Glama
xiaobenyang-com

HackerNews-Search

get-latest-posts

get-latest-posts

Retrieve recent HackerNews content sorted by date. Filter by content type, paginate results, and customize display to monitor platform activity.

Instructions

Retrieve the most recent HackerNews posts sorted by date.

Returns posts in chronological order (newest first), including all types of content unless filtered.

Supports:

  • Filter by content type using tags (story, comment, poll, show_hn, ask_hn, etc.)

  • Pagination to view older posts

  • Customizable results per page (default: 20)

  • Empty query to get all recent posts

Examples:

  • Get latest stories: { "tags": ["story"] }

  • Get latest comments: { "tags": ["comment"] }

  • Get all recent activity: { }

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

Use this to monitor real-time HackerNews activity or find the newest content.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tagsNo
pageNo
hitsPerPageNo

Implementation Reference

  • src/mcp.ts:90-132 (registration)
    Dynamic registration of tools fetched from remote API (https://mcp.xiaobenyang.com/getMcpDesc), including 'get-latest-posts'. Calls addToolXiaoBenYangApi for each tool with parsed schema and generic handler.
    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);
    }
  • Core handler logic that performs the HTTP POST to remote API endpoint with toolName as 'func' header, returns text content. Used for all tools including get-latest-posts.
    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 adds toolName to args and calls calcXiaoBenYangApi. Registered as the tool executor for get-latest-posts.
    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:51-65 (registration)
    Helper function to register a tool with generic handler and dynamic schema. Called for each tool including get-latest-posts.
        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 parsing from remote JSON to Zod types for tool input validation, used for get-latest-posts schema.
    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();
        }
    });
Behavior4/5

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

With no annotations, the description carries full burden and does well: it discloses sorting behavior ('chronological order, newest first'), content scope ('all types unless filtered'), pagination support, default values ('default: 20'), and that empty query returns all recent posts. It doesn't mention rate limits or authentication needs, but covers key operational traits adequately for a read-only tool.

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

Conciseness5/5

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

Well-structured and front-loaded: purpose statement first, then bulleted features, examples, and usage guidance. Every sentence adds value—no fluff. The bullet points efficiently organize key capabilities, and examples are directly actionable.

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

Completeness4/5

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

For a 3-parameter tool with no annotations and no output schema, the description is highly complete: it covers purpose, usage, parameters, and behavior. It doesn't detail the exact output structure (e.g., post fields), but given the tool's straightforward nature and lack of output schema, this is a minor gap. Overall, it provides sufficient context for effective use.

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

Parameters5/5

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

Schema description coverage is 0%, so the description must compensate fully. It explains all 3 parameters: 'tags' for filtering by content type with examples, 'page' for pagination, and 'hitsPerPage' for customizable results with default. The examples provide concrete usage patterns, adding significant meaning beyond the bare schema.

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 specific action ('retrieve'), resource ('most recent HackerNews posts'), and scope ('sorted by date, newest first'). It distinguishes from siblings like 'get-front-page' (which likely shows curated content) and 'search-posts' (which likely searches by keyword rather than recency).

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

Usage Guidelines5/5

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

Explicit guidance is provided: 'Use this to monitor real-time HackerNews activity or find the newest content.' It distinguishes from alternatives by focusing on recency and filtering by tags, unlike 'get-item' (single item) or 'search-posts' (keyword search). The examples further clarify when to use specific parameter combinations.

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

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