Skip to main content
Glama
by opgginc

get-lol-matches

Fetch upcoming League of Legends match schedules from OP.GG Esports. Access structured match data to integrate real-time esports information into AI agents or workflows.

Instructions

Get upcoming LoL match schedules from OP.GG Esports

Input Schema

NameRequiredDescriptionDefault

No arguments

Input Schema (JSON Schema)

{ "type": "object" }

Implementation Reference

  • The main handler for the 'get-lol-matches' tool. It calls fetchUpcomingMatches, formats the data into MatchInfo objects, constructs a formatted text response with match details, and handles errors by returning an error message.
    server.tool('get-lol-matches', 'Get upcoming LoL match schedules from OP.GG Esports', async () => { try { // Fetch match schedules const matches = await fetchUpcomingMatches(); // Format results const formattedMatches = matches.map((match: any): MatchInfo => { const league = match.tournament?.serie?.league || {}; return { id: match.id, name: match.name, status: match.status?.toUpperCase(), awayScore: match.awayScore, homeScore: match.homeScore, scheduledAt: match.scheduledAt, numberOfGames: match.numberOfGames, league: league.shortName || 'Unknown', }; }); return { content: [ { type: 'text', text: `Upcoming match schedules:\n\n${formattedMatches .map( (match: MatchInfo) => `Match: ${match.name}\nLeague: ${match.league}\nStatus: ${match.status}\nScore: ${match.homeScore} - ${match.awayScore}\nScheduled at: ${new Date(match.scheduledAt).toLocaleString()}\nDetails: https://esports.op.gg/matches/${match.id}\n---` ) .join('\n')}`, }, ], }; } catch (error) { return { content: [ { type: 'text', text: `Error fetching match schedules: ${error instanceof Error ? error.message : String(error)}`, }, ], }; } });
  • TypeScript interface defining the structure of formatted match information used within the tool handler.
    interface MatchInfo { id: number; name: string; status: string; homeScore: number; awayScore: number; scheduledAt: string | number | Date; league: string; numberOfGames?: number; }
  • Helper function that performs the HTTP POST request to the OP.GG Esports GraphQL API to retrieve upcoming matches data.
    async function fetchUpcomingMatches() { try { const response = await fetch(GRAPHQL_ENDPOINT, { method: 'POST', headers: { 'Content-Type': 'application/json', 'User-Agent': 'MCP', }, body: JSON.stringify({ query: UPCOMING_MATCHES_QUERY, }), }); if (!response.ok) { throw new Error(`API request failed: ${response.status} ${response.statusText}`); } const data = (await response.json()) as any; if (data.errors) { throw new Error(`GraphQL error: ${JSON.stringify(data.errors)}`); } return data.data.upcomingMatches; } catch (error) { console.error('Error calling OP.GG Esports API:', error); throw error; } }
  • GraphQL query string used by fetchUpcomingMatches to fetch upcoming LoL matches data including details like ID, name, scores, schedule, and league.
    const UPCOMING_MATCHES_QUERY = ` query MCPListUpcomingMatches { upcomingMatches { id name status awayScore homeScore scheduledAt numberOfGames tournament { serie { league { shortName } } } } } `;
  • Constant defining the GraphQL API endpoint URL for OP.GG Esports.
    const GRAPHQL_ENDPOINT = 'https://esports.op.gg/matches/graphql';

Other Tools

Related 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/opgginc/esports-mcp'

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