Skip to main content
Glama
mikechao

balldontlie-mcp

get_game

Retrieve detailed information about a specific NBA, MLB, or NFL game using its unique game ID. This tool helps users access game data for sports analysis or reference purposes.

Instructions

Get a specific game from one of the following leagues NBA (National Basketball Association), MLB (Major League Baseball), NFL (National Football League)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
leagueYes
gameIdYesGame ID to get the game for, the value should be Game ID from previous call of get_games tool

Implementation Reference

  • The handler function that implements the core logic of the 'get_game' tool. It fetches the game data from the appropriate league API based on the league and gameId, formats it using helper functions, and returns the formatted text or an error.
    async ({ league, gameId }) => {
      switch (league) {
        case 'NBA': {
          const nbaGame = await api.nba.getGame(gameId);
          if (nbaGame.data) {
            const text = formatNBAGame(nbaGame.data);
            return { content: [{ type: 'text', text }] };
          }
          return { content: [{ type: 'text', text: `Game ID ${gameId} not found` }], isError: true };
        }
        case 'MLB': {
          const mlbGame = await api.mlb.getGame(gameId);
          if (mlbGame.data) {
            const text = formatMLBGame(mlbGame.data);
            return { content: [{ type: 'text', text }] };
          }
          return { content: [{ type: 'text', text: `Game ID ${gameId} not found` }], isError: true };
        }
        case 'NFL': {
          const nflGame = await api.nfl.getGame(gameId);
          if (nflGame.data) {
            const text = formatNFLGame(nflGame.data);
            return { content: [{ type: 'text', text }] };
          }
          return { content: [{ type: 'text', text: `Game ID ${gameId} not found` }], isError: true };
        }
        default: {
          return {
            content: [{ type: 'text', text: `Unknown league: ${league}` }],
            isError: true,
          };
        }
      }
    },
  • src/index.ts:289-330 (registration)
    The registration of the 'get_game' tool using McpServer.tool method, specifying name, description, input schema, and handler function.
    server.tool(
      'get_game',
      'Get a specific game from one of the following leagues NBA (National Basketball Association), MLB (Major League Baseball), NFL (National Football League)',
      {
        league: leagueEnum,
        gameId: z.number().describe('Game ID to get the game for, the value should be Game ID from previous call of get_games tool'),
      },
      async ({ league, gameId }) => {
        switch (league) {
          case 'NBA': {
            const nbaGame = await api.nba.getGame(gameId);
            if (nbaGame.data) {
              const text = formatNBAGame(nbaGame.data);
              return { content: [{ type: 'text', text }] };
            }
            return { content: [{ type: 'text', text: `Game ID ${gameId} not found` }], isError: true };
          }
          case 'MLB': {
            const mlbGame = await api.mlb.getGame(gameId);
            if (mlbGame.data) {
              const text = formatMLBGame(mlbGame.data);
              return { content: [{ type: 'text', text }] };
            }
            return { content: [{ type: 'text', text: `Game ID ${gameId} not found` }], isError: true };
          }
          case 'NFL': {
            const nflGame = await api.nfl.getGame(gameId);
            if (nflGame.data) {
              const text = formatNFLGame(nflGame.data);
              return { content: [{ type: 'text', text }] };
            }
            return { content: [{ type: 'text', text: `Game ID ${gameId} not found` }], isError: true };
          }
          default: {
            return {
              content: [{ type: 'text', text: `Unknown league: ${league}` }],
              isError: true,
            };
          }
        }
      },
    );
  • Zod input schema for the 'get_game' tool, defining league (enum) and gameId (number) parameters.
    {
      league: leagueEnum,
      gameId: z.number().describe('Game ID to get the game for, the value should be Game ID from previous call of get_games tool'),
    },
  • Shared Zod enum schema for league types, used in the input schema of 'get_game' and other tools.
    const leagueEnum = z.enum(['NBA', 'MLB', 'NFL']);
    export type LeagueEnum = z.infer<typeof leagueEnum>;
  • Helper function to format NBA game data into a readable string, used in the NBA case of the get_game handler.
    export function formatNBAGame(game: NBAGame): string {
      return `Game ID: ${game.id}\n`
        + `Date: ${game.date}\n`
        + `Season: ${game.season}\n`
        + `Status: ${game.status}\n`
        + `Period: ${game.period}\n`
        + `Time: ${game.time}\n`
        + `Postseason: ${game.postseason}\n`
        + `Score: ${game.home_team.full_name} ${game.home_team_score} - ${game.visitor_team_score} ${game.visitor_team.full_name}\n`
        + `Home Team: ${game.home_team.full_name} (${game.home_team.abbreviation})\n`
        + `Visitor Team: ${game.visitor_team.full_name} (${game.visitor_team.abbreviation})\n`;
    }
Behavior2/5

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

With no annotations provided, the description carries full burden but lacks behavioral details. It doesn't disclose if this is a read-only operation, what permissions are needed, error handling, or response format. The mention of 'Game ID from previous call of get_games tool' in the schema hints at dependencies but isn't elaborated in the description.

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

Conciseness4/5

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

The description is a single, efficient sentence that front-loads the purpose without unnecessary words. It could be slightly more structured by separating league details, but it avoids redundancy and stays focused on the core function.

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

Completeness2/5

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

Given no annotations, no output schema, and incomplete parameter documentation (50% coverage), the description is inadequate. It doesn't explain return values, error cases, or behavioral traits, leaving significant gaps for a tool that retrieves specific data with dependencies on other calls.

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 50% (only 'gameId' has a description). The description adds no parameter-specific information beyond what's in the schema, such as explaining league abbreviations or gameId format. It partially compensates by listing leagues, but doesn't detail parameters, resulting in a baseline score due to moderate schema coverage.

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 action ('Get') and resource ('a specific game'), specifying the supported leagues (NBA, MLB, NFL). It distinguishes from sibling 'get_games' by focusing on a single game rather than multiple games, though it doesn't explicitly contrast with 'get_players' or '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 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 like 'get_games' for listing games or 'get_players'/'get_teams' for other data. It mentions the leagues but doesn't explain selection criteria or prerequisites, leaving usage context implied at best.

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