Skip to main content
Glama

Get top stories

get_top_stories

Retrieve current top stories from Hacker News to stay informed about trending technology and programming topics.

Instructions

Get the current top Hacker News stories.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
storiesYes
returnedYes

Implementation Reference

  • The handler implementation for the `get_top_stories` tool in `HackerNewsServer`, which calls the client's `getTopStories` method.
    handler: async ({ limit }, context) => {
      await context.log("info", "Fetching top Hacker News stories");
      const stories = await this.client.getTopStories(limit);
      return {
        stories: [...stories],
        returned: stories.length,
      };
    },
  • Registration of the `get_top_stories` tool within the `HackerNewsServer` class.
    this.registerTool(
      defineTool({
        name: "get_top_stories",
        title: "Get top stories",
        description: "Get the current top Hacker News stories.",
        inputSchema: {
          limit: z.number().int().min(1).max(30).default(10),
        },
        outputSchema: {
          stories: z.array(storySummarySchema),
          returned: z.number().int(),
        },
        handler: async ({ limit }, context) => {
          await context.log("info", "Fetching top Hacker News stories");
          const stories = await this.client.getTopStories(limit);
          return {
            stories: [...stories],
            returned: stories.length,
          };
        },
        renderText: ({ stories }) => stories.map((story) => `${story.title} (${story.score ?? 0} points)`).join("\n"),
      }),
  • The `getTopStories` method on `FetchHackerNewsClient` that actually performs the API request to fetch top stories.
    public async getTopStories(limit: number): Promise<ReadonlyArray<HackerNewsStorySummary>> {
      const ids = await this.fetchJson(new URL(`${this.apiBaseUrl}/topstories.json`), z.array(z.number().int().nonnegative()));
      const items = await Promise.all(ids.slice(0, limit).map((id) => this.fetchItem(id)));
      return items
        .filter((item): item is z.infer<typeof hnItemSchema> => isHnItem(item) && item.type === "story")
        .map((item) => this.toStorySummary(item));
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure but offers only minimal context ('current' implies timeliness). It fails to mention rate limits, caching behavior, what 'top' algorithmically means, or any authentication requirements.

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

Conciseness3/5

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

The description consists of a single efficient sentence with no redundant words, achieving literal brevity. However, the extreme conciseness results in underspecification given the lack of schema documentation and behavioral annotations.

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?

While the existence of an output schema excuses the description from detailing return values, the description remains incomplete due to its failure to document the undocumented 'limit' parameter or distinguish usage from sibling tools. For a tool with low complexity (one optional parameter), the description inadequately prepares the agent to invoke the tool correctly.

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

Parameters1/5

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

The input schema has 0% description coverage for its single 'limit' parameter, yet the description provides no compensatory documentation about this parameter's purpose, constraints, or default value of 10. The description omits any mention of the parameter entirely, leaving the agent unaware of the ability to control result set size between 1-30 items.

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

Purpose4/5

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

The description clearly states the action ('Get') and resource ('current top Hacker News stories'), identifying the specific data source and content type. However, it does not explicitly differentiate from the sibling 'search_stories' regarding when to retrieve top stories versus performing a search.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus the available alternatives like 'search_stories' or 'get_item_thread'. There are no stated prerequisites, conditions, or exclusions for usage.

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/Markgatcha/universal-mcp-toolkit'

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