get_mlb_search_players
Search for MLB players by name using a specified sport ID and search key. Retrieve player data in JSON format for integration with AI applications or baseball analysis tools.
Instructions
Search for players by name.
Args: fullname (str): Player name to search for. sport_id (int): Sport ID (default: 1 for MLB). search_key (str): Search key (default: "fullname").
Returns: dict: Player search results.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| fullname | Yes | ||
| search_key | No | fullname | |
| sport_id | No |
Implementation Reference
- mlb_api.py:579-597 (handler)The main handler function for the 'get_mlb_search_players' tool. It searches for MLB players by fullname using the mlbstatsapi library and returns player IDs or an error.@mcp.tool() def get_mlb_search_players(fullname: str, sport_id: int = 1, search_key: str = "fullname") -> dict: """ Search for players by name. Args: fullname (str): Player name to search for. sport_id (int): Sport ID (default: 1 for MLB). search_key (str): Search key (default: "fullname"). Returns: dict: Player search results. """ try: player_ids = mlb.get_people_id(fullname, sport_id=sport_id, search_key=search_key) return {"player_ids": player_ids} except Exception as e: return {"error": str(e)}
- main.py:22-22 (registration)Registers all MLB tools, including 'get_mlb_search_players', by calling setup_mlb_tools which defines functions decorated with @mcp.tool().setup_mlb_tools(mcp)