@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,83 @@
|
|
|
1
|
+
import type { Context } from "@rekog/mcp-nest";
|
|
2
|
+
import { AnkiConnectClient } from "@/mcp/clients/anki-connect.client";
|
|
3
|
+
export declare class ListDecksTool {
|
|
4
|
+
private readonly ankiClient;
|
|
5
|
+
private readonly logger;
|
|
6
|
+
constructor(ankiClient: AnkiConnectClient);
|
|
7
|
+
listDecks({ include_stats }: {
|
|
8
|
+
include_stats?: boolean;
|
|
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,117 @@
|
|
|
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 ListDecksTool_1;
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.ListDecksTool = 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 ListDecksTool = ListDecksTool_1 = class ListDecksTool {
|
|
20
|
+
ankiClient;
|
|
21
|
+
logger = new common_1.Logger(ListDecksTool_1.name);
|
|
22
|
+
constructor(ankiClient) {
|
|
23
|
+
this.ankiClient = ankiClient;
|
|
24
|
+
}
|
|
25
|
+
async listDecks({ include_stats }, context) {
|
|
26
|
+
try {
|
|
27
|
+
const includeStats = include_stats || false;
|
|
28
|
+
this.logger.log(`Listing Anki decks with stats: ${includeStats}`);
|
|
29
|
+
await context.reportProgress({ progress: 10, total: 100 });
|
|
30
|
+
const deckNames = await this.ankiClient.invoke("deckNames");
|
|
31
|
+
if (!deckNames || deckNames.length === 0) {
|
|
32
|
+
this.logger.log("No decks found");
|
|
33
|
+
await context.reportProgress({ progress: 100, total: 100 });
|
|
34
|
+
return (0, anki_utils_1.createSuccessResponse)({
|
|
35
|
+
success: true,
|
|
36
|
+
message: "No decks found in Anki",
|
|
37
|
+
decks: [],
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
await context.reportProgress({ progress: 50, total: 100 });
|
|
41
|
+
let decks;
|
|
42
|
+
let summary;
|
|
43
|
+
if (includeStats) {
|
|
44
|
+
const deckStatsResponse = await this.ankiClient.invoke("getDeckStats", {
|
|
45
|
+
decks: deckNames,
|
|
46
|
+
});
|
|
47
|
+
const statsArray = Object.values(deckStatsResponse);
|
|
48
|
+
decks = deckNames.map((name) => {
|
|
49
|
+
const stats = statsArray.find((s) => s.name === name);
|
|
50
|
+
if (stats) {
|
|
51
|
+
return {
|
|
52
|
+
name,
|
|
53
|
+
stats: {
|
|
54
|
+
deck_id: stats.deck_id || 0,
|
|
55
|
+
name,
|
|
56
|
+
new_count: stats.new_count || 0,
|
|
57
|
+
learn_count: stats.learn_count || 0,
|
|
58
|
+
review_count: stats.review_count || 0,
|
|
59
|
+
total_new: stats.new_count || 0,
|
|
60
|
+
total_cards: stats.total_in_deck || 0,
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
return { name };
|
|
65
|
+
});
|
|
66
|
+
summary = decks.reduce((acc, deck) => {
|
|
67
|
+
if (deck.stats) {
|
|
68
|
+
acc.total_cards += deck.stats.total_cards;
|
|
69
|
+
acc.new_cards += deck.stats.new_count;
|
|
70
|
+
acc.learning_cards += deck.stats.learn_count;
|
|
71
|
+
acc.review_cards += deck.stats.review_count;
|
|
72
|
+
}
|
|
73
|
+
return acc;
|
|
74
|
+
}, { total_cards: 0, new_cards: 0, learning_cards: 0, review_cards: 0 });
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
decks = deckNames.map((name) => ({ name }));
|
|
78
|
+
}
|
|
79
|
+
await context.reportProgress({ progress: 100, total: 100 });
|
|
80
|
+
this.logger.log(`Found ${decks.length} decks`);
|
|
81
|
+
const response = {
|
|
82
|
+
success: true,
|
|
83
|
+
decks,
|
|
84
|
+
total: decks.length,
|
|
85
|
+
};
|
|
86
|
+
if (summary) {
|
|
87
|
+
response.summary = summary;
|
|
88
|
+
}
|
|
89
|
+
return (0, anki_utils_1.createSuccessResponse)(response);
|
|
90
|
+
}
|
|
91
|
+
catch (error) {
|
|
92
|
+
this.logger.error("Failed to list decks", error);
|
|
93
|
+
return (0, anki_utils_1.createErrorResponse)(error);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
exports.ListDecksTool = ListDecksTool;
|
|
98
|
+
__decorate([
|
|
99
|
+
(0, mcp_nest_1.Tool)({
|
|
100
|
+
name: "list_decks",
|
|
101
|
+
description: "List all available Anki decks, optionally with statistics. Remember to sync first at the start of a review session for latest data.",
|
|
102
|
+
parameters: zod_1.z.object({
|
|
103
|
+
include_stats: zod_1.z
|
|
104
|
+
.boolean()
|
|
105
|
+
.default(false)
|
|
106
|
+
.describe("Include card count statistics for each deck"),
|
|
107
|
+
}),
|
|
108
|
+
}),
|
|
109
|
+
__metadata("design:type", Function),
|
|
110
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
111
|
+
__metadata("design:returntype", Promise)
|
|
112
|
+
], ListDecksTool.prototype, "listDecks", null);
|
|
113
|
+
exports.ListDecksTool = ListDecksTool = ListDecksTool_1 = __decorate([
|
|
114
|
+
(0, common_1.Injectable)(),
|
|
115
|
+
__metadata("design:paramtypes", [anki_connect_client_1.AnkiConnectClient])
|
|
116
|
+
], ListDecksTool);
|
|
117
|
+
//# sourceMappingURL=list-decks.tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-decks.tool.js","sourceRoot":"","sources":["../../../../../src/mcp/primitives/essential/tools/list-decks.tool.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAAoD;AACpD,8CAAuC;AAEvC,6BAAwB;AACxB,8EAAsE;AAEtE,0DAGgC;AAMzB,IAAM,aAAa,qBAAnB,MAAM,aAAa;IAGK;IAFZ,MAAM,GAAG,IAAI,eAAM,CAAC,eAAa,CAAC,IAAI,CAAC,CAAC;IAEzD,YAA6B,UAA6B;QAA7B,eAAU,GAAV,UAAU,CAAmB;IAAG,CAAC;IAaxD,AAAN,KAAK,CAAC,SAAS,CACb,EAAE,aAAa,EAA+B,EAC9C,OAAgB;QAEhB,IAAI,CAAC;YACH,MAAM,YAAY,GAAG,aAAa,IAAI,KAAK,CAAC;YAC5C,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,kCAAkC,YAAY,EAAE,CAAC,CAAC;YAClE,MAAM,OAAO,CAAC,cAAc,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC;YAG3D,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,MAAM,CAAW,WAAW,CAAC,CAAC;YAEtE,IAAI,CAAC,SAAS,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBACzC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;gBAClC,MAAM,OAAO,CAAC,cAAc,CA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AAC;YACf,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,sBAAsB,EAAE,KAAK,CAAC,CAAC;YACjD,OAAO,IAAA,gCAAmB,EAAC,KAAK,CAAC,CAAC;QACpC,CAAC;IACH,CAAC;CACF,CAAA;AAjHY,sCAAa;AAgBlB;IAXL,IAAA,eAAI,EAAC;QACJ,IAAI,EAAE,YAAY;QAClB,WAAW,EACT,qIAAqI;QACvI,UAAU,EAAE,OAAC,CAAC,MAAM,CAAC;YACnB,aAAa,EAAE,OAAC;iBACb,OAAO,EAAE;iBACT,OAAO,CAAC,KAAK,CAAC;iBACd,QAAQ,CAAC,6CAA6C,CAAC;SAC3D,CAAC;KACH,CAAC;;;;8CAiGD;wBAhHU,aAAa;IADzB,IAAA,mBAAU,GAAE;qCAI8B,uCAAiB;GAH/C,aAAa,CAiHzB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { AnkiConnectClient } from "@/mcp/clients/anki-connect.client";
|
|
2
|
+
export interface DeleteMediaFileParams {
|
|
3
|
+
filename: string;
|
|
4
|
+
}
|
|
5
|
+
export interface DeleteMediaFileResult {
|
|
6
|
+
success: boolean;
|
|
7
|
+
filename: string;
|
|
8
|
+
message: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function deleteMediaFile(params: DeleteMediaFileParams, client: AnkiConnectClient): Promise<DeleteMediaFileResult>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deleteMediaFile = deleteMediaFile;
|
|
4
|
+
async function deleteMediaFile(params, client) {
|
|
5
|
+
const { filename } = params;
|
|
6
|
+
if (!filename || filename.trim() === "") {
|
|
7
|
+
throw new Error("Filename cannot be empty");
|
|
8
|
+
}
|
|
9
|
+
await client.invoke("deleteMediaFile", {
|
|
10
|
+
filename,
|
|
11
|
+
});
|
|
12
|
+
return {
|
|
13
|
+
success: true,
|
|
14
|
+
filename,
|
|
15
|
+
message: `Successfully deleted media file: ${filename}`,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=deleteMediaFile.action.js.map
|
package/dist/mcp/primitives/essential/tools/mediaActions/actions/deleteMediaFile.action.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deleteMediaFile.action.js","sourceRoot":"","sources":["../../../../../../../src/mcp/primitives/essential/tools/mediaActions/actions/deleteMediaFile.action.ts"],"names":[],"mappings":";;AAsBA,0CAqBC;AArBM,KAAK,UAAU,eAAe,CACnC,MAA6B,EAC7B,MAAyB;IAEzB,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,CAAC;IAG5B,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;QACxC,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;IAC9C,CAAC;IAGD,MAAM,MAAM,CAAC,MAAM,CAAO,iBAAiB,EAAE;QAC3C,QAAQ;KACT,CAAC,CAAC;IAEH,OAAO;QACL,OAAO,EAAE,IAAI;QACb,QAAQ;QACR,OAAO,EAAE,oCAAoC,QAAQ,EAAE;KACxD,CAAC;AACJ,CAAC"}
|
package/dist/mcp/primitives/essential/tools/mediaActions/actions/getMediaFilesNames.action.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { AnkiConnectClient } from "@/mcp/clients/anki-connect.client";
|
|
2
|
+
export interface GetMediaFilesNamesParams {
|
|
3
|
+
pattern?: string;
|
|
4
|
+
}
|
|
5
|
+
export interface GetMediaFilesNamesResult {
|
|
6
|
+
success: boolean;
|
|
7
|
+
files: string[];
|
|
8
|
+
count: number;
|
|
9
|
+
message: string;
|
|
10
|
+
pattern?: string;
|
|
11
|
+
}
|
|
12
|
+
export declare function getMediaFilesNames(params: GetMediaFilesNamesParams, client: AnkiConnectClient): Promise<GetMediaFilesNamesResult>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getMediaFilesNames = getMediaFilesNames;
|
|
4
|
+
async function getMediaFilesNames(params, client) {
|
|
5
|
+
const { pattern } = params;
|
|
6
|
+
const ankiParams = {};
|
|
7
|
+
if (pattern) {
|
|
8
|
+
ankiParams.pattern = pattern;
|
|
9
|
+
}
|
|
10
|
+
const result = await client.invoke("getMediaFilesNames", ankiParams);
|
|
11
|
+
const message = pattern
|
|
12
|
+
? `Found ${result.length} media file(s) matching pattern "${pattern}"`
|
|
13
|
+
: `Found ${result.length} media file(s)`;
|
|
14
|
+
return {
|
|
15
|
+
success: true,
|
|
16
|
+
files: result,
|
|
17
|
+
count: result.length,
|
|
18
|
+
message,
|
|
19
|
+
...(pattern && { pattern }),
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=getMediaFilesNames.action.js.map
|
package/dist/mcp/primitives/essential/tools/mediaActions/actions/getMediaFilesNames.action.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getMediaFilesNames.action.js","sourceRoot":"","sources":["../../../../../../../src/mcp/primitives/essential/tools/mediaActions/actions/getMediaFilesNames.action.ts"],"names":[],"mappings":";;AAyBA,gDA6BC;AA7BM,KAAK,UAAU,kBAAkB,CACtC,MAAgC,EAChC,MAAyB;IAEzB,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC;IAG3B,MAAM,UAAU,GAAwB,EAAE,CAAC;IAC3C,IAAI,OAAO,EAAE,CAAC;QACZ,UAAU,CAAC,OAAO,GAAG,OAAO,CAAC;IAC/B,CAAC;IAGD,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,MAAM,CAChC,oBAAoB,EACpB,UAAU,CACX,CAAC;IAEF,MAAM,OAAO,GAAG,OAAO;QACrB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,oCAAoC,OAAO,GAAG;QACtE,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,gBAAgB,CAAC;IAE3C,OAAO;QACL,OAAO,EAAE,IAAI;QACb,KAAK,EAAE,MAAM;QACb,KAAK,EAAE,MAAM,CAAC,MAAM;QACpB,OAAO;QACP,GAAG,CAAC,OAAO,IAAI,EAAE,OAAO,EAAE,CAAC;KAC5B,CAAC;AACJ,CAAC"}
|
package/dist/mcp/primitives/essential/tools/mediaActions/actions/retrieveMediaFile.action.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { AnkiConnectClient } from "@/mcp/clients/anki-connect.client";
|
|
2
|
+
export interface RetrieveMediaFileParams {
|
|
3
|
+
filename: string;
|
|
4
|
+
}
|
|
5
|
+
export interface RetrieveMediaFileResult {
|
|
6
|
+
success: boolean;
|
|
7
|
+
filename: string;
|
|
8
|
+
data: string | null;
|
|
9
|
+
message: string;
|
|
10
|
+
found: boolean;
|
|
11
|
+
}
|
|
12
|
+
export declare function retrieveMediaFile(params: RetrieveMediaFileParams, client: AnkiConnectClient): Promise<RetrieveMediaFileResult>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.retrieveMediaFile = retrieveMediaFile;
|
|
4
|
+
async function retrieveMediaFile(params, client) {
|
|
5
|
+
const { filename } = params;
|
|
6
|
+
if (!filename || filename.trim() === "") {
|
|
7
|
+
throw new Error("Filename cannot be empty");
|
|
8
|
+
}
|
|
9
|
+
const result = await client.invoke("retrieveMediaFile", {
|
|
10
|
+
filename,
|
|
11
|
+
});
|
|
12
|
+
if (result === false) {
|
|
13
|
+
return {
|
|
14
|
+
success: true,
|
|
15
|
+
filename,
|
|
16
|
+
data: null,
|
|
17
|
+
message: `Media file not found: ${filename}`,
|
|
18
|
+
found: false,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
return {
|
|
22
|
+
success: true,
|
|
23
|
+
filename,
|
|
24
|
+
data: result,
|
|
25
|
+
message: `Successfully retrieved media file: ${filename}`,
|
|
26
|
+
found: true,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=retrieveMediaFile.action.js.map
|
package/dist/mcp/primitives/essential/tools/mediaActions/actions/retrieveMediaFile.action.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retrieveMediaFile.action.js","sourceRoot":"","sources":["../../../../../../../src/mcp/primitives/essential/tools/mediaActions/actions/retrieveMediaFile.action.ts"],"names":[],"mappings":";;AAyBA,8CAkCC;AAlCM,KAAK,UAAU,iBAAiB,CACrC,MAA+B,EAC/B,MAAyB;IAEzB,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,CAAC;IAG5B,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;QACxC,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;IAC9C,CAAC;IAGD,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,MAAM,CAAiB,mBAAmB,EAAE;QACtE,QAAQ;KACT,CAAC,CAAC;IAGH,IAAI,MAAM,KAAK,KAAK,EAAE,CAAC;QACrB,OAAO;YACL,OAAO,EAAE,IAAI;YACb,QAAQ;YACR,IAAI,EAAE,IAAI;YACV,OAAO,EAAE,yBAAyB,QAAQ,EAAE;YAC5C,KAAK,EAAE,KAAK;SACb,CAAC;IACJ,CAAC;IAED,OAAO;QACL,OAAO,EAAE,IAAI;QACb,QAAQ;QACR,IAAI,EAAE,MAAM;QACZ,OAAO,EAAE,sCAAsC,QAAQ,EAAE;QACzD,KAAK,EAAE,IAAI;KACZ,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { AnkiConnectClient } from "@/mcp/clients/anki-connect.client";
|
|
2
|
+
export interface StoreMediaFileParams {
|
|
3
|
+
filename: string;
|
|
4
|
+
data?: string;
|
|
5
|
+
path?: string;
|
|
6
|
+
url?: string;
|
|
7
|
+
deleteExisting?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface StoreMediaFileResult {
|
|
10
|
+
success: boolean;
|
|
11
|
+
filename: string;
|
|
12
|
+
message: string;
|
|
13
|
+
prefixedWithUnderscore: boolean;
|
|
14
|
+
}
|
|
15
|
+
export declare function storeMediaFile(params: StoreMediaFileParams, client: AnkiConnectClient): Promise<StoreMediaFileResult>;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.storeMediaFile = storeMediaFile;
|
|
4
|
+
async function storeMediaFile(params, client) {
|
|
5
|
+
const { filename, data, path, url, deleteExisting = true } = params;
|
|
6
|
+
if (!data && !path && !url) {
|
|
7
|
+
throw new Error("Must provide either data, path, or url parameter");
|
|
8
|
+
}
|
|
9
|
+
const sources = [data, path, url].filter(Boolean);
|
|
10
|
+
if (sources.length > 1) {
|
|
11
|
+
throw new Error("Cannot provide multiple sources (data, path, url). Choose one.");
|
|
12
|
+
}
|
|
13
|
+
if (!filename || filename.trim() === "") {
|
|
14
|
+
throw new Error("Filename cannot be empty");
|
|
15
|
+
}
|
|
16
|
+
const prefixedWithUnderscore = filename.startsWith("_");
|
|
17
|
+
const ankiParams = {
|
|
18
|
+
filename,
|
|
19
|
+
deleteExisting,
|
|
20
|
+
};
|
|
21
|
+
if (data) {
|
|
22
|
+
ankiParams.data = data;
|
|
23
|
+
}
|
|
24
|
+
else if (path) {
|
|
25
|
+
ankiParams.path = path;
|
|
26
|
+
}
|
|
27
|
+
else if (url) {
|
|
28
|
+
ankiParams.url = url;
|
|
29
|
+
}
|
|
30
|
+
const result = await client.invoke("storeMediaFile", ankiParams);
|
|
31
|
+
if (!result) {
|
|
32
|
+
throw new Error("Failed to store media file");
|
|
33
|
+
}
|
|
34
|
+
return {
|
|
35
|
+
success: true,
|
|
36
|
+
filename: result,
|
|
37
|
+
message: `Successfully stored media file: ${result}`,
|
|
38
|
+
prefixedWithUnderscore,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=storeMediaFile.action.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storeMediaFile.action.js","sourceRoot":"","sources":["../../../../../../../src/mcp/primitives/essential/tools/mediaActions/actions/storeMediaFile.action.ts"],"names":[],"mappings":";;AAoCA,wCAuDC;AAvDM,KAAK,UAAU,cAAc,CAClC,MAA4B,EAC5B,MAAyB;IAEzB,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,cAAc,GAAG,IAAI,EAAE,GAAG,MAAM,CAAC;IAGpE,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC;QAC3B,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;IACtE,CAAC;IAGD,MAAM,OAAO,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAClD,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACvB,MAAM,IAAI,KAAK,CACb,gEAAgE,CACjE,CAAC;IACJ,CAAC;IAGD,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;QACxC,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;IAC9C,CAAC;IAGD,MAAM,sBAAsB,GAAG,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;IAGxD,MAAM,UAAU,GAAwB;QACtC,QAAQ;QACR,cAAc;KACf,CAAC;IAEF,IAAI,IAAI,EAAE,CAAC;QACT,UAAU,CAAC,IAAI,GAAG,IAAI,CAAC;IACzB,CAAC;SAAM,IAAI,IAAI,EAAE,CAAC;QAChB,UAAU,CAAC,IAAI,GAAG,IAAI,CAAC;IACzB,CAAC;SAAM,IAAI,GAAG,EAAE,CAAC;QACf,UAAU,CAAC,GAAG,GAAG,GAAG,CAAC;IACvB,CAAC;IAGD,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,MAAM,CAAS,gBAAgB,EAAE,UAAU,CAAC,CAAC;IAGzE,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;IAChD,CAAC;IAED,OAAO;QACL,OAAO,EAAE,IAAI;QACb,QAAQ,EAAE,MAAM;QAChB,OAAO,EAAE,mCAAmC,MAAM,EAAE;QACpD,sBAAsB;KACvB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { MediaActionsTool } from "./mediaActions.tool";
|
|
2
|
+
export type { StoreMediaFileParams, StoreMediaFileResult, } from "./actions/storeMediaFile.action";
|
|
3
|
+
export type { RetrieveMediaFileParams, RetrieveMediaFileResult, } from "./actions/retrieveMediaFile.action";
|
|
4
|
+
export type { GetMediaFilesNamesParams, GetMediaFilesNamesResult, } from "./actions/getMediaFilesNames.action";
|
|
5
|
+
export type { DeleteMediaFileParams, DeleteMediaFileResult, } from "./actions/deleteMediaFile.action";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MediaActionsTool = void 0;
|
|
4
|
+
var mediaActions_tool_1 = require("./mediaActions.tool");
|
|
5
|
+
Object.defineProperty(exports, "MediaActionsTool", { enumerable: true, get: function () { return mediaActions_tool_1.MediaActionsTool; } });
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/mcp/primitives/essential/tools/mediaActions/index.ts"],"names":[],"mappings":";;;AAIA,yDAAuD;AAA9C,qHAAA,gBAAgB,OAAA"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import type { Context } from "@rekog/mcp-nest";
|
|
2
|
+
import { AnkiConnectClient } from "@/mcp/clients/anki-connect.client";
|
|
3
|
+
export declare class MediaActionsTool {
|
|
4
|
+
private readonly ankiClient;
|
|
5
|
+
private readonly logger;
|
|
6
|
+
constructor(ankiClient: AnkiConnectClient);
|
|
7
|
+
execute(params: {
|
|
8
|
+
action: "storeMediaFile" | "retrieveMediaFile" | "getMediaFilesNames" | "deleteMediaFile";
|
|
9
|
+
filename?: string;
|
|
10
|
+
data?: string;
|
|
11
|
+
path?: string;
|
|
12
|
+
url?: string;
|
|
13
|
+
deleteExisting?: boolean;
|
|
14
|
+
pattern?: string;
|
|
15
|
+
}, context: Context): Promise<{
|
|
16
|
+
[x: string]: unknown;
|
|
17
|
+
content: ({
|
|
18
|
+
[x: string]: unknown;
|
|
19
|
+
type: "text";
|
|
20
|
+
text: string;
|
|
21
|
+
_meta?: {
|
|
22
|
+
[x: string]: unknown;
|
|
23
|
+
} | undefined;
|
|
24
|
+
} | {
|
|
25
|
+
[x: string]: unknown;
|
|
26
|
+
type: "image";
|
|
27
|
+
data: string;
|
|
28
|
+
mimeType: string;
|
|
29
|
+
_meta?: {
|
|
30
|
+
[x: string]: unknown;
|
|
31
|
+
} | undefined;
|
|
32
|
+
} | {
|
|
33
|
+
[x: string]: unknown;
|
|
34
|
+
type: "audio";
|
|
35
|
+
data: string;
|
|
36
|
+
mimeType: string;
|
|
37
|
+
_meta?: {
|
|
38
|
+
[x: string]: unknown;
|
|
39
|
+
} | undefined;
|
|
40
|
+
} | {
|
|
41
|
+
[x: string]: unknown;
|
|
42
|
+
type: "resource_link";
|
|
43
|
+
name: string;
|
|
44
|
+
uri: string;
|
|
45
|
+
_meta?: {
|
|
46
|
+
[x: string]: unknown;
|
|
47
|
+
} | undefined;
|
|
48
|
+
mimeType?: string | undefined;
|
|
49
|
+
title?: string | undefined;
|
|
50
|
+
description?: string | undefined;
|
|
51
|
+
icons?: {
|
|
52
|
+
[x: string]: unknown;
|
|
53
|
+
src: string;
|
|
54
|
+
mimeType?: string | undefined;
|
|
55
|
+
sizes?: string[] | undefined;
|
|
56
|
+
}[] | undefined;
|
|
57
|
+
} | {
|
|
58
|
+
[x: string]: unknown;
|
|
59
|
+
type: "resource";
|
|
60
|
+
resource: {
|
|
61
|
+
[x: string]: unknown;
|
|
62
|
+
text: string;
|
|
63
|
+
uri: string;
|
|
64
|
+
_meta?: {
|
|
65
|
+
[x: string]: unknown;
|
|
66
|
+
} | undefined;
|
|
67
|
+
mimeType?: string | undefined;
|
|
68
|
+
} | {
|
|
69
|
+
[x: string]: unknown;
|
|
70
|
+
uri: string;
|
|
71
|
+
blob: string;
|
|
72
|
+
_meta?: {
|
|
73
|
+
[x: string]: unknown;
|
|
74
|
+
} | undefined;
|
|
75
|
+
mimeType?: string | undefined;
|
|
76
|
+
};
|
|
77
|
+
_meta?: {
|
|
78
|
+
[x: string]: unknown;
|
|
79
|
+
} | undefined;
|
|
80
|
+
})[];
|
|
81
|
+
_meta?: {
|
|
82
|
+
[x: string]: unknown;
|
|
83
|
+
} | undefined;
|
|
84
|
+
structuredContent?: {
|
|
85
|
+
[x: string]: unknown;
|
|
86
|
+
} | undefined;
|
|
87
|
+
isError?: boolean | undefined;
|
|
88
|
+
}>;
|
|
89
|
+
}
|
|
@@ -0,0 +1,141 @@
|
|
|
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 MediaActionsTool_1;
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.MediaActionsTool = 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
|
+
const storeMediaFile_action_1 = require("./actions/storeMediaFile.action");
|
|
20
|
+
const retrieveMediaFile_action_1 = require("./actions/retrieveMediaFile.action");
|
|
21
|
+
const getMediaFilesNames_action_1 = require("./actions/getMediaFilesNames.action");
|
|
22
|
+
const deleteMediaFile_action_1 = require("./actions/deleteMediaFile.action");
|
|
23
|
+
let MediaActionsTool = MediaActionsTool_1 = class MediaActionsTool {
|
|
24
|
+
ankiClient;
|
|
25
|
+
logger = new common_1.Logger(MediaActionsTool_1.name);
|
|
26
|
+
constructor(ankiClient) {
|
|
27
|
+
this.ankiClient = ankiClient;
|
|
28
|
+
}
|
|
29
|
+
async execute(params, context) {
|
|
30
|
+
try {
|
|
31
|
+
this.logger.log(`Executing media action: ${params.action}`);
|
|
32
|
+
let result;
|
|
33
|
+
switch (params.action) {
|
|
34
|
+
case "storeMediaFile":
|
|
35
|
+
if (!params.filename) {
|
|
36
|
+
throw new Error("filename is required for storeMediaFile action");
|
|
37
|
+
}
|
|
38
|
+
await context.reportProgress({ progress: 25, total: 100 });
|
|
39
|
+
result = await (0, storeMediaFile_action_1.storeMediaFile)({
|
|
40
|
+
filename: params.filename,
|
|
41
|
+
data: params.data,
|
|
42
|
+
path: params.path,
|
|
43
|
+
url: params.url,
|
|
44
|
+
deleteExisting: params.deleteExisting,
|
|
45
|
+
}, this.ankiClient);
|
|
46
|
+
await context.reportProgress({ progress: 100, total: 100 });
|
|
47
|
+
break;
|
|
48
|
+
case "retrieveMediaFile":
|
|
49
|
+
if (!params.filename) {
|
|
50
|
+
throw new Error("filename is required for retrieveMediaFile action");
|
|
51
|
+
}
|
|
52
|
+
await context.reportProgress({ progress: 50, total: 100 });
|
|
53
|
+
result = await (0, retrieveMediaFile_action_1.retrieveMediaFile)({ filename: params.filename }, this.ankiClient);
|
|
54
|
+
await context.reportProgress({ progress: 100, total: 100 });
|
|
55
|
+
break;
|
|
56
|
+
case "getMediaFilesNames":
|
|
57
|
+
await context.reportProgress({ progress: 50, total: 100 });
|
|
58
|
+
result = await (0, getMediaFilesNames_action_1.getMediaFilesNames)({ pattern: params.pattern }, this.ankiClient);
|
|
59
|
+
await context.reportProgress({ progress: 100, total: 100 });
|
|
60
|
+
break;
|
|
61
|
+
case "deleteMediaFile":
|
|
62
|
+
if (!params.filename) {
|
|
63
|
+
throw new Error("filename is required for deleteMediaFile action");
|
|
64
|
+
}
|
|
65
|
+
await context.reportProgress({ progress: 50, total: 100 });
|
|
66
|
+
result = await (0, deleteMediaFile_action_1.deleteMediaFile)({ filename: params.filename }, this.ankiClient);
|
|
67
|
+
await context.reportProgress({ progress: 100, total: 100 });
|
|
68
|
+
break;
|
|
69
|
+
default: {
|
|
70
|
+
const _exhaustive = params.action;
|
|
71
|
+
throw new Error(`Unknown action: ${_exhaustive}`);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
this.logger.log(`Successfully executed ${params.action}`);
|
|
75
|
+
return (0, anki_utils_1.createSuccessResponse)(result);
|
|
76
|
+
}
|
|
77
|
+
catch (error) {
|
|
78
|
+
this.logger.error(`Failed to execute ${params.action}`, error);
|
|
79
|
+
return (0, anki_utils_1.createErrorResponse)(error, {
|
|
80
|
+
action: params.action,
|
|
81
|
+
hint: "Make sure Anki is running and the media file/path is valid",
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
exports.MediaActionsTool = MediaActionsTool;
|
|
87
|
+
__decorate([
|
|
88
|
+
(0, mcp_nest_1.Tool)({
|
|
89
|
+
name: "mediaActions",
|
|
90
|
+
description: `Manage Anki media files (audio/images). Supports four actions:
|
|
91
|
+
- storeMediaFile: Upload media to Anki (supports base64 data, file paths, or URLs)
|
|
92
|
+
- retrieveMediaFile: Download media from Anki as base64
|
|
93
|
+
- getMediaFilesNames: List media files (optionally filter by pattern)
|
|
94
|
+
- deleteMediaFile: Remove media file from Anki
|
|
95
|
+
|
|
96
|
+
Perfect for workflows like ElevenLabs TTS → Anki audio flashcards.`,
|
|
97
|
+
parameters: zod_1.z.object({
|
|
98
|
+
action: zod_1.z
|
|
99
|
+
.enum([
|
|
100
|
+
"storeMediaFile",
|
|
101
|
+
"retrieveMediaFile",
|
|
102
|
+
"getMediaFilesNames",
|
|
103
|
+
"deleteMediaFile",
|
|
104
|
+
])
|
|
105
|
+
.describe("The media action to perform"),
|
|
106
|
+
filename: zod_1.z
|
|
107
|
+
.string()
|
|
108
|
+
.optional()
|
|
109
|
+
.describe("Filename (required for storeMediaFile, retrieveMediaFile, deleteMediaFile)"),
|
|
110
|
+
data: zod_1.z
|
|
111
|
+
.string()
|
|
112
|
+
.optional()
|
|
113
|
+
.describe("[storeMediaFile only] Base64-encoded file content"),
|
|
114
|
+
path: zod_1.z
|
|
115
|
+
.string()
|
|
116
|
+
.optional()
|
|
117
|
+
.describe("[storeMediaFile only] Absolute file path"),
|
|
118
|
+
url: zod_1.z
|
|
119
|
+
.string()
|
|
120
|
+
.optional()
|
|
121
|
+
.describe("[storeMediaFile only] URL to download file from"),
|
|
122
|
+
deleteExisting: zod_1.z
|
|
123
|
+
.boolean()
|
|
124
|
+
.optional()
|
|
125
|
+
.default(true)
|
|
126
|
+
.describe("[storeMediaFile only] Overwrite existing file (default: true)"),
|
|
127
|
+
pattern: zod_1.z
|
|
128
|
+
.string()
|
|
129
|
+
.optional()
|
|
130
|
+
.describe('[getMediaFilesNames only] Filter pattern (e.g., "*.mp3")'),
|
|
131
|
+
}),
|
|
132
|
+
}),
|
|
133
|
+
__metadata("design:type", Function),
|
|
134
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
135
|
+
__metadata("design:returntype", Promise)
|
|
136
|
+
], MediaActionsTool.prototype, "execute", null);
|
|
137
|
+
exports.MediaActionsTool = MediaActionsTool = MediaActionsTool_1 = __decorate([
|
|
138
|
+
(0, common_1.Injectable)(),
|
|
139
|
+
__metadata("design:paramtypes", [anki_connect_client_1.AnkiConnectClient])
|
|
140
|
+
], MediaActionsTool);
|
|
141
|
+
//# sourceMappingURL=mediaActions.tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mediaActions.tool.js","sourceRoot":"","sources":["../../../../../../src/mcp/primitives/essential/tools/mediaActions/mediaActions.tool.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAAoD;AACpD,8CAAuC;AAEvC,6BAAwB;AACxB,iFAAsE;AACtE,6DAGgC;AAChC,2EAGyC;AACzC,iFAG4C;AAC5C,mFAG6C;AAC7C,6EAG0C;AAOnC,IAAM,gBAAgB,wBAAtB,MAAM,gBAAgB;IAGE;IAFZ,MAAM,GAAG,IAAI,eAAM,CAAC,kBAAgB,CAAC,IAAI,CAAC,CAAC;IAE5D,YAA6B,UAA6B;QAA7B,eAAU,GAAV,UAAU,CAAmB;IAAG,CAAC;IAmDxD,AAAN,KAAK,CAAC,OAAO,CACX,MAYC,EACD,OAAgB;QAEhB,IAAI,CAAC;YACH,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,2BAA2B,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;YAE5D,IAAI,MAIqB,CAAC;YAG1B,QAAQ,MAAM,CAAC,MAAM,EAAE,CAAC;gBACtB,KAAK,gBAAgB;oBACnB,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;wBACrB,MAAM,IAAI,K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