get_bracket
Retrieve the knockout bracket for a tournament by specifying the sport and competition slug. Access bracket data for football, basketball, cricket, or tennis.
Instructions
Get the knockout bracket for a tournament (e.g. 'uefa-champions-league', 'nba-playoffs').
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sport | Yes | Sport to query. One of football, basketball, cricket, tennis. | |
| slug | Yes | Competition slug. |
Implementation Reference
- src/index.js:151-165 (schema)Tool schema definition for 'get_bracket' — defines input params (sport enum + slug), maps to API path /api/widget/bracket/
{ name: "get_bracket", description: "Get the knockout bracket for a tournament (e.g. 'uefa-champions-league', 'nba-playoffs').", inputSchema: { type: "object", properties: { sport: sportSchema, slug: { type: "string", description: "Competition slug." }, }, required: ["sport", "slug"], }, path: "/api/widget/bracket/", paramMap: (args) => ({ sport: args.sport, slug: args.slug }), }, - src/index.js:183-183 (registration)Registration: TOOLS array includes get_bracket; TOOL_BY_NAME map allows name-based dispatch at runtime
const TOOL_BY_NAME = new Map(TOOLS.map((t) => [t.name, t])); - src/index.js:228-270 (handler)Generic CallTool handler that dispatches to any tool (including get_bracket) by looking up the TOOL_BY_NAME map, calling paramMap, then invoking callApi with the tool's path
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, }; });