create_category
Create a new category by specifying a name, with optional description, publication status, and parent category.
Instructions
Create a category.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Title of the category. | |
| description | No | The description of the category. | |
| is_published | No | Boolean if the category is published on the website. | |
| parent_id | No | Unique identifier of the parent category |
Implementation Reference
- src/tools/categories.ts:70-78 (handler)The actual handler logic for the create_category tool. It receives a body object (containing name, optional description, is_published, parent_id), calls apiPost to POST /categories, logs the response, and formats the result using formatCreate.
async (body) => { try { const record = await apiPost<EduframeRecord>("/categories", body); void logResponse("create_category", body, record); return formatCreate(record, "categorie"); } catch (error) { return formatError(error); } }, - src/tools/categories.ts:63-68 (schema)Input schema for create_category tool. Defines required 'name' (string) and optional 'description' (string), 'is_published' (boolean), and 'parent_id' (number) using Zod validation.
inputSchema: { name: z.string().describe("Title of the category."), description: z.string().optional().describe("The description of the category."), is_published: z.boolean().optional().describe("Boolean if the category is published on the website."), parent_id: z.number().int().optional().describe("Unique identifier of the parent category"), }, - src/tools/categories.ts:58-79 (registration)Registration of the 'create_category' tool using server.registerTool(), which wires the name, description, annotations, inputSchema, and handler together.
server.registerTool( "create_category", { description: "Create a category.", annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false }, inputSchema: { name: z.string().describe("Title of the category."), description: z.string().optional().describe("The description of the category."), is_published: z.boolean().optional().describe("Boolean if the category is published on the website."), parent_id: z.number().int().optional().describe("Unique identifier of the parent category"), }, }, async (body) => { try { const record = await apiPost<EduframeRecord>("/categories", body); void logResponse("create_category", body, record); return formatCreate(record, "categorie"); } catch (error) { return formatError(error); } }, ); - src/tools/index.ts:128-131 (registration)The registerAllTools function that iterates over all tool registration functions, including registerCategorieTools (which registers create_category).
export function registerAllTools(server: McpServer): void { for (const register of tools) { register(server); } - src/formatters.ts:85-93 (helper)The formatCreate helper used by create_category to format the API response into a human-readable success message with the created record.
export function formatCreate(record: EduframeRecord, resourceName: string): CallToolResult { return { content: [ { type: "text", text: `Successfully created ${resourceName}:\n\n${formatJSON(record)}${RESPONSE_LOG_HINT}`, }, ], };