get_mlb_draft
Retrieve detailed MLB draft data for a specific year using an API tool designed for accessing baseball statistics and player information.
Instructions
Get draft information for a specific year.
Args: year_id (int): Draft year.
Returns: dict: Draft information.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| year_id | Yes |
Implementation Reference
- mlb_api.py:619-635 (handler)The core handler function for the 'get_mlb_draft' MCP tool. It fetches MLB draft data for a given year using mlbstatsapi.Mlb().get_draft() and handles errors. The @mcp.tool() decorator registers it as an MCP tool, with schema inferred from the function signature (year_id: int) and docstring.@mcp.tool() def get_mlb_draft(year_id: int) -> dict: """ Get draft information for a specific year. Args: year_id (int): Draft year. Returns: dict: Draft information. """ try: draft = mlb.get_draft(year_id) return {"draft": draft} except Exception as e: return {"error": str(e)}
- mlb_api.py:619-635 (registration)The @mcp.tool() decorator on the get_mlb_draft function registers it within the setup_mlb_tools(mcp) function, making it available as an MCP tool named 'get_mlb_draft'.@mcp.tool() def get_mlb_draft(year_id: int) -> dict: """ Get draft information for a specific year. Args: year_id (int): Draft year. Returns: dict: Draft information. """ try: draft = mlb.get_draft(year_id) return {"draft": draft} except Exception as e: return {"error": str(e)}
- mlb_api.py:620-629 (schema)The function signature (year_id: int -> dict) and docstring define the input schema (year_id as integer) and output (dict with 'draft' or 'error').def get_mlb_draft(year_id: int) -> dict: """ Get draft information for a specific year. Args: year_id (int): Draft year. Returns: dict: Draft information. """