get_keyword
Retrieve keyword impression data from Bing Webmaster Tools for specific queries, countries, languages, and date ranges to analyze search performance.
Instructions
Get keyword impressions for a selected period.
Args: query: The keyword query country: The country code language: The language code start_date: The start date of the period end_date: The end date of the period
Returns: Optional[Keyword]: Keyword impression data, or None if no data available
Raises: BingWebmasterError: If keyword data cannot be retrieved
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| self | Yes | ||
| query | Yes | ||
| country | Yes | ||
| language | Yes | ||
| start_date | Yes | ||
| end_date | Yes |
Implementation Reference
- Handler logic for the 'get_keyword' tool: asynchronous wrapper function that executes the underlying keyword_analysis.KeywordAnalysisService.get_keyword method via the service instance.async def wrapper(*args: Any, **kwargs: Any) -> Any: # Filter out any 'self' arguments that might be passed by the MCP client kwargs = {k: v for k, v in kwargs.items() if k != "self"} async with service as s: service_obj = getattr(s, service_attr) # Get the method from the instance method = getattr(service_obj, method_name) # Call the method directly - it's already bound to the instance return await method(*args, **kwargs)
- Generates the input schema for the tool by inspecting and adapting the signature of the original service method (KeywordAnalysisService.get_keyword).# Get the original method original_method = getattr(service_class, method_name) # Get the signature sig = inspect.signature(original_method) # Remove 'self' parameter from signature parameters = list(sig.parameters.values())[1:] # Skip 'self' # Create new signature without 'self' new_sig = sig.replace(parameters=parameters)
- mcp_server_bwt/tools/bing_webmaster.py:151-151 (registration)Registers the 'get_keyword' tool with the MCP server by creating and assigning the wrapped handler function.get_keyword = wrap_service_method(mcp, service, "keywords", "get_keyword") # noqa: F841
- mcp_server_bwt/main.py:17-17 (registration)Overall registration entry point: calls add_bing_webmaster_tools which includes the specific get_keyword registration.add_bing_webmaster_tools(mcp, bing_service)
- Helper mapping that provides the KeywordAnalysisService class for 'keywords' service, used for method lookup and signature introspection.SERVICE_CLASSES = { "sites": site_management.SiteManagementService, "submission": submission.SubmissionService, "traffic": traffic_analysis.TrafficAnalysisService, "crawling": crawling.CrawlingService, "keywords": keyword_analysis.KeywordAnalysisService, "links": link_analysis.LinkAnalysisService, "content": content_management.ContentManagementService, "blocking": content_blocking.ContentBlockingService, "regional": regional_settings.RegionalSettingsService, "urls": url_management.UrlManagementService, }