get_team_roster
Get the complete squad list for any World Cup team and year, including each player's jersey number, position, date of birth, club, goals, and captain status.
Instructions
Full squad for one team in one tournament — every player with jersey, position, DOB, club, goals, captain flag. Use this for "who was on Spain's 2010 squad?" or "show me Italy's 2006 roster".
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Team name, e.g. "Brazil" | |
| year | Yes | Tournament year |
Implementation Reference
- src/index.ts:222-223 (handler)The handler for get_team_roster calls the API endpoint /teams/{name}/roster?year={year} with the team name and tournament year as parameters.
handler: async (args: { name: string; year: number }) => api(`/teams/${encodeURIComponent(args.name)}/roster?year=${args.year}`), - src/index.ts:218-221 (schema)The zod schema for get_team_roster defines two required parameters: name (string, min 2 chars) and year (integer, 1930-2030).
schema: z.object({ name: z.string().min(2).describe('Team name, e.g. "Brazil"'), year: z.number().int().min(1930).max(2030).describe('Tournament year'), }).strict(), - src/index.ts:212-224 (registration)The tool 'get_team_roster' is registered in the 'tools' array with its name, description, schema, and handler. The registration is consumed by the ListToolsRequestSchema and CallToolRequestSchema handlers in the MCP server wiring.
{ name: 'get_team_roster', description: 'Full squad for one team in one tournament — every player with jersey, position, ' + 'DOB, club, goals, captain flag. Use this for "who was on Spain\'s 2010 squad?" or ' + '"show me Italy\'s 2006 roster".', schema: z.object({ name: z.string().min(2).describe('Team name, e.g. "Brazil"'), year: z.number().int().min(1930).max(2030).describe('Tournament year'), }).strict(), handler: async (args: { name: string; year: number }) => api(`/teams/${encodeURIComponent(args.name)}/roster?year=${args.year}`), }, - src/index.ts:70-91 (helper)The 'api' helper function handles HTTP requests to the Zafronix WC API, adding auth headers and parsing JSON responses. It is used by the get_team_roster handler to make the actual API call.
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>; }