Skip to main content
Glama

addClozeCard

Create cloze deletion flashcards for Anki by specifying text with {{c1::hidden}} sections, front content, back explanations, deck ID, and optional tags.

Instructions

Add a cloze deletion card to a deck

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
backYesBack side of the card
clozeTextYesCloze text with {{c1::text}} format
deckIdYesID of the deck to add card to
frontYesFront side of the card
tagsNoTags for the card

Implementation Reference

  • The handler function for addClozeCard, which adds a single cloze deletion card to the specified deck by calling the Anki batch cards API with cardType 'CLOZE'.
    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)}`;
      }
    },
  • Zod input schema defining the parameters for the addClozeCard tool: 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:190-221 (registration)
    The server.addTool registration for the addClozeCard tool, including description, handler, name, and parameters schema.
      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'),
      }),
    });

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/zlatanpham/anki-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server