@ankimcp/anki-mcp-server 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +7 -0
- package/README.md +756 -0
- package/bin/ankimcp.js +12 -0
- package/dist/anki-config.service.d.ts +10 -0
- package/dist/anki-config.service.js +42 -0
- package/dist/anki-config.service.js.map +1 -0
- package/dist/app.module.d.ts +5 -0
- package/dist/app.module.js +84 -0
- package/dist/app.module.js.map +1 -0
- package/dist/bootstrap.d.ts +3 -0
- package/dist/bootstrap.js +39 -0
- package/dist/bootstrap.js.map +1 -0
- package/dist/cli.d.ts +9 -0
- package/dist/cli.js +114 -0
- package/dist/cli.js.map +1 -0
- package/dist/http/guards/origin-validation.guard.d.ts +7 -0
- package/dist/http/guards/origin-validation.guard.js +52 -0
- package/dist/http/guards/origin-validation.guard.js.map +1 -0
- package/dist/main-http.d.ts +1 -0
- package/dist/main-http.js +42 -0
- package/dist/main-http.js.map +1 -0
- package/dist/main-stdio.d.ts +1 -0
- package/dist/main-stdio.js +20 -0
- package/dist/main-stdio.js.map +1 -0
- package/dist/mcp/clients/__mocks__/anki-connect.client.d.ts +6 -0
- package/dist/mcp/clients/__mocks__/anki-connect.client.js +18 -0
- package/dist/mcp/clients/__mocks__/anki-connect.client.js.map +1 -0
- package/dist/mcp/clients/anki-connect.client.d.ts +15 -0
- package/dist/mcp/clients/anki-connect.client.js +145 -0
- package/dist/mcp/clients/anki-connect.client.js.map +1 -0
- package/dist/mcp/config/anki-config.interface.d.ts +7 -0
- package/dist/mcp/config/anki-config.interface.js +5 -0
- package/dist/mcp/config/anki-config.interface.js.map +1 -0
- package/dist/mcp/primitives/essential/index.d.ts +32 -0
- package/dist/mcp/primitives/essential/index.js +130 -0
- package/dist/mcp/primitives/essential/index.js.map +1 -0
- package/dist/mcp/primitives/essential/prompts/review-session.prompt.d.ts +12 -0
- package/dist/mcp/primitives/essential/prompts/review-session.prompt.js +113 -0
- package/dist/mcp/primitives/essential/prompts/review-session.prompt.js.map +1 -0
- package/dist/mcp/primitives/essential/prompts/twenty-rules.prompt/content.md +195 -0
- package/dist/mcp/primitives/essential/prompts/twenty-rules.prompt/index.d.ts +12 -0
- package/dist/mcp/primitives/essential/prompts/twenty-rules.prompt/index.js +89 -0
- package/dist/mcp/primitives/essential/prompts/twenty-rules.prompt/index.js.map +1 -0
- package/dist/mcp/primitives/essential/resources/system-info.resource.d.ts +21 -0
- package/dist/mcp/primitives/essential/resources/system-info.resource.js +115 -0
- package/dist/mcp/primitives/essential/resources/system-info.resource.js.map +1 -0
- package/dist/mcp/primitives/essential/tools/add-note.tool.d.ts +93 -0
- package/dist/mcp/primitives/essential/tools/add-note.tool.js +185 -0
- package/dist/mcp/primitives/essential/tools/add-note.tool.js.map +1 -0
- package/dist/mcp/primitives/essential/tools/create-deck.tool.d.ts +83 -0
- package/dist/mcp/primitives/essential/tools/create-deck.tool.js +121 -0
- package/dist/mcp/primitives/essential/tools/create-deck.tool.js.map +1 -0
- package/dist/mcp/primitives/essential/tools/create-model.tool.d.ts +88 -0
- package/dist/mcp/primitives/essential/tools/create-model.tool.js +144 -0
- package/dist/mcp/primitives/essential/tools/create-model.tool.js.map +1 -0
- package/dist/mcp/primitives/essential/tools/delete-notes.tool.d.ts +84 -0
- package/dist/mcp/primitives/essential/tools/delete-notes.tool.js +120 -0
- package/dist/mcp/primitives/essential/tools/delete-notes.tool.js.map +1 -0
- package/dist/mcp/primitives/essential/tools/find-notes.tool.d.ts +83 -0
- package/dist/mcp/primitives/essential/tools/find-notes.tool.js +106 -0
- package/dist/mcp/primitives/essential/tools/find-notes.tool.js.map +1 -0
- package/dist/mcp/primitives/essential/tools/get-due-cards.tool.d.ts +84 -0
- package/dist/mcp/primitives/essential/tools/get-due-cards.tool.js +108 -0
- package/dist/mcp/primitives/essential/tools/get-due-cards.tool.js.map +1 -0
- package/dist/mcp/primitives/essential/tools/list-decks.tool.d.ts +83 -0
- package/dist/mcp/primitives/essential/tools/list-decks.tool.js +117 -0
- package/dist/mcp/primitives/essential/tools/list-decks.tool.js.map +1 -0
- package/dist/mcp/primitives/essential/tools/mediaActions/actions/deleteMediaFile.action.d.ts +10 -0
- package/dist/mcp/primitives/essential/tools/mediaActions/actions/deleteMediaFile.action.js +18 -0
- package/dist/mcp/primitives/essential/tools/mediaActions/actions/deleteMediaFile.action.js.map +1 -0
- package/dist/mcp/primitives/essential/tools/mediaActions/actions/getMediaFilesNames.action.d.ts +12 -0
- package/dist/mcp/primitives/essential/tools/mediaActions/actions/getMediaFilesNames.action.js +22 -0
- package/dist/mcp/primitives/essential/tools/mediaActions/actions/getMediaFilesNames.action.js.map +1 -0
- package/dist/mcp/primitives/essential/tools/mediaActions/actions/retrieveMediaFile.action.d.ts +12 -0
- package/dist/mcp/primitives/essential/tools/mediaActions/actions/retrieveMediaFile.action.js +29 -0
- package/dist/mcp/primitives/essential/tools/mediaActions/actions/retrieveMediaFile.action.js.map +1 -0
- package/dist/mcp/primitives/essential/tools/mediaActions/actions/storeMediaFile.action.d.ts +15 -0
- package/dist/mcp/primitives/essential/tools/mediaActions/actions/storeMediaFile.action.js +41 -0
- package/dist/mcp/primitives/essential/tools/mediaActions/actions/storeMediaFile.action.js.map +1 -0
- package/dist/mcp/primitives/essential/tools/mediaActions/index.d.ts +5 -0
- package/dist/mcp/primitives/essential/tools/mediaActions/index.js +6 -0
- package/dist/mcp/primitives/essential/tools/mediaActions/index.js.map +1 -0
- package/dist/mcp/primitives/essential/tools/mediaActions/mediaActions.tool.d.ts +89 -0
- package/dist/mcp/primitives/essential/tools/mediaActions/mediaActions.tool.js +141 -0
- package/dist/mcp/primitives/essential/tools/mediaActions/mediaActions.tool.js.map +1 -0
- package/dist/mcp/primitives/essential/tools/model-field-names.tool.d.ts +83 -0
- package/dist/mcp/primitives/essential/tools/model-field-names.tool.js +119 -0
- package/dist/mcp/primitives/essential/tools/model-field-names.tool.js.map +1 -0
- package/dist/mcp/primitives/essential/tools/model-names.tool.d.ts +81 -0
- package/dist/mcp/primitives/essential/tools/model-names.tool.js +80 -0
- package/dist/mcp/primitives/essential/tools/model-names.tool.js.map +1 -0
- package/dist/mcp/primitives/essential/tools/model-styling.tool.d.ts +83 -0
- package/dist/mcp/primitives/essential/tools/model-styling.tool.js +93 -0
- package/dist/mcp/primitives/essential/tools/model-styling.tool.js.map +1 -0
- package/dist/mcp/primitives/essential/tools/notes-info.tool.d.ts +83 -0
- package/dist/mcp/primitives/essential/tools/notes-info.tool.js +111 -0
- package/dist/mcp/primitives/essential/tools/notes-info.tool.js.map +1 -0
- package/dist/mcp/primitives/essential/tools/present-card.tool.d.ts +84 -0
- package/dist/mcp/primitives/essential/tools/present-card.tool.js +100 -0
- package/dist/mcp/primitives/essential/tools/present-card.tool.js.map +1 -0
- package/dist/mcp/primitives/essential/tools/rate-card.tool.d.ts +84 -0
- package/dist/mcp/primitives/essential/tools/rate-card.tool.js +101 -0
- package/dist/mcp/primitives/essential/tools/rate-card.tool.js.map +1 -0
- package/dist/mcp/primitives/essential/tools/sync.tool.d.ts +81 -0
- package/dist/mcp/primitives/essential/tools/sync.tool.js +61 -0
- package/dist/mcp/primitives/essential/tools/sync.tool.js.map +1 -0
- package/dist/mcp/primitives/essential/tools/update-model-styling.tool.d.ts +84 -0
- package/dist/mcp/primitives/essential/tools/update-model-styling.tool.js +119 -0
- package/dist/mcp/primitives/essential/tools/update-model-styling.tool.js.map +1 -0
- package/dist/mcp/primitives/essential/tools/update-note-fields.tool.d.ts +96 -0
- package/dist/mcp/primitives/essential/tools/update-note-fields.tool.js +154 -0
- package/dist/mcp/primitives/essential/tools/update-note-fields.tool.js.map +1 -0
- package/dist/mcp/primitives/gui/index.d.ts +23 -0
- package/dist/mcp/primitives/gui/index.js +94 -0
- package/dist/mcp/primitives/gui/index.js.map +1 -0
- package/dist/mcp/primitives/gui/tools/gui-add-cards.tool.d.ts +88 -0
- package/dist/mcp/primitives/gui/tools/gui-add-cards.tool.js +111 -0
- package/dist/mcp/primitives/gui/tools/gui-add-cards.tool.js.map +1 -0
- package/dist/mcp/primitives/gui/tools/gui-browse.tool.d.ts +87 -0
- package/dist/mcp/primitives/gui/tools/gui-browse.tool.js +99 -0
- package/dist/mcp/primitives/gui/tools/gui-browse.tool.js.map +1 -0
- package/dist/mcp/primitives/gui/tools/gui-current-card.tool.d.ts +81 -0
- package/dist/mcp/primitives/gui/tools/gui-current-card.tool.js +76 -0
- package/dist/mcp/primitives/gui/tools/gui-current-card.tool.js.map +1 -0
- package/dist/mcp/primitives/gui/tools/gui-deck-browser.tool.d.ts +81 -0
- package/dist/mcp/primitives/gui/tools/gui-deck-browser.tool.js +64 -0
- package/dist/mcp/primitives/gui/tools/gui-deck-browser.tool.js.map +1 -0
- package/dist/mcp/primitives/gui/tools/gui-deck-overview.tool.d.ts +83 -0
- package/dist/mcp/primitives/gui/tools/gui-deck-overview.tool.js +88 -0
- package/dist/mcp/primitives/gui/tools/gui-deck-overview.tool.js.map +1 -0
- package/dist/mcp/primitives/gui/tools/gui-edit-note.tool.d.ts +83 -0
- package/dist/mcp/primitives/gui/tools/gui-edit-note.tool.js +80 -0
- package/dist/mcp/primitives/gui/tools/gui-edit-note.tool.js.map +1 -0
- package/dist/mcp/primitives/gui/tools/gui-select-card.tool.d.ts +83 -0
- package/dist/mcp/primitives/gui/tools/gui-select-card.tool.js +90 -0
- package/dist/mcp/primitives/gui/tools/gui-select-card.tool.js.map +1 -0
- package/dist/mcp/primitives/gui/tools/gui-selected-notes.tool.d.ts +81 -0
- package/dist/mcp/primitives/gui/tools/gui-selected-notes.tool.js +83 -0
- package/dist/mcp/primitives/gui/tools/gui-selected-notes.tool.js.map +1 -0
- package/dist/mcp/primitives/gui/tools/gui-show-answer.tool.d.ts +81 -0
- package/dist/mcp/primitives/gui/tools/gui-show-answer.tool.js +74 -0
- package/dist/mcp/primitives/gui/tools/gui-show-answer.tool.js.map +1 -0
- package/dist/mcp/primitives/gui/tools/gui-show-question.tool.d.ts +81 -0
- package/dist/mcp/primitives/gui/tools/gui-show-question.tool.js +74 -0
- package/dist/mcp/primitives/gui/tools/gui-show-question.tool.js.map +1 -0
- package/dist/mcp/primitives/gui/tools/gui-undo.tool.d.ts +81 -0
- package/dist/mcp/primitives/gui/tools/gui-undo.tool.js +74 -0
- package/dist/mcp/primitives/gui/tools/gui-undo.tool.js.map +1 -0
- package/dist/mcp/types/anki.types.d.ts +180 -0
- package/dist/mcp/types/anki.types.js +18 -0
- package/dist/mcp/types/anki.types.js.map +1 -0
- package/dist/mcp/utils/anki.utils.d.ts +19 -0
- package/dist/mcp/utils/anki.utils.js +157 -0
- package/dist/mcp/utils/anki.utils.js.map +1 -0
- package/dist/mcp/utils/markdown.utils.d.ts +4 -0
- package/dist/mcp/utils/markdown.utils.js +60 -0
- package/dist/mcp/utils/markdown.utils.js.map +1 -0
- package/dist/mcp/utils/mcpb-workarounds.d.ts +1 -0
- package/dist/mcp/utils/mcpb-workarounds.js +13 -0
- package/dist/mcp/utils/mcpb-workarounds.js.map +1 -0
- package/dist/services/ngrok.service.d.ts +15 -0
- package/dist/services/ngrok.service.js +120 -0
- package/dist/services/ngrok.service.js.map +1 -0
- package/dist/test-fixtures/mock-data.d.ts +126 -0
- package/dist/test-fixtures/mock-data.js +112 -0
- package/dist/test-fixtures/mock-data.js.map +1 -0
- package/dist/test-fixtures/test-helpers.d.ts +12 -0
- package/dist/test-fixtures/test-helpers.js +24 -0
- package/dist/test-fixtures/test-helpers.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/package.json +168 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
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;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var GuiDeckBrowserTool_1;
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.GuiDeckBrowserTool = void 0;
|
|
14
|
+
const common_1 = require("@nestjs/common");
|
|
15
|
+
const mcp_nest_1 = require("@rekog/mcp-nest");
|
|
16
|
+
const zod_1 = require("zod");
|
|
17
|
+
const anki_connect_client_1 = require("../../../clients/anki-connect.client");
|
|
18
|
+
const anki_utils_1 = require("../../../utils/anki.utils");
|
|
19
|
+
let GuiDeckBrowserTool = GuiDeckBrowserTool_1 = class GuiDeckBrowserTool {
|
|
20
|
+
ankiClient;
|
|
21
|
+
logger = new common_1.Logger(GuiDeckBrowserTool_1.name);
|
|
22
|
+
constructor(ankiClient) {
|
|
23
|
+
this.ankiClient = ankiClient;
|
|
24
|
+
}
|
|
25
|
+
async guiDeckBrowser(_args, context) {
|
|
26
|
+
try {
|
|
27
|
+
this.logger.log("Opening Deck Browser");
|
|
28
|
+
await context.reportProgress({ progress: 50, total: 100 });
|
|
29
|
+
await this.ankiClient.invoke("guiDeckBrowser");
|
|
30
|
+
await context.reportProgress({ progress: 100, total: 100 });
|
|
31
|
+
this.logger.log("Deck Browser opened");
|
|
32
|
+
return (0, anki_utils_1.createSuccessResponse)({
|
|
33
|
+
success: true,
|
|
34
|
+
message: "Deck Browser opened successfully",
|
|
35
|
+
hint: "All decks are now visible in the Anki GUI. User can select a deck to study or manage.",
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
this.logger.error("Failed to open Deck Browser", error);
|
|
40
|
+
return (0, anki_utils_1.createErrorResponse)(error, {
|
|
41
|
+
hint: "Make sure Anki is running and the GUI is visible",
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
exports.GuiDeckBrowserTool = GuiDeckBrowserTool;
|
|
47
|
+
__decorate([
|
|
48
|
+
(0, mcp_nest_1.Tool)({
|
|
49
|
+
name: "guiDeckBrowser",
|
|
50
|
+
description: "Open Anki Deck Browser dialog showing all decks. " +
|
|
51
|
+
"IMPORTANT: Only use when user explicitly requests opening the deck browser. " +
|
|
52
|
+
"This tool is for deck management and organization workflows, NOT for review sessions. " +
|
|
53
|
+
"Use this when user wants to see all decks or manage deck structure.",
|
|
54
|
+
parameters: zod_1.z.object({}),
|
|
55
|
+
}),
|
|
56
|
+
__metadata("design:type", Function),
|
|
57
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
58
|
+
__metadata("design:returntype", Promise)
|
|
59
|
+
], GuiDeckBrowserTool.prototype, "guiDeckBrowser", null);
|
|
60
|
+
exports.GuiDeckBrowserTool = GuiDeckBrowserTool = GuiDeckBrowserTool_1 = __decorate([
|
|
61
|
+
(0, common_1.Injectable)(),
|
|
62
|
+
__metadata("design:paramtypes", [anki_connect_client_1.AnkiConnectClient])
|
|
63
|
+
], GuiDeckBrowserTool);
|
|
64
|
+
//# sourceMappingURL=gui-deck-browser.tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gui-deck-browser.tool.js","sourceRoot":"","sources":["../../../../../src/mcp/primitives/gui/tools/gui-deck-browser.tool.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAAoD;AACpD,8CAAuC;AAEvC,6BAAwB;AACxB,8EAAsE;AACtE,0DAGgC;AAMzB,IAAM,kBAAkB,0BAAxB,MAAM,kBAAkB;IAGA;IAFZ,MAAM,GAAG,IAAI,eAAM,CAAC,oBAAkB,CAAC,IAAI,CAAC,CAAC;IAE9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1,83 @@
|
|
|
1
|
+
import type { Context } from "@rekog/mcp-nest";
|
|
2
|
+
import { AnkiConnectClient } from "@/mcp/clients/anki-connect.client";
|
|
3
|
+
export declare class GuiDeckOverviewTool {
|
|
4
|
+
private readonly ankiClient;
|
|
5
|
+
private readonly logger;
|
|
6
|
+
constructor(ankiClient: AnkiConnectClient);
|
|
7
|
+
guiDeckOverview({ name }: {
|
|
8
|
+
name: string;
|
|
9
|
+
}, context: Context): Promise<{
|
|
10
|
+
[x: string]: unknown;
|
|
11
|
+
content: ({
|
|
12
|
+
[x: string]: unknown;
|
|
13
|
+
type: "text";
|
|
14
|
+
text: string;
|
|
15
|
+
_meta?: {
|
|
16
|
+
[x: string]: unknown;
|
|
17
|
+
} | undefined;
|
|
18
|
+
} | {
|
|
19
|
+
[x: string]: unknown;
|
|
20
|
+
type: "image";
|
|
21
|
+
data: string;
|
|
22
|
+
mimeType: string;
|
|
23
|
+
_meta?: {
|
|
24
|
+
[x: string]: unknown;
|
|
25
|
+
} | undefined;
|
|
26
|
+
} | {
|
|
27
|
+
[x: string]: unknown;
|
|
28
|
+
type: "audio";
|
|
29
|
+
data: string;
|
|
30
|
+
mimeType: string;
|
|
31
|
+
_meta?: {
|
|
32
|
+
[x: string]: unknown;
|
|
33
|
+
} | undefined;
|
|
34
|
+
} | {
|
|
35
|
+
[x: string]: unknown;
|
|
36
|
+
type: "resource_link";
|
|
37
|
+
name: string;
|
|
38
|
+
uri: string;
|
|
39
|
+
_meta?: {
|
|
40
|
+
[x: string]: unknown;
|
|
41
|
+
} | undefined;
|
|
42
|
+
mimeType?: string | undefined;
|
|
43
|
+
title?: string | undefined;
|
|
44
|
+
description?: string | undefined;
|
|
45
|
+
icons?: {
|
|
46
|
+
[x: string]: unknown;
|
|
47
|
+
src: string;
|
|
48
|
+
mimeType?: string | undefined;
|
|
49
|
+
sizes?: string[] | undefined;
|
|
50
|
+
}[] | undefined;
|
|
51
|
+
} | {
|
|
52
|
+
[x: string]: unknown;
|
|
53
|
+
type: "resource";
|
|
54
|
+
resource: {
|
|
55
|
+
[x: string]: unknown;
|
|
56
|
+
text: string;
|
|
57
|
+
uri: string;
|
|
58
|
+
_meta?: {
|
|
59
|
+
[x: string]: unknown;
|
|
60
|
+
} | undefined;
|
|
61
|
+
mimeType?: string | undefined;
|
|
62
|
+
} | {
|
|
63
|
+
[x: string]: unknown;
|
|
64
|
+
uri: string;
|
|
65
|
+
blob: string;
|
|
66
|
+
_meta?: {
|
|
67
|
+
[x: string]: unknown;
|
|
68
|
+
} | undefined;
|
|
69
|
+
mimeType?: string | undefined;
|
|
70
|
+
};
|
|
71
|
+
_meta?: {
|
|
72
|
+
[x: string]: unknown;
|
|
73
|
+
} | undefined;
|
|
74
|
+
})[];
|
|
75
|
+
_meta?: {
|
|
76
|
+
[x: string]: unknown;
|
|
77
|
+
} | undefined;
|
|
78
|
+
structuredContent?: {
|
|
79
|
+
[x: string]: unknown;
|
|
80
|
+
} | undefined;
|
|
81
|
+
isError?: boolean | undefined;
|
|
82
|
+
}>;
|
|
83
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
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;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var GuiDeckOverviewTool_1;
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.GuiDeckOverviewTool = void 0;
|
|
14
|
+
const common_1 = require("@nestjs/common");
|
|
15
|
+
const mcp_nest_1 = require("@rekog/mcp-nest");
|
|
16
|
+
const zod_1 = require("zod");
|
|
17
|
+
const anki_connect_client_1 = require("../../../clients/anki-connect.client");
|
|
18
|
+
const anki_utils_1 = require("../../../utils/anki.utils");
|
|
19
|
+
let GuiDeckOverviewTool = GuiDeckOverviewTool_1 = class GuiDeckOverviewTool {
|
|
20
|
+
ankiClient;
|
|
21
|
+
logger = new common_1.Logger(GuiDeckOverviewTool_1.name);
|
|
22
|
+
constructor(ankiClient) {
|
|
23
|
+
this.ankiClient = ankiClient;
|
|
24
|
+
}
|
|
25
|
+
async guiDeckOverview({ name }, context) {
|
|
26
|
+
try {
|
|
27
|
+
this.logger.log(`Opening Deck Overview for deck "${name}"`);
|
|
28
|
+
await context.reportProgress({ progress: 50, total: 100 });
|
|
29
|
+
const success = await this.ankiClient.invoke("guiDeckOverview", {
|
|
30
|
+
name,
|
|
31
|
+
});
|
|
32
|
+
await context.reportProgress({ progress: 100, total: 100 });
|
|
33
|
+
if (!success) {
|
|
34
|
+
this.logger.warn(`Failed to open Deck Overview for deck "${name}"`);
|
|
35
|
+
return (0, anki_utils_1.createErrorResponse)(new Error(`Failed to open Deck Overview for deck "${name}"`), {
|
|
36
|
+
deckName: name,
|
|
37
|
+
hint: "Deck not found or Anki GUI is not responding. Use list_decks to see available decks.",
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
this.logger.log(`Deck Overview opened for deck "${name}"`);
|
|
41
|
+
return (0, anki_utils_1.createSuccessResponse)({
|
|
42
|
+
success: true,
|
|
43
|
+
deckName: name,
|
|
44
|
+
message: `Deck Overview opened for deck "${name}"`,
|
|
45
|
+
hint: "The deck statistics and study options are now visible in the Anki GUI.",
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
this.logger.error("Failed to open Deck Overview", error);
|
|
50
|
+
if (error instanceof Error) {
|
|
51
|
+
if (error.message.includes("not found") ||
|
|
52
|
+
error.message.includes("invalid")) {
|
|
53
|
+
return (0, anki_utils_1.createErrorResponse)(error, {
|
|
54
|
+
deckName: name,
|
|
55
|
+
hint: "Deck not found. Use list_decks to see available decks.",
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return (0, anki_utils_1.createErrorResponse)(error, {
|
|
60
|
+
deckName: name,
|
|
61
|
+
hint: "Make sure Anki is running and the deck name is correct",
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
exports.GuiDeckOverviewTool = GuiDeckOverviewTool;
|
|
67
|
+
__decorate([
|
|
68
|
+
(0, mcp_nest_1.Tool)({
|
|
69
|
+
name: "guiDeckOverview",
|
|
70
|
+
description: "Open Anki Deck Overview dialog for a specific deck. Shows deck statistics and study options. Returns true if succeeded. " +
|
|
71
|
+
"IMPORTANT: Only use when user explicitly requests opening deck overview. " +
|
|
72
|
+
"This tool is for deck management and note organization workflows, NOT for review sessions.",
|
|
73
|
+
parameters: zod_1.z.object({
|
|
74
|
+
name: zod_1.z
|
|
75
|
+
.string()
|
|
76
|
+
.min(1)
|
|
77
|
+
.describe("Deck name to open (get from list_decks)"),
|
|
78
|
+
}),
|
|
79
|
+
}),
|
|
80
|
+
__metadata("design:type", Function),
|
|
81
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
82
|
+
__metadata("design:returntype", Promise)
|
|
83
|
+
], GuiDeckOverviewTool.prototype, "guiDeckOverview", null);
|
|
84
|
+
exports.GuiDeckOverviewTool = GuiDeckOverviewTool = GuiDeckOverviewTool_1 = __decorate([
|
|
85
|
+
(0, common_1.Injectable)(),
|
|
86
|
+
__metadata("design:paramtypes", [anki_connect_client_1.AnkiConnectClient])
|
|
87
|
+
], GuiDeckOverviewTool);
|
|
88
|
+
//# sourceMappingURL=gui-deck-overview.tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gui-deck-overview.tool.js","sourceRoot":"","sources":["../../../../../src/mcp/primitives/gui/tools/gui-deck-overview.tool.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAAoD;AACpD,8CAAuC;AAEvC,6BAAwB;AACxB,8EAAsE;AACtE,0DAGgC;AAMzB,IAAM,mBAAmB,2BAAzB,MAAM,mBAAmB;IAGD;IAFZ,MAAM,GAAG,IAAI,eAAM,CAAC,qBAAmB,CAAC,IAAI,CAAC,CAAC;IAE/D,YAA6B,UAA6B;QAA7B,eAAU,GAAV,UAAU,CAAmB;IAAG,CAAC;IAexD,AAAN,KAAK,CAAC,eAAe,CAAC,EAAE,IAAI,EAAoB,EAAE,OAAgB;QAChE,IAAI,CAAC;YACH,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,mCAAmC,IAAI,GAAG,CAAC,CAAC;YAC5D,MAAM,OAAO,CAAC,cAAc,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC;YAG3D,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,MAAM,CAAU,iBAAiB,EAAE;gBACvE,IAAI;aACL,CAAC,CAAC;YAEH,MAAM,OAAO,CAAC,cAAc,CAAC,EAAE,QAAQ,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC;YAE5D,IAAI,CAAC,OAAO,EAAE,CAAC;gBACb,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,0CAA0C,IAAI,GAAG,CAAC,CAAC;gBACpE,OAAO,IAAA,gCAAmB,EACxB,IAAI,KAAK,CAAC,0CAA0C,IAAI,GAAG,CAAC,EAC5D;oBACE,QAAQ,EAAE,IAAI;oBACd,IAAI,EAAE,sFAAsF;iBAC7F,CACF,CAAC;YACJ,CAAC;YAED,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,kC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og/mcp-nest";
|
|
2
|
+
import { AnkiConnectClient } from "@/mcp/clients/anki-connect.client";
|
|
3
|
+
export declare class GuiEditNoteTool {
|
|
4
|
+
private readonly ankiClient;
|
|
5
|
+
private readonly logger;
|
|
6
|
+
constructor(ankiClient: AnkiConnectClient);
|
|
7
|
+
guiEditNote({ note }: {
|
|
8
|
+
note: number;
|
|
9
|
+
}, context: Context): Promise<{
|
|
10
|
+
[x: string]: unknown;
|
|
11
|
+
content: ({
|
|
12
|
+
[x: string]: unknown;
|
|
13
|
+
type: "text";
|
|
14
|
+
text: string;
|
|
15
|
+
_meta?: {
|
|
16
|
+
[x: string]: unknown;
|
|
17
|
+
} | undefined;
|
|
18
|
+
} | {
|
|
19
|
+
[x: string]: unknown;
|
|
20
|
+
type: "image";
|
|
21
|
+
data: string;
|
|
22
|
+
mimeType: string;
|
|
23
|
+
_meta?: {
|
|
24
|
+
[x: string]: unknown;
|
|
25
|
+
} | undefined;
|
|
26
|
+
} | {
|
|
27
|
+
[x: string]: unknown;
|
|
28
|
+
type: "audio";
|
|
29
|
+
data: string;
|
|
30
|
+
mimeType: string;
|
|
31
|
+
_meta?: {
|
|
32
|
+
[x: string]: unknown;
|
|
33
|
+
} | undefined;
|
|
34
|
+
} | {
|
|
35
|
+
[x: string]: unknown;
|
|
36
|
+
type: "resource_link";
|
|
37
|
+
name: string;
|
|
38
|
+
uri: string;
|
|
39
|
+
_meta?: {
|
|
40
|
+
[x: string]: unknown;
|
|
41
|
+
} | undefined;
|
|
42
|
+
mimeType?: string | undefined;
|
|
43
|
+
title?: string | undefined;
|
|
44
|
+
description?: string | undefined;
|
|
45
|
+
icons?: {
|
|
46
|
+
[x: string]: unknown;
|
|
47
|
+
src: string;
|
|
48
|
+
mimeType?: string | undefined;
|
|
49
|
+
sizes?: string[] | undefined;
|
|
50
|
+
}[] | undefined;
|
|
51
|
+
} | {
|
|
52
|
+
[x: string]: unknown;
|
|
53
|
+
type: "resource";
|
|
54
|
+
resource: {
|
|
55
|
+
[x: string]: unknown;
|
|
56
|
+
text: string;
|
|
57
|
+
uri: string;
|
|
58
|
+
_meta?: {
|
|
59
|
+
[x: string]: unknown;
|
|
60
|
+
} | undefined;
|
|
61
|
+
mimeType?: string | undefined;
|
|
62
|
+
} | {
|
|
63
|
+
[x: string]: unknown;
|
|
64
|
+
uri: string;
|
|
65
|
+
blob: string;
|
|
66
|
+
_meta?: {
|
|
67
|
+
[x: string]: unknown;
|
|
68
|
+
} | undefined;
|
|
69
|
+
mimeType?: string | undefined;
|
|
70
|
+
};
|
|
71
|
+
_meta?: {
|
|
72
|
+
[x: string]: unknown;
|
|
73
|
+
} | undefined;
|
|
74
|
+
})[];
|
|
75
|
+
_meta?: {
|
|
76
|
+
[x: string]: unknown;
|
|
77
|
+
} | undefined;
|
|
78
|
+
structuredContent?: {
|
|
79
|
+
[x: string]: unknown;
|
|
80
|
+
} | undefined;
|
|
81
|
+
isError?: boolean | undefined;
|
|
82
|
+
}>;
|
|
83
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
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;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var GuiEditNoteTool_1;
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.GuiEditNoteTool = void 0;
|
|
14
|
+
const common_1 = require("@nestjs/common");
|
|
15
|
+
const mcp_nest_1 = require("@rekog/mcp-nest");
|
|
16
|
+
const zod_1 = require("zod");
|
|
17
|
+
const anki_connect_client_1 = require("../../../clients/anki-connect.client");
|
|
18
|
+
const anki_utils_1 = require("../../../utils/anki.utils");
|
|
19
|
+
let GuiEditNoteTool = GuiEditNoteTool_1 = class GuiEditNoteTool {
|
|
20
|
+
ankiClient;
|
|
21
|
+
logger = new common_1.Logger(GuiEditNoteTool_1.name);
|
|
22
|
+
constructor(ankiClient) {
|
|
23
|
+
this.ankiClient = ankiClient;
|
|
24
|
+
}
|
|
25
|
+
async guiEditNote({ note }, context) {
|
|
26
|
+
try {
|
|
27
|
+
this.logger.log(`Opening note editor for note ${note}`);
|
|
28
|
+
await context.reportProgress({ progress: 50, total: 100 });
|
|
29
|
+
await this.ankiClient.invoke("guiEditNote", { note });
|
|
30
|
+
await context.reportProgress({ progress: 100, total: 100 });
|
|
31
|
+
this.logger.log(`Note editor opened for note ${note}`);
|
|
32
|
+
return (0, anki_utils_1.createSuccessResponse)({
|
|
33
|
+
success: true,
|
|
34
|
+
noteId: note,
|
|
35
|
+
message: `Note editor opened for note ${note}`,
|
|
36
|
+
hint: "The user can now edit the note fields, tags, and cards in the Anki GUI. Changes will be saved when they close the editor.",
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
this.logger.error("Failed to open note editor", error);
|
|
41
|
+
if (error instanceof Error) {
|
|
42
|
+
if (error.message.includes("not found") ||
|
|
43
|
+
error.message.includes("invalid")) {
|
|
44
|
+
return (0, anki_utils_1.createErrorResponse)(error, {
|
|
45
|
+
noteId: note,
|
|
46
|
+
hint: "Note not found. Use findNotes to search for notes and get valid note IDs.",
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return (0, anki_utils_1.createErrorResponse)(error, {
|
|
51
|
+
noteId: note,
|
|
52
|
+
hint: "Make sure Anki is running and the note ID is valid",
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
exports.GuiEditNoteTool = GuiEditNoteTool;
|
|
58
|
+
__decorate([
|
|
59
|
+
(0, mcp_nest_1.Tool)({
|
|
60
|
+
name: "guiEditNote",
|
|
61
|
+
description: "Open Anki note editor dialog for a specific note ID. Allows manual editing of note fields, tags, and cards in the GUI. " +
|
|
62
|
+
"IMPORTANT: Only use when user explicitly requests editing a note via GUI. " +
|
|
63
|
+
"This tool is for note editing workflows when user wants to manually edit in Anki interface. " +
|
|
64
|
+
"For programmatic editing, use updateNoteFields instead.",
|
|
65
|
+
parameters: zod_1.z.object({
|
|
66
|
+
note: zod_1.z
|
|
67
|
+
.number()
|
|
68
|
+
.positive()
|
|
69
|
+
.describe("Note ID to edit (get from findNotes or notesInfo)"),
|
|
70
|
+
}),
|
|
71
|
+
}),
|
|
72
|
+
__metadata("design:type", Function),
|
|
73
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
74
|
+
__metadata("design:returntype", Promise)
|
|
75
|
+
], GuiEditNoteTool.prototype, "guiEditNote", null);
|
|
76
|
+
exports.GuiEditNoteTool = GuiEditNoteTool = GuiEditNoteTool_1 = __decorate([
|
|
77
|
+
(0, common_1.Injectable)(),
|
|
78
|
+
__metadata("design:paramtypes", [anki_connect_client_1.AnkiConnectClient])
|
|
79
|
+
], GuiEditNoteTool);
|
|
80
|
+
//# sourceMappingURL=gui-edit-note.tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gui-edit-note.tool.js","sourceRoot":"","sources":["../../../../../src/mcp/primitives/gui/tools/gui-edit-note.tool.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAAoD;AACpD,8CAAuC;AAEvC,6BAAwB;AACxB,8EAAsE;AACtE,0DAGgC;AAMzB,IAAM,eAAe,uBAArB,MAAM,eAAe;IAGG;IAFZ,MAAM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CAAC;gBACL,CAAC;YACH,CAAC;YAED,OAAO,IAAA,gCAAmB,EAAC,KAAK,EAAE;gBAChC,MAAM,EAAE,IAAI;gBACZ,IAAI,EAAE,oDAAoD;aAC3D,CAAC,CAAC;QACL,CAAC;IACH,CAAC;CACF,CAAA;AAzDY,0CAAe;AAmBpB;IAdL,IAAA,eAAI,EAAC;QACJ,IAAI,EAAE,aAAa;QACnB,WAAW,EACT,yHAAyH;YACzH,4EAA4E;YAC5E,8FAA8F;YAC9F,yDAAyD;QAC3D,UAAU,EAAE,OAAC,CAAC,MAAM,CAAC;YACnB,IAAI,EAAE,OAAC;iBACJ,MAAM,EAAE;iBACR,QAAQ,EAAE;iBACV,QAAQ,CAAC,mDAAmD,CAAC;SACjE,CAAC;KACH,CAAC;;;;kDAsCD;0BAxDU,eAAe;IAD3B,IAAA,mBAAU,GAAE;qCAI8B,uCAAiB;GAH/C,eAAe,CAyD3B"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import type { Context } from "@rekog/mcp-nest";
|
|
2
|
+
import { AnkiConnectClient } from "@/mcp/clients/anki-connect.client";
|
|
3
|
+
export declare class GuiSelectCardTool {
|
|
4
|
+
private readonly ankiClient;
|
|
5
|
+
private readonly logger;
|
|
6
|
+
constructor(ankiClient: AnkiConnectClient);
|
|
7
|
+
guiSelectCard({ card }: {
|
|
8
|
+
card: number;
|
|
9
|
+
}, context: Context): Promise<{
|
|
10
|
+
[x: string]: unknown;
|
|
11
|
+
content: ({
|
|
12
|
+
[x: string]: unknown;
|
|
13
|
+
type: "text";
|
|
14
|
+
text: string;
|
|
15
|
+
_meta?: {
|
|
16
|
+
[x: string]: unknown;
|
|
17
|
+
} | undefined;
|
|
18
|
+
} | {
|
|
19
|
+
[x: string]: unknown;
|
|
20
|
+
type: "image";
|
|
21
|
+
data: string;
|
|
22
|
+
mimeType: string;
|
|
23
|
+
_meta?: {
|
|
24
|
+
[x: string]: unknown;
|
|
25
|
+
} | undefined;
|
|
26
|
+
} | {
|
|
27
|
+
[x: string]: unknown;
|
|
28
|
+
type: "audio";
|
|
29
|
+
data: string;
|
|
30
|
+
mimeType: string;
|
|
31
|
+
_meta?: {
|
|
32
|
+
[x: string]: unknown;
|
|
33
|
+
} | undefined;
|
|
34
|
+
} | {
|
|
35
|
+
[x: string]: unknown;
|
|
36
|
+
type: "resource_link";
|
|
37
|
+
name: string;
|
|
38
|
+
uri: string;
|
|
39
|
+
_meta?: {
|
|
40
|
+
[x: string]: unknown;
|
|
41
|
+
} | undefined;
|
|
42
|
+
mimeType?: string | undefined;
|
|
43
|
+
title?: string | undefined;
|
|
44
|
+
description?: string | undefined;
|
|
45
|
+
icons?: {
|
|
46
|
+
[x: string]: unknown;
|
|
47
|
+
src: string;
|
|
48
|
+
mimeType?: string | undefined;
|
|
49
|
+
sizes?: string[] | undefined;
|
|
50
|
+
}[] | undefined;
|
|
51
|
+
} | {
|
|
52
|
+
[x: string]: unknown;
|
|
53
|
+
type: "resource";
|
|
54
|
+
resource: {
|
|
55
|
+
[x: string]: unknown;
|
|
56
|
+
text: string;
|
|
57
|
+
uri: string;
|
|
58
|
+
_meta?: {
|
|
59
|
+
[x: string]: unknown;
|
|
60
|
+
} | undefined;
|
|
61
|
+
mimeType?: string | undefined;
|
|
62
|
+
} | {
|
|
63
|
+
[x: string]: unknown;
|
|
64
|
+
uri: string;
|
|
65
|
+
blob: string;
|
|
66
|
+
_meta?: {
|
|
67
|
+
[x: string]: unknown;
|
|
68
|
+
} | undefined;
|
|
69
|
+
mimeType?: string | undefined;
|
|
70
|
+
};
|
|
71
|
+
_meta?: {
|
|
72
|
+
[x: string]: unknown;
|
|
73
|
+
} | undefined;
|
|
74
|
+
})[];
|
|
75
|
+
_meta?: {
|
|
76
|
+
[x: string]: unknown;
|
|
77
|
+
} | undefined;
|
|
78
|
+
structuredContent?: {
|
|
79
|
+
[x: string]: unknown;
|
|
80
|
+
} | undefined;
|
|
81
|
+
isError?: boolean | undefined;
|
|
82
|
+
}>;
|
|
83
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
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;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var GuiSelectCardTool_1;
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.GuiSelectCardTool = void 0;
|
|
14
|
+
const common_1 = require("@nestjs/common");
|
|
15
|
+
const mcp_nest_1 = require("@rekog/mcp-nest");
|
|
16
|
+
const zod_1 = require("zod");
|
|
17
|
+
const anki_connect_client_1 = require("../../../clients/anki-connect.client");
|
|
18
|
+
const anki_utils_1 = require("../../../utils/anki.utils");
|
|
19
|
+
let GuiSelectCardTool = GuiSelectCardTool_1 = class GuiSelectCardTool {
|
|
20
|
+
ankiClient;
|
|
21
|
+
logger = new common_1.Logger(GuiSelectCardTool_1.name);
|
|
22
|
+
constructor(ankiClient) {
|
|
23
|
+
this.ankiClient = ankiClient;
|
|
24
|
+
}
|
|
25
|
+
async guiSelectCard({ card }, context) {
|
|
26
|
+
try {
|
|
27
|
+
this.logger.log(`Selecting card ${card} in Card Browser`);
|
|
28
|
+
await context.reportProgress({ progress: 50, total: 100 });
|
|
29
|
+
const success = await this.ankiClient.invoke("guiSelectCard", {
|
|
30
|
+
card,
|
|
31
|
+
});
|
|
32
|
+
await context.reportProgress({ progress: 100, total: 100 });
|
|
33
|
+
if (!success) {
|
|
34
|
+
this.logger.warn("Card Browser is not open");
|
|
35
|
+
return (0, anki_utils_1.createErrorResponse)(new Error("Card Browser is not open"), {
|
|
36
|
+
cardId: card,
|
|
37
|
+
hint: "Use guiBrowse to open the Card Browser first, then try selecting the card again.",
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
this.logger.log(`Successfully selected card ${card} in Card Browser`);
|
|
41
|
+
return (0, anki_utils_1.createSuccessResponse)({
|
|
42
|
+
success: true,
|
|
43
|
+
cardId: card,
|
|
44
|
+
browserOpen: true,
|
|
45
|
+
message: `Successfully selected card ${card} in Card Browser`,
|
|
46
|
+
hint: "The card is now selected. Use guiEditNote to edit the associated note, or guiSelectedNotes to get note IDs.",
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
this.logger.error("Failed to select card in browser", error);
|
|
51
|
+
if (error instanceof Error) {
|
|
52
|
+
if (error.message.includes("not found") ||
|
|
53
|
+
error.message.includes("invalid")) {
|
|
54
|
+
return (0, anki_utils_1.createErrorResponse)(error, {
|
|
55
|
+
cardId: card,
|
|
56
|
+
hint: "Card ID not found. Make sure the card exists and is visible in the current browser search.",
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return (0, anki_utils_1.createErrorResponse)(error, {
|
|
61
|
+
cardId: card,
|
|
62
|
+
hint: "Make sure Anki is running, the Card Browser is open, and the card ID is valid",
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
exports.GuiSelectCardTool = GuiSelectCardTool;
|
|
68
|
+
__decorate([
|
|
69
|
+
(0, mcp_nest_1.Tool)({
|
|
70
|
+
name: "guiSelectCard",
|
|
71
|
+
description: "Select a specific card in an open Card Browser window. Returns true if browser is open and card was selected, false if browser is not open. " +
|
|
72
|
+
"IMPORTANT: Only use when user explicitly requests selecting a card in the browser. " +
|
|
73
|
+
"This tool is for note editing/creation workflows, NOT for review sessions. " +
|
|
74
|
+
"The Card Browser must already be open (use guiBrowse first).",
|
|
75
|
+
parameters: zod_1.z.object({
|
|
76
|
+
card: zod_1.z
|
|
77
|
+
.number()
|
|
78
|
+
.positive()
|
|
79
|
+
.describe("Card ID to select in the browser (get from guiBrowse results)"),
|
|
80
|
+
}),
|
|
81
|
+
}),
|
|
82
|
+
__metadata("design:type", Function),
|
|
83
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
84
|
+
__metadata("design:returntype", Promise)
|
|
85
|
+
], GuiSelectCardTool.prototype, "guiSelectCard", null);
|
|
86
|
+
exports.GuiSelectCardTool = GuiSelectCardTool = GuiSelectCardTool_1 = __decorate([
|
|
87
|
+
(0, common_1.Injectable)(),
|
|
88
|
+
__metadata("design:paramtypes", [anki_connect_client_1.AnkiConnectClient])
|
|
89
|
+
], GuiSelectCardTool);
|
|
90
|
+
//# sourceMappingURL=gui-select-card.tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gui-select-card.tool.js","sourceRoot":"","sources":["../../../../../src/mcp/primitives/gui/tools/gui-select-card.tool.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAAoD;AACpD,8CAAuC;AAEvC,6BAAwB;AACxB,8EAAsE;AACtE,0DAGgC;AAMzB,IAAM,iBAAiB,yBAAvB,MAAM,iBAAiB;IAGC;IAFZ,MAAM,GAAG,IAAI,eAAM,CAAC,mBAAiB,CAAC,IAAI,CAAC,CAAC;IAE7D,YAA6B,UAA6B;QAA7B,eAAU,GAAV,UAAU,CAAmB;IAAG,CAAC;IAkBxD,AAAN,KAAK,CAAC,aAAa,CAAC,EAAE,IAAI,EAAoB,EAAE,OAAgB;QAC9D,IAAI,CAAC;YACH,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,kBAAkB,IAAI,kBAAkB,CAAC,CAAC;YAC1D,MAAM,OAA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