get_tracker
Retrieve live tracker data including player positions and animation frames for a football match using its numeric ID.
Instructions
Get live match tracker data (position, animation frames) for a match by numeric id. Usually only useful for football.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sport | Yes | Sport to query. One of football, basketball, cricket, tennis. | |
| id | Yes | Numeric match id from the upstream provider. |
Implementation Reference
- src/index.js:166-180 (registration)Tool registration: the 'get_tracker' tool is defined in the TOOLS array with its name, description, inputSchema (sport + id), API path (/api/widget/tracker/), and paramMap function that maps args to query params.
{ name: "get_tracker", description: "Get live match tracker data (position, animation frames) for a match by numeric id. Usually only useful for football.", inputSchema: { type: "object", properties: { sport: sportSchema, id: { type: "string", description: "Numeric match id from the upstream provider." }, }, required: ["sport", "id"], }, path: "/api/widget/tracker/", paramMap: (args) => ({ sport: args.sport, id: args.id }), }, - src/index.js:46-50 (schema)Shared sport schema used in get_tracker's inputSchema, validating sport must be one of: football, basketball, cricket, tennis.
const sportSchema = { type: "string", enum: SPORTS, description: "Sport to query. One of football, basketball, cricket, tennis.", }; - src/index.js:183-183 (registration)A Map keyed by tool name that provides O(1) lookup of tool definitions from the TOOLS array. Used in the CallToolRequestSchema handler to find the get_tracker definition at runtime.
const TOOL_BY_NAME = new Map(TOOLS.map((t) => [t.name, t])); - src/index.js:228-270 (handler)Generic tool handler that processes all tools including get_tracker. It looks up the tool by name from TOOL_BY_NAME, validates the sport arg, calls the API via callApi() using the tool's path and paramMap, and returns JSON response with attribution. No custom per-tool logic — all tools share this same handler.
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:187-203 (helper)Generic API fetch helper used by get_tracker and all other tools. Builds URL from API_BASE + path, appends query params, fetches with JSON headers, returns status/url/body.
async function callApi(path, params) { const url = new URL(API_BASE + path); for (const [k, v] of Object.entries(params)) { if (v !== undefined && v !== null && v !== "") url.searchParams.set(k, String(v)); } const res = await fetch(url, { headers: { "Accept": "application/json", "User-Agent": UA }, }); const text = await res.text(); let body; try { body = JSON.parse(text); } catch { body = { raw: text, _parse_error: "response was not valid JSON" }; } return { status: res.status, url: url.toString(), body }; }