google_search_news
Search Google for news articles using specific queries, filters, and location parameters to retrieve current information from the web.
Instructions
Search Google for results
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| q | Yes | The query to search for | |
| gl | No | The country to search in, e.g. us, uk, ca, au, etc. | |
| location | No | The location to search in, e.g. San Francisco, CA, USA | |
| hl | No | The language to search in, e.g. en, es, fr, de, etc. | |
| page | No | The page number to return, first page is 1 (integer value as string) | 1 |
| tbs | No | The time period to search in, e.g. d, w, m, y | |
| num | No | The number of results to return, max is 100 (integer value as string) | 10 |
Implementation Reference
- src/serper_mcp_server/core.py:14-18 (handler)Core handler function for google_search_news: extracts 'news' from tool name, builds Serper API URL https://google.serper.dev/news, and fetches JSON response.async def google(tool: SerperTools, request: BaseModel) -> Dict[str, Any]: uri_path = tool.value.split("_")[-1] url = f"https://google.serper.dev/{uri_path}" return await fetch_json(url, request)
- src/serper_mcp_server/server.py:73-79 (handler)Dispatch logic in @server.call_tool() that handles google_search_news by parsing tool name to SerperTools enum, instantiating SearchRequest, calling google() handler, and formatting response.if not SerperTools.has_value(name): raise ValueError(f"Tool {name} not found") tool = SerperTools(name) request = google_request_map[tool](**arguments) result = await google(tool, request) return [TextContent(text=json.dumps(result, indent=2), type="text")]
- Pydantic SearchRequest schema used for input validation of google_search_news tool.class SearchRequest(BaseRequest): tbs: Optional[str] = Field( None, description="The time period to search in, e.g. d, w, m, y" ) num: str = Field( "10", pattern=r"^([1-9]|[1-9]\d|100)$", description="The number of results to return, max is 100 (integer value as string)", )
- src/serper_mcp_server/server.py:25-38 (registration)Mapping of tool names to input schemas; maps 'google_search_news' to SearchRequest.google_request_map = { SerperTools.GOOGLE_SEARCH: SearchRequest, SerperTools.GOOGLE_SEARCH_IMAGES: SearchRequest, SerperTools.GOOGLE_SEARCH_VIDEOS: SearchRequest, SerperTools.GOOGLE_SEARCH_PLACES: AutocorrectRequest, SerperTools.GOOGLE_SEARCH_MAPS: MapsRequest, SerperTools.GOOGLE_SEARCH_REVIEWS: ReviewsRequest, SerperTools.GOOGLE_SEARCH_NEWS: SearchRequest, SerperTools.GOOGLE_SEARCH_SHOPPING: ShoppingRequest, SerperTools.GOOGLE_SEARCH_LENS: LensRequest, SerperTools.GOOGLE_SEARCH_SCHOLAR: AutocorrectRequest, SerperTools.GOOGLE_SEARCH_PATENTS: PatentsRequest, SerperTools.GOOGLE_SEARCH_AUTOCOMPLETE: AutocorrectRequest, }
- src/serper_mcp_server/enums.py:4-23 (helper)SerperTools enum defining the tool name 'google_search_news' and utility method has_value() used in dispatch.class SerperTools(StrEnum): GOOGLE_SEARCH = "google_search" GOOGLE_SEARCH_IMAGES = "google_search_images" GOOGLE_SEARCH_VIDEOS = "google_search_videos" GOOGLE_SEARCH_PLACES = "google_search_places" GOOGLE_SEARCH_MAPS = "google_search_maps" GOOGLE_SEARCH_REVIEWS = "google_search_reviews" GOOGLE_SEARCH_NEWS = "google_search_news" GOOGLE_SEARCH_SHOPPING = "google_search_shopping" GOOGLE_SEARCH_LENS = "google_search_lens" GOOGLE_SEARCH_SCHOLAR = "google_search_scholar" GOOGLE_SEARCH_PATENTS = "google_search_patents" GOOGLE_SEARCH_AUTOCOMPLETE = "google_search_autocomplete" WEBPAGE_SCRAPE = "webpage_scrape" @classmethod def has_value(cls, value: str) -> bool: return value in cls._value2member_map_