fourget_web_search
Search the web using the 4get meta search engine to find web results with titles, URLs, descriptions, and optional featured answers. Supports pagination and extended search mode.
Instructions
Search the web using the 4get meta search engine. Returns web results with titles, URLs, descriptions, and optional featured answers. Supports pagination via the 'npt' token and extended search mode.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | ||
| page_token | No | ||
| extended_search | No | ||
| engine | No | Optional search engine override (maps to 4get "scraper" query parameter). | |
| extra_params | No |
Implementation Reference
- src/server.py:132-144 (handler)The main handler function for the 'fourget_web_search' MCP tool. It processes input parameters and delegates the web search to FourGetClient.web_search.async def fourget_web_search( query: str, page_token: str | None = None, extended_search: bool = False, engine: EngineParam = None, extra_params: dict[str, Any] | None = None, ) -> dict[str, Any]: return await client.web_search( query=query, page_token=page_token, extended_search=extended_search, options=combine_options(engine, extra_params), )
- src/server.py:124-131 (registration)Registers the 'fourget_web_search' tool with the FastMCP server instance using the custom register_tool decorator.@register_tool( name='fourget_web_search', description=( 'Search the web using the 4get meta search engine. Returns web results ' 'with titles, URLs, descriptions, and optional featured answers. ' "Supports pagination via the 'npt' token and extended search mode." ), )
- src/server.py:52-55 (schema)Type definitions for the tool's 'engine' parameter schema, including SearchEngine enum and EngineParam annotation used for input validation.EngineParam = Annotated[ SearchEngine | None, Field(description='Optional search engine override (maps to 4get "scraper" query parameter).'), ]
- src/server.py:113-123 (helper)Helper function used by the handler to merge the 'engine' override with extra parameters into the options dict passed to the client.def combine_options( engine: SearchEngine | None, extras: dict[str, Any] | None ) -> dict[str, Any] | None: if engine is None and not extras: return None options = dict(extras) if extras else {} if engine is not None: options['scraper'] = engine.value return options
- src/client.py:67-109 (helper)Supporting client method that implements the web search logic (API call, caching, retries) invoked by the tool handler.async def web_search( self, query: str, *, page_token: str | None = None, extended_search: bool | None = None, options: Mapping[str, Any] | None = None, ) -> dict[str, Any]: """Perform a web search using the 4get API. Args: query: Search query string. Ignored when using page_token. page_token: Pagination token from previous response's 'npt' field. extended_search: Enable extended search for more comprehensive results. options: Additional search parameters (e.g., language, region). Returns: Search response containing: - status: "ok" for successful requests - web: List of web search results with title, url, description - npt: Next page token for pagination (if available) - answer: Featured answer/snippet (if available) - spelling: Spelling correction info - related: List of related search terms Raises: FourGetAuthError: Rate limited or invalid authentication FourGetAPIError: API returned non-success status FourGetTransportError: Network or HTTP protocol errors FourGetError: Generic client errors Example: >>> result = await client.web_search("model context protocol") >>> for item in result['web']: >>> print(f"{item['title']}: {item['url']}") """ return await self._call_search( 'web', query, page_token=page_token, options=options, include_extended=extended_search, )