get_mlb_player_info
Retrieve detailed player information from MLB data sources by providing a player ID. This tool accesses baseball statistics and player data for integration into applications.
Instructions
Get information about a specific player by ID.
Args: player_id (int): The player ID.
Returns: dict: Player information.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| player_id | Yes |
Implementation Reference
- mlb_api.py:353-369 (handler)The main handler function for the 'get_mlb_player_info' tool. It retrieves player information using the MLB stats API and is decorated with @mcp.tool() which handles registration in the MCP server.@mcp.tool() def get_mlb_player_info(player_id: int) -> dict: """ Get information about a specific player by ID. Args: player_id (int): The player ID. Returns: dict: Player information. """ try: player_info = mlb.get_person(player_id) return {"player_info": player_info} except Exception as e: return {"error": str(e)}
- main.py:22-22 (registration)The call to setup_mlb_tools(mcp) in the main server initialization, which defines and registers the get_mlb_player_info tool along with other MLB tools.setup_mlb_tools(mcp)
- mlb_api.py:355-363 (schema)The docstring provides the input schema (player_id: int) and output description (dict: Player information). Type hints also serve as schema.""" Get information about a specific player by ID. Args: player_id (int): The player ID. Returns: dict: Player information. """
- tests/test_mlb_api.py:30-30 (registration)In tests, setup_mlb_tools is called to register tools for testing purposes.mlb_api.setup_mlb_tools(mcp)