verify_site
Verify site ownership in Bing Webmaster Tools to access analytics and manage search performance.
Instructions
Attempt to verify ownership of a site
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| site_url | Yes |
Implementation Reference
- mcp_server_bwt/main.py:162-177 (handler)The main handler function for the 'verify_site' tool. It uses the @mcp.tool decorator for registration and calls the Bing Webmaster API's VerifySite endpoint to attempt site verification.@mcp.tool(name="verify_site", description="Attempt to verify ownership of a site") async def verify_site( site_url: Annotated[str, "The URL of the site to verify"] ) -> Dict[str, Any]: """ Attempt to verify ownership of a site. Args: site_url: The URL of the site to verify Returns: Verification result """ async with api: result = await api._make_request("VerifySite", "POST", {"siteUrl": site_url}) return {"verified": result, "site_url": site_url}
- mcp_server_bwt/main.py:59-111 (helper)The _make_request helper method in BingWebmasterAPI class, used by verify_site to perform the actual API call to 'VerifySite' endpoint.async def _make_request( self, endpoint: str, method: str = "GET", json_data: Optional[Dict[str, Any]] = None, params: Optional[Dict[str, Any]] = None, ) -> Any: """Make a request to the Bing API and handle OData responses.""" if not self.client: raise RuntimeError( "API client not initialized. Use 'async with api:' context manager." ) headers = {"Content-Type": "application/json; charset=utf-8"} # Build URL with API key if "?" in endpoint: url = f"{self.base_url}/{endpoint}&apikey={self.api_key}" else: url = f"{self.base_url}/{endpoint}?apikey={self.api_key}" # Add additional parameters if provided if params: for key, value in params.items(): url += f"&{key}={value}" try: if method == "GET": response = await self.client.get(url, headers=headers) else: response = await self.client.request( method, url, headers=headers, json=json_data ) if response.status_code != 200: error_text = response.text logger.error(f"API error {response.status_code}: {error_text}") raise Exception(f"API error {response.status_code}: {error_text}") data = response.json() # Handle OData response format if "d" in data: return data["d"] return data except httpx.TimeoutException: logger.error(f"Request timeout for {endpoint}") raise Exception("Request timed out") except Exception as e: logger.error(f"Request failed: {str(e)}") raise