@laomeifun/my-anki-mcp 0.11.0 → 0.11.2
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 -7
- package/README.md +760 -782
- package/bin/ankimcp.js +12 -12
- package/dist/cli.js +57 -57
- package/dist/mcp/primitives/essential/prompts/review-session.prompt.js +66 -66
- package/dist/mcp/primitives/essential/prompts/twenty-rules.prompt/content.md +195 -195
- package/dist/mcp/primitives/essential/tools/add-note.tool.js +14 -4
- package/dist/mcp/primitives/essential/tools/add-note.tool.js.map +1 -1
- package/dist/mcp/primitives/essential/tools/add-notes.tool.js +19 -5
- package/dist/mcp/primitives/essential/tools/add-notes.tool.js.map +1 -1
- package/dist/mcp/primitives/essential/tools/mediaActions/mediaActions.tool.js +6 -6
- package/dist/mcp/primitives/essential/tools/tagActions/tagActions.tool.js +7 -7
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +183 -183
package/README.md
CHANGED
|
@@ -1,783 +1,761 @@
|
|
|
1
|
-
# Anki MCP
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
>
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
>
|
|
11
|
-
>
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
- `
|
|
40
|
-
- `
|
|
41
|
-
- `
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
- `
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
-
|
|
76
|
-
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
**Method
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
**
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
npm install
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
--
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
The `
|
|
352
|
-
|
|
353
|
-
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
**
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
**
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
-
|
|
410
|
-
-
|
|
411
|
-
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
```bash
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
When
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
The
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
#### Step
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
```
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
**
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
npm run
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
npm
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
#
|
|
671
|
-
npm run
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
npm run
|
|
675
|
-
|
|
676
|
-
#
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
-
|
|
685
|
-
-
|
|
686
|
-
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
- **
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
- **
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
-
|
|
733
|
-
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
-
|
|
737
|
-
-
|
|
738
|
-
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
**
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
-
|
|
756
|
-
|
|
757
|
-
-
|
|
758
|
-
|
|
759
|
-
- [
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
## License & Attribution
|
|
763
|
-
|
|
764
|
-
This project is licensed under the GNU Affero General Public License v3.0 or later (AGPL-3.0-or-later).
|
|
765
|
-
|
|
766
|
-
### Why AGPL-3.0?
|
|
767
|
-
|
|
768
|
-
This license was chosen to maintain compatibility with Anki's AGPL-3.0 license for potential future integration scenarios.
|
|
769
|
-
|
|
770
|
-
**What this means:**
|
|
771
|
-
- **Personal use**: Use the software freely
|
|
772
|
-
- **Running as a service for others**: You must provide source code access (AGPL Section 13)
|
|
773
|
-
- **Modifying and distributing**: Share your improvements under AGPL-3.0-or-later
|
|
774
|
-
|
|
775
|
-
For complete license terms, see the [LICENSE](LICENSE) file.
|
|
776
|
-
|
|
777
|
-
### Third-Party Attributions
|
|
778
|
-
|
|
779
|
-
- **Anki®** is a registered trademark of Ankitects Pty Ltd. This project is an unofficial third-party tool and is not affiliated with, endorsed by, or sponsored by Ankitects Pty Ltd. The Anki logo is used under the alternative license for referencing Anki with a link to [https://apps.ankiweb.net](https://apps.ankiweb.net). For the official Anki application, visit [https://apps.ankiweb.net](https://apps.ankiweb.net).
|
|
780
|
-
|
|
781
|
-
- **Model Context Protocol (MCP)** is an open standard by Anthropic. The MCP logo is from the official [MCP documentation repository](https://github.com/modelcontextprotocol/docs) and is used under the MIT License. For more information about MCP, visit [https://modelcontextprotocol.io](https://modelcontextprotocol.io).
|
|
782
|
-
|
|
1
|
+
# My Anki MCP
|
|
2
|
+
|
|
3
|
+
A Model Context Protocol (MCP) server for Anki - enables AI assistants to interact with your Anki flashcards.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@laomeifun/my-anki-mcp)
|
|
6
|
+
|
|
7
|
+
<div align="center">
|
|
8
|
+
<img src="./docs/images/ankimcp.png" alt="Anki + MCP Integration" width="600" />
|
|
9
|
+
|
|
10
|
+
<p><strong>Seamlessly integrate <a href="https://apps.ankiweb.net">Anki</a> with AI assistants through the <a href="https://modelcontextprotocol.io">Model Context Protocol</a></strong></p>
|
|
11
|
+
</div>
|
|
12
|
+
|
|
13
|
+
**Beta** - This project is in active development. APIs and features may change.
|
|
14
|
+
|
|
15
|
+
A Model Context Protocol (MCP) server that enables AI assistants to interact with Anki, the spaced repetition flashcard application.
|
|
16
|
+
|
|
17
|
+
Transform your Anki experience with natural language interaction.
|
|
18
|
+
|
|
19
|
+
## Available Tools
|
|
20
|
+
|
|
21
|
+
### Review & Study
|
|
22
|
+
- `sync` - Sync with AnkiWeb
|
|
23
|
+
- `get_due_cards` - Get cards for review
|
|
24
|
+
- `present_card` - Show card for review
|
|
25
|
+
- `rate_card` - Rate card performance
|
|
26
|
+
|
|
27
|
+
### Deck Management
|
|
28
|
+
- `list_decks` - Show available decks
|
|
29
|
+
- `createDeck` - Create new decks
|
|
30
|
+
|
|
31
|
+
### Note Management
|
|
32
|
+
- `addNote` - Create new notes
|
|
33
|
+
- `findNotes` - Search for notes using Anki query syntax
|
|
34
|
+
- `notesInfo` - Get detailed information about notes (fields, tags, CSS)
|
|
35
|
+
- `updateNoteFields` - Update existing note fields (CSS-aware, supports HTML)
|
|
36
|
+
- `deleteNotes` - Delete notes and their cards
|
|
37
|
+
|
|
38
|
+
### Media Management
|
|
39
|
+
- `mediaActions` - Manage media files (audio/images)
|
|
40
|
+
- `storeMediaFile` - Upload media from base64 data, file paths, or URLs
|
|
41
|
+
- `retrieveMediaFile` - Download media as base64
|
|
42
|
+
- `getMediaFilesNames` - List media files with optional pattern filtering
|
|
43
|
+
- `deleteMediaFile` - Remove media files
|
|
44
|
+
|
|
45
|
+
**💡 Best Practice for Images:**
|
|
46
|
+
- ✅ **Use file paths** (e.g., `/Users/you/image.png`) - Fast and efficient
|
|
47
|
+
- ✅ **Use URLs** (e.g., `https://example.com/image.jpg`) - Direct download
|
|
48
|
+
- ❌ **Avoid base64** - Extremely slow and token-inefficient
|
|
49
|
+
|
|
50
|
+
Just tell Claude where the image is, and it will handle the upload automatically using the most efficient method.
|
|
51
|
+
|
|
52
|
+
### Model/Template Management
|
|
53
|
+
- `modelNames` - List note types
|
|
54
|
+
- `modelFieldNames` - Get fields for a note type
|
|
55
|
+
- `modelStyling` - Get CSS styling for a note type
|
|
56
|
+
|
|
57
|
+
## Prerequisites
|
|
58
|
+
|
|
59
|
+
- [Anki](https://apps.ankiweb.net/) with [AnkiConnect](https://github.com/FooSoft/anki-connect) plugin installed
|
|
60
|
+
- Node.js 20+
|
|
61
|
+
|
|
62
|
+
## Installation
|
|
63
|
+
|
|
64
|
+
This server works in two modes:
|
|
65
|
+
|
|
66
|
+
- **Local mode (STDIO)** - For Claude Desktop on your computer (recommended for most users)
|
|
67
|
+
- **Remote mode (HTTP)** - For web-based AI assistants like ChatGPT or Claude.ai
|
|
68
|
+
|
|
69
|
+
### Option 1: MCPB Bundle (Recommended - Local Mode)
|
|
70
|
+
|
|
71
|
+
The easiest way to install this MCP server for Claude Desktop:
|
|
72
|
+
|
|
73
|
+
1. Download the latest `.mcpb` bundle from the [Releases](https://github.com/laomeifun/my-anki-mcp/releases) page
|
|
74
|
+
2. In Claude Desktop, install the extension:
|
|
75
|
+
- **Method 1**: Go to Settings → Extensions, then drag and drop the `.mcpb` file
|
|
76
|
+
- **Method 2**: Go to Settings → Developer → Extensions → Install Extension, then select the `.mcpb` file
|
|
77
|
+
3. Configure AnkiConnect URL if needed (defaults to `http://localhost:8765`)
|
|
78
|
+
4. Restart Claude Desktop
|
|
79
|
+
|
|
80
|
+
That's it! The bundle includes everything needed to run the server locally.
|
|
81
|
+
|
|
82
|
+
### Option 2: NPM Package with STDIO (For Other MCP Clients)
|
|
83
|
+
|
|
84
|
+
Want to use Anki with MCP clients like **Cursor IDE**, **Cline**, or **Zed Editor**? Use the npm package with the `--stdio` flag:
|
|
85
|
+
|
|
86
|
+
**Supported Clients:**
|
|
87
|
+
- [Cursor IDE](https://www.cursor.com/) - AI-powered code editor
|
|
88
|
+
- [Cline](https://github.com/cline/cline) - VS Code extension for AI assistance
|
|
89
|
+
- [Zed Editor](https://zed.dev/) - Fast, modern code editor
|
|
90
|
+
- Other MCP clients that support STDIO transport
|
|
91
|
+
|
|
92
|
+
**Configuration - Choose one method:**
|
|
93
|
+
|
|
94
|
+
**Method 1: Using npx (recommended - no installation needed)**
|
|
95
|
+
|
|
96
|
+
```json
|
|
97
|
+
{
|
|
98
|
+
"mcpServers": {
|
|
99
|
+
"anki-mcp": {
|
|
100
|
+
"command": "npx",
|
|
101
|
+
"args": ["-y", "@laomeifun/my-anki-mcp", "--stdio"],
|
|
102
|
+
"env": {
|
|
103
|
+
"ANKI_CONNECT_URL": "http://localhost:8765"
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
**Method 2: Using global installation**
|
|
111
|
+
|
|
112
|
+
First, install globally:
|
|
113
|
+
```bash
|
|
114
|
+
npm install -g @laomeifun/my-anki-mcp
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Then configure:
|
|
118
|
+
```json
|
|
119
|
+
{
|
|
120
|
+
"mcpServers": {
|
|
121
|
+
"anki-mcp": {
|
|
122
|
+
"command": "ankimcp",
|
|
123
|
+
"args": ["--stdio"],
|
|
124
|
+
"env": {
|
|
125
|
+
"ANKI_CONNECT_URL": "http://localhost:8765"
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
**Configuration file locations:**
|
|
133
|
+
- **Cursor IDE**: `~/.cursor/mcp.json` (macOS/Linux) or `%USERPROFILE%\.cursor\mcp.json` (Windows)
|
|
134
|
+
- **Cline**: Accessible via settings UI in VS Code
|
|
135
|
+
- **Zed Editor**: Install as MCP extension through extension marketplace
|
|
136
|
+
|
|
137
|
+
For client-specific features and troubleshooting, consult your MCP client's documentation.
|
|
138
|
+
|
|
139
|
+
### Option 3: HTTP Mode (For Remote AI Assistants)
|
|
140
|
+
|
|
141
|
+
Want to use Anki with ChatGPT or Claude.ai in your browser? This mode lets you connect web-based AI tools to your local Anki.
|
|
142
|
+
|
|
143
|
+
**How it works (simple explanation):**
|
|
144
|
+
1. You run a small server on your computer (where Anki is installed)
|
|
145
|
+
2. Use the built-in `--ngrok` flag to automatically create a public tunnel URL
|
|
146
|
+
3. Share that URL with ChatGPT or Claude.ai
|
|
147
|
+
4. Now the AI can talk to your Anki through the internet!
|
|
148
|
+
|
|
149
|
+
**New in v0.8.0:** Integrated ngrok support with the `--ngrok` flag - no need to run ngrok separately!
|
|
150
|
+
|
|
151
|
+
**Setup - Choose one method:**
|
|
152
|
+
|
|
153
|
+
**Method 1: Using npx (recommended - no installation needed)**
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
# Quick start
|
|
157
|
+
npx @laomeifun/my-anki-mcp
|
|
158
|
+
|
|
159
|
+
# With ngrok tunnel (recommended for web-based AI)
|
|
160
|
+
npx @laomeifun/my-anki-mcp --ngrok
|
|
161
|
+
|
|
162
|
+
# With custom options
|
|
163
|
+
npx @laomeifun/my-anki-mcp --port 8080 --host 0.0.0.0
|
|
164
|
+
npx @laomeifun/my-anki-mcp --anki-connect http://localhost:8765
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
**Method 2: Using global installation**
|
|
168
|
+
|
|
169
|
+
```bash
|
|
170
|
+
# Install once
|
|
171
|
+
npm install -g @laomeifun/my-anki-mcp
|
|
172
|
+
|
|
173
|
+
# Run the server
|
|
174
|
+
ankimcp
|
|
175
|
+
|
|
176
|
+
# With ngrok tunnel (recommended for web-based AI)
|
|
177
|
+
ankimcp --ngrok
|
|
178
|
+
|
|
179
|
+
# With custom options
|
|
180
|
+
ankimcp --port 8080 --host 0.0.0.0
|
|
181
|
+
ankimcp --anki-connect http://localhost:8765
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
**Method 3: Install from source (for development)**
|
|
185
|
+
|
|
186
|
+
```bash
|
|
187
|
+
npm install
|
|
188
|
+
npm run build
|
|
189
|
+
npm run start:prod:http
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
**CLI Options:**
|
|
193
|
+
|
|
194
|
+
```bash
|
|
195
|
+
ankimcp [options]
|
|
196
|
+
|
|
197
|
+
Options:
|
|
198
|
+
--stdio Run in STDIO mode (for MCP clients)
|
|
199
|
+
-p, --port <port> Port to listen on (HTTP mode, default: 3000)
|
|
200
|
+
-h, --host <host> Host to bind to (HTTP mode, default: 127.0.0.1)
|
|
201
|
+
-a, --anki-connect <url> AnkiConnect URL (default: http://localhost:8765)
|
|
202
|
+
--ngrok Start ngrok tunnel (requires global ngrok installation)
|
|
203
|
+
--help Show help message
|
|
204
|
+
|
|
205
|
+
Usage with npx (no installation needed):
|
|
206
|
+
npx @laomeifun/my-anki-mcp # HTTP mode
|
|
207
|
+
npx @laomeifun/my-anki-mcp --port 8080 # Custom port
|
|
208
|
+
npx @laomeifun/my-anki-mcp --stdio # STDIO mode
|
|
209
|
+
npx @laomeifun/my-anki-mcp --ngrok # HTTP mode with ngrok tunnel
|
|
210
|
+
|
|
211
|
+
Usage with global installation:
|
|
212
|
+
npm install -g @laomeifun/my-anki-mcp # Install once
|
|
213
|
+
ankimcp # HTTP mode
|
|
214
|
+
ankimcp --port 8080 # Custom port
|
|
215
|
+
ankimcp --stdio # STDIO mode
|
|
216
|
+
ankimcp --ngrok # HTTP mode with ngrok tunnel
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
**Using with ngrok:**
|
|
220
|
+
|
|
221
|
+
**Method 1: Integrated (Recommended - One Command)**
|
|
222
|
+
|
|
223
|
+
```bash
|
|
224
|
+
# One-time setup (if you haven't already):
|
|
225
|
+
npm install -g ngrok
|
|
226
|
+
ngrok config add-authtoken <your-token> # Get token from https://dashboard.ngrok.com
|
|
227
|
+
|
|
228
|
+
# Start server with ngrok tunnel in one command:
|
|
229
|
+
ankimcp --ngrok
|
|
230
|
+
|
|
231
|
+
# The tunnel URL will be displayed in the startup banner
|
|
232
|
+
# Example output:
|
|
233
|
+
# 🌐 Ngrok tunnel: https://abc123.ngrok-free.app
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
**Method 2: Manual (Two Terminals)**
|
|
237
|
+
|
|
238
|
+
```bash
|
|
239
|
+
# Terminal 1: Start the server
|
|
240
|
+
ankimcp
|
|
241
|
+
|
|
242
|
+
# Terminal 2: Create tunnel
|
|
243
|
+
ngrok http 3000
|
|
244
|
+
|
|
245
|
+
# Copy the ngrok URL (looks like: https://abc123.ngrok-free.app)
|
|
246
|
+
# Share this URL with your AI assistant
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
**Benefits of `--ngrok` flag:**
|
|
250
|
+
- ✅ One command instead of two terminals
|
|
251
|
+
- ✅ Automatic cleanup when you press Ctrl+C
|
|
252
|
+
- ✅ URL displayed directly in the startup banner
|
|
253
|
+
- ✅ Works with custom ports: `ankimcp --port 8080 --ngrok`
|
|
254
|
+
|
|
255
|
+
**Security note:** Anyone with your ngrok URL can access your Anki, so keep that URL private!
|
|
256
|
+
|
|
257
|
+
### Option 4: Manual Installation from Source (Local Mode)
|
|
258
|
+
|
|
259
|
+
For development or advanced usage:
|
|
260
|
+
|
|
261
|
+
```bash
|
|
262
|
+
npm install
|
|
263
|
+
npm run build
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
## Connect to Claude Desktop (Local Mode)
|
|
267
|
+
|
|
268
|
+
You can configure the server in Claude Desktop by either:
|
|
269
|
+
- Going to: Settings → Developer → Edit Config
|
|
270
|
+
- Or manually editing the config file
|
|
271
|
+
|
|
272
|
+
### Configuration
|
|
273
|
+
|
|
274
|
+
Add the following to your Claude Desktop config:
|
|
275
|
+
|
|
276
|
+
```json
|
|
277
|
+
{
|
|
278
|
+
"mcpServers": {
|
|
279
|
+
"anki-mcp": {
|
|
280
|
+
"command": "node",
|
|
281
|
+
"args": ["/path/to/anki-mcp-server/dist/main-stdio.js"],
|
|
282
|
+
"env": {
|
|
283
|
+
"ANKI_CONNECT_URL": "http://localhost:8765"
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
Replace `/path/to/anki-mcp-server` with your actual project path.
|
|
291
|
+
|
|
292
|
+
### Config File Locations
|
|
293
|
+
|
|
294
|
+
- **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
|
|
295
|
+
- **Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
|
|
296
|
+
- **Linux**: `~/.config/Claude/claude_desktop_config.json`
|
|
297
|
+
|
|
298
|
+
For more details, see the [official MCP documentation](https://modelcontextprotocol.io/docs/develop/connect-local-servers).
|
|
299
|
+
|
|
300
|
+
## Environment Variables (Optional)
|
|
301
|
+
|
|
302
|
+
| Variable | Description | Default |
|
|
303
|
+
|----------|-------------|---------|
|
|
304
|
+
| `ANKI_CONNECT_URL` | AnkiConnect URL | `http://localhost:8765` |
|
|
305
|
+
| `ANKI_CONNECT_API_VERSION` | API version | `6` |
|
|
306
|
+
| `ANKI_CONNECT_API_KEY` | API key if configured in AnkiConnect | - |
|
|
307
|
+
| `ANKI_CONNECT_TIMEOUT` | Request timeout in ms | `5000` |
|
|
308
|
+
|
|
309
|
+
## Usage Examples
|
|
310
|
+
|
|
311
|
+
### Searching and Updating Notes
|
|
312
|
+
|
|
313
|
+
```
|
|
314
|
+
# Search for notes in a specific deck
|
|
315
|
+
findNotes(query: "deck:Spanish")
|
|
316
|
+
|
|
317
|
+
# Get detailed information about notes
|
|
318
|
+
notesInfo(notes: [1234567890, 1234567891])
|
|
319
|
+
|
|
320
|
+
# Update a note's fields (HTML content supported)
|
|
321
|
+
updateNoteFields(note: {
|
|
322
|
+
id: 1234567890,
|
|
323
|
+
fields: {
|
|
324
|
+
"Front": "<b>¿Cómo estás?</b>",
|
|
325
|
+
"Back": "How are you?"
|
|
326
|
+
}
|
|
327
|
+
})
|
|
328
|
+
|
|
329
|
+
# Delete notes (requires confirmation)
|
|
330
|
+
deleteNotes(notes: [1234567890], confirmDeletion: true)
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
### Anki Query Syntax Examples
|
|
334
|
+
|
|
335
|
+
The `findNotes` tool supports Anki's powerful query syntax:
|
|
336
|
+
|
|
337
|
+
- `"deck:DeckName"` - All notes in a specific deck
|
|
338
|
+
- `"tag:important"` - Notes with the "important" tag
|
|
339
|
+
- `"is:due"` - Cards that are due for review
|
|
340
|
+
- `"is:new"` - New cards that haven't been studied
|
|
341
|
+
- `"added:7"` - Notes added in the last 7 days
|
|
342
|
+
- `"front:hello"` - Notes with "hello" in the front field
|
|
343
|
+
- `"flag:1"` - Notes with red flag
|
|
344
|
+
- `"prop:due<=2"` - Cards due within 2 days
|
|
345
|
+
- `"deck:Spanish tag:verb"` - Spanish deck notes with verb tag (AND)
|
|
346
|
+
- `"deck:Spanish OR deck:French"` - Notes from either deck
|
|
347
|
+
|
|
348
|
+
### Important Notes
|
|
349
|
+
|
|
350
|
+
#### CSS and HTML Handling
|
|
351
|
+
- The `notesInfo` tool returns CSS styling information for proper rendering awareness
|
|
352
|
+
- The `updateNoteFields` tool supports HTML content in fields and preserves CSS styling
|
|
353
|
+
- Each note model has its own CSS styling - use `modelStyling` to get model-specific CSS
|
|
354
|
+
|
|
355
|
+
#### Update Warning
|
|
356
|
+
⚠️ **IMPORTANT**: When using `updateNoteFields`, do NOT view the note in Anki's browser while updating, or the fields will not update properly. Close the browser or switch to a different note before updating. See [Known Issues](#known-issues) for more details.
|
|
357
|
+
|
|
358
|
+
#### Deletion Safety
|
|
359
|
+
The `deleteNotes` tool requires explicit confirmation (`confirmDeletion: true`) to prevent accidental deletions. Deleting a note removes ALL associated cards permanently.
|
|
360
|
+
|
|
361
|
+
## Known Issues
|
|
362
|
+
|
|
363
|
+
### Critical Limitations
|
|
364
|
+
|
|
365
|
+
#### Note Updates Fail When Viewed in Browser
|
|
366
|
+
⚠️ **IMPORTANT**: When updating notes using `updateNoteFields`, the update will silently fail if the note is currently being viewed in Anki's browser window. This is an upstream AnkiConnect limitation.
|
|
367
|
+
|
|
368
|
+
**Workaround**: Always close the browser or navigate to a different note before updating.
|
|
369
|
+
|
|
370
|
+
## Development
|
|
371
|
+
|
|
372
|
+
### Transport Modes
|
|
373
|
+
|
|
374
|
+
This server supports two MCP transport modes via **separate entry points**:
|
|
375
|
+
|
|
376
|
+
#### STDIO Mode (Default)
|
|
377
|
+
- For local MCP clients like Claude Desktop
|
|
378
|
+
- Uses standard input/output for communication
|
|
379
|
+
- **Entry point**: `dist/main-stdio.js`
|
|
380
|
+
- **Run**: `npm run start:prod:stdio` or `node dist/main-stdio.js`
|
|
381
|
+
- **MCPB bundle**: Uses STDIO mode
|
|
382
|
+
|
|
383
|
+
#### HTTP Mode (Streamable HTTP)
|
|
384
|
+
- For remote MCP clients and web-based integrations
|
|
385
|
+
- Uses MCP Streamable HTTP protocol
|
|
386
|
+
- **Entry point**: `dist/main-http.js`
|
|
387
|
+
- **Run**: `npm run start:prod:http` or `node dist/main-http.js`
|
|
388
|
+
- **Default port**: 3000 (configurable via `PORT` env var)
|
|
389
|
+
- **Default host**: `127.0.0.1` (configurable via `HOST` env var)
|
|
390
|
+
- **MCP endpoint**: `http://127.0.0.1:3000/` (root path)
|
|
391
|
+
|
|
392
|
+
#### Building
|
|
393
|
+
|
|
394
|
+
```bash
|
|
395
|
+
npm run build # Builds once, creates dist/ with both entry points
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
Both `main-stdio.js` and `main-http.js` are in the same `dist/` directory. Choose which to run based on your needs.
|
|
399
|
+
|
|
400
|
+
#### HTTP Mode Configuration
|
|
401
|
+
|
|
402
|
+
**Environment Variables:**
|
|
403
|
+
- `PORT` - HTTP server port (default: 3000)
|
|
404
|
+
- `HOST` - Bind address (default: 127.0.0.1 for localhost-only)
|
|
405
|
+
- `ALLOWED_ORIGINS` - Comma-separated list of allowed origins for CORS (default: localhost)
|
|
406
|
+
- `LOG_LEVEL` - Logging level (default: info)
|
|
407
|
+
|
|
408
|
+
**Security:**
|
|
409
|
+
- Origin header validation (prevents DNS rebinding attacks)
|
|
410
|
+
- Binds to localhost (127.0.0.1) by default
|
|
411
|
+
- No authentication in current version (OAuth support planned)
|
|
412
|
+
|
|
413
|
+
**Example: Running Modes**
|
|
414
|
+
```bash
|
|
415
|
+
# Development - STDIO mode (watch mode with auto-rebuild)
|
|
416
|
+
npm run start:dev:stdio
|
|
417
|
+
|
|
418
|
+
# Development - HTTP mode (watch mode with auto-rebuild)
|
|
419
|
+
npm run start:dev:http
|
|
420
|
+
|
|
421
|
+
# Production - STDIO mode
|
|
422
|
+
npm run start:prod:stdio
|
|
423
|
+
# or
|
|
424
|
+
node dist/main-stdio.js
|
|
425
|
+
|
|
426
|
+
# Production - HTTP mode
|
|
427
|
+
npm run start:prod:http
|
|
428
|
+
# or
|
|
429
|
+
PORT=8080 HOST=0.0.0.0 node dist/main-http.js
|
|
430
|
+
```
|
|
431
|
+
|
|
432
|
+
### Building an MCPB Bundle
|
|
433
|
+
|
|
434
|
+
To create a distributable MCPB bundle:
|
|
435
|
+
|
|
436
|
+
```bash
|
|
437
|
+
npm run mcpb:bundle
|
|
438
|
+
```
|
|
439
|
+
|
|
440
|
+
This command will:
|
|
441
|
+
1. Sync version from `package.json` to `manifest.json`
|
|
442
|
+
2. Remove old `.mcpb` files
|
|
443
|
+
3. Build the TypeScript project
|
|
444
|
+
4. Package `dist/` and `node_modules/` into an `.mcpb` file
|
|
445
|
+
5. Run `mcpb clean` to remove devDependencies (optimizes bundle from ~47MB to ~10MB)
|
|
446
|
+
|
|
447
|
+
The output file will be named `anki-mcp-server-X.X.X.mcpb` and can be distributed for one-click installation.
|
|
448
|
+
|
|
449
|
+
#### What Gets Bundled
|
|
450
|
+
|
|
451
|
+
The MCPB package includes:
|
|
452
|
+
- Compiled JavaScript (`dist/` directory - includes both entry points)
|
|
453
|
+
- Production dependencies only (`node_modules/` - devDependencies removed by `mcpb clean`)
|
|
454
|
+
- Package metadata (`package.json`)
|
|
455
|
+
- Manifest configuration (`manifest.json` - configured to use `main-stdio.js`)
|
|
456
|
+
- Icon (`icon.png`)
|
|
457
|
+
|
|
458
|
+
Source files, tests, and development configs are automatically excluded via `.mcpbignore`.
|
|
459
|
+
|
|
460
|
+
### Logging in Claude Desktop
|
|
461
|
+
|
|
462
|
+
When running as an MCPB extension in Claude Desktop, logs are written to:
|
|
463
|
+
|
|
464
|
+
**Log Location**: `~/Library/Logs/Claude/` (macOS)
|
|
465
|
+
|
|
466
|
+
The logs are split across multiple files:
|
|
467
|
+
- **main.log** - General Claude Desktop application logs
|
|
468
|
+
- **mcp-server-Anki MCP Server.log** - MCP protocol messages for this extension
|
|
469
|
+
- **mcp.log** - Combined MCP logs from all servers
|
|
470
|
+
|
|
471
|
+
**Note**: The pino logger output (INFO, ERROR, WARN messages from the server code) goes to stderr and appears in the MCP-specific log files. Claude Desktop determines which log file receives which messages, but generally:
|
|
472
|
+
- Application startup and MCP protocol communication → MCP-specific log
|
|
473
|
+
- Server internal logging (pino) → Both MCP-specific log and sometimes main.log
|
|
474
|
+
|
|
475
|
+
To view logs in real-time:
|
|
476
|
+
```bash
|
|
477
|
+
tail -f ~/Library/Logs/Claude/mcp-server-Anki\ MCP\ Server.log
|
|
478
|
+
```
|
|
479
|
+
|
|
480
|
+
### Debugging the MCP Server
|
|
481
|
+
|
|
482
|
+
You can debug the MCP server using the MCP Inspector and attaching a debugger from your IDE (WebStorm, VS Code, etc.).
|
|
483
|
+
|
|
484
|
+
**Note for HTTP Mode:** When testing HTTP mode (Streamable HTTP) with MCP Inspector, use "Connection Type: Via Proxy" to avoid CORS errors.
|
|
485
|
+
|
|
486
|
+
#### Step 1: Configure Debug Server in MCP Inspector
|
|
487
|
+
|
|
488
|
+
The `mcp-inspector-config.json` already includes a debug server configuration:
|
|
489
|
+
|
|
490
|
+
```json
|
|
491
|
+
{
|
|
492
|
+
"mcpServers": {
|
|
493
|
+
"stdio-server-debug": {
|
|
494
|
+
"type": "stdio",
|
|
495
|
+
"command": "node",
|
|
496
|
+
"args": ["--inspect-brk=9229", "dist/main-stdio.js"],
|
|
497
|
+
"env": {
|
|
498
|
+
"MCP_SERVER_NAME": "anki-mcp-stdio-debug",
|
|
499
|
+
"MCP_SERVER_VERSION": "1.0.0",
|
|
500
|
+
"LOG_LEVEL": "debug"
|
|
501
|
+
},
|
|
502
|
+
"note": "Anki MCP server with debugging enabled on port 9229"
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
```
|
|
507
|
+
|
|
508
|
+
#### Step 2: Start the Debug Server
|
|
509
|
+
|
|
510
|
+
Run the MCP Inspector with the debug server:
|
|
511
|
+
|
|
512
|
+
```bash
|
|
513
|
+
npm run inspector:debug
|
|
514
|
+
```
|
|
515
|
+
|
|
516
|
+
This will start the server with Node.js debugging enabled on port 9229 and pause execution at the first line.
|
|
517
|
+
|
|
518
|
+
#### Step 3: Attach Debugger from Your IDE
|
|
519
|
+
|
|
520
|
+
##### WebStorm
|
|
521
|
+
1. Go to **Run → Edit Configurations**
|
|
522
|
+
2. Add a new **Attach to Node.js/Chrome** configuration
|
|
523
|
+
3. Set the port to `9229`
|
|
524
|
+
4. Click **Debug** to attach
|
|
525
|
+
|
|
526
|
+
##### VS Code
|
|
527
|
+
1. Open the Debug panel (Ctrl+Shift+D / Cmd+Shift+D)
|
|
528
|
+
2. Select **Debug MCP Server (Attach)** configuration
|
|
529
|
+
3. Press F5 to attach
|
|
530
|
+
|
|
531
|
+
#### Step 4: Set Breakpoints and Debug
|
|
532
|
+
|
|
533
|
+
Once attached, you can:
|
|
534
|
+
- Set breakpoints in your TypeScript source files
|
|
535
|
+
- Step through code execution
|
|
536
|
+
- Inspect variables and call stack
|
|
537
|
+
- Use the debug console for evaluating expressions
|
|
538
|
+
|
|
539
|
+
The debugger will work with source maps, allowing you to debug the original TypeScript code rather than the compiled JavaScript.
|
|
540
|
+
|
|
541
|
+
### Debugging with Claude Desktop
|
|
542
|
+
|
|
543
|
+
You can also debug the MCP server while it runs inside Claude Desktop by enabling the Node.js debugger and attaching your IDE.
|
|
544
|
+
|
|
545
|
+
#### Step 1: Configure Claude Desktop for Debugging
|
|
546
|
+
|
|
547
|
+
Update your Claude Desktop config to enable debugging:
|
|
548
|
+
|
|
549
|
+
**macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
|
|
550
|
+
**Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
|
|
551
|
+
**Linux**: `~/.config/Claude/claude_desktop_config.json`
|
|
552
|
+
|
|
553
|
+
```json
|
|
554
|
+
{
|
|
555
|
+
"mcpServers": {
|
|
556
|
+
"anki-mcp": {
|
|
557
|
+
"command": "node",
|
|
558
|
+
"args": [
|
|
559
|
+
"--inspect=9229",
|
|
560
|
+
"<path_to_project>/anki-mcp-server/dist/main-stdio.js"
|
|
561
|
+
],
|
|
562
|
+
"env": {
|
|
563
|
+
"ANKI_CONNECT_URL": "http://localhost:8765"
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
```
|
|
569
|
+
|
|
570
|
+
**Key change**: Add `--inspect=9229` before the path to `dist/main-stdio.js`
|
|
571
|
+
|
|
572
|
+
**Debug options**:
|
|
573
|
+
- `--inspect=9229` - Start debugger immediately, doesn't block (recommended)
|
|
574
|
+
- `--inspect-brk=9229` - Pause execution until debugger attaches (for debugging startup issues)
|
|
575
|
+
|
|
576
|
+
#### Step 2: Restart Claude Desktop
|
|
577
|
+
|
|
578
|
+
After saving the config, restart Claude Desktop. The MCP server will now run with debugging enabled on port 9229.
|
|
579
|
+
|
|
580
|
+
#### Step 3: Attach Debugger from Your IDE
|
|
581
|
+
|
|
582
|
+
##### WebStorm
|
|
583
|
+
|
|
584
|
+
1. Go to **Run → Edit Configurations**
|
|
585
|
+
2. Click the **+** button and select **Attach to Node.js/Chrome**
|
|
586
|
+
3. Configure:
|
|
587
|
+
- **Name**: `Attach to Anki MCP (Claude Desktop)`
|
|
588
|
+
- **Host**: `localhost`
|
|
589
|
+
- **Port**: `9229`
|
|
590
|
+
- **Attach to**: `Node.js < 8` or `Chrome or Node.js > 6.3` (depending on WebStorm version)
|
|
591
|
+
4. Click **OK**
|
|
592
|
+
5. Click **Debug** (Shift+F9) to attach
|
|
593
|
+
|
|
594
|
+
##### VS Code
|
|
595
|
+
|
|
596
|
+
1. Add to `.vscode/launch.json`:
|
|
597
|
+
|
|
598
|
+
```json
|
|
599
|
+
{
|
|
600
|
+
"version": "0.2.0",
|
|
601
|
+
"configurations": [
|
|
602
|
+
{
|
|
603
|
+
"type": "node",
|
|
604
|
+
"request": "attach",
|
|
605
|
+
"name": "Attach to Anki MCP (Claude Desktop)",
|
|
606
|
+
"port": 9229,
|
|
607
|
+
"skipFiles": ["<node_internals>/**"],
|
|
608
|
+
"sourceMaps": true,
|
|
609
|
+
"outFiles": ["${workspaceFolder}/dist/**/*.js"]
|
|
610
|
+
}
|
|
611
|
+
]
|
|
612
|
+
}
|
|
613
|
+
```
|
|
614
|
+
|
|
615
|
+
2. Open the Debug panel (Ctrl+Shift+D / Cmd+Shift+D)
|
|
616
|
+
3. Select **Attach to Anki MCP (Claude Desktop)**
|
|
617
|
+
4. Press F5 to attach
|
|
618
|
+
|
|
619
|
+
#### Step 4: Debug in Real-Time
|
|
620
|
+
|
|
621
|
+
Once attached, you can:
|
|
622
|
+
- Set breakpoints in your TypeScript source files (e.g., `src/mcp/primitives/essential/tools/create-model.tool.ts`)
|
|
623
|
+
- Use Claude Desktop normally - breakpoints will hit when tools are invoked
|
|
624
|
+
- Step through code execution
|
|
625
|
+
- Inspect variables and call stack
|
|
626
|
+
- Use the debug console
|
|
627
|
+
|
|
628
|
+
**Example**: Set a breakpoint in `create-model.tool.ts` at line 119, then ask Claude to create a new model. The debugger will pause at your breakpoint!
|
|
629
|
+
|
|
630
|
+
**Note**: The debugger stays attached as long as Claude Desktop is running. You can detach/reattach anytime without restarting Claude Desktop.
|
|
631
|
+
|
|
632
|
+
### Build Commands
|
|
633
|
+
|
|
634
|
+
```bash
|
|
635
|
+
npm run build # Build the project (compile TypeScript to JavaScript)
|
|
636
|
+
npm run start:dev:stdio # STDIO mode with watch (auto-rebuild)
|
|
637
|
+
npm run start:dev:http # HTTP mode with watch (auto-rebuild)
|
|
638
|
+
npm run type-check # Run TypeScript type checking
|
|
639
|
+
npm run lint # Run ESLint
|
|
640
|
+
npm run mcpb:bundle # Sync version, clean, build, and create MCPB bundle
|
|
641
|
+
```
|
|
642
|
+
|
|
643
|
+
### NPM Package Testing (Local)
|
|
644
|
+
|
|
645
|
+
Test the npm package locally before publishing:
|
|
646
|
+
|
|
647
|
+
```bash
|
|
648
|
+
# 1. Create local package
|
|
649
|
+
npm run pack:local # Builds and creates @laomeifun/my-anki-mcp-*.tgz
|
|
650
|
+
|
|
651
|
+
# 2. Install globally from local package
|
|
652
|
+
npm run install:local # Installs from ./@laomeifun/my-anki-mcp-*.tgz
|
|
653
|
+
|
|
654
|
+
# 3. Test the command
|
|
655
|
+
ankimcp # Runs HTTP server on port 3000
|
|
656
|
+
|
|
657
|
+
# 4. Uninstall when done testing
|
|
658
|
+
npm run uninstall:local # Removes global installation
|
|
659
|
+
```
|
|
660
|
+
|
|
661
|
+
**How it works:**
|
|
662
|
+
- `npm pack` creates a `.tgz` file identical to what npm publish would create
|
|
663
|
+
- Installing from `.tgz` simulates what users get from `npm install -g @laomeifun/my-anki-mcp`
|
|
664
|
+
- This lets you test the full user experience before publishing to npm
|
|
665
|
+
|
|
666
|
+
### Testing Commands
|
|
667
|
+
|
|
668
|
+
```bash
|
|
669
|
+
npm test # Run all tests
|
|
670
|
+
npm run test:unit # Run unit tests only
|
|
671
|
+
npm run test:tools # Run tool-specific tests
|
|
672
|
+
npm run test:workflows # Run workflow integration tests
|
|
673
|
+
npm run test:e2e # Run end-to-end tests
|
|
674
|
+
npm run test:cov # Run tests with coverage report
|
|
675
|
+
npm run test:watch # Run tests in watch mode
|
|
676
|
+
npm run test:debug # Run tests with debugger
|
|
677
|
+
npm run test:ci # Run tests for CI (silent, with coverage)
|
|
678
|
+
```
|
|
679
|
+
|
|
680
|
+
### Test Coverage
|
|
681
|
+
|
|
682
|
+
The project maintains 70% minimum coverage thresholds for:
|
|
683
|
+
- Branches
|
|
684
|
+
- Functions
|
|
685
|
+
- Lines
|
|
686
|
+
- Statements
|
|
687
|
+
|
|
688
|
+
Coverage reports are generated in the `coverage/` directory.
|
|
689
|
+
|
|
690
|
+
## Versioning
|
|
691
|
+
|
|
692
|
+
This project follows [Semantic Versioning](https://semver.org/) with a pre-1.0 development approach:
|
|
693
|
+
|
|
694
|
+
- **0.x.x** - Beta/Development versions (current phase)
|
|
695
|
+
- **0.1.x** - Bug fixes and patches
|
|
696
|
+
- **0.2.0+** - New features or minor improvements
|
|
697
|
+
- **Breaking changes** are acceptable in 0.x versions
|
|
698
|
+
|
|
699
|
+
- **1.0.0** - First stable release
|
|
700
|
+
- Will be released when the API is stable and tested
|
|
701
|
+
- Breaking changes will require major version bumps (2.0.0, etc.)
|
|
702
|
+
|
|
703
|
+
**Current Status**: `0.8.0` - Active beta development. New features include integrated ngrok tunneling (`--ngrok` flag), the `twenty_rules` prompt for evidence-based flashcard creation, media file management, and improved prompt system. APIs may change based on feedback and testing.
|
|
704
|
+
|
|
705
|
+
## Similar Projects
|
|
706
|
+
|
|
707
|
+
If you're exploring Anki MCP integrations, here are other projects in this space:
|
|
708
|
+
|
|
709
|
+
### [scorzeth/anki-mcp-server](https://github.com/scorzeth/anki-mcp-server)
|
|
710
|
+
- **Status**: Appears to be abandoned (no recent updates)
|
|
711
|
+
- Early implementation of Anki MCP integration
|
|
712
|
+
|
|
713
|
+
### [nailuoGG/anki-mcp-server](https://github.com/nailuoGG/anki-mcp-server)
|
|
714
|
+
- **Approach**: Lightweight, single-file implementation
|
|
715
|
+
- **Architecture**: Procedural code structure with all tools in one file
|
|
716
|
+
- **Good for**: Simple use cases, minimal dependencies
|
|
717
|
+
|
|
718
|
+
**Why this project differs:**
|
|
719
|
+
- **Enterprise-grade architecture**: Built on NestJS with dependency injection
|
|
720
|
+
- **Modular design**: Each tool is a separate class with clear separation of concerns
|
|
721
|
+
- **Maintainability**: Easy to extend with new features without touching existing code
|
|
722
|
+
- **Testing**: Comprehensive test suite with 70% coverage requirement
|
|
723
|
+
- **Type safety**: Strict TypeScript with Zod validation
|
|
724
|
+
- **Error handling**: Robust error handling with helpful user feedback
|
|
725
|
+
- **Production-ready**: Proper logging, progress reporting, and MCPB bundle support
|
|
726
|
+
- **Scalability**: Can easily grow from basic tools to complex workflows
|
|
727
|
+
|
|
728
|
+
**Use case**: If you need a solid foundation for building advanced Anki integrations or plan to extend functionality significantly, this project's architectural approach makes it easier to maintain and scale over time.
|
|
729
|
+
|
|
730
|
+
## Useful Links
|
|
731
|
+
|
|
732
|
+
- [Model Context Protocol Documentation](https://modelcontextprotocol.io/docs)
|
|
733
|
+
- [AnkiConnect API Documentation](https://git.sr.ht/~foosoft/anki-connect)
|
|
734
|
+
- [Claude Desktop Download](https://claude.ai/download)
|
|
735
|
+
- [Building Desktop Extensions (Anthropic Blog)](https://www.anthropic.com/engineering/desktop-extensions)
|
|
736
|
+
- [MCP Servers Repository](https://github.com/modelcontextprotocol/servers)
|
|
737
|
+
- [NestJS Documentation](https://docs.nestjs.com)
|
|
738
|
+
- [Anki Official Website](https://apps.ankiweb.net/)
|
|
739
|
+
|
|
740
|
+
## License & Attribution
|
|
741
|
+
|
|
742
|
+
This project is licensed under the GNU Affero General Public License v3.0 or later (AGPL-3.0-or-later).
|
|
743
|
+
|
|
744
|
+
### Why AGPL-3.0?
|
|
745
|
+
|
|
746
|
+
This license was chosen to maintain compatibility with Anki's AGPL-3.0 license for potential future integration scenarios.
|
|
747
|
+
|
|
748
|
+
**What this means:**
|
|
749
|
+
- **Personal use**: Use the software freely
|
|
750
|
+
- **Running as a service for others**: You must provide source code access (AGPL Section 13)
|
|
751
|
+
- **Modifying and distributing**: Share your improvements under AGPL-3.0-or-later
|
|
752
|
+
|
|
753
|
+
For complete license terms, see the [LICENSE](LICENSE) file.
|
|
754
|
+
|
|
755
|
+
### Third-Party Attributions
|
|
756
|
+
|
|
757
|
+
- **Anki®** is a registered trademark of Ankitects Pty Ltd. This project is an unofficial third-party tool and is not affiliated with, endorsed by, or sponsored by Ankitects Pty Ltd. The Anki logo is used under the alternative license for referencing Anki with a link to [https://apps.ankiweb.net](https://apps.ankiweb.net). For the official Anki application, visit [https://apps.ankiweb.net](https://apps.ankiweb.net).
|
|
758
|
+
|
|
759
|
+
- **Model Context Protocol (MCP)** is an open standard by Anthropic. The MCP logo is from the official [MCP documentation repository](https://github.com/modelcontextprotocol/docs) and is used under the MIT License. For more information about MCP, visit [https://modelcontextprotocol.io](https://modelcontextprotocol.io).
|
|
760
|
+
|
|
783
761
|
- This is an independent project that bridges Anki and MCP technologies. All trademarks, service marks, trade names, product names, and logos are the property of their respective owners.
|