@spacholski1225/anki-connect-mcp 1.0.1
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 +21 -0
- package/README.md +198 -0
- package/dist/index.js +362 -0
- package/dist/methods/anki.js +22 -0
- package/dist/tools/cards.js +118 -0
- package/dist/tools/decks.js +139 -0
- package/dist/tools/graphical.js +133 -0
- package/dist/tools/media.js +48 -0
- package/dist/tools/misc.js +171 -0
- package/dist/tools/models.js +50 -0
- package/dist/tools/notes.js +120 -0
- package/dist/types/anki/base.js +12 -0
- package/dist/types/anki/cards.js +1 -0
- package/dist/types/anki/decks.js +1 -0
- package/dist/types/anki/index.js +9 -0
- package/dist/types/anki/media.js +1 -0
- package/dist/types/anki/misc.js +1 -0
- package/dist/types/anki/models.js +1 -0
- package/dist/types/anki/notes.js +1 -0
- package/package.json +43 -0
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { callAnkiConnect } from '../methods/anki.js';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a note using the given deck and model, with the provided field values and tags.
|
|
4
|
+
* Returns the identifier of the created note on success, and null on failure.
|
|
5
|
+
* @param note - Note object containing deck name, model name, fields, tags, and optional audio
|
|
6
|
+
*/
|
|
7
|
+
export async function addNote(note) {
|
|
8
|
+
const request = {
|
|
9
|
+
action: 'addNote',
|
|
10
|
+
version: 6,
|
|
11
|
+
params: {
|
|
12
|
+
note
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
return await callAnkiConnect(request);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Creates multiple notes using the given deck and model, with the provided field values and tags.
|
|
19
|
+
* Returns an array of identifiers of the created notes (notes that could not be created will have a null identifier).
|
|
20
|
+
* @param notes - Array of note objects to create
|
|
21
|
+
*/
|
|
22
|
+
export async function addNotes(notes) {
|
|
23
|
+
const request = {
|
|
24
|
+
action: 'addNotes',
|
|
25
|
+
version: 6,
|
|
26
|
+
params: {
|
|
27
|
+
notes
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
return await callAnkiConnect(request);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Accepts an array of objects which define parameters for candidate notes and returns an array of booleans
|
|
34
|
+
* indicating whether or not the parameters at the corresponding index could be used to create a new note.
|
|
35
|
+
* @param notes - Array of note objects to check
|
|
36
|
+
*/
|
|
37
|
+
export async function canAddNotes(notes) {
|
|
38
|
+
const request = {
|
|
39
|
+
action: 'canAddNotes',
|
|
40
|
+
version: 6,
|
|
41
|
+
params: {
|
|
42
|
+
notes
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
return await callAnkiConnect(request);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Modify the fields of an existing note.
|
|
49
|
+
* @param noteUpdate - Object containing note ID and fields to update
|
|
50
|
+
*/
|
|
51
|
+
export async function updateNoteFields(noteUpdate) {
|
|
52
|
+
const request = {
|
|
53
|
+
action: 'updateNoteFields',
|
|
54
|
+
version: 6,
|
|
55
|
+
params: {
|
|
56
|
+
note: noteUpdate
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
return await callAnkiConnect(request);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Adds tags to notes by note ID.
|
|
63
|
+
* @param notes - Array of note IDs
|
|
64
|
+
* @param tags - Space-separated string of tags to add
|
|
65
|
+
*/
|
|
66
|
+
export async function addTags(notes, tags) {
|
|
67
|
+
const request = {
|
|
68
|
+
action: 'addTags',
|
|
69
|
+
version: 6,
|
|
70
|
+
params: {
|
|
71
|
+
notes,
|
|
72
|
+
tags
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
return await callAnkiConnect(request);
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Remove tags from notes by note ID.
|
|
79
|
+
* @param notes - Array of note IDs
|
|
80
|
+
* @param tags - Space-separated string of tags to remove
|
|
81
|
+
*/
|
|
82
|
+
export async function removeTags(notes, tags) {
|
|
83
|
+
const request = {
|
|
84
|
+
action: 'removeTags',
|
|
85
|
+
version: 6,
|
|
86
|
+
params: {
|
|
87
|
+
notes,
|
|
88
|
+
tags
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
return await callAnkiConnect(request);
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Returns an array of note IDs for a given query. Same query syntax as guiBrowse.
|
|
95
|
+
* @param query - Search query string
|
|
96
|
+
*/
|
|
97
|
+
export async function findNotes(query) {
|
|
98
|
+
const request = {
|
|
99
|
+
action: 'findNotes',
|
|
100
|
+
version: 6,
|
|
101
|
+
params: {
|
|
102
|
+
query
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
return await callAnkiConnect(request);
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Returns a list of objects containing for each note ID the note fields, tags, note type and the cards belonging to the note.
|
|
109
|
+
* @param notes - Array of note IDs to get information for
|
|
110
|
+
*/
|
|
111
|
+
export async function notesInfo(notes) {
|
|
112
|
+
const request = {
|
|
113
|
+
action: 'notesInfo',
|
|
114
|
+
version: 6,
|
|
115
|
+
params: {
|
|
116
|
+
notes
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
return await callAnkiConnect(request);
|
|
120
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type guard to check if response has error
|
|
3
|
+
*/
|
|
4
|
+
export function hasError(response) {
|
|
5
|
+
return response.error !== null;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Type guard to check if response is successful
|
|
9
|
+
*/
|
|
10
|
+
export function isSuccess(response) {
|
|
11
|
+
return response.error === null;
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@spacholski1225/anki-connect-mcp",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "MCP server for Anki Connect integration",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"anki-connect-mcp": "dist/index.js"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "tsc",
|
|
11
|
+
"prepublishOnly": "npm run build",
|
|
12
|
+
"start": "node dist/index.js"
|
|
13
|
+
},
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "git+https://github.com/spacholski1225/anki-connect-mcp.git"
|
|
17
|
+
},
|
|
18
|
+
"keywords": ["mcp", "anki", "server", "connect"],
|
|
19
|
+
"author": "spacholski1225",
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"type": "module",
|
|
22
|
+
"bugs": {
|
|
23
|
+
"url": "https://github.com/spacholski1225/anki-connect-mcp/issues"
|
|
24
|
+
},
|
|
25
|
+
"homepage": "https://github.com/spacholski1225/anki-connect-mcp#readme",
|
|
26
|
+
"files": [
|
|
27
|
+
"dist/**/*",
|
|
28
|
+
"README.md",
|
|
29
|
+
"package.json"
|
|
30
|
+
],
|
|
31
|
+
"engines": {
|
|
32
|
+
"node": ">=18.0.0"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@types/node": "^22.15.29",
|
|
36
|
+
"ts-node": "^10.9.2",
|
|
37
|
+
"typescript": "^5.8.3"
|
|
38
|
+
},
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"@modelcontextprotocol/sdk": "^1.12.1",
|
|
41
|
+
"axios": "^1.9.0"
|
|
42
|
+
}
|
|
43
|
+
}
|