cards_to_notes
Convert Anki card IDs into corresponding note IDs to organize and manage study materials efficiently. Ideal for users needing precise note identification in their decks.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cardIds | Yes | Array of card IDs to get note IDs for |
Implementation Reference
- src/tools/cards.ts:437-460 (registration)The registration of the 'cards_to_notes' MCP tool within the registerCardTools function. Includes the input schema (cardIds: array of numbers) and the handler logic that fetches note IDs corresponding to the given card IDs using the AnkiConnect API.// Tool: Convert cards to notes server.tool( 'cards_to_notes', { cardIds: z.array(z.number()).describe('Array of card IDs to get note IDs for'), }, async ({ cardIds }) => { try { const noteIds = await ankiClient.card.cardsToNotes({ cards: cardIds }); return { content: [ { type: 'text', text: `Note IDs: ${JSON.stringify(noteIds)}`, }, ], }; } catch (error) { throw new Error( `Failed to get note IDs from cards: ${error instanceof Error ? error.message : String(error)}` ); } } );
- src/tools/cards.ts:440-441 (schema)Zod input schema for the 'cards_to_notes' tool requiring an array of numeric card IDs.{ cardIds: z.array(z.number()).describe('Array of card IDs to get note IDs for'),
- src/tools/cards.ts:443-459 (handler)Handler function implementing the core logic of the tool: converts card IDs to note IDs via ankiClient and returns them as a text response.async ({ cardIds }) => { try { const noteIds = await ankiClient.card.cardsToNotes({ cards: cardIds }); return { content: [ { type: 'text', text: `Note IDs: ${JSON.stringify(noteIds)}`, }, ], }; } catch (error) { throw new Error( `Failed to get note IDs from cards: ${error instanceof Error ? error.message : String(error)}` ); } }
- src/resources/cards.ts:172-193 (helper)A related MCP resource handler with identical core logic (cardsToNotes call), providing note IDs via URI template 'anki:///cards/{cardIds}/notes' as JSON.'cards_to_notes', new ResourceTemplate('anki:///cards/{cardIds}/notes', { list: undefined }), async (uri) => { try { const cardIds = parseCardIds(uri); const noteIds = await ankiClient.card.cardsToNotes({ cards: cardIds }); return { contents: [ { uri: uri.href, mimeType: 'application/json', text: JSON.stringify(noteIds, null, 2), }, ], }; } catch (error) { throw new Error( `Failed to get note IDs from cards: ${error instanceof Error ? error.message : String(error)}` ); } }