addBasicCard
Create a basic flashcard with front and back content, assign it to a deck, and optionally add tags for organization.
Instructions
Add a single basic card to a deck
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| back | Yes | Back side of the card | |
| 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:158-178 (handler)The execute handler for the 'addBasicCard' tool, which adds a single basic card to a deck by making a POST request to the Anki API batch endpoint with cardType 'BASIC'.execute: async args => { try { const data = await ankiApiRequest( 'POST', `/api/v1/decks/${args.deckId}/cards/batch`, { cards: [ { back: args.back, cardType: 'BASIC', 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:180-185 (schema)Zod input schema defining parameters for the 'addBasicCard' tool: deckId (string), front (string), back (string), tags (optional string array).parameters: z.object({ back: z.string().describe('Back side of the card'), 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:156-186 (registration)The server.addTool call that registers the 'addBasicCard' tool with its name, description, handler, and parameters.server.addTool({ description: 'Add a single basic 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: 'BASIC', front: args.front, tags: args.tags || [], }, ], }, ); return JSON.stringify(data, null, 2); } catch (error) { return `Error: ${error instanceof Error ? error.message : String(error)}`; } }, name: 'addBasicCard', parameters: z.object({ back: z.string().describe('Back side of the card'), 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'), }), });