Skip to main content
Glama
mikechao

balldontlie-mcp

get_players

Retrieve a list of players from NBA, MLB, or NFL leagues. Filter by first or last name and paginate through results to find specific player information.

Instructions

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
leagueYes
firstNameNoFirst name of the player to search for, optional
lastNameNoLast name of the player to search for, optional
cursorNoCursor for pagination, the value should be next_cursor from previous call of get_players tool, optional

Implementation Reference

  • src/index.ts:100-213 (registration)
    Registration of the 'get_players' tool via server.tool(), defining name, description, schema, and handler.
    server.tool(
      `get_players`,
      `Gets the list of players from one of the following leagues NBA (National Basketball Association), MLB (Major League Baseball), NFL (National Football League)`,
      {
        league: leagueEnum,
        firstName: z.string().optional().describe('First name of the player to search for, optional'),
        lastName: z.string().optional().describe('Last name of the player to search for, optional'),
        cursor: z.number().optional().describe('Cursor for pagination, the value should be next_cursor from previous call of get_players tool, optional'),
      },
      async ({ league, firstName = undefined, lastName = undefined, cursor = undefined }) => {
        switch (league) {
          case 'NBA': {
            const nbaPlayers = await api.nba.getPlayers({
              first_name: firstName,
              last_name: lastName,
              cursor,
            });
            const text = nbaPlayers.data.map((player) => {
              return `Player ID: ${player.id}\n`
                + `First Name: ${player.first_name}\n`
                + `Last Name: ${player.last_name}\n`
                + `Position: ${player.position}\n`
                + `Height: ${player.height}\n`
                + `Weight: ${player.weight}\n`
                + `Jersey Number: ${player.jersey_number}\n`
                + `College: ${player.college}\n`
                + `Country: ${player.country}\n`
                + `Draft Year: ${player.draft_year}\n`
                + `Draft Round: ${player.draft_round}\n`
                + `Draft Number: ${player.draft_number}\n`
                + `Team ID: ${player.team.id}\n`
                + `Team Name: ${player.team.name}\n`;
            }).join('\n-----\n');
            let finalText = text;
            if (nbaPlayers.meta?.next_cursor) {
              finalText += `\n\nPagination Information:\nnext_cursor: ${nbaPlayers.meta.next_cursor}`;
            }
            return { content: [{ type: 'text', text: finalText }] };
          }
    
          case 'MLB': {
            const mlbPlayers = await api.mlb.getPlayers({
              first_name: firstName,
              last_name: lastName,
              cursor,
            });
            const text = mlbPlayers.data.map((player) => {
              return `Player ID: ${player.id}\n`
                + `First Name: ${player.first_name}\n`
                + `Last Name: ${player.last_name}\n`
                + `Full Name: ${player.full_name}\n`
                + `Debut Year: ${player.debut_year}\n`
                + `Jersey: ${player.jersey}\n`
                + `College: ${player.college}\n`
                + `Position: ${player.position}\n`
                + `Active: ${player.active}\n`
                + `Birth Place: ${player.birth_place}\n`
                + `Date of Birth: ${player.dob}\n`
                + `Age: ${player.age}\n`
                + `Height: ${player.height}\n`
                + `Weight: ${player.weight}\n`
                + `Draft: ${player.draft}\n`
                + `Bats/Throws: ${player.bats_throws}\n`
                + `Team ID: ${player.team.id}\n`
                + `Team Name: ${player.team.name}\n`;
            }).join('\n-----\n');
            let finalText = text;
            if (mlbPlayers.meta?.next_cursor) {
              finalText += `\n\nPagination Information:\nnext_cursor: ${mlbPlayers.meta.next_cursor}`;
            }
            return { content: [{ type: 'text', text: finalText }] };
          }
    
          case 'NFL': {
            const nflPlayers = await api.nfl.getPlayers({
              first_name: firstName,
              last_name: lastName,
              cursor,
            });
            const text = nflPlayers.data.map((player) => {
              return `ID: ${player.id}\n`
                + `First Name: ${player.first_name}\n`
                + `Last Name: ${player.last_name}\n`
                + `Position: ${player.position}\n`
                + `Position Abbreviation: ${player.position_abbreviation}\n`
                + `Height: ${player.height}\n`
                + `Weight: ${player.weight}\n`
                + `Jersey Number: ${player.jersey_number}\n`
                + `College: ${player.college}\n`
                + `Experience: ${player.experience}\n`
                + `Age: ${player.age}\n`
                + `Team ID: ${player.team.id}\n`
                + `Team Name: ${player.team.name}\n`
                + `Team Location: ${player.team.location}\n`
                + `Team Abbreviation: ${player.team.abbreviation}\n`
                + `Team Conference: ${player.team.conference}\n`
                + `Team Division: ${player.team.division}\n`;
            }).join('\n-----\n');
            let finalText = text;
            if (nflPlayers.meta?.next_cursor) {
              finalText += `\n\nPagination Information:\nnext_cursor: ${nflPlayers.meta.next_cursor}`;
            }
            return { content: [{ type: 'text', text: finalText }] };
          }
    
          default: {
            return {
              content: [{ type: 'text', text: `Unknown league: ${league}` }],
              isError: true,
            };
          }
        }
      },
    );
  • Input schema for get_players: league (enum NBA/MLB/NFL), optional firstName, optional lastName, optional cursor for pagination.
    {
      league: leagueEnum,
      firstName: z.string().optional().describe('First name of the player to search for, optional'),
      lastName: z.string().optional().describe('Last name of the player to search for, optional'),
      cursor: z.number().optional().describe('Cursor for pagination, the value should be next_cursor from previous call of get_players tool, optional'),
    },
  • Handler function for get_players. Dispatches to api.nba.getPlayers, api.mlb.getPlayers, or api.nfl.getPlayers based on league. Formats player data into text responses with pagination support.
      async ({ league, firstName = undefined, lastName = undefined, cursor = undefined }) => {
        switch (league) {
          case 'NBA': {
            const nbaPlayers = await api.nba.getPlayers({
              first_name: firstName,
              last_name: lastName,
              cursor,
            });
            const text = nbaPlayers.data.map((player) => {
              return `Player ID: ${player.id}\n`
                + `First Name: ${player.first_name}\n`
                + `Last Name: ${player.last_name}\n`
                + `Position: ${player.position}\n`
                + `Height: ${player.height}\n`
                + `Weight: ${player.weight}\n`
                + `Jersey Number: ${player.jersey_number}\n`
                + `College: ${player.college}\n`
                + `Country: ${player.country}\n`
                + `Draft Year: ${player.draft_year}\n`
                + `Draft Round: ${player.draft_round}\n`
                + `Draft Number: ${player.draft_number}\n`
                + `Team ID: ${player.team.id}\n`
                + `Team Name: ${player.team.name}\n`;
            }).join('\n-----\n');
            let finalText = text;
            if (nbaPlayers.meta?.next_cursor) {
              finalText += `\n\nPagination Information:\nnext_cursor: ${nbaPlayers.meta.next_cursor}`;
            }
            return { content: [{ type: 'text', text: finalText }] };
          }
    
          case 'MLB': {
            const mlbPlayers = await api.mlb.getPlayers({
              first_name: firstName,
              last_name: lastName,
              cursor,
            });
            const text = mlbPlayers.data.map((player) => {
              return `Player ID: ${player.id}\n`
                + `First Name: ${player.first_name}\n`
                + `Last Name: ${player.last_name}\n`
                + `Full Name: ${player.full_name}\n`
                + `Debut Year: ${player.debut_year}\n`
                + `Jersey: ${player.jersey}\n`
                + `College: ${player.college}\n`
                + `Position: ${player.position}\n`
                + `Active: ${player.active}\n`
                + `Birth Place: ${player.birth_place}\n`
                + `Date of Birth: ${player.dob}\n`
                + `Age: ${player.age}\n`
                + `Height: ${player.height}\n`
                + `Weight: ${player.weight}\n`
                + `Draft: ${player.draft}\n`
                + `Bats/Throws: ${player.bats_throws}\n`
                + `Team ID: ${player.team.id}\n`
                + `Team Name: ${player.team.name}\n`;
            }).join('\n-----\n');
            let finalText = text;
            if (mlbPlayers.meta?.next_cursor) {
              finalText += `\n\nPagination Information:\nnext_cursor: ${mlbPlayers.meta.next_cursor}`;
            }
            return { content: [{ type: 'text', text: finalText }] };
          }
    
          case 'NFL': {
            const nflPlayers = await api.nfl.getPlayers({
              first_name: firstName,
              last_name: lastName,
              cursor,
            });
            const text = nflPlayers.data.map((player) => {
              return `ID: ${player.id}\n`
                + `First Name: ${player.first_name}\n`
                + `Last Name: ${player.last_name}\n`
                + `Position: ${player.position}\n`
                + `Position Abbreviation: ${player.position_abbreviation}\n`
                + `Height: ${player.height}\n`
                + `Weight: ${player.weight}\n`
                + `Jersey Number: ${player.jersey_number}\n`
                + `College: ${player.college}\n`
                + `Experience: ${player.experience}\n`
                + `Age: ${player.age}\n`
                + `Team ID: ${player.team.id}\n`
                + `Team Name: ${player.team.name}\n`
                + `Team Location: ${player.team.location}\n`
                + `Team Abbreviation: ${player.team.abbreviation}\n`
                + `Team Conference: ${player.team.conference}\n`
                + `Team Division: ${player.team.division}\n`;
            }).join('\n-----\n');
            let finalText = text;
            if (nflPlayers.meta?.next_cursor) {
              finalText += `\n\nPagination Information:\nnext_cursor: ${nflPlayers.meta.next_cursor}`;
            }
            return { content: [{ type: 'text', text: finalText }] };
          }
    
          default: {
            return {
              content: [{ type: 'text', text: `Unknown league: ${league}` }],
              isError: true,
            };
          }
        }
      },
    );
  • The leagueEnum shared schema (enum of 'NBA', 'MLB', 'NFL') used as the league parameter in get_players.
    const leagueEnum = z.enum(['NBA', 'MLB', 'NFL']);
    export type LeagueEnum = z.infer<typeof leagueEnum>;
Behavior2/5

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

No annotations are provided, so the description must fully inform about behavior. It only states a read operation without mentioning pagination (cursor parameter exists), rate limits, or other behavioral traits, leaving gaps.

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 a single clear sentence that efficiently communicates the tool's purpose without unnecessary verbosity.

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 the tool's simplicity and lack of output schema, the description covers basic purpose but omits context about optional parameters and pagination cursor usage, leaving some completeness 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 coverage is 75% (three of four parameters have descriptions), and the description adds no extra parameter information. Baseline of 3 is appropriate as the schema does the heavy lifting.

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?

The description clearly specifies the verb 'Gets the list' and resource 'players', and explicitly lists the leagues (NBA, MLB, NFL), distinguishing it from siblings like get_game and get_teams.

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?

The description implies usage for retrieving players by league but does not explicitly state when to use this tool over alternatives like get_game or get_teams, nor does it provide exclusion criteria.

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