UNPKG

anki-mcp-http

Version:

Model Context Protocol server for Anki - enables AI assistants to interact with your Anki flashcards

76 lines 4.13 kB
"use strict"; var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; var GuiCurrentCardTool_1; Object.defineProperty(exports, "__esModule", { value: true }); exports.GuiCurrentCardTool = void 0; const common_1 = require("@nestjs/common"); const mcp_nest_1 = require("@rekog/mcp-nest"); const zod_1 = require("zod"); const anki_connect_client_1 = require("../../../clients/anki-connect.client"); const anki_utils_1 = require("../../../utils/anki.utils"); let GuiCurrentCardTool = GuiCurrentCardTool_1 = class GuiCurrentCardTool { ankiClient; logger = new common_1.Logger(GuiCurrentCardTool_1.name); constructor(ankiClient) { this.ankiClient = ankiClient; } async guiCurrentCard(_args, context) { try { this.logger.log('Getting current card information from GUI'); await context.reportProgress({ progress: 50, total: 100 }); const cardInfo = await this.ankiClient.invoke('guiCurrentCard'); await context.reportProgress({ progress: 100, total: 100 }); if (!cardInfo) { this.logger.log('Not currently in review mode'); return (0, anki_utils_1.createSuccessResponse)({ success: true, cardInfo: null, inReview: false, message: 'Not currently in review mode', hint: 'Open a deck in Anki and start reviewing to see current card information.', }); } this.logger.log(`Retrieved current card: ${cardInfo.cardId} from deck "${cardInfo.deckName}"`); return (0, anki_utils_1.createSuccessResponse)({ success: true, cardInfo, inReview: true, message: `Current card: ${cardInfo.cardId} from deck "${cardInfo.deckName}"`, hint: 'Use guiEditNote to edit the note associated with this card.', }); } catch (error) { this.logger.error('Failed to get current card information', error); return (0, anki_utils_1.createErrorResponse)(error, { hint: 'Make sure Anki is running and the GUI is visible', }); } } }; exports.GuiCurrentCardTool = GuiCurrentCardTool; __decorate([ (0, mcp_nest_1.Tool)({ name: 'guiCurrentCard', description: 'Get information about the current card displayed in review mode. Returns card details (question, answer, deck, model, etc.) or null if not in review. ' + 'CRITICAL: This tool is ONLY for note editing/creation workflows when user needs to check what card is currently displayed in the GUI. ' + 'NEVER use this for conducting review sessions. Use the dedicated review tools (get_due_cards, present_card, rate_card) instead. ' + 'IMPORTANT: Only use when user explicitly requests current card information.', parameters: zod_1.z.object({}), }), __metadata("design:type", Function), __metadata("design:paramtypes", [Object, Object]), __metadata("design:returntype", Promise) ], GuiCurrentCardTool.prototype, "guiCurrentCard", null); exports.GuiCurrentCardTool = GuiCurrentCardTool = GuiCurrentCardTool_1 = __decorate([ (0, common_1.Injectable)(), __metadata("design:paramtypes", [anki_connect_client_1.AnkiConnectClient]) ], GuiCurrentCardTool); //# sourceMappingURL=gui-current-card.tool.js.map