submit_url
Submit a URL to Bing Webmaster Tools for indexing to improve search visibility and ensure content is crawled.
Instructions
Submit a single URL for indexing.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| site_url | Yes | ||
| url | Yes |
Implementation Reference
- mcp_server_bwt/main.py:301-318 (handler)The handler function for the 'submit_url' MCP tool. It takes site_url and url parameters, uses the BingWebmasterAPI to make a POST request to 'SubmitUrl' endpoint, and returns a success message. The @mcp.tool decorator registers it with the MCP server.@mcp.tool(name="submit_url", description="Submit a single URL for indexing.") async def submit_url( site_url: Annotated[str, "The URL of the site"], url: Annotated[str, "The specific URL to submit"], ) -> Dict[str, str]: """ Submit a single URL for indexing. Args: site_url: The URL of the site url: The specific URL to submit Returns: Success message """ async with api: await api._make_request("SubmitUrl", "POST", {"siteUrl": site_url, "url": url}) return {"message": f"URL {url} submitted successfully"}
- mcp_server_bwt/main.py:301-301 (registration)The @mcp.tool decorator registers the submit_url function as an MCP tool with the specified name and description.@mcp.tool(name="submit_url", description="Submit a single URL for indexing.")
- mcp_server_bwt/main.py:59-110 (helper)The _make_request method of BingWebmasterAPI class, used by submit_url to perform the actual API call to 'SubmitUrl' 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