Skip to main content
Glama

create_model

Build custom Anki flashcards by defining model names, field order, card templates, CSS, and cloze type using the create_model tool in Anki MCP.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cardTemplatesYesArray of card templates with Front and Back content
cssNoCustom CSS styling for the model
inOrderFieldsYesArray of field names in order
isClozeNoWhether the model should be a cloze type
modelNameYesName of the model to create

Implementation Reference

  • Handler function that processes inputs, prepares parameters including optional CSS and cloze settings, invokes ankiClient.model.createModel, and responds with success message containing the new model ID or propagates errors.
    async ({ modelName, inOrderFields, cardTemplates, css, isCloze }) => { try { const modelParams: { modelName: string; inOrderFields: string[]; cardTemplates: { [key: string]: string; Back: string; Front: string }[]; css?: string; isCloze?: boolean; } = { modelName, inOrderFields, cardTemplates, }; if (css !== undefined) { modelParams.css = css; } if (isCloze !== undefined) { modelParams.isCloze = isCloze; } const result = await ankiClient.model.createModel(modelParams); return { content: [ { type: 'text', text: `Successfully created model "${modelName}" with ID: ${result.id}`, }, ], }; } catch (error) { throw new Error( `Failed to create model "${modelName}": ${error instanceof Error ? error.message : String(error)}` ); } }
  • Zod input schema validating modelName (required string), inOrderFields (array of strings), cardTemplates (array of template objects with Front/Back and additional properties), optional css and isCloze.
    { modelName: z.string().describe('Name of the model to create'), inOrderFields: z.array(z.string()).describe('Array of field names in order'), cardTemplates: z .array( z .object({ Front: z.string().describe('Front template content'), Back: z.string().describe('Back template content'), }) .and(z.record(z.string())) ) .describe('Array of card templates with Front and Back content'), css: z.string().optional().describe('Custom CSS styling for the model'), isCloze: z.boolean().optional().describe('Whether the model should be a cloze type'), },
  • Registration of the 'create_model' tool on the MCP server using server.tool(), including name, input schema, and handler function.
    server.tool( 'create_model', { modelName: z.string().describe('Name of the model to create'), inOrderFields: z.array(z.string()).describe('Array of field names in order'), cardTemplates: z .array( z .object({ Front: z.string().describe('Front template content'), Back: z.string().describe('Back template content'), }) .and(z.record(z.string())) ) .describe('Array of card templates with Front and Back content'), css: z.string().optional().describe('Custom CSS styling for the model'), isCloze: z.boolean().optional().describe('Whether the model should be a cloze type'), }, async ({ modelName, inOrderFields, cardTemplates, css, isCloze }) => { try { const modelParams: { modelName: string; inOrderFields: string[]; cardTemplates: { [key: string]: string; Back: string; Front: string }[]; css?: string; isCloze?: boolean; } = { modelName, inOrderFields, cardTemplates, }; if (css !== undefined) { modelParams.css = css; } if (isCloze !== undefined) { modelParams.isCloze = isCloze; } const result = await ankiClient.model.createModel(modelParams); return { content: [ { type: 'text', text: `Successfully created model "${modelName}" with ID: ${result.id}`, }, ], }; } catch (error) { throw new Error( `Failed to create model "${modelName}": ${error instanceof Error ? error.message : String(error)}` ); } } );

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/arielbk/anki-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server