get_top_scorers
Retrieve top scorers or assist leaders for any competition in football, basketball, cricket, or tennis. Provide sport and competition slug to view ranked player stats.
Instructions
Get the top scorers (or top assisters) for a competition. Useful for 'who's leading the Premier League scoring charts?'.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sport | Yes | Sport to query. One of football, basketball, cricket, tennis. | |
| slug | Yes | Competition slug. | |
| limit | No | ||
| stat | No | goals |
Implementation Reference
- src/index.js:114-135 (registration)The 'get_top_scorers' tool is registered as the 5th entry in the TOOLS array (lines 114-135). It defines the tool name, description, input schema (sport, slug, limit, stat), API path (/api/widget/topscorers/), and a paramMap that converts user args to API query parameters.
{ name: "get_top_scorers", description: "Get the top scorers (or top assisters) for a competition. Useful for 'who's leading the Premier League scoring charts?'.", inputSchema: { type: "object", properties: { sport: sportSchema, slug: { type: "string", description: "Competition slug." }, limit: { type: "integer", minimum: 1, maximum: 50, default: 20 }, stat: { type: "string", enum: ["goals", "assists"], default: "goals" }, }, required: ["sport", "slug"], }, path: "/api/widget/topscorers/", paramMap: (args) => ({ sport: args.sport, slug: args.slug, limit: args.limit ?? 20, stat: args.stat ?? "goals", }), }, - src/index.js:118-127 (schema)The input schema for get_top_scorers requires 'sport' (string enum: football/basketball/cricket/tennis) and 'slug' (competition slug string), with optional 'limit' (integer 1-50, default 20) and 'stat' (enum 'goals'/'assists', default 'goals').
inputSchema: { type: "object", properties: { sport: sportSchema, slug: { type: "string", description: "Competition slug." }, limit: { type: "integer", minimum: 1, maximum: 50, default: 20 }, stat: { type: "string", enum: ["goals", "assists"], default: "goals" }, }, required: ["sport", "slug"], }, - src/index.js:228-270 (handler)The handler is a generic CallToolRequestSchema handler (lines 228-270) that looks up the tool by name in TOOL_BY_NAME, calls paramMap(args) to build query params, invokes callApi() with the tool's path/params, and returns the JSON response wrapped with attribution.
server.setRequestHandler(CallToolRequestSchema, async (req) => { const { name, arguments: rawArgs } = req.params; const tool = TOOL_BY_NAME.get(name); if (!tool) { return { isError: true, content: [{ type: "text", text: `Unknown tool: ${name}` }], }; } const args = rawArgs ?? {}; if (args.sport && !SPORTS.includes(args.sport)) { return { isError: true, content: [ { type: "text", text: `Invalid sport '${args.sport}'. Must be one of: ${SPORTS.join(", ")}.` }, ], }; } const params = tool.paramMap(args); let result; try { result = await callApi(tool.path, params); } catch (err) { return { isError: true, content: [{ type: "text", text: `Network error calling SportScore API: ${err.message}` }], }; } const envelope = { tool: name, request_url: result.url, http_status: result.status, data: result.body, ...attributionFooter(), }; return { content: [{ type: "text", text: JSON.stringify(envelope, null, 2) }], isError: result.status >= 400, }; }); - src/index.js:183-183 (registration)The TOOL_BY_NAME Map is built from the TOOLS array and is used by the handler to look up tool configs by name at runtime.
const TOOL_BY_NAME = new Map(TOOLS.map((t) => [t.name, t]));