Skip to main content
Glama
guillochon

mlb-api-mcp

get_mlb_search_teams

Search for MLB teams by name or ID to retrieve detailed team information and statistics from baseball data sources.

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
team_nameYes
search_keyNoname

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function implementing the 'get_mlb_search_teams' tool. It loads MLB team data from 'current_mlb_teams.csv' and searches for matches based on team_name and search_key ('name', 'id', or 'all'), returning matching teams as a list of dicts or an 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)}
  • main.py:12-23 (registration)
    The import and call to setup_mlb_tools(mcp) which registers all MLB tools, including 'get_mlb_search_teams', to the MCP server instance.
    from mlb_api import setup_mlb_tools
    
    # Suppress websockets deprecation warnings
    warnings.filterwarnings("ignore", category=DeprecationWarning, module="websockets")
    warnings.filterwarnings("ignore", category=DeprecationWarning, module="uvicorn.protocols.websockets")
    
    # Create FastMCP server instance
    mcp = FastMCP("MLB API MCP Server")
    
    # Setup all MLB and generic tools
    setup_mlb_tools(mcp)
    setup_generic_tools(mcp)
  • The input schema and documentation for the tool, defining parameters team_name (required str) and search_key (optional str, default 'name'), and return type 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.
    """
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It mentions the tool searches and returns results, but lacks critical behavioral details: whether it's read-only (implied but not stated), how results are structured, if there are rate limits, authentication needs, or pagination. The description is minimal and doesn't compensate for missing annotations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured and front-loaded with the core purpose, followed by clear sections for Args and Returns. Every sentence earns its place: the first sentence defines the tool, and subsequent lines efficiently document parameters and return type without redundancy.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no annotations, 0% schema coverage, but an output schema exists, the description is partially complete. It covers the basic purpose and parameters but lacks behavioral context (e.g., safety, limits) and doesn't explain return values since the output schema handles that. For a search tool with two parameters, this is minimally adequate but has clear gaps.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate. It adds meaning by explaining 'team_name' accepts 'name or ID' and 'search_key' can be 'name', 'id', or 'all', which clarifies beyond the bare schema. However, it doesn't detail format constraints (e.g., ID format) or default behavior for 'search_key', leaving gaps. Baseline 3 is appropriate as it adds some but not complete semantics.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Search for teams by name or ID.' This specifies the verb ('search'), resource ('teams'), and search criteria. It distinguishes from siblings like 'get_mlb_teams' (likely lists all teams) and 'get_mlb_team_info' (likely gets details for a specific team), though it doesn't explicitly contrast them.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention when to prefer it over 'get_mlb_teams' (which might return all teams without filtering) or 'get_mlb_team_info' (which might require a specific team ID). Usage is implied only by the tool name and description.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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