Skip to main content
Glama

get_mlb_search_teams

Search MLB teams by name or ID using a structured query. Retrieve detailed team information by specifying a search key ("name", "id", or "all") for accurate results.

Instructions

Search for teams by name or ID.

Args: team_name (str): Team name or ID to search for. search_key (str): Search key ("name", "id", or "all").

Returns: dict: Team search results.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
search_keyNoname
team_nameYes

Implementation Reference

  • The handler function for the 'get_mlb_search_teams' tool. It loads MLB teams from 'current_mlb_teams.csv' and searches based on team_name and search_key ('name', 'id', or 'all'). Returns matching teams or error.
    @mcp.tool() def get_mlb_search_teams(team_name: str, search_key: str = "name") -> dict: """ Search for teams by name or ID. Args: team_name (str): Team name or ID to search for. search_key (str): Search key ("name", "id", or "all"). Returns: dict: Team search results. """ try: import csv # Load teams from CSV teams = [] with open("current_mlb_teams.csv", "r") as f: reader = csv.DictReader(f) for row in reader: teams.append(row) # Search for teams results = [] for team in teams: if search_key == "id": if team_name == team["team_id"]: results.append(team) elif search_key == "name": if team_name.lower() in team["team_name"].lower(): results.append(team) else: # search_key == "all" if team_name == team["team_id"] or team_name.lower() in team["team_name"].lower(): results.append(team) return {"teams": results} except Exception as e: return {"error": str(e)}
  • mlb_api.py:653-653 (registration)
    The @mcp.tool() decorator registers the get_mlb_search_teams function as an MCP tool within the setup_mlb_tools function.
    @mcp.tool()

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