Skip to main content
Glama

match.snapshot

Retrieve match statistics including form, rankings, goals scored/conceded, and recent results for football betting analysis.

Instructions

Restituisce forma, classifica, gol fatti/subiti e ultimi risultati per il match richiesto.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
match_idYesmatch_id fornito da API-Football

Implementation Reference

  • Core handler function that fetches and assembles the match snapshot data including fixture, standings, team stats, and recent results for both teams.
    export const buildMatchSnapshot = async (matchId: number): Promise<MatchSnapshot> => {
      const fixture = await apiFootball.getFixture(matchId);
      if (!fixture) {
        throw new Error(`Fixture ${matchId} not found on API-Football`);
      }
    
      const standings = await apiFootball.getStandingsMap();
      const [homeStats, awayStats] = await Promise.all([
        apiFootball.getTeamStatistics(fixture.homeTeam.id),
        apiFootball.getTeamStatistics(fixture.awayTeam.id),
      ]);
    
      const [homeResults, awayResults] = await Promise.all([
        apiFootball.getRecentMatches(fixture.homeTeam.id),
        apiFootball.getRecentMatches(fixture.awayTeam.id),
      ]);
    
      const homeSnapshot = enrichTeamSnapshot(fixture.homeTeam.id, standings, homeStats, homeResults);
      const awaySnapshot = enrichTeamSnapshot(fixture.awayTeam.id, standings, awayStats, awayResults);
    
      return {
        match: fixture,
        home: {
          ...homeSnapshot,
          team: fixture.homeTeam,
        },
        away: {
          ...awaySnapshot,
          team: fixture.awayTeam,
        },
      };
    };
  • Registers the 'match.snapshot' tool with FastMCP, including schema, description, and execute handler that delegates to buildMatchSnapshot.
    export const registerMatchSnapshotTool = (server: FastMCP) => {
      server.addTool({
        name: "match.snapshot",
        description: "Restituisce forma, classifica, gol fatti/subiti e ultimi risultati per il match richiesto.",
        parameters: z.object({
          match_id: z.number().int().describe("match_id fornito da API-Football"),
        }),
        execute: async (args) => {
          const snapshot = await buildMatchSnapshot(args.match_id);
          return JSON.stringify(snapshot, null, 2);
        },
      });
    };
  • Zod schema defining the input parameter 'match_id' as integer.
    parameters: z.object({
      match_id: z.number().int().describe("match_id fornito da API-Football"),
    }),
  • Helper function to enrich team snapshot with league position, points, form, average goals, and recent results.
    const enrichTeamSnapshot = (
      teamId: number,
      standings: Map<number, { position: number; points: number; form?: string }>,
      stats: { avgGoalsFor: number; avgGoalsAgainst: number } | undefined,
      recentResults: TeamSnapshot["recentResults"],
    ): Omit<TeamSnapshot, "team"> => {
      const standing = standings.get(teamId);
      return {
        leaguePosition: standing?.position,
        points: standing?.points,
        form: standing?.form,
        avgGoalsFor: stats?.avgGoalsFor,
        avgGoalsAgainst: stats?.avgGoalsAgainst,
        recentResults,
      };
    };
  • src/index.ts:17-17 (registration)
    Top-level call to register the match.snapshot tool in the main server setup.
    registerMatchSnapshotTool(server);

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/Valerio357/bet-mcp'

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