edubase_delete_exam
Archive or delete an exam from the platform by providing its exam identification string.
Instructions
Remove/archive exam.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| exam | Yes | exam identification string |
Implementation Reference
- src/tools/exams.ts:78-86 (schema)Tool definition (schema) for edubase_delete_exam - defines name, description, input (exam ID string), and empty output schema
// DELETE /exam - Remove/archive exam { name: 'edubase_delete_exam', description: "Remove/archive exam.", inputSchema: z.object({ exam: z.string().describe('exam identification string'), }), outputSchema: z.object({}).optional(), }, - src/index.ts:203-263 (handler)Generic handler for all edubase tools including edubase_delete_exam - splits tool name to extract HTTP method ('delete') and endpoint ('exam'), then calls sendEduBaseApiRequest with the method, constructed endpoint URL, and input args
Object.values(EDUBASE_API_TOOLS_ANNOTATED).forEach((tool) => { /* Register tools */ server.registerTool(tool.name, { description: tool.description, inputSchema: tool.inputSchema as any, outputSchema: tool.outputSchema as any, annotations: tool.annotations, }, async (args: any, ctx: any): Promise<CallToolResult> => { try { const name = tool.name; /* Decompose request and check arguments */ if (!name.match(/^edubase_(get|post|delete)/)) { throw new Error('Invalid tool configuration'); } if (!args) { throw new Error('No arguments provided'); } /* Prepare and send API request */ const [ , method, ...endpoint ] = name.split('_'); const response = await sendEduBaseApiRequest(method, (apiUrl || EDUBASE_API_URL) + '/' + endpoint.join(':'), args, authentication); /* Return response */ if (z.object({}).strict().safeParse(tool.outputSchema).success) { /* Endpoint with empty output schema */ return { content: [{ type: 'text', text: '{}' }], structuredContent: {}, isError: false, }; } else if (response.length == 0) { /* Endpoint without response */ return { content: [{ type: 'text', text: 'Success.' }], isError: false, }; } else if (typeof response != 'object') { /* Response should be an object (hash or list) at this point */ throw new Error('Invalid response'); } else { /* Return response (schema will be validated automatically) */ return { content: [{ type: 'text', text: JSON.stringify(response) }], structuredContent: response, isError: false, }; } } catch (error) { /* Request failed */ return { content: [{ type: 'text', text: `${error instanceof Error ? error.message : String(error)}`, }], isError: true, }; } }); - src/index.ts:205-210 (registration)Registration of edubase_delete_exam (and all other tools) via server.registerTool using the tool's definition from the exported array
server.registerTool(tool.name, { description: tool.description, inputSchema: tool.inputSchema as any, outputSchema: tool.outputSchema as any, annotations: tool.annotations, }, async (args: any, ctx: any): Promise<CallToolResult> => { - src/tools.ts:95-109 (registration)Aggregation of all tool definitions including EDUBASE_API_TOOLS_EXAMS where edubase_delete_exam is defined
export const EDUBASE_API_TOOLS = [ ...EDUBASE_API_TOOLS_COMMON, ...EDUBASE_API_TOOLS_QUESTIONS, ...EDUBASE_API_TOOLS_EXAMS, ...EDUBASE_API_TOOLS_PLAYS, ...EDUBASE_API_TOOLS_QUIZES, ...EDUBASE_API_TOOLS_USERS, ...EDUBASE_API_TOOLS_CLASSES, ...EDUBASE_API_TOOLS_ORGANIZATIONS, ...EDUBASE_API_TOOLS_INTEGRATIONS, ...EDUBASE_API_TOOLS_TAGS, ...EDUBASE_API_TOOLS_PERMISSIONS, ...EDUBASE_API_TOOLS_METRICS ] as EduBaseApiTool[]; export const EDUBASE_API_TOOLS_ANNOTATED = withToolAnnotations(EDUBASE_API_TOOLS); - src/index.ts:311-363 (helper)Helper function that sends the actual HTTP DELETE request to the EduBase API endpoint for edubase_delete_exam
async function sendEduBaseApiRequest(method: string, endpoint: string, data: object, authentication: EduBaseAuthentication | null) { /* Check method and endpoint */ method = method.toUpperCase() if (!['GET', 'POST', 'DELETE'].includes(method)) { throw new Error('Invalid method: "' + method + '"'); } if (endpoint.length == 0) { throw new Error('Invalid endpoint'); } /* Check rate limit */ checkRateLimit(); /* Prepare authentication (prefer EDUBASE_API_APP and EDUBASE_API_KEY environment variables) */ if (!authentication) { authentication = { app: EDUBASE_API_APP, secret: EDUBASE_API_KEY }; } else { if (!authentication.hasOwnProperty('app') || authentication.app.length == 0 || EDUBASE_API_APP.length > 0) { authentication.app = EDUBASE_API_APP; } if (!authentication.hasOwnProperty('secret') || authentication.secret.length == 0 || EDUBASE_API_KEY.length > 0) { authentication.secret = EDUBASE_API_KEY; } } /* Send request with input data */ let headers = { 'Content-Type': 'application/json', 'Accept-Encoding': 'gzip', 'EduBase-API-Client': 'MCP', 'EduBase-API-Transport': (STREAMABLE_HTTP) ? 'Streamable HTTP' : ((SSE) ? 'SSE' : 'Stdio'), 'EduBase-API-App': authentication.app, 'EduBase-API-Secret': authentication.secret }; const response = await fetch(endpoint + (method == 'GET' ? '?' + queryString.stringify(data) : ''), { method: method, body: (method != 'GET' ? JSON.stringify(data) : undefined), headers: headers }); if (!response.ok) { throw new Error(`EduBase API error: ${response.status} ${response.statusText}` + (response.headers.has('EduBase-API-Error') ? ` (${response.headers.get('EduBase-API-Error')})` : '')); } /* Parse response and return as object */ let clonedResponse = response.clone(); try { /* First try to decode as JSON */ return await response.json(); } catch (error) { /* Response might be empty string with a 200 status code */ return await clonedResponse.text(); } }