Skip to main content
Glama

search_engine

Extract search engine results from Google, Bing, or Yandex to obtain URLs, titles, and descriptions for web research and data collection.

Instructions

Scrape search results from Google, Bing or Yandex. Returns SERP results in markdown (URL, title, description)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYes
engineNogoogle
cursorNoPagination cursor for next page

Implementation Reference

  • Handler for the 'search_engine' tool. Constructs a search URL using the search_url helper, sends a POST request to BrightData API's /request endpoint using the unlocker zone, requests markdown format, and returns the scraped SERP results.
    execute: tool_fn('search_engine', async({query, engine, cursor})=>{ let response = await axios({ url: 'https://api.brightdata.com/request', method: 'POST', data: { url: search_url(engine, query, cursor), zone: unlocker_zone, format: 'raw', data_format: 'markdown', }, headers: api_headers(), responseType: 'text', }); return response.data; }),
  • Zod schema defining the input parameters for the 'search_engine' tool: 'query' (required string), 'engine' (optional enum ['google', 'bing', 'yandex'], defaults to 'google'), 'cursor' (optional string for pagination).
    parameters: z.object({ query: z.string(), engine: z.enum([ 'google', 'bing', 'yandex', ]).optional().default('google'), cursor: z.string().optional().describe('Pagination cursor for next page'), }),
  • server.js:130-159 (registration)
    Registers the 'search_engine' tool with the FastMCP server using addTool, specifying name, description, input schema, and execute handler.
    addTool({ name: 'search_engine', description: 'Scrape search results from Google, Bing or Yandex. Returns ' +'SERP results in markdown (URL, title, description)', parameters: z.object({ query: z.string(), engine: z.enum([ 'google', 'bing', 'yandex', ]).optional().default('google'), cursor: z.string().optional().describe('Pagination cursor for next page'), }), execute: tool_fn('search_engine', async({query, engine, cursor})=>{ let response = await axios({ url: 'https://api.brightdata.com/request', method: 'POST', data: { url: search_url(engine, query, cursor), zone: unlocker_zone, format: 'raw', data_format: 'markdown', }, headers: api_headers(), responseType: 'text', }); return response.data; }), });
  • Helper function that constructs the search engine URL (Google, Bing, or Yandex) based on the query, engine, and cursor (for pagination), properly encoding the query and calculating start/page parameters.
    function search_url(engine, query, cursor){ let q = encodeURIComponent(query); let page = cursor ? parseInt(cursor) : 0; let start = page * 10; if (engine=='yandex') return `https://yandex.com/search/?text=${q}&p=${page}`; if (engine=='bing') return `https://www.bing.com/search?q=${q}&first=${start + 1}`; return `https://www.google.com/search?q=${q}&start=${start}`; }

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/dsouza-anush/brightdata-mcp-heroku'

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