gui_add_cards
Add structured notes to a specified Anki deck using a chosen note model, populate fields, and assign tags for organized study material
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| deckName | Yes | Name of the deck to add the note to | |
| fields | Yes | Object with field names as keys and field content as values | |
| modelName | Yes | Name of the note model/type | |
| tags | No | Array of tags to add to the note |
Implementation Reference
- src/tools/graphical.ts:20-43 (handler)Executes the tool logic by constructing a note object from inputs and calling ankiClient.graphical.guiAddCards to open Anki's Add Cards GUI dialog.async ({ deckName, modelName, fields, tags }) => { try { const note = { deckName, modelName, fields, tags: tags || [], }; const result = await ankiClient.graphical.guiAddCards({ note }); return { content: [ { type: 'text', text: `Opened Add Cards dialog and added note with ID: ${result}`, }, ], }; } catch (error) { throw new Error( `Failed to open Add Cards dialog: ${error instanceof Error ? error.message : String(error)}` ); } }
- src/tools/graphical.ts:12-19 (schema)Zod schema defining the input parameters for the gui_add_cards tool: deckName (string), modelName (string), fields (record<string,string>), tags (optional array<string>).{ deckName: z.string().describe('Name of the deck to add the note to'), modelName: z.string().describe('Name of the note model/type'), fields: z .record(z.string()) .describe('Object with field names as keys and field content as values'), tags: z.array(z.string()).optional().describe('Array of tags to add to the note'), },
- src/tools/graphical.ts:11-44 (registration)Registers the 'gui_add_cards' MCP tool with the server, specifying name, input schema, and handler function.'gui_add_cards', { deckName: z.string().describe('Name of the deck to add the note to'), modelName: z.string().describe('Name of the note model/type'), fields: z .record(z.string()) .describe('Object with field names as keys and field content as values'), tags: z.array(z.string()).optional().describe('Array of tags to add to the note'), }, async ({ deckName, modelName, fields, tags }) => { try { const note = { deckName, modelName, fields, tags: tags || [], }; const result = await ankiClient.graphical.guiAddCards({ note }); return { content: [ { type: 'text', text: `Opened Add Cards dialog and added note with ID: ${result}`, }, ], }; } catch (error) { throw new Error( `Failed to open Add Cards dialog: ${error instanceof Error ? error.message : String(error)}` ); } } );