get_live_matches
Retrieve live cricket match details from Cricbuzz, including match descriptions and URLs, using the MCP server for cricket data.
Instructions
Get live cricket matches from Cricbuzz.
Returns: list: A list of dictionaries, each containing the match description and a URL. Example: [{"match": "IND vs AUS...", "url": "https://..."}]
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- cricket_server.py:328-370 (handler)The handler function decorated with @mcp.tool() that implements get_live_matches by scraping the Cricbuzz live scores page to extract and return a list of currently live cricket matches with their descriptions and URLs.@mcp.tool() def get_live_matches() -> list: """Get live cricket matches from Cricbuzz. Returns: list: A list of dictionaries, each containing the match description and a URL. Example: [{"match": "IND vs AUS...", "url": "https://..."}] """ link = "https://www.cricbuzz.com/cricket-match/live-scores" try: response = requests.get(link, headers=HEADERS, timeout=10) response.raise_for_status() # Raise an exception for bad status codes source = response.text page = BeautifulSoup(source, "lxml") container = page.find("div", id="page-wrapper") if not container: return [{"error": "Could not find the main page wrapper"}] matches = container.find_all("div", class_="cb-mtch-lst") live_matches = [] for match in matches: description_tag = match.find("a", class_="text-hvr-underline") if description_tag: match_text = description_tag.text.strip() url_suffix = description_tag.get("href") if url_suffix: url = "https://www.cricbuzz.com" + url_suffix live_matches.append({"match": match_text, "url": url}) return live_matches except requests.exceptions.ConnectionError as e: return [{"error": f"Connection error: {str(e)}"}] except requests.exceptions.Timeout as e: return [{"error": f"Request timeout: {str(e)}"}] except requests.exceptions.HTTPError as e: return [{"error": f"HTTP error: {str(e)}"}] except Exception as e: return [{"error": f"Failed to get live matches: {str(e)}"}]
- cricket_server.py:328-328 (registration)The @mcp.tool() decorator registers the get_live_matches function as an MCP tool.@mcp.tool()
- cricket_server.py:330-335 (schema)The docstring provides the schema description for the tool's input (none) and output (list of dicts with 'match' and 'url')."""Get live cricket matches from Cricbuzz. Returns: list: A list of dictionaries, each containing the match description and a URL. Example: [{"match": "IND vs AUS...", "url": "https://..."}] """
- cricket_server.py:231-231 (helper)Reference to get_live_matches in the docstring of the get_match_details tool.match_url (str): The URL of the match on Cricbuzz (can be obtained from get_live_matches).