model_field_reposition
Reposition fields in Anki note templates by specifying model name, field name, and new index for improved organization and workflow.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| fieldName | Yes | Name of the field to reposition | |
| index | Yes | New position for the field (0-based) | |
| modelName | Yes | Name of the model |
Implementation Reference
- src/tools/model.ts:205-225 (handler)The asynchronous handler function that implements the core logic of the 'model_field_reposition' tool. It calls the Anki client to reposition the specified field in the model and returns a success message or throws an error.async ({ modelName, fieldName, index }) => { try { await ankiClient.model.modelFieldReposition({ modelName, fieldName, index, }); return { content: [ { type: 'text', text: `Successfully repositioned field "${fieldName}" to position ${index} in model "${modelName}"`, }, ], }; } catch (error) { throw new Error( `Failed to reposition field "${fieldName}" in model "${modelName}": ${error instanceof Error ? error.message : String(error)}` ); } }
- src/tools/model.ts:200-204 (schema)Zod schema validating the input parameters for the 'model_field_reposition' tool: modelName (string), fieldName (string), and index (number).{ modelName: z.string().describe('Name of the model'), fieldName: z.string().describe('Name of the field to reposition'), index: z.number().describe('New position for the field (0-based)'), },
- src/tools/model.ts:198-226 (registration)The server.tool() call that registers the 'model_field_reposition' tool with the MCP server, including its name, input schema, and handler function.server.tool( 'model_field_reposition', { modelName: z.string().describe('Name of the model'), fieldName: z.string().describe('Name of the field to reposition'), index: z.number().describe('New position for the field (0-based)'), }, async ({ modelName, fieldName, index }) => { try { await ankiClient.model.modelFieldReposition({ modelName, fieldName, index, }); return { content: [ { type: 'text', text: `Successfully repositioned field "${fieldName}" to position ${index} in model "${modelName}"`, }, ], }; } catch (error) { throw new Error( `Failed to reposition field "${fieldName}" in model "${modelName}": ${error instanceof Error ? error.message : String(error)}` ); } } );