ctftime_event
Retrieve comprehensive details for a CTFtime event by providing its unique event identifier.
Instructions
Get full details for a specific CTFtime event by event_id.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| event_id | Yes | CTFtime event id. |
Implementation Reference
- src/index.ts:96-111 (handler)Handler function for the ctftime_event tool. Takes event_id, fetches full event details from CTFtime API /events/{event_id}/, and returns the data as formatted JSON text.
server.registerTool( "ctftime_event", { description: "Get full details for a specific CTFtime event by event_id.", inputSchema: { event_id: z.number().int().min(1).describe("CTFtime event id."), }, }, async ({ event_id }) => { const url = `${CTFtime_API_BASE}/events/${event_id}/`; const data = await getJson<any>(url); return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }], }; } ); - src/index.ts:97-102 (schema)Schema definition for ctftime_event tool. Accepts a single required integer event_id parameter (min 1).
"ctftime_event", { description: "Get full details for a specific CTFtime event by event_id.", inputSchema: { event_id: z.number().int().min(1).describe("CTFtime event id."), }, - src/index.ts:96-111 (registration)Registration of the ctftime_event tool on the MCP server via server.registerTool().
server.registerTool( "ctftime_event", { description: "Get full details for a specific CTFtime event by event_id.", inputSchema: { event_id: z.number().int().min(1).describe("CTFtime event id."), }, }, async ({ event_id }) => { const url = `${CTFtime_API_BASE}/events/${event_id}/`; const data = await getJson<any>(url); return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }], }; } ); - src/index.ts:9-26 (helper)Generic helper function getJson<T>() used by the handler to fetch and parse JSON from the CTFtime API with proper 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; }