Skip to main content
Glama

get_mlb_draft

Retrieve MLB draft data for a specified year to access player selections and draft details.

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' tool. It is decorated with @mcp.tool(), accepts a year_id parameter, fetches MLB draft data using the mlbstatsapi library, and returns it wrapped in a dictionary or an error message.
    @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)}
  • main.py:19-23 (registration)
    Registers the 'get_mlb_draft' tool (along with other MLB tools) by calling setup_mlb_tools(mcp), which defines and registers the tool functions using the MCP decorator.
    mcp = FastMCP("MLB API MCP Server") # Setup all MLB and generic tools setup_mlb_tools(mcp) setup_generic_tools(mcp)
  • The function signature and docstring define the input schema (year_id: int) and output (dict with 'draft' or 'error'), used by MCP for tool schema.
    @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)}

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