google_search_shopping
Search Google Shopping to find product listings, compare prices, and retrieve shopping results with customizable country, location, and language filters.
Instructions
Search Google for results
Input 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 |
| autocorrect | No | Automatically correct (boolean value as string: 'true' or 'false') | true |
| num | No | The number of results to return, max is 100 (integer value as string) | 10 |
Implementation Reference
- src/serper_mcp_server/enums.py:12-12 (registration)Enum definition of the tool name 'google_search_shopping' as a SerperTools member
GOOGLE_SEARCH_SHOPPING = "google_search_shopping" - src/serper_mcp_server/server.py:25-38 (registration)Registration of the tool in the google_request_map, mapping the enum to ShoppingRequest schema. The tool is then registered in list_tools() via iteration.
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/server.py:62-79 (handler)Generic call_tool handler that dispatches to the google() core function for any google search tool, including google_search_shopping. It looks up the request schema from google_request_map and calls google(tool, request).
@server.call_tool() async def call_tool(name: str, arguments: dict[str, Any]) -> Sequence[TextContent | ImageContent | EmbeddedResource]: if not SERPER_API_KEY: return [TextContent(text=f"SERPER_API_KEY is empty!", type="text")] try: if name == SerperTools.WEBPAGE_SCRAPE.value: request = WebpageRequest(**arguments) result = await scape(request) return [TextContent(text=json.dumps(result, indent=2), type="text")] 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")] - src/serper_mcp_server/core.py:14-17 (helper)The google() async function that constructs the API URL by extracting the last segment of the tool enum value (e.g., 'shopping' from 'google_search_shopping') and calls fetch_json to the Serper API.
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) - ShoppingRequest schema - defines the input parameters for google_search_shopping: q (query), gl, location, hl, page (inherited from BaseRequest), plus autocorrect and num fields.
class ShoppingRequest(BaseRequest): autocorrect: Optional[str] = Field( "true", pattern=r"^(true|false)$", description="Automatically correct (boolean value as string: 'true' or 'false')", ) 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)", )