Skip to main content
Glama

manage_decks

Create, delete, list, configure, and organize Anki decks. Move cards between decks and manage deck settings for effective flashcard organization.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
operationYesDeck management operation
deckNameNoDeck name
deckNamesNoDeck names (for batch operations)
deleteCardsNoDelete cards when deleting deck
cardIdsNoCard IDs to move
targetDeckNoTarget deck for moving cards
configIdNoConfig ID to apply

Implementation Reference

  • Registration of the 'manage_decks' tool with the MCP server inside registerConsolidatedTools function. Includes schema and handler.
    server.tool(
      'manage_decks',
      {
        operation: z
          .enum(['create', 'delete', 'list', 'get_stats', 'move_cards', 'get_config', 'set_config'])
          .describe('Deck management operation'),
    
        deckName: z.string().optional().describe('Deck name'),
        deckNames: z.array(z.string()).optional().describe('Deck names (for batch operations)'),
        deleteCards: z.boolean().optional().describe('Delete cards when deleting deck'),
    
        cardIds: z.array(z.number()).optional().describe('Card IDs to move'),
        targetDeck: z.string().optional().describe('Target deck for moving cards'),
    
        configId: z.number().optional().describe('Config ID to apply'),
      },
      async ({ operation, deckName, deckNames, deleteCards, cardIds, targetDeck, configId }) => {
        try {
          switch (operation) {
            case 'create': {
              if (!deckName) {
                throw new Error('create requires deckName');
              }
              const result = await ankiClient.deck.createDeck({ deck: deckName });
              return {
                content: [
                  {
                    type: 'text',
                    text: `✓ Created deck "${deckName}" (ID: ${result})`,
                  },
                ],
              };
            }
    
            case 'delete': {
              if (!deckNames || deckNames.length === 0) {
                throw new Error('delete requires deckNames');
              }
              await ankiClient.deck.deleteDecks({
                decks: deckNames,
                cardsToo: (deleteCards ?? true) as true,
              });
              return {
                content: [
                  {
                    type: 'text',
                    text: `✓ Deleted deck(s): ${deckNames.join(', ')}${deleteCards !== false ? ' (including cards)' : ''}`,
                  },
                ],
              };
            }
    
            case 'list': {
              const decks = await ankiClient.deck.deckNamesAndIds();
              const deckList = Object.entries(decks)
                .map(([name, id]) => `  • ${name} (ID: ${id})`)
                .join('\n');
              return {
                content: [
                  {
                    type: 'text',
                    text: `Decks (${Object.keys(decks).length}):\n${deckList}`,
                  },
                ],
              };
            }
    
            case 'get_stats': {
              if (!deckName) {
                throw new Error('get_stats requires deckName');
              }
              const stats = await ankiClient.deck.getDeckStats({ decks: [deckName] });
              return {
                content: [
                  {
                    type: 'text',
                    text: `Statistics for "${deckName}":\n${JSON.stringify(stats, null, 2)}`,
                  },
                ],
              };
            }
    
            case 'move_cards': {
              if (!cardIds || !targetDeck) {
                throw new Error('move_cards requires cardIds and targetDeck');
              }
              await ankiClient.deck.changeDeck({ cards: cardIds, deck: targetDeck });
              return {
                content: [
                  {
                    type: 'text',
                    text: `✓ Moved ${cardIds.length} card(s) to "${targetDeck}"`,
                  },
                ],
              };
            }
    
            case 'get_config': {
              if (!deckName) {
                throw new Error('get_config requires deckName');
              }
              const config = await ankiClient.deck.getDeckConfig({ deck: deckName });
              return {
                content: [
                  {
                    type: 'text',
                    text: `Config for "${deckName}":\n${JSON.stringify(config, null, 2)}`,
                  },
                ],
              };
            }
    
            case 'set_config': {
              if (!deckNames || !configId) {
                throw new Error('set_config requires deckNames and configId');
              }
              await ankiClient.deck.setDeckConfigId({ configId, decks: deckNames });
              return {
                content: [
                  {
                    type: 'text',
                    text: `✓ Applied config ${configId} to: ${deckNames.join(', ')}`,
                  },
                ],
              };
            }
    
            default:
              throw new Error(`Unknown operation: ${operation}`);
          }
        } catch (error) {
          throw new Error(
            `manage_decks failed: ${error instanceof Error ? error.message : String(error)}`
          );
        }
      }
  • Handler function implementing deck management operations: create, delete, list decks, get stats, move cards, manage config.
    async ({ operation, deckName, deckNames, deleteCards, cardIds, targetDeck, configId }) => {
      try {
        switch (operation) {
          case 'create': {
            if (!deckName) {
              throw new Error('create requires deckName');
            }
            const result = await ankiClient.deck.createDeck({ deck: deckName });
            return {
              content: [
                {
                  type: 'text',
                  text: `✓ Created deck "${deckName}" (ID: ${result})`,
                },
              ],
            };
          }
    
          case 'delete': {
            if (!deckNames || deckNames.length === 0) {
              throw new Error('delete requires deckNames');
            }
            await ankiClient.deck.deleteDecks({
              decks: deckNames,
              cardsToo: (deleteCards ?? true) as true,
            });
            return {
              content: [
                {
                  type: 'text',
                  text: `✓ Deleted deck(s): ${deckNames.join(', ')}${deleteCards !== false ? ' (including cards)' : ''}`,
                },
              ],
            };
          }
    
          case 'list': {
            const decks = await ankiClient.deck.deckNamesAndIds();
            const deckList = Object.entries(decks)
              .map(([name, id]) => `  • ${name} (ID: ${id})`)
              .join('\n');
            return {
              content: [
                {
                  type: 'text',
                  text: `Decks (${Object.keys(decks).length}):\n${deckList}`,
                },
              ],
            };
          }
    
          case 'get_stats': {
            if (!deckName) {
              throw new Error('get_stats requires deckName');
            }
            const stats = await ankiClient.deck.getDeckStats({ decks: [deckName] });
            return {
              content: [
                {
                  type: 'text',
                  text: `Statistics for "${deckName}":\n${JSON.stringify(stats, null, 2)}`,
                },
              ],
            };
          }
    
          case 'move_cards': {
            if (!cardIds || !targetDeck) {
              throw new Error('move_cards requires cardIds and targetDeck');
            }
            await ankiClient.deck.changeDeck({ cards: cardIds, deck: targetDeck });
            return {
              content: [
                {
                  type: 'text',
                  text: `✓ Moved ${cardIds.length} card(s) to "${targetDeck}"`,
                },
              ],
            };
          }
    
          case 'get_config': {
            if (!deckName) {
              throw new Error('get_config requires deckName');
            }
            const config = await ankiClient.deck.getDeckConfig({ deck: deckName });
            return {
              content: [
                {
                  type: 'text',
                  text: `Config for "${deckName}":\n${JSON.stringify(config, null, 2)}`,
                },
              ],
            };
          }
    
          case 'set_config': {
            if (!deckNames || !configId) {
              throw new Error('set_config requires deckNames and configId');
            }
            await ankiClient.deck.setDeckConfigId({ configId, decks: deckNames });
            return {
              content: [
                {
                  type: 'text',
                  text: `✓ Applied config ${configId} to: ${deckNames.join(', ')}`,
                },
              ],
            };
          }
    
          default:
            throw new Error(`Unknown operation: ${operation}`);
        }
      } catch (error) {
        throw new Error(
          `manage_decks failed: ${error instanceof Error ? error.message : String(error)}`
        );
      }
  • Zod schema defining input parameters for the manage_decks tool.
    {
      operation: z
        .enum(['create', 'delete', 'list', 'get_stats', 'move_cards', 'get_config', 'set_config'])
        .describe('Deck management operation'),
    
      deckName: z.string().optional().describe('Deck name'),
      deckNames: z.array(z.string()).optional().describe('Deck names (for batch operations)'),
      deleteCards: z.boolean().optional().describe('Delete cards when deleting deck'),
    
      cardIds: z.array(z.number()).optional().describe('Card IDs to move'),
      targetDeck: z.string().optional().describe('Target deck for moving cards'),
    
      configId: z.number().optional().describe('Config ID to apply'),
    },
Behavior1/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Tool has no description.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness1/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Tool has no description.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness1/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Tool has no description.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters1/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Tool has no description.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose1/5

Does the description clearly state what the tool does and how it differs from similar tools?

Tool has no description.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines1/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Tool has no description.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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