list_teams
Find all national teams that have competed in any FIFA World Cup, filtered by confederation. View first and last appearance year and total appearances for each team.
Instructions
List every national team that has ever played a World Cup, with confederation, first/last appearance year, and total appearances. Useful for "which African nations have made the World Cup?" or "list every CONMEBOL team". Pair with get_team for a specific country.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| confederation | No |
Implementation Reference
- src/index.ts:192-197 (handler)Handler function for the list_teams tool. Builds a /teams API path with optional confederation query param and calls the API helper.
handler: async (args: { confederation?: string }) => { const params = new URLSearchParams(); if (args.confederation) params.set('confederation', args.confederation); const path = `/teams${params.toString() ? `?${params.toString()}` : ''}`; return api(path); }, - src/index.ts:188-191 (schema)Zod schema for list_teams input validation. Accepts an optional confederation parameter restricted to the six FIFA confederation codes.
schema: z.object({ confederation: z.enum(['UEFA', 'CONMEBOL', 'CONCACAF', 'AFC', 'CAF', 'OFC']).optional() .describe('Filter by confederation (optional)'), }).strict(), - src/index.ts:181-198 (registration)Tool registration within the tools array, including name, description, schema, and handler for the list_teams tool.
{ name: 'list_teams', description: 'List every national team that has ever played a World Cup, with confederation, ' + 'first/last appearance year, and total appearances. Useful for "which African nations ' + 'have made the World Cup?" or "list every CONMEBOL team". Pair with get_team for a ' + 'specific country.', schema: z.object({ confederation: z.enum(['UEFA', 'CONMEBOL', 'CONCACAF', 'AFC', 'CAF', 'OFC']).optional() .describe('Filter by confederation (optional)'), }).strict(), handler: async (args: { confederation?: string }) => { const params = new URLSearchParams(); if (args.confederation) params.set('confederation', args.confederation); const path = `/teams${params.toString() ? `?${params.toString()}` : ''}`; return api(path); }, }, - src/index.ts:70-91 (helper)The api() fetch helper called by the list_teams handler to make authenticated HTTP requests to the backend API.
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>; }