Skip to main content
Glama
tarun7r

cricket-mcp-server

get_icc_rankings

Fetch official ICC cricket rankings for Test, ODI, and T20 formats. Retrieve top players and teams by category: batting, bowling, all-rounder, or teams.

Instructions

Fetches official ICC cricket rankings for various categories. Use this tool to answer questions about top players and teams in Test, ODI, and T20 formats.

For example, you can answer questions like:

  • "Who are the top 10 ODI batsmen?"

  • "Show me the test bowling rankings."

  • "What are the T20 team rankings?"

  • "icc ranking odi batsman"

Args: category (str): The ranking category. Must be one of: "batting", "bowling", "all-rounder", or "teams".

Returns: dict: A dictionary with rankings for Test, ODI, and T20 formats. Each format contains a list of players or teams with their position, name, country, and rating.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
categoryYes

Implementation Reference

  • The handler function implementing the get_icc_rankings tool. It scrapes ICC rankings from Cricbuzz for categories like batting, bowling, all-rounder, or teams across Test, ODI, and T20 formats. The @mcp.tool() decorator handles automatic registration and schema generation from the docstring.
    @mcp.tool()
    def get_icc_rankings(category: str) -> dict:
        """
        Fetches official ICC cricket rankings for various categories. Use this tool to answer questions about top players and teams in Test, ODI, and T20 formats.
    
        For example, you can answer questions like:
        - "Who are the top 10 ODI batsmen?"
        - "Show me the test bowling rankings."
        - "What are the T20 team rankings?"
        - "icc ranking odi batsman"
    
        Args:
            category (str): The ranking category. Must be one of: "batting", "bowling", "all-rounder", or "teams".
                            
        Returns:
            dict: A dictionary with rankings for Test, ODI, and T20 formats. 
                  Each format contains a list of players or teams with their position, name, country, and rating.
        """
        if category not in ["batting", "bowling", "all-rounder", "teams"]:
            return {"error": "Invalid category. Choose from 'batting', 'bowling', 'all-rounder', 'teams'."}
    
        # The 'all-rounder' category is spelled as 'all-rounder' in the URL
        url_category = category if category != "all-rounder" else "all-rounder"
        link = f"https://www.cricbuzz.com/cricket-stats/icc-rankings/men/{url_category}"
    
        try:
            response = requests.get(link, headers=HEADERS, timeout=10)
            response.raise_for_status()
            source = response.text
            page = BeautifulSoup(source, "lxml")
    
            rankings = {}
            
            # Define formats to scrape
            formats = ["test", "odi", "t20"]
            
            # Map category to the format used in ng-show directive
            category_map = {
                "batting": "batsmen",
                "bowling": "bowlers",
                "all-rounder": "allrounders",
                "teams": "teams"
            }
            angular_category = category_map.get(category)
    
            for f in formats:
                format_key = f"{angular_category}-{f}s" # e.g., batsmen-tests
                if f == 't20':
                     format_key = f"{angular_category}-t20s"
    
                # Find the container for the specific format
                format_container = page.find("div", {"ng-show": f"'{format_key}' == act_rank_format"})
                
                if not format_container:
                    continue
    
                ranking_list = []
                
                if category == "teams":
                    # Find all team rows
                    rows = format_container.find_all("div", class_="cb-col cb-col-100 cb-font-14 cb-brdr-thin-btm text-center")
                    for row in rows:
                        position = row.find("div", class_="cb-col cb-col-20 cb-lst-itm-sm").text.strip()
                        team_name = row.find("div", class_="cb-col cb-col-50 cb-lst-itm-sm text-left").text.strip()
                        rating = row.find_all("div", class_="cb-col cb-col-14 cb-lst-itm-sm")[0].text.strip()
                        points = row.find_all("div", class_="cb-col cb-col-14 cb-lst-itm-sm")[1].text.strip()
    
                        ranking_list.append({
                            "position": position,
                            "team": team_name,
                            "rating": rating,
                            "points": points
                        })
                else:
                    # Find all player rows
                    rows = format_container.find_all("div", class_="cb-col cb-col-100 cb-font-14 cb-lst-itm text-center")
    
                    for row in rows:
                        position = row.find("div", class_="cb-col cb-col-16 cb-rank-tbl cb-font-16").text.strip()
                        rating = row.find("div", class_="cb-col cb-col-17 cb-rank-tbl pull-right").text.strip()
                        
                        player_info = row.find("div", class_="cb-col cb-col-67 cb-rank-plyr")
                        player_name = player_info.find("a").text.strip()
                        country = player_info.find("div", class_="cb-font-12 text-gray").text.strip()
    
                        ranking_list.append({
                            "position": position,
                            "player": player_name,
                            "country": country,
                            "rating": rating
                        })
                
                rankings[f] = ranking_list
    
            return rankings
    
        except requests.exceptions.RequestException as e:
            return {"error": f"Request failed: {str(e)}"}
        except Exception as e:
            return {"error": f"An error occurred: {str(e)}"}
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. It mentions the tool fetches 'official' rankings, implying authoritative data, but lacks details on rate limits, authentication needs, or potential data freshness issues. The description doesn't contradict any annotations (none exist), but could provide more behavioral context.

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 efficiently structured with a clear purpose statement, usage guidance, concrete examples, and parameter/return documentation. Every sentence adds value without redundancy, and it's appropriately sized for the tool's complexity.

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 single parameter and no output schema, the description provides complete usage context including parameter details and return format. It could slightly improve by mentioning if the tool returns all formats simultaneously or requires separate calls, but overall it's quite comprehensive for this tool's scope.

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

Parameters4/5

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

The schema has 0% description coverage, but the description fully compensates by clearly explaining the single parameter 'category' with its valid values ('batting', 'bowling', 'all-rounder', or 'teams') and purpose. This adds significant meaning 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 ('Fetches official ICC cricket rankings') and resource ('for various categories'), distinguishing it from sibling tools like get_cricket_news or get_player_stats by focusing exclusively on rankings rather than news, schedules, or statistics.

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

Usage Guidelines5/5

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

It explicitly states when to use this tool ('to answer questions about top players and teams in Test, ODI, and T20 formats') and provides concrete examples of questions it can answer, clearly differentiating its purpose from alternatives like get_player_stats or web_search.

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