Skip to main content
Glama
mikechao

balldontlie-mcp

get_teams

Retrieve a list of teams from the NBA, MLB, or NFL leagues by specifying the league name.

Instructions

Gets the list of team from one of the following leagues NBA (National Basketball Association), MLB (Major League Baseball), NFL (National Football League)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
leagueYes

Implementation Reference

  • The tool handler for 'get_teams'. It accepts a 'league' parameter (NBA, MLB, or NFL), fetches teams via the Balldontlie SDK (api.nba.getTeams(), api.mlb.getTeams(), or api.nfl.getTeams()), formats the team data into text, and returns it as content.
    async ({ league }) => {
      switch (league) {
        case 'NBA': {
          const nbaTeams = await api.nba.getTeams();
          const text = nbaTeams.data.map((team) => {
            return `Team ID: ${team.id}\n`
              + `Full Name: ${team.full_name}\n`
              + `Name: ${team.name}\n`
              + `Abbreviation: ${team.abbreviation}\n`
              + `City: ${team.city}\n`
              + `Conference: ${team.conference}\n`
              + `Division: ${team.division}\n`;
          }).join('\n-----\n');
          return { content: [{ type: 'text', text }] };
        }
    
        case 'MLB': {
          const mlbTeams = await api.mlb.getTeams();
          const text = mlbTeams.data.map((team) => {
            return `Team ID: ${team.id}\n`
              + `Display Name: ${team.display_name}\n`
              + `Name: ${team.name}\n`
              + `Abbreviation: ${team.abbreviation}\n`
              + `Location: ${team.location}\n`
              + `League: ${team.league}\n`
              + `Division: ${team.division}\n`
              + `Slug: ${team.slug}\n`;
          }).join('\n-----\n'); ;
          return { content: [{ type: 'text', text }] };
        }
    
        case 'NFL': {
          const nlfTeams = await api.nfl.getTeams();
          const text = nlfTeams.data.map((team) => {
            return `Team ID: ${team.id}\n`
              + `Name: ${team.name}\n`
              + `Abbreviation: ${team.abbreviation}\n`
              + `Full Name: ${team.full_name}\n`
              + `Location: ${team.location}\n`
              + `Conference: ${team.conference}\n`
              + `Division: ${team.division}\n`;
          }).join('\n-----\n');
          return { content: [{ type: 'text', text }] };
        }
    
        default: {
          return {
            content: [{ type: 'text', text: `Unknown league: ${league}` }],
            isError: true,
          };
        }
      }
    },
  • Input schema for the 'get_teams' tool. Defines a single required parameter 'league' which must be one of 'NBA', 'MLB', or 'NFL' (via z.enum).
    {
      league: leagueEnum,
    },
  • src/index.ts:39-98 (registration)
    Registration of the 'get_teams' tool via server.tool(). Registers the tool name, description, input schema, and handler function with the MCP server.
    server.tool(
      'get_teams',
      'Gets the list of team from one of the following leagues NBA (National Basketball Association), MLB (Major League Baseball), NFL (National Football League)',
      {
        league: leagueEnum,
      },
      async ({ league }) => {
        switch (league) {
          case 'NBA': {
            const nbaTeams = await api.nba.getTeams();
            const text = nbaTeams.data.map((team) => {
              return `Team ID: ${team.id}\n`
                + `Full Name: ${team.full_name}\n`
                + `Name: ${team.name}\n`
                + `Abbreviation: ${team.abbreviation}\n`
                + `City: ${team.city}\n`
                + `Conference: ${team.conference}\n`
                + `Division: ${team.division}\n`;
            }).join('\n-----\n');
            return { content: [{ type: 'text', text }] };
          }
    
          case 'MLB': {
            const mlbTeams = await api.mlb.getTeams();
            const text = mlbTeams.data.map((team) => {
              return `Team ID: ${team.id}\n`
                + `Display Name: ${team.display_name}\n`
                + `Name: ${team.name}\n`
                + `Abbreviation: ${team.abbreviation}\n`
                + `Location: ${team.location}\n`
                + `League: ${team.league}\n`
                + `Division: ${team.division}\n`
                + `Slug: ${team.slug}\n`;
            }).join('\n-----\n'); ;
            return { content: [{ type: 'text', text }] };
          }
    
          case 'NFL': {
            const nlfTeams = await api.nfl.getTeams();
            const text = nlfTeams.data.map((team) => {
              return `Team ID: ${team.id}\n`
                + `Name: ${team.name}\n`
                + `Abbreviation: ${team.abbreviation}\n`
                + `Full Name: ${team.full_name}\n`
                + `Location: ${team.location}\n`
                + `Conference: ${team.conference}\n`
                + `Division: ${team.division}\n`;
            }).join('\n-----\n');
            return { content: [{ type: 'text', text }] };
          }
    
          default: {
            return {
              content: [{ type: 'text', text: `Unknown league: ${league}` }],
              isError: true,
            };
          }
        }
      },
    );
Behavior3/5

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

No annotations provided, so description carries full burden. It describes a straightforward read operation with no disclosure of authentication, rate limits, or result format. Minimal behavioral context beyond purpose.

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?

Single sentence conveys all necessary information without redundancy. Front-loaded with action and resource.

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

Completeness4/5

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

Given simple structure (1 param, no output schema), description covers the core functionality. Could mention return structure (e.g., team names or IDs) but not essential for selection. Minor gap in completeness.

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

Parameters4/5

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

Schema has one param 'league' with enum but no description. Description adds meaning by listing the three league values and indicating they serve as selection criteria. Adds value beyond the bare schema.

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

Purpose5/5

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

Description clearly states verb 'gets' and resource 'teams', with specific leagues (NBA, MLB, NFL). Distinguishes from sibling tools (get_game, get_games, get_players) by focusing on team listing.

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

Usage Guidelines3/5

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

Specifies the tool retrieves teams from listed leagues, but no guidance on when to use vs alternatives or when not to use. Implicitly clear but lacks explicit context for decision-making.

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/mikechao/balldontlie-mcp'

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