Skip to main content
Glama

get_website_urls

Extract and filter URLs from any website based on a search query to find relevant pages quickly.

Instructions

Search and retrieve relevant URLs from a website

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
search_queryYesThe search query to sort URLs by.
urlYesThe URL of the website to map.

Implementation Reference

  • The async handler function that implements the tool logic by calling the Olostep Map API with the provided website URL and search query, returning relevant URLs or error messages.
    handler: async ({ url, search_query }: { url: string; search_query: string }, apiKey: string) => { try { const headers = new Headers({ 'Content-Type': 'application/json', 'Authorization': `Bearer ${apiKey}` }); const payload = { url: url, search_query: search_query, top_n: 100 }; const response = await fetch(OLOSTEP_MAP_API_URL, { method: 'POST', headers: headers, body: JSON.stringify(payload) }); if (!response.ok) { const errorDetails = await response.json(); return { isError: true, content: [{ type: "text", text: `Olostep API Error: ${response.status} ${response.statusText}. Details: ${JSON.stringify(errorDetails)}` }] }; } const data = await response.json() as OlostepMapApiResponse; if (data.urls && data.urls.length > 0) { return { content: [{ type: "text", text: `Found ${data.urls_count} URLs matching your query:\n\n${data.urls.join('\n')}` }] }; } else { return { content: [{ type: "text", text: "No URLs found matching your search query." }] }; } } catch (error: unknown) { return { isError: true, content: [{ type: "text", text: `Error: Failed to fetch website map. ${error instanceof Error ? error.message : String(error)}` }] }; } }
  • Zod schema defining the input parameters for the tool: 'url' (website URL) and 'search_query' (search term).
    schema: { url: z.string().url().describe("The URL of the website to map."), search_query: z.string().describe("The search query to sort URLs by."), },
  • src/index.ts:40-51 (registration)
    Registration of the 'get_website_urls' tool on the MCP server, using the name, description, schema, and a wrapper around the handler that injects the API key.
    server.tool( getWebsiteMap.name, getWebsiteMap.description, getWebsiteMap.schema, async (params) => { const result = await getWebsiteMap.handler(params, OLOSTEP_API_KEY); return { ...result, content: result.content.map(item => ({ ...item, type: item.type as "text" })) }; } );

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/olostep/olostep-mcp-server'

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