Skip to main content
Glama

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
NameRequiredDescriptionDefault
year_idYes

Implementation Reference

  • 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)}
  • 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. """

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/guillochon/mlb-api-mcp'

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