@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 ModelFieldNamesTool {
|
|
4
|
+
private readonly ankiClient;
|
|
5
|
+
private readonly logger;
|
|
6
|
+
constructor(ankiClient: AnkiConnectClient);
|
|
7
|
+
modelFieldNames({ modelName }: {
|
|
8
|
+
modelName: 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,119 @@
|
|
|
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 ModelFieldNamesTool_1;
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.ModelFieldNamesTool = 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 ModelFieldNamesTool = ModelFieldNamesTool_1 = class ModelFieldNamesTool {
|
|
20
|
+
ankiClient;
|
|
21
|
+
logger = new common_1.Logger(ModelFieldNamesTool_1.name);
|
|
22
|
+
constructor(ankiClient) {
|
|
23
|
+
this.ankiClient = ankiClient;
|
|
24
|
+
}
|
|
25
|
+
async modelFieldNames({ modelName }, context) {
|
|
26
|
+
try {
|
|
27
|
+
this.logger.log(`Retrieving field names for model: ${modelName}`);
|
|
28
|
+
await context.reportProgress({ progress: 25, total: 100 });
|
|
29
|
+
const fieldNames = await this.ankiClient.invoke("modelFieldNames", {
|
|
30
|
+
modelName: modelName,
|
|
31
|
+
});
|
|
32
|
+
await context.reportProgress({ progress: 75, total: 100 });
|
|
33
|
+
if (!fieldNames) {
|
|
34
|
+
this.logger.warn(`Model not found: ${modelName}`);
|
|
35
|
+
await context.reportProgress({ progress: 100, total: 100 });
|
|
36
|
+
return (0, anki_utils_1.createErrorResponse)(new Error(`Model "${modelName}" not found`), {
|
|
37
|
+
modelName: modelName,
|
|
38
|
+
hint: "Use modelNames tool to see available models",
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
if (fieldNames.length === 0) {
|
|
42
|
+
this.logger.warn(`No fields found for model: ${modelName}`);
|
|
43
|
+
await context.reportProgress({ progress: 100, total: 100 });
|
|
44
|
+
return (0, anki_utils_1.createSuccessResponse)({
|
|
45
|
+
success: true,
|
|
46
|
+
modelName: modelName,
|
|
47
|
+
fieldNames: [],
|
|
48
|
+
total: 0,
|
|
49
|
+
message: `Model "${modelName}" has no fields`,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
await context.reportProgress({ progress: 100, total: 100 });
|
|
53
|
+
this.logger.log(`Found ${fieldNames.length} fields for model ${modelName}`);
|
|
54
|
+
let exampleFields;
|
|
55
|
+
const lowerModelName = modelName.toLowerCase();
|
|
56
|
+
if (lowerModelName.includes("basic") &&
|
|
57
|
+
!lowerModelName.includes("reversed")) {
|
|
58
|
+
exampleFields = {
|
|
59
|
+
Front: "Question or prompt text",
|
|
60
|
+
Back: "Answer or response text",
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
else if (lowerModelName.includes("basic") &&
|
|
64
|
+
lowerModelName.includes("reversed")) {
|
|
65
|
+
exampleFields = {
|
|
66
|
+
Front: "First side of the card",
|
|
67
|
+
Back: "Second side of the card",
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
else if (lowerModelName.includes("cloze")) {
|
|
71
|
+
exampleFields = {
|
|
72
|
+
Text: "The {{c1::hidden}} text will be replaced with [...] on the card",
|
|
73
|
+
Extra: "Additional information or hints",
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
const response = {
|
|
77
|
+
success: true,
|
|
78
|
+
modelName: modelName,
|
|
79
|
+
fieldNames: fieldNames,
|
|
80
|
+
total: fieldNames.length,
|
|
81
|
+
message: `Model "${modelName}" has ${fieldNames.length} field${fieldNames.length !== 1 ? "s" : ""}`,
|
|
82
|
+
};
|
|
83
|
+
if (exampleFields) {
|
|
84
|
+
response.example = exampleFields;
|
|
85
|
+
response.hint =
|
|
86
|
+
"Use these field names as keys when creating notes with addNote tool";
|
|
87
|
+
}
|
|
88
|
+
return (0, anki_utils_1.createSuccessResponse)(response);
|
|
89
|
+
}
|
|
90
|
+
catch (error) {
|
|
91
|
+
this.logger.error(`Failed to retrieve field names for model ${modelName}`, error);
|
|
92
|
+
return (0, anki_utils_1.createErrorResponse)(error, {
|
|
93
|
+
modelName: modelName,
|
|
94
|
+
hint: "Make sure the model name is correct and Anki is running",
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
exports.ModelFieldNamesTool = ModelFieldNamesTool;
|
|
100
|
+
__decorate([
|
|
101
|
+
(0, mcp_nest_1.Tool)({
|
|
102
|
+
name: "modelFieldNames",
|
|
103
|
+
description: "Get the field names for a specific note type (model). Use this to know what fields are required when creating notes of this type.",
|
|
104
|
+
parameters: zod_1.z.object({
|
|
105
|
+
modelName: zod_1.z
|
|
106
|
+
.string()
|
|
107
|
+
.min(1)
|
|
108
|
+
.describe("The name of the model/note type to get fields for"),
|
|
109
|
+
}),
|
|
110
|
+
}),
|
|
111
|
+
__metadata("design:type", Function),
|
|
112
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
113
|
+
__metadata("design:returntype", Promise)
|
|
114
|
+
], ModelFieldNamesTool.prototype, "modelFieldNames", null);
|
|
115
|
+
exports.ModelFieldNamesTool = ModelFieldNamesTool = ModelFieldNamesTool_1 = __decorate([
|
|
116
|
+
(0, common_1.Injectable)(),
|
|
117
|
+
__metadata("design:paramtypes", [anki_connect_client_1.AnkiConnectClient])
|
|
118
|
+
], ModelFieldNamesTool);
|
|
119
|
+
//# sourceMappingURL=model-field-names.tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-field-names.tool.js","sourceRoot":"","sources":["../../../../../src/mcp/primitives/essential/tools/model-field-names.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;IAaxD,AAAN,KAAK,CAAC,eAAe,CACnB,EAAE,SAAS,EAAyB,EACpC,OAAgB;QAEhB,IAAI,CAAC;YACH,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,qCAAqC,SAAS,EAAE,CAAC,CAAC;YAClE,MAAM,OAAO,CAAC,cAAc,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC;YAG3D,MAAM,UAAU,GAAG,MAAM,IAAI,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K,CACN,CAAC;YACF,OAAO,IAAA,gCAAmB,EAAC,KAAK,EAAE;gBAChC,SAAS,EAAE,SAAS;gBACpB,IAAI,EAAE,yDAAyD;aAChE,CAAC,CAAC;QACL,CAAC;IACH,CAAC;CACF,CAAA;AApHY,kDAAmB;AAgBxB;IAXL,IAAA,eAAI,EAAC;QACJ,IAAI,EAAE,iBAAiB;QACvB,WAAW,EACT,mIAAmI;QACrI,UAAU,EAAE,OAAC,CAAC,MAAM,CAAC;YACnB,SAAS,EAAE,OAAC;iBACT,MAAM,EAAE;iBACR,GAAG,CAAC,CAAC,CAAC;iBACN,QAAQ,CAAC,mDAAmD,CAAC;SACjE,CAAC;KACH,CAAC;;;;0DAoGD;8BAnHU,mBAAmB;IAD/B,IAAA,mBAAU,GAAE;qCAI8B,uCAAiB;GAH/C,mBAAmB,CAoH/B"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { Context } from "@rekog/mcp-nest";
|
|
2
|
+
import { AnkiConnectClient } from "@/mcp/clients/anki-connect.client";
|
|
3
|
+
export declare class ModelNamesTool {
|
|
4
|
+
private readonly ankiClient;
|
|
5
|
+
private readonly logger;
|
|
6
|
+
constructor(ankiClient: AnkiConnectClient);
|
|
7
|
+
modelNames(_args: Record<string, never>, context: Context): Promise<{
|
|
8
|
+
[x: string]: unknown;
|
|
9
|
+
content: ({
|
|
10
|
+
[x: string]: unknown;
|
|
11
|
+
type: "text";
|
|
12
|
+
text: string;
|
|
13
|
+
_meta?: {
|
|
14
|
+
[x: string]: unknown;
|
|
15
|
+
} | undefined;
|
|
16
|
+
} | {
|
|
17
|
+
[x: string]: unknown;
|
|
18
|
+
type: "image";
|
|
19
|
+
data: string;
|
|
20
|
+
mimeType: string;
|
|
21
|
+
_meta?: {
|
|
22
|
+
[x: string]: unknown;
|
|
23
|
+
} | undefined;
|
|
24
|
+
} | {
|
|
25
|
+
[x: string]: unknown;
|
|
26
|
+
type: "audio";
|
|
27
|
+
data: string;
|
|
28
|
+
mimeType: string;
|
|
29
|
+
_meta?: {
|
|
30
|
+
[x: string]: unknown;
|
|
31
|
+
} | undefined;
|
|
32
|
+
} | {
|
|
33
|
+
[x: string]: unknown;
|
|
34
|
+
type: "resource_link";
|
|
35
|
+
name: string;
|
|
36
|
+
uri: string;
|
|
37
|
+
_meta?: {
|
|
38
|
+
[x: string]: unknown;
|
|
39
|
+
} | undefined;
|
|
40
|
+
mimeType?: string | undefined;
|
|
41
|
+
title?: string | undefined;
|
|
42
|
+
description?: string | undefined;
|
|
43
|
+
icons?: {
|
|
44
|
+
[x: string]: unknown;
|
|
45
|
+
src: string;
|
|
46
|
+
mimeType?: string | undefined;
|
|
47
|
+
sizes?: string[] | undefined;
|
|
48
|
+
}[] | undefined;
|
|
49
|
+
} | {
|
|
50
|
+
[x: string]: unknown;
|
|
51
|
+
type: "resource";
|
|
52
|
+
resource: {
|
|
53
|
+
[x: string]: unknown;
|
|
54
|
+
text: string;
|
|
55
|
+
uri: string;
|
|
56
|
+
_meta?: {
|
|
57
|
+
[x: string]: unknown;
|
|
58
|
+
} | undefined;
|
|
59
|
+
mimeType?: string | undefined;
|
|
60
|
+
} | {
|
|
61
|
+
[x: string]: unknown;
|
|
62
|
+
uri: string;
|
|
63
|
+
blob: string;
|
|
64
|
+
_meta?: {
|
|
65
|
+
[x: string]: unknown;
|
|
66
|
+
} | undefined;
|
|
67
|
+
mimeType?: string | undefined;
|
|
68
|
+
};
|
|
69
|
+
_meta?: {
|
|
70
|
+
[x: string]: unknown;
|
|
71
|
+
} | undefined;
|
|
72
|
+
})[];
|
|
73
|
+
_meta?: {
|
|
74
|
+
[x: string]: unknown;
|
|
75
|
+
} | undefined;
|
|
76
|
+
structuredContent?: {
|
|
77
|
+
[x: string]: unknown;
|
|
78
|
+
} | undefined;
|
|
79
|
+
isError?: boolean | undefined;
|
|
80
|
+
}>;
|
|
81
|
+
}
|
|
@@ -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 ModelNamesTool_1;
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.ModelNamesTool = 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 ModelNamesTool = ModelNamesTool_1 = class ModelNamesTool {
|
|
20
|
+
ankiClient;
|
|
21
|
+
logger = new common_1.Logger(ModelNamesTool_1.name);
|
|
22
|
+
constructor(ankiClient) {
|
|
23
|
+
this.ankiClient = ankiClient;
|
|
24
|
+
}
|
|
25
|
+
async modelNames(_args, context) {
|
|
26
|
+
try {
|
|
27
|
+
this.logger.log("Retrieving model names from Anki");
|
|
28
|
+
await context.reportProgress({ progress: 25, total: 100 });
|
|
29
|
+
const modelNames = await this.ankiClient.invoke("modelNames");
|
|
30
|
+
await context.reportProgress({ progress: 75, total: 100 });
|
|
31
|
+
if (!modelNames || modelNames.length === 0) {
|
|
32
|
+
this.logger.log("No models found");
|
|
33
|
+
await context.reportProgress({ progress: 100, total: 100 });
|
|
34
|
+
return (0, anki_utils_1.createSuccessResponse)({
|
|
35
|
+
success: true,
|
|
36
|
+
message: "No note types found in Anki",
|
|
37
|
+
modelNames: [],
|
|
38
|
+
total: 0,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
await context.reportProgress({ progress: 100, total: 100 });
|
|
42
|
+
this.logger.log(`Found ${modelNames.length} models`);
|
|
43
|
+
return (0, anki_utils_1.createSuccessResponse)({
|
|
44
|
+
success: true,
|
|
45
|
+
modelNames: modelNames,
|
|
46
|
+
total: modelNames.length,
|
|
47
|
+
message: `Found ${modelNames.length} note types`,
|
|
48
|
+
commonTypes: {
|
|
49
|
+
basic: modelNames.includes("Basic") ? "Basic" : null,
|
|
50
|
+
basicReversed: modelNames.includes("Basic (and reversed card)")
|
|
51
|
+
? "Basic (and reversed card)"
|
|
52
|
+
: null,
|
|
53
|
+
cloze: modelNames.includes("Cloze") ? "Cloze" : null,
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
this.logger.error("Failed to retrieve model names", error);
|
|
59
|
+
return (0, anki_utils_1.createErrorResponse)(error, {
|
|
60
|
+
hint: "Make sure Anki is running and AnkiConnect is installed",
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
exports.ModelNamesTool = ModelNamesTool;
|
|
66
|
+
__decorate([
|
|
67
|
+
(0, mcp_nest_1.Tool)({
|
|
68
|
+
name: "modelNames",
|
|
69
|
+
description: "Get a list of all available note type (model) names in Anki. Use this to see what note types are available before creating notes.",
|
|
70
|
+
parameters: zod_1.z.object({}),
|
|
71
|
+
}),
|
|
72
|
+
__metadata("design:type", Function),
|
|
73
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
74
|
+
__metadata("design:returntype", Promise)
|
|
75
|
+
], ModelNamesTool.prototype, "modelNames", null);
|
|
76
|
+
exports.ModelNamesTool = ModelNamesTool = ModelNamesTool_1 = __decorate([
|
|
77
|
+
(0, common_1.Injectable)(),
|
|
78
|
+
__metadata("design:paramtypes", [anki_connect_client_1.AnkiConnectClient])
|
|
79
|
+
], ModelNamesTool);
|
|
80
|
+
//# sourceMappingURL=model-names.tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-names.tool.js","sourceRoot":"","sources":["../../../../../src/mcp/primitives/essential/tools/model-names.tool.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAAoD;AACpD,8CAAuC;AAEvC,6BAAwB;AACxB,8EAAsE;AACtE,0DAGgC;AAMzB,IAAM,cAAc,sBAApB,MAAM,cAAc;IAGI;IAFZ,MAAM,GAAG,IAAI,eAAM,CAAC,gBAAc,CAAC,IAAI,CAAC,CAAC;IAE1D,YAA6B,UAA6B;QAA7B,eAAU,GAAV,UAAU,CAAmB;IAAG,CAAC;IAQxD,AAAN,KAAK,CAAC,UAAU,CAAC,KAA4B,EAAE,OAAgB;QAC7D,IAAI,CAAC;YACH,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,kCAAkC,CAAC,CAAC;YACpD,MAAM,OAAO,CAAC,cAAc,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC;YAG3D,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,MAAM,CAAW,YAAY,CAAC,CAAC;YAExE,MAAM,OAAO,CAAC,cAAc,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC;YAE3D,IAAI,CAAC,UAAU,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBAC3C,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;gBACnC,MAAM,OAAO,CAAC,cAAc,CAAC,EAAE,QAAQ,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,CA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ACrI,UAAU,EAAE,OAAC,CAAC,MAAM,CAAC,EAAE,CAAC;KACzB,CAAC;;;;gDA4CD;yBAtDU,cAAc;IAD1B,IAAA,mBAAU,GAAE;qCAI8B,uCAAiB;GAH/C,cAAc,CAuD1B"}
|
|
@@ -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 ModelStylingTool {
|
|
4
|
+
private readonly ankiClient;
|
|
5
|
+
private readonly logger;
|
|
6
|
+
constructor(ankiClient: AnkiConnectClient);
|
|
7
|
+
modelStyling({ modelName }: {
|
|
8
|
+
modelName: 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,93 @@
|
|
|
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 ModelStylingTool_1;
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.ModelStylingTool = 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 ModelStylingTool = ModelStylingTool_1 = class ModelStylingTool {
|
|
20
|
+
ankiClient;
|
|
21
|
+
logger = new common_1.Logger(ModelStylingTool_1.name);
|
|
22
|
+
constructor(ankiClient) {
|
|
23
|
+
this.ankiClient = ankiClient;
|
|
24
|
+
}
|
|
25
|
+
async modelStyling({ modelName }, context) {
|
|
26
|
+
try {
|
|
27
|
+
this.logger.log(`Retrieving CSS styling for model: ${modelName}`);
|
|
28
|
+
await context.reportProgress({ progress: 25, total: 100 });
|
|
29
|
+
const styling = await this.ankiClient.invoke("modelStyling", {
|
|
30
|
+
modelName: modelName,
|
|
31
|
+
});
|
|
32
|
+
await context.reportProgress({ progress: 75, total: 100 });
|
|
33
|
+
if (!styling || !styling.css) {
|
|
34
|
+
this.logger.warn(`No styling found for model: ${modelName}`);
|
|
35
|
+
await context.reportProgress({ progress: 100, total: 100 });
|
|
36
|
+
return (0, anki_utils_1.createErrorResponse)(new Error(`Model "${modelName}" not found or has no styling`), {
|
|
37
|
+
modelName: modelName,
|
|
38
|
+
hint: "Use modelNames tool to see available models",
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
await context.reportProgress({ progress: 100, total: 100 });
|
|
42
|
+
const css = styling.css;
|
|
43
|
+
const cssLength = css.length;
|
|
44
|
+
const hasCardClass = css.includes(".card");
|
|
45
|
+
const hasFrontClass = css.includes(".front");
|
|
46
|
+
const hasBackClass = css.includes(".back");
|
|
47
|
+
const hasClozeClass = css.includes(".cloze");
|
|
48
|
+
this.logger.log(`Retrieved CSS styling for model ${modelName} (${cssLength} chars)`);
|
|
49
|
+
return (0, anki_utils_1.createSuccessResponse)({
|
|
50
|
+
success: true,
|
|
51
|
+
modelName: modelName,
|
|
52
|
+
css: css,
|
|
53
|
+
cssInfo: {
|
|
54
|
+
length: cssLength,
|
|
55
|
+
hasCardStyling: hasCardClass,
|
|
56
|
+
hasFrontStyling: hasFrontClass,
|
|
57
|
+
hasBackStyling: hasBackClass,
|
|
58
|
+
hasClozeStyling: hasClozeClass,
|
|
59
|
+
},
|
|
60
|
+
message: `Retrieved CSS styling for model "${modelName}"`,
|
|
61
|
+
hint: "This CSS is automatically applied when cards of this type are rendered in Anki",
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
this.logger.error(`Failed to retrieve styling for model ${modelName}`, error);
|
|
66
|
+
return (0, anki_utils_1.createErrorResponse)(error, {
|
|
67
|
+
modelName: modelName,
|
|
68
|
+
hint: "Make sure the model name is correct and Anki is running",
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
exports.ModelStylingTool = ModelStylingTool;
|
|
74
|
+
__decorate([
|
|
75
|
+
(0, mcp_nest_1.Tool)({
|
|
76
|
+
name: "modelStyling",
|
|
77
|
+
description: "Get the CSS styling for a specific note type (model). This CSS is used when rendering cards of this type.",
|
|
78
|
+
parameters: zod_1.z.object({
|
|
79
|
+
modelName: zod_1.z
|
|
80
|
+
.string()
|
|
81
|
+
.min(1)
|
|
82
|
+
.describe("The name of the model/note type to get styling for"),
|
|
83
|
+
}),
|
|
84
|
+
}),
|
|
85
|
+
__metadata("design:type", Function),
|
|
86
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
87
|
+
__metadata("design:returntype", Promise)
|
|
88
|
+
], ModelStylingTool.prototype, "modelStyling", null);
|
|
89
|
+
exports.ModelStylingTool = ModelStylingTool = ModelStylingTool_1 = __decorate([
|
|
90
|
+
(0, common_1.Injectable)(),
|
|
91
|
+
__metadata("design:paramtypes", [anki_connect_client_1.AnkiConnectClient])
|
|
92
|
+
], ModelStylingTool);
|
|
93
|
+
//# sourceMappingURL=model-styling.tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-styling.tool.js","sourceRoot":"","sources":["../../../../../src/mcp/primitives/essential/tools/model-styling.tool.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAAoD;AACpD,8CAAuC;AAEvC,6BAAwB;AACxB,8EAAsE;AACtE,0DAGgC;AAMzB,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;IAaxD,AAAN,KAAK,CAAC,YAAY,CAAC,EAAE,SAAS,EAAyB,EAAE,OAAgB;QACvE,IAAI,CAAC;YACH,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,qCAAqC,SAAS,EAAE,CAAC,CAAC;YAClE,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,CAC1C,cAAc,EACd;gBACE,SAAS,EAAE,SAAS;aACrB,CACF,CAAC;YAEF,MAAM,OAAO,CAAC,cAAc,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC;YAE3D,IAAI,CAAC,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC;gBAC7B,IA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;aACvF,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,MAAM,CAAC,KAAK,CACf,wCAAwC,SAAS,EAAE,EACnD,KAAK,CACN,CAAC;YACF,OAAO,IAAA,gCAAmB,EAAC,KAAK,EAAE;gBAChC,SAAS,EAAE,SAAS;gBACpB,IAAI,EAAE,yDAAyD;aAChE,CAAC,CAAC;QACL,CAAC;IACH,CAAC;CACF,CAAA;AAlFY,4CAAgB;AAgBrB;IAXL,IAAA,eAAI,EAAC;QACJ,IAAI,EAAE,cAAc;QACpB,WAAW,EACT,2GAA2G;QAC7G,UAAU,EAAE,OAAC,CAAC,MAAM,CAAC;YACnB,SAAS,EAAE,OAAC;iBACT,MAAM,EAAE;iBACR,GAAG,CAAC,CAAC,CAAC;iBACN,QAAQ,CAAC,oDAAoD,CAAC;SAClE,CAAC;KACH,CAAC;;;;oDAkED;2BAjFU,gBAAgB;IAD5B,IAAA,mBAAU,GAAE;qCAI8B,uCAAiB;GAH/C,gBAAgB,CAkF5B"}
|
|
@@ -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 NotesInfoTool {
|
|
4
|
+
private readonly ankiClient;
|
|
5
|
+
private readonly logger;
|
|
6
|
+
constructor(ankiClient: AnkiConnectClient);
|
|
7
|
+
notesInfo({ notes }: {
|
|
8
|
+
notes: 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
|
+
}
|