model_field_add
Add a custom field to a specified model at a defined position using Anki MCP. Enhance model structure by inserting fields where needed.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| fieldName | Yes | Name of the field to add | |
| index | Yes | Position to insert the field (0-based) | |
| modelName | Yes | Name of the model |
Implementation Reference
- src/tools/model.ts:107-135 (handler)Full MCP tool definition including registration, input schema (Zod), and handler function that executes modelFieldAdd via ankiClient and returns success/error response.server.tool( 'model_field_add', { modelName: z.string().describe('Name of the model'), fieldName: z.string().describe('Name of the field to add'), index: z.number().describe('Position to insert the field (0-based)'), }, async ({ modelName, fieldName, index }) => { try { await ankiClient.model.modelFieldAdd({ modelName, fieldName, index, }); return { content: [ { type: 'text', text: `Successfully added field "${fieldName}" to model "${modelName}" at position ${index}`, }, ], }; } catch (error) { throw new Error( `Failed to add field "${fieldName}" to model "${modelName}": ${error instanceof Error ? error.message : String(error)}` ); } } );