add_site
Register a website with Bing Webmaster Tools to enable search engine monitoring and optimization features.
Instructions
Add a new site to Bing Webmaster Tools
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| site_url | Yes |
Implementation Reference
- mcp_server_bwt/main.py:144-160 (handler)The handler function for the 'add_site' tool, which adds a new site by calling the Bing Webmaster API's AddSite endpoint.@mcp.tool(name="add_site", description="Add a new site to Bing Webmaster Tools") async def add_site( site_url: Annotated[str, "The URL of the site to add"] ) -> Dict[str, str]: """ Add a new site to Bing Webmaster Tools. Args: site_url: The URL of the site to add Returns: Success message """ async with api: await api._make_request("AddSite", "POST", {"siteUrl": site_url}) return {"message": f"Site {site_url} added successfully"}
- mcp_server_bwt/main.py:144-144 (registration)Registers the 'add_site' tool with MCP using the @mcp.tool decorator.@mcp.tool(name="add_site", description="Add a new site to Bing Webmaster Tools")
- mcp_server_bwt/main.py:59-111 (helper)The _make_request helper method in BingWebmasterAPI class used by add_site to perform the API call.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