Skip to main content
Glama

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

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 }; } );

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