fourget_web_search
Search the web using the 4get meta search engine to retrieve web results with titles, URLs, descriptions, and optional featured answers, supporting 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 |
|---|---|---|---|
| extended_search | No | ||
| extra_params | No | ||
| page_token | No | ||
| query | Yes |
Implementation Reference
- src/server.py:132-144 (handler)The MCP tool handler function 'fourget_web_search' that processes inputs and delegates the web search to FourGetClient.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)Registration of the 'fourget_web_search' tool using the custom @register_tool decorator which applies FastMCP's mcp.tool.@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)Pydantic type annotation for the optional 'engine' parameter, using SearchEngine enum.EngineParam = Annotated[ SearchEngine | None, Field(description='Optional search engine override (maps to 4get "scraper" query parameter).'), ]
- src/server.py:113-123 (helper)Helper function to merge engine selection and extra parameters into the options dict for the 4get API.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)Core implementation in FourGetClient that handles the web search API interaction, caching, and retries.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, )