Skip to main content
Glama

study_session

Manage Anki flashcard study sessions by finding due cards, answering reviews, suspending cards, and tracking learning progress.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
operationYesStudy session operation
queryNoSearch query to find cards (for find_due)
cardIdsNoCard IDs to operate on
answersNoCard answers (for answer operation)
daysNoDays from today for due date (for reschedule)

Implementation Reference

  • Handler function implementing the core logic for the 'study_session' tool. Supports operations: find_due, answer, suspend, unsuspend, check_status, forget, relearn. Uses ankiClient to interact with Anki.
    async ({ operation, query, cardIds, answers }) => {
      try {
        switch (operation) {
          case 'find_due': {
            if (!query) {
              throw new Error('find_due requires query parameter');
            }
            const foundCardIds = await ankiClient.card.findCards({ query });
    
            if (foundCardIds.length > 0) {
              const dueStatus = await ankiClient.card.areDue({ cards: foundCardIds });
              const dueCards = foundCardIds.filter((_, idx) => dueStatus[idx]);
              return {
                content: [
                  {
                    type: 'text',
                    text: `Found ${foundCardIds.length} cards matching "${query}"\n${dueCards.length} are due for review now\nDue card IDs: [${dueCards.join(', ')}]`,
                  },
                ],
              };
            }
    
            return {
              content: [
                {
                  type: 'text',
                  text: `No cards found matching "${query}"`,
                },
              ],
            };
          }
    
          case 'answer': {
            if (!answers || answers.length === 0) {
              throw new Error('answer requires answers array');
            }
            const results = await ankiClient.card.answerCards({ answers });
            const successCount = results.filter(Boolean).length;
            return {
              content: [
                {
                  type: 'text',
                  text: `✓ Answered ${successCount}/${answers.length} cards successfully`,
                },
              ],
            };
          }
    
          case 'suspend': {
            if (!cardIds || cardIds.length === 0) {
              throw new Error('suspend requires cardIds');
            }
            await ankiClient.card.suspend({ cards: cardIds });
            return {
              content: [
                {
                  type: 'text',
                  text: `✓ Suspended ${cardIds.length} card(s)`,
                },
              ],
            };
          }
    
          case 'unsuspend': {
            if (!cardIds || cardIds.length === 0) {
              throw new Error('unsuspend requires cardIds');
            }
            await ankiClient.card.unsuspend({ cards: cardIds });
            return {
              content: [
                {
                  type: 'text',
                  text: `✓ Unsuspended ${cardIds.length} card(s)`,
                },
              ],
            };
          }
    
          case 'check_status': {
            if (!cardIds || cardIds.length === 0) {
              throw new Error('check_status requires cardIds');
            }
            const [dueStatus, suspendedStatus] = await Promise.all([
              ankiClient.card.areDue({ cards: cardIds }),
              ankiClient.card.areSuspended({ cards: cardIds }),
            ]);
    
            const statusInfo = cardIds.map((id, idx) => ({
              cardId: id,
              isDue: dueStatus[idx],
              isSuspended: suspendedStatus[idx],
            }));
    
            return {
              content: [
                {
                  type: 'text',
                  text: `Card status:\n${JSON.stringify(statusInfo, null, 2)}`,
                },
              ],
            };
          }
    
          case 'forget': {
            if (!cardIds || cardIds.length === 0) {
              throw new Error('forget requires cardIds');
            }
            await ankiClient.card.forgetCards({ cards: cardIds });
            return {
              content: [
                {
                  type: 'text',
                  text: `✓ Reset ${cardIds.length} card(s) to new status`,
                },
              ],
            };
          }
    
          case 'relearn': {
            if (!cardIds || cardIds.length === 0) {
              throw new Error('relearn requires cardIds');
            }
            await ankiClient.card.relearnCards({ cards: cardIds });
            return {
              content: [
                {
                  type: 'text',
                  text: `✓ Set ${cardIds.length} card(s) to relearn`,
                },
              ],
            };
          }
    
          default:
            throw new Error(`Unknown operation: ${operation}`);
        }
      } catch (error) {
        throw new Error(
          `study_session failed: ${error instanceof Error ? error.message : String(error)}`
        );
      }
    }
  • Zod input schema validation for the study_session tool parameters.
    {
      operation: z
        .enum(['find_due', 'answer', 'suspend', 'unsuspend', 'check_status', 'forget', 'relearn'])
        .describe('Study session operation'),
    
      query: z.string().optional().describe('Search query to find cards (for find_due)'),
    
      cardIds: z.array(z.number()).optional().describe('Card IDs to operate on'),
    
      answers: z
        .array(
          z.object({
            cardId: z.number(),
            ease: z.number().min(1).max(4).describe('1=Again, 2=Hard, 3=Good, 4=Easy'),
          })
        )
        .optional()
        .describe('Card answers (for answer operation)'),
    
      days: z.string().optional().describe('Days from today for due date (for reschedule)'),
    },
  • MCP server.tool registration call for the 'study_session' tool, including inline schema and handler.
    server.tool(
      'study_session',
      {
        operation: z
          .enum(['find_due', 'answer', 'suspend', 'unsuspend', 'check_status', 'forget', 'relearn'])
          .describe('Study session operation'),
    
        query: z.string().optional().describe('Search query to find cards (for find_due)'),
    
        cardIds: z.array(z.number()).optional().describe('Card IDs to operate on'),
    
        answers: z
          .array(
            z.object({
              cardId: z.number(),
              ease: z.number().min(1).max(4).describe('1=Again, 2=Hard, 3=Good, 4=Easy'),
            })
          )
          .optional()
          .describe('Card answers (for answer operation)'),
    
        days: z.string().optional().describe('Days from today for due date (for reschedule)'),
      },
      async ({ operation, query, cardIds, answers }) => {
        try {
          switch (operation) {
            case 'find_due': {
              if (!query) {
                throw new Error('find_due requires query parameter');
              }
              const foundCardIds = await ankiClient.card.findCards({ query });
    
              if (foundCardIds.length > 0) {
                const dueStatus = await ankiClient.card.areDue({ cards: foundCardIds });
                const dueCards = foundCardIds.filter((_, idx) => dueStatus[idx]);
                return {
                  content: [
                    {
                      type: 'text',
                      text: `Found ${foundCardIds.length} cards matching "${query}"\n${dueCards.length} are due for review now\nDue card IDs: [${dueCards.join(', ')}]`,
                    },
                  ],
                };
              }
    
              return {
                content: [
                  {
                    type: 'text',
                    text: `No cards found matching "${query}"`,
                  },
                ],
              };
            }
    
            case 'answer': {
              if (!answers || answers.length === 0) {
                throw new Error('answer requires answers array');
              }
              const results = await ankiClient.card.answerCards({ answers });
              const successCount = results.filter(Boolean).length;
              return {
                content: [
                  {
                    type: 'text',
                    text: `✓ Answered ${successCount}/${answers.length} cards successfully`,
                  },
                ],
              };
            }
    
            case 'suspend': {
              if (!cardIds || cardIds.length === 0) {
                throw new Error('suspend requires cardIds');
              }
              await ankiClient.card.suspend({ cards: cardIds });
              return {
                content: [
                  {
                    type: 'text',
                    text: `✓ Suspended ${cardIds.length} card(s)`,
                  },
                ],
              };
            }
    
            case 'unsuspend': {
              if (!cardIds || cardIds.length === 0) {
                throw new Error('unsuspend requires cardIds');
              }
              await ankiClient.card.unsuspend({ cards: cardIds });
              return {
                content: [
                  {
                    type: 'text',
                    text: `✓ Unsuspended ${cardIds.length} card(s)`,
                  },
                ],
              };
            }
    
            case 'check_status': {
              if (!cardIds || cardIds.length === 0) {
                throw new Error('check_status requires cardIds');
              }
              const [dueStatus, suspendedStatus] = await Promise.all([
                ankiClient.card.areDue({ cards: cardIds }),
                ankiClient.card.areSuspended({ cards: cardIds }),
              ]);
    
              const statusInfo = cardIds.map((id, idx) => ({
                cardId: id,
                isDue: dueStatus[idx],
                isSuspended: suspendedStatus[idx],
              }));
    
              return {
                content: [
                  {
                    type: 'text',
                    text: `Card status:\n${JSON.stringify(statusInfo, null, 2)}`,
                  },
                ],
              };
            }
    
            case 'forget': {
              if (!cardIds || cardIds.length === 0) {
                throw new Error('forget requires cardIds');
              }
              await ankiClient.card.forgetCards({ cards: cardIds });
              return {
                content: [
                  {
                    type: 'text',
                    text: `✓ Reset ${cardIds.length} card(s) to new status`,
                  },
                ],
              };
            }
    
            case 'relearn': {
              if (!cardIds || cardIds.length === 0) {
                throw new Error('relearn requires cardIds');
              }
              await ankiClient.card.relearnCards({ cards: cardIds });
              return {
                content: [
                  {
                    type: 'text',
                    text: `✓ Set ${cardIds.length} card(s) to relearn`,
                  },
                ],
              };
            }
    
            default:
              throw new Error(`Unknown operation: ${operation}`);
          }
        } catch (error) {
          throw new Error(
            `study_session failed: ${error instanceof Error ? error.message : String(error)}`
          );
        }
      }
    );
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