ctftime_team
Get detailed information about a CTFtime team using its unique team ID. Access team data from the CTFtime API.
Instructions
Get information about a specific team by team_id.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| team_id | Yes | CTFtime team id. |
Implementation Reference
- src/index.ts:169-184 (handler)Registration and handler for the 'ctftime_team' tool. Uses server.registerTool to define the tool with an input schema requiring a team_id (positive integer), then fetches team data from the CTFtime API at '/teams/{team_id}/' and returns the JSON response as text content.
server.registerTool( "ctftime_team", { description: "Get information about a specific team by team_id.", inputSchema: { team_id: z.number().int().min(1).describe("CTFtime team id."), }, }, async ({ team_id }) => { const url = `${CTFtime_API_BASE}/teams/${team_id}/`; const data = await getJson<any>(url); return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }], }; } ); - src/index.ts:169-184 (registration)The tool is registered via server.registerTool with the name 'ctftime_team'.
server.registerTool( "ctftime_team", { description: "Get information about a specific team by team_id.", inputSchema: { team_id: z.number().int().min(1).describe("CTFtime team id."), }, }, async ({ team_id }) => { const url = `${CTFtime_API_BASE}/teams/${team_id}/`; const data = await getJson<any>(url); return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }], }; } ); - src/index.ts:9-26 (helper)The getJson helper function used by the handler to fetch data from the CTFtime API with proper headers and error handling.
async function getJson<T>(url: string): Promise<T> { const res = await fetch(url, { headers: { Accept: "application/json", // CTFtime doesn't require a UA header for this API, but it helps with debugging and etiquette. "User-Agent": "mcp-ctftime/0.1.0 (+https://ctftime.org/api/)", }, }); if (!res.ok) { const text = await res.text().catch(() => ""); throw new Error( `CTFtime API error ${res.status} for ${url}${ text ? `: ${text.slice(0, 300)}` : "" }` ); } return (await res.json()) as T; }