Skip to main content
Glama

get_mlb_teams

Retrieve MLB team data by specifying sport ID and optional season year for comprehensive baseball statistics integration.

Instructions

Get all teams for a specific sport.

Args: sport_id (int): Sport ID (default: 1 for MLB). season (Optional[int]): Filter teams by a specific season (year).

Returns: dict: All teams for the specified sport.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sport_idNo
seasonNo

Implementation Reference

  • The handler function decorated with @mcp.tool(), which registers and implements the get_mlb_teams tool. It retrieves MLB teams data using the mlb library, supporting optional season filtering, and returns teams or error.
    @mcp.tool() def get_mlb_teams(sport_id: int = 1, season: Optional[int] = None) -> dict: """ Get all teams for a specific sport. Args: sport_id (int): Sport ID (default: 1 for MLB). season (Optional[int]): Filter teams by a specific season (year). Returns: dict: All teams for the specified sport. """ try: params = {} if season is not None: params["season"] = season teams = mlb.get_teams(sport_id=sport_id, **params) return {"teams": teams} 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