Skip to main content
Glama

get_due_cards

Retrieve a specified number of Anki flashcards due for review to manage study sessions and track progress.

Instructions

Returns a given number (num) of cards due for review.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
numYesNumber of due cards to get

Implementation Reference

  • Handler for the 'get_due_cards' tool. It retrieves due cards using the helper findCardsAndOrder with query 'is:due', slices the first 'num' cards, and returns them as JSON string in the response content.
    case "get_due_cards": {
      const num = Number(args.num);
    
      const cards = await findCardsAndOrder("is:due");
    
      return {
        content: [{
          type: "text",
          text: JSON.stringify(cards.slice(0, num))
        }]
      };
    }
  • index.ts:191-204 (registration)
    Registration of the 'get_due_cards' tool in the ListTools response, including name, description, and input schema requiring a 'num' parameter.
    {
      name: "get_due_cards",
      description: "Returns a given number (num) of cards due for review.",
      inputSchema: {
        type: "object",
        properties: {
          num: {
            type: "number",
            description: "Number of due cards to get"
          }
        },
        required: ["num"]
      },
    },
  • Input schema for the 'get_due_cards' tool, defining an object with a required 'num' number property.
    inputSchema: {
      type: "object",
      properties: {
        num: {
          type: "number",
          description: "Number of due cards to get"
        }
      },
      required: ["num"]
    },
  • Helper function used by the handler to find cards matching the query (e.g., 'is:due'), fetch their info, clean question and answer fields, and sort by due date.
    async function findCardsAndOrder(query: string): Promise<Card[]> {
      const cardIds = await client.card.findCards({
        query: formatQuery(query)
      });
      const cards: Card[] = (await client.card.cardsInfo({ cards: cardIds })).map(card => ({
        cardId: card.cardId,
        question: cleanWithRegex(card.question),
        answer: cleanWithRegex(card.answer),
        due: card.due
      })).sort((a: Card, b: Card) => a.due - b.due);
    
      return cards;
    }

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/scorzeth/anki-mcp-server'

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