get_rank_and_traffic_stats
Retrieve ranking positions and traffic data for a website from Bing Webmaster Tools to monitor search performance and analyze visitor trends.
Instructions
Get ranking and traffic statistics for a site.
Args: site_url: The URL of the site
Returns: List[RankAndTrafficStats]: List of ranking and traffic statistics
Raises: BingWebmasterError: If statistics cannot be retrieved
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| self | Yes | ||
| site_url | Yes |
Implementation Reference
- The core handler logic for the tool (shared across all Bing Webmaster tools). It wraps the service method with @mcp.tool(), copies the signature and docstring, and executes the underlying traffic_analysis.TrafficAnalysisService.get_rank_and_traffic_stats method via the BingWebmasterService instance.# Create wrapper function with same signature @mcp.tool() @wraps(original_method) 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) # Copy signature and docstring wrapper.__signature__ = new_sig # type: ignore wrapper.__doc__ = original_method.__doc__
- mcp_server_bwt/tools/bing_webmaster.py:136-138 (registration)Specific registration of the 'get_rank_and_traffic_stats' tool by invoking the wrap_service_method helper with the appropriate service ('traffic') and method name.get_rank_and_traffic_stats = wrap_service_method( # noqa: F841 mcp, service, "traffic", "get_rank_and_traffic_stats" )
- mcp_server_bwt/main.py:17-17 (registration)Overall registration entry point where all Bing Webmaster tools, including 'get_rank_and_traffic_stats', are added to the MCP server instance.add_bing_webmaster_tools(mcp, bing_service)
- Initializes the 'traffic' service attribute on BingWebmasterService, which provides the underlying get_rank_and_traffic_stats method used by the tool.self.traffic = traffic_analysis.TrafficAnalysisService(self.client)