Skip to main content
Glama
tarun7r

cricket-mcp-server

get_match_details

Retrieve comprehensive cricket match details, including title, result, and scorecard data for each innings, by providing a Cricbuzz URL via the cricket-mcp-server.

Instructions

Get detailed scorecard for a specific cricket match from a Cricbuzz URL.

Args: match_url (str): The URL of the match on Cricbuzz (can be obtained from get_live_matches).

Returns: dict: A dictionary containing match details including: - Match title and result. - A scorecard for each innings with batting and bowling stats.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
match_urlYes

Implementation Reference

  • The handler function for the 'get_match_details' tool. It scrapes the Cricbuzz match page for title, result, and detailed scorecard including batting and bowling stats for each innings. Registered via @mcp.tool() decorator.
    @mcp.tool()
    def get_match_details(match_url: str) -> dict:
        """
        Get detailed scorecard for a specific cricket match from a Cricbuzz URL.
        
        Args:
            match_url (str): The URL of the match on Cricbuzz (can be obtained from get_live_matches).
            
        Returns:
            dict: A dictionary containing match details including:
                  - Match title and result.
                  - A scorecard for each innings with batting and bowling stats.
        """
        if not match_url or "cricbuzz.com" not in match_url:
            return {"error": "A valid Cricbuzz match URL is required."}
            
        try:
            response = requests.get(match_url, headers=HEADERS, timeout=10)
            response.raise_for_status()
            source = response.text
            page = BeautifulSoup(source, "lxml")
        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 fetch or parse match page: {str(e)}"}
    
        match_data = {}
    
        # Extract title and result
        title_tag = page.find("h1", class_="cb-nav-hdr")
        if title_tag:
            match_data["title"] = title_tag.text.strip()
        
        result_tag = page.find("div", class_="cb-nav-text")
        if result_tag:
            match_data["result"] = result_tag.text.strip()
    
        # Scorecard
        scorecard = {}
        innings_divs = page.find_all("div", id=re.compile(r"^inning_\d+$"))
    
        for i, inning_div in enumerate(innings_divs):
            inning_key = f"inning_{i+1}"
            inning_data = {"batting": [], "bowling": []}
            
            inning_title_tag = inning_div.find("div", class_="cb-scrd-hdr-rw")
            if inning_title_tag:
                 inning_data["title"] = inning_title_tag.text.strip()
            
            # Batting stats
            batsmen = inning_div.find_all("div", class_=lambda x: x and x.startswith('cb-col cb-col-w-'))
            for batsman in batsmen:
                cols = batsman.find_all("div", class_=lambda x: x and x.startswith('cb-col cb-col-w-'))
                if len(cols) > 1 and "batsman" in cols[0].text.lower(): # Header row
                    continue
    
                if len(cols) >= 7:
                    player_name = cols[0].text.strip()
                    if "Extras" in player_name or not player_name:
                        continue
                    
                    inning_data["batting"].append({
                        "player": player_name,
                        "dismissal": cols[1].text.strip(),
                        "R": cols[2].text.strip(),
                        "B": cols[3].text.strip(),
                        "4s": cols[4].text.strip(),
                        "6s": cols[5].text.strip(),
                        "SR": cols[6].text.strip(),
                    })
    
            # Bowling stats
            bowlers_section = inning_div.find("div", class_="cb-col-bowlers")
            if bowlers_section:
                bowlers = bowlers_section.find_all("div", class_="cb-scrd-itms")
                for bowler in bowlers:
                    cols = bowler.find_all("div", class_=lambda x: x and x.startswith('cb-col cb-col-w-'))
                    if len(cols) > 1 and "bowler" in cols[0].text.lower(): # Header row
                        continue
                    
                    if len(cols) >= 6:
                        player_name = cols[0].text.strip()
                        if not player_name:
                            continue
                        
                        inning_data["bowling"].append({
                            "player": player_name,
                            "O": cols[1].text.strip(),
                            "M": cols[2].text.strip(),
                            "R": cols[3].text.strip(),
                            "W": cols[4].text.strip(),
                            "Econ": cols[5].text.strip(),
                        })
            
            scorecard[inning_key] = inning_data
        
        match_data["scorecard"] = scorecard
        return match_data
  • The @mcp.tool() decorator registers the get_match_details function as an MCP tool in FastMCP.
    @mcp.tool()
  • Type hints and docstring define the input schema (match_url: str) and output format (dict with title, result, scorecard).
    def get_match_details(match_url: str) -> dict:
        """
        Get detailed scorecard for a specific cricket match from a Cricbuzz URL.
        
        Args:
            match_url (str): The URL of the match on Cricbuzz (can be obtained from get_live_matches).
            
        Returns:
            dict: A dictionary containing match details including:
                  - Match title and result.
                  - A scorecard for each innings with batting and bowling stats.
        """
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It describes what the tool returns (match details and scorecards) which is helpful, but doesn't mention potential limitations like rate limits, authentication needs, error conditions, or what happens with invalid URLs. It provides basic behavioral context but lacks operational details.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is perfectly structured and front-loaded: the first sentence states the core purpose, followed by clear Args and Returns sections. Every sentence earns its place by providing essential information without redundancy. The formatting with clear sections enhances readability.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (single parameter, no output schema, no annotations), the description is quite complete. It explains the purpose, parameter, and return format. The main gap is the lack of output schema which would help structure expectations, but the Returns section provides good semantic information about what to expect.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 0% schema description coverage and only 1 parameter, the description fully compensates by clearly explaining the match_url parameter: what it is ('URL of the match on Cricbuzz'), its format (str), and where to obtain it ('can be obtained from get_live_matches'). This adds significant value beyond the bare schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Get detailed scorecard'), resource ('for a specific cricket match'), and source ('from a Cricbuzz URL'). It distinguishes itself from siblings like get_live_matches (which lists matches) and get_live_commentary (which provides commentary rather than scorecard details).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context on when to use this tool: when you have a match URL from get_live_matches and need detailed scorecard information. It doesn't explicitly state when NOT to use it or name alternatives, but the context is sufficient for most scenarios.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

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/tarun7r/cricket-mcp-server'

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