get_new_cards
Retrieve a specified number of new, unseen flashcards from Anki for review or study sessions.
Instructions
Returns a given number (num) of new and unseen cards.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| num | Yes | Number of new cards to get |
Implementation Reference
- index.ts:295-306 (handler)Handler function for the 'get_new_cards' tool within the CallToolRequestSchema. It parses the 'num' argument, fetches new cards using the helper findCardsAndOrder with query 'is:new', slices the first N cards, and returns them serialized as JSON text.case "get_new_cards": { const num = Number(args.num); const cards = await findCardsAndOrder("is:new"); return { content: [{ type: "text", text: JSON.stringify(cards.slice(0, num)) }] }; }
- index.ts:206-218 (registration)Registration of the 'get_new_cards' tool in the ListToolsRequestSchema response, including the tool name, description, and input schema definition.name: "get_new_cards", description: "Returns a given number (num) of new and unseen cards.", inputSchema: { type: "object", properties: { num: { type: "number", description: "Number of new cards to get" } }, required: ["num"] }, }
- index.ts:208-217 (schema)Input schema definition for the 'get_new_cards' tool, specifying a required 'num' property of type number.inputSchema: { type: "object", properties: { num: { type: "number", description: "Number of new cards to get" } }, required: ["num"] },
- index.ts:93-105 (helper)Helper function called by the get_new_cards handler to find cards matching the 'is:new' query, retrieve their details, clean the 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; }