Skip to main content
Glama
isiahw1

mcp-server-bing-webmaster

remove_site

Remove a website from Bing Webmaster Tools to stop tracking and managing its performance data.

Instructions

Remove a site from Bing Webmaster Tools

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
site_urlYes

Implementation Reference

  • The main handler function for the 'remove_site' MCP tool. It is decorated with @mcp.tool for registration and executes the logic by calling the Bing Webmaster API's RemoveSite endpoint via the shared 'api' instance.
    @mcp.tool(name="remove_site", description="Remove a site from Bing Webmaster Tools") async def remove_site( site_url: Annotated[str, "The URL of the site to remove"] ) -> Dict[str, str]: """ Remove a site from Bing Webmaster Tools. Args: site_url: The URL of the site to remove Returns: Success message """ async with api: await api._make_request("RemoveSite", "POST", {"siteUrl": site_url}) return {"message": f"Site {site_url} removed successfully"}
  • Global instantiation of the BingWebmasterAPI client used by the remove_site handler.
    api = BingWebmasterAPI(API_KEY)
  • The BingWebmasterAPI class providing the _make_request method used by the remove_site tool to interact with the Bing Webmaster Tools API.
    class BingWebmasterAPI: """Client for Bing Webmaster Tools API with OData response handling.""" def __init__(self, api_key: str): self.api_key = api_key self.base_url = API_BASE_URL self.client = None async def __aenter__(self): # Create a new client for each context self.client = httpx.AsyncClient(timeout=30.0) return self async def __aexit__(self, exc_type, exc_val, exc_tb): # Close the client when exiting the context if self.client: await self.client.aclose() self.client = None async def close(self): """Explicitly close the HTTP client.""" if self.client: await self.client.aclose() self.client = None 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 def _ensure_type_field(self, data: Any, type_name: str) -> Any: """Ensure __type field is present for MCP compatibility.""" if isinstance(data, list): for item in data: if isinstance(item, dict) and "__type" not in item: item["__type"] = f"{type_name}:#Microsoft.Bing.Webmaster.Api" elif isinstance(data, dict) and "__type" not in data: data["__type"] = f"{type_name}:#Microsoft.Bing.Webmaster.Api" return data

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/isiahw1/mcp-server-bing-webmaster'

If you have feedback or need assistance with the MCP directory API, please join our Discord server