get_player_career
Retrieve a player's complete World Cup history, including team, position, goals, and captain status for each tournament. Use this to compare careers like Pelé or Messi across multiple World Cups.
Instructions
Get a player's full World Cup career: every tournament they appeared in, with team/position/jersey/goals/captain status per year. Use this when the user wants a "all of Pelé's World Cup matches" or "compare Messi's 4 World Cups" view. The name should be the canonical name (use search_players first if unsure).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Player name, e.g. "Diego Maradona", "Lionel Messi" |
Implementation Reference
- src/index.ts:178-179 (handler)The handler function for get_player_career: calls the API endpoint `/players/{name}` with the encoded player name. This is the core execution logic that fetches the player's full World Cup career data.
handler: async (args: { name: string }) => api(`/players/${encodeURIComponent(args.name)}`), - src/index.ts:175-177 (schema)Zod schema for get_player_career input validation: requires a `name` string (min 2 chars) describing the player's canonical name.
schema: z.object({ name: z.string().min(2).describe('Player name, e.g. "Diego Maradona", "Lionel Messi"'), }).strict(), - src/index.ts:168-180 (registration)Tool registration entry in the `tools` array (lines 113-331). Defines name 'get_player_career', description explaining usage (full career, per-tournament appearance data), and binds schema + handler together.
{ name: 'get_player_career', description: 'Get a player\'s full World Cup career: every tournament they appeared in, with ' + 'team/position/jersey/goals/captain status per year. Use this when the user wants a ' + '"all of Pelé\'s World Cup matches" or "compare Messi\'s 4 World Cups" view. The ' + 'name should be the canonical name (use search_players first if unsure).', schema: z.object({ name: z.string().min(2).describe('Player name, e.g. "Diego Maradona", "Lionel Messi"'), }).strict(), handler: async (args: { name: string }) => api(`/players/${encodeURIComponent(args.name)}`), }, - src/index.ts:70-91 (helper)The `api()` helper function used by the handler to make authenticated HTTP requests to the Zafronix FIFA World Cup API. Handles auth via X-API-Key header and error reporting.
async function api<T = unknown>(path: string): Promise<T> { if (!API_KEY) { throw new Error( 'WC_API_KEY is not set in the environment. Get a free key at ' + 'https://api.zafronix.com/signup and add it to your MCP client ' + 'config: { "env": { "WC_API_KEY": "zwc_pk_..." } }', ); } const url = path.startsWith('http') ? path : `${API_BASE}${path}`; const res = await fetch(url, { headers: { 'X-API-Key': API_KEY, 'Accept': 'application/json', 'User-Agent': 'wc-mcp/0.1.2', }, }); if (!res.ok) { const body = await res.text().catch(() => ''); throw new Error(`API ${res.status} ${res.statusText} on ${path}: ${body.slice(0, 240)}`); } return res.json() as Promise<T>; }