addClozeCard
Create cloze deletion flashcards for Anki by specifying text with {{c1::hidden}} sections, front content, back content, deck ID, and optional tags.
Instructions
Add a cloze deletion card to a deck
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| back | Yes | Back side of the card | |
| clozeText | Yes | Cloze text with {{c1::text}} format | |
| deckId | Yes | ID of the deck to add card to | |
| front | Yes | Front side of the card | |
| tags | No | Tags for the card |
Implementation Reference
- src/index.ts:191-212 (handler)The execute function that implements the logic for adding a single cloze deletion card to an Anki deck by making a POST request to the batch cards endpoint.execute: async args => { try { const data = await ankiApiRequest( 'POST', `/api/v1/decks/${args.deckId}/cards/batch`, { cards: [ { back: args.back, cardType: 'CLOZE', clozeText: args.clozeText, front: args.front, tags: args.tags || [], }, ], }, ); return JSON.stringify(data, null, 2); } catch (error) { return `Error: ${error instanceof Error ? error.message : String(error)}`; } },
- src/index.ts:214-220 (schema)Zod schema defining the input parameters for the addClozeCard tool, including deckId, front, back, clozeText, and optional tags.parameters: z.object({ back: z.string().describe('Back side of the card'), clozeText: z.string().describe('Cloze text with {{c1::text}} format'), deckId: z.string().describe('ID of the deck to add card to'), front: z.string().describe('Front side of the card'), tags: z.array(z.string()).optional().describe('Tags for the card'), }),
- src/index.ts:189-221 (registration)The server.addTool call that registers the addClozeCard tool with its description, handler, name, and parameters.server.addTool({ description: 'Add a cloze deletion card to a deck', execute: async args => { try { const data = await ankiApiRequest( 'POST', `/api/v1/decks/${args.deckId}/cards/batch`, { cards: [ { back: args.back, cardType: 'CLOZE', clozeText: args.clozeText, front: args.front, tags: args.tags || [], }, ], }, ); return JSON.stringify(data, null, 2); } catch (error) { return `Error: ${error instanceof Error ? error.message : String(error)}`; } }, name: 'addClozeCard', parameters: z.object({ back: z.string().describe('Back side of the card'), clozeText: z.string().describe('Cloze text with {{c1::text}} format'), deckId: z.string().describe('ID of the deck to add card to'), front: z.string().describe('Front side of the card'), tags: z.array(z.string()).optional().describe('Tags for the card'), }), });