Skip to main content
Glama
wei
by wei

Search Posts by URL

search-by-url

Find HackerNews posts that link to a specific URL. Use this tool to discover discussions and comments related to any webpage or online resource.

Instructions

Search for HackerNews posts that link to a specific URL

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
hitsPerPageNoNumber of results per page (default: 20)
pageNoPage number for pagination (default: 0)
urlYesThe URL to search for

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
hitsYes
pageYes
nbHitsYes
nbPagesYes
hitsPerPageYes

Implementation Reference

  • Handler function for 'search-by-url' tool. It constructs a search query on the HackerNews Algolia API restricted to the 'url' attribute, fetches the results using the shared fetchHN helper, and returns formatted content.
    async ({ url, page, hitsPerPage }) => {
      const params = new URLSearchParams();
      params.append('query', url);
      params.append('restrictSearchableAttributes', 'url');
      if (page !== undefined) params.append('page', page.toString());
      if (hitsPerPage !== undefined) params.append('hitsPerPage', hitsPerPage.toString());
      
      const endpoint = `/search?${params.toString()}`;
      const result = await fetchHN(endpoint);
      
      return {
        content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
        structuredContent: result
      };
    }
  • Schema definition for the 'search-by-url' tool, including input schema (url required, optional pagination) and output schema matching the HN API search response structure.
    {
      title: 'Search Posts by URL',
      description: 'Search for HackerNews posts that link to a specific URL',
      inputSchema: {
        url: z.string().describe('The URL to search for'),
        page: z.number().optional().describe('Page number for pagination (default: 0)'),
        hitsPerPage: z.number().optional().describe('Number of results per page (default: 20)')
      },
      outputSchema: {
        hits: z.array(z.any()),
        nbHits: z.number(),
        nbPages: z.number(),
        page: z.number(),
        hitsPerPage: z.number()
      }
    },
  • src/index.ts:405-438 (registration)
    Registration of the 'search-by-url' tool using server.registerTool, including name, schema, and inline handler function.
    server.registerTool(
      'search-by-url',
      {
        title: 'Search Posts by URL',
        description: 'Search for HackerNews posts that link to a specific URL',
        inputSchema: {
          url: z.string().describe('The URL to search for'),
          page: z.number().optional().describe('Page number for pagination (default: 0)'),
          hitsPerPage: z.number().optional().describe('Number of results per page (default: 20)')
        },
        outputSchema: {
          hits: z.array(z.any()),
          nbHits: z.number(),
          nbPages: z.number(),
          page: z.number(),
          hitsPerPage: z.number()
        }
      },
      async ({ url, page, hitsPerPage }) => {
        const params = new URLSearchParams();
        params.append('query', url);
        params.append('restrictSearchableAttributes', 'url');
        if (page !== undefined) params.append('page', page.toString());
        if (hitsPerPage !== undefined) params.append('hitsPerPage', hitsPerPage.toString());
        
        const endpoint = `/search?${params.toString()}`;
        const result = await fetchHN(endpoint);
        
        return {
          content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
          structuredContent: result
        };
      }
    );
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 only states the basic action without mentioning critical details like rate limits, authentication needs, pagination behavior beyond the schema, or what the output contains. For a search tool with no annotation coverage, this is a significant gap in transparency.

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?

The description is a single, clear sentence that efficiently conveys the core functionality without any fluff or redundancy. It is appropriately sized and front-loaded, making it easy for an agent to parse quickly.

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

Completeness3/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 (search operation with pagination), no annotations, and the presence of an output schema, the description is minimally adequate. It covers the basic purpose but lacks behavioral context and usage guidance. The output schema mitigates some completeness issues, but the description should do more to compensate for the absence of annotations.

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?

Schema description coverage is 100%, so the schema already documents all three parameters (url, hitsPerPage, page) with their purposes and defaults. The description adds no additional semantic context beyond implying URL-based filtering, which aligns with the schema. This meets the baseline for high schema coverage.

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 tool's purpose: 'Search for HackerNews posts that link to a specific URL.' It specifies the verb ('search'), resource ('HackerNews posts'), and target ('specific URL'). However, it doesn't explicitly differentiate from sibling tools like 'search-posts' or 'search-posts-by-date' beyond the URL focus, which prevents a perfect score.

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 alternatives. With siblings like 'search-posts' and 'search-posts-by-date' available, it lacks explicit instructions on scenarios where URL-based searching is preferred over other search methods or general browsing tools.

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/wei/hn-mcp-server-vibe'

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