Skip to main content
Glama

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
NameRequiredDescriptionDefault
cardIdsYesArray of card IDs to get note IDs for

Implementation Reference

  • 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)}` ); } } );
  • 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'),
  • 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)}` ); } }
  • 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)}` ); } }

Other Tools

Related Tools

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

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