model_template_add
Add custom templates to Anki card models, enabling users to define Front and Back content for personalized study cards.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| modelName | Yes | Name of the model | |
| template | Yes | Template object with Front and Back content |
Implementation Reference
- src/tools/model.ts:322-354 (handler)Full MCP tool definition including registration, input schema (modelName: string, template: object with Front/Back), and handler function that calls ankiClient.model.modelTemplateAdd to add a card template to the specified Anki model.server.tool( 'model_template_add', { modelName: z.string().describe('Name of the model'), template: z .object({ Front: z.string().describe('Front template content'), Back: z.string().describe('Back template content'), }) .and(z.record(z.string())) .describe('Template object with Front and Back content'), }, async ({ modelName, template }) => { try { await ankiClient.model.modelTemplateAdd({ modelName, template, }); return { content: [ { type: 'text', text: `Successfully added template to model "${modelName}"`, }, ], }; } catch (error) { throw new Error( `Failed to add template to model "${modelName}": ${error instanceof Error ? error.message : String(error)}` ); } } );