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
| Name | Required | Description | Default |
|---|---|---|---|
| match_id | Yes | match_id fornito da API-Football |
Implementation Reference
- src/services/matchSnapshot.ts:4-35 (handler)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, }, }; };
- src/tools/matchSnapshot.ts:5-17 (registration)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); }, }); };
- src/tools/matchSnapshot.ts:9-11 (schema)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"), }),
- src/services/matchSnapshot.ts:37-52 (helper)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);