get_player
Retrieve player statistics and metadata by providing a sport and player slug.
Instructions
Get player statistics and metadata by player slug (e.g. 'lionel-messi', 'lebron-james', 'virat-kohli').
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sport | Yes | Sport to query. One of football, basketball, cricket, tennis. | |
| slug | Yes | Player slug. |
Implementation Reference
- src/index.js:136-150 (schema)Tool definition for 'get_player' including its input schema, API path, and parameter mapping function.
{ name: "get_player", description: "Get player statistics and metadata by player slug (e.g. 'lionel-messi', 'lebron-james', 'virat-kohli').", inputSchema: { type: "object", properties: { sport: sportSchema, slug: { type: "string", description: "Player slug." }, }, required: ["sport", "slug"], }, path: "/api/widget/player/", paramMap: (args) => ({ sport: args.sport, slug: args.slug }), }, - src/index.js:183-183 (registration)Registration of all tools (including get_player) into a Map for lookup by name.
const TOOL_BY_NAME = new Map(TOOLS.map((t) => [t.name, t])); - src/index.js:228-270 (handler)General CallTool handler that dispatches all tool calls (including get_player) by looking up the tool's path and paramMap from TOOL_BY_NAME, calling the API via callApi(), and returning the JSON response.
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, }; });