iflow-mcp_ujisati_anki-mcp 0.1.0__tar.gz

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.
@@ -0,0 +1,175 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py,cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ #Pipfile.lock
96
+
97
+ # UV
98
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ #uv.lock
102
+
103
+ # poetry
104
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
105
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
106
+ # commonly ignored for libraries.
107
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
108
+ #poetry.lock
109
+
110
+ # pdm
111
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
112
+ #pdm.lock
113
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
114
+ # in version control.
115
+ # https://pdm.fming.dev/latest/usage/project/#working-with-version-control
116
+ .pdm.toml
117
+ .pdm-python
118
+ .pdm-build/
119
+
120
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
121
+ __pypackages__/
122
+
123
+ # Celery stuff
124
+ celerybeat-schedule
125
+ celerybeat.pid
126
+
127
+ # SageMath parsed files
128
+ *.sage.py
129
+
130
+ # Environments
131
+ .env
132
+ .venv
133
+ env/
134
+ venv/
135
+ ENV/
136
+ env.bak/
137
+ venv.bak/
138
+
139
+ # Spyder project settings
140
+ .spyderproject
141
+ .spyproject
142
+
143
+ # Rope project settings
144
+ .ropeproject
145
+
146
+ # mkdocs documentation
147
+ /site
148
+
149
+ # mypy
150
+ .mypy_cache/
151
+ .dmypy.json
152
+ dmypy.json
153
+
154
+ # Pyre type checker
155
+ .pyre/
156
+
157
+ # pytype static type analyzer
158
+ .pytype/
159
+
160
+ # Cython debug symbols
161
+ cython_debug/
162
+
163
+ # PyCharm
164
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
165
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
166
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
167
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
168
+ #.idea/
169
+
170
+ # Ruff stuff:
171
+ .ruff_cache/
172
+
173
+ # PyPI configuration file
174
+ .pypirc
175
+ .aider*
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 ujisati
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,150 @@
1
+ Metadata-Version: 2.4
2
+ Name: iflow-mcp_ujisati_anki-mcp
3
+ Version: 0.1.0
4
+ Summary: Add your description here
5
+ Author-email: ujisati <98663233+ujisati@users.noreply.github.com>
6
+ License-File: LICENSE
7
+ Requires-Python: >=3.11
8
+ Requires-Dist: fastmcp>=2.3.3
9
+ Requires-Dist: httpx>=0.28.1
10
+ Description-Content-Type: text/markdown
11
+
12
+ # anki-mcp
13
+
14
+ A Model Context Protocol (MCP) server for interacting with Anki flashcards via the AnkiConnect add-on. This server exposes AnkiConnect actions as MCP tools, organized into logical services.
15
+
16
+ ## Prerequisites
17
+
18
+ - Anki desktop application
19
+ - AnkiConnect add-on installed and configured in Anki
20
+ - Python 3.8+
21
+ - `uv` (for running and installing dependencies, optional but recommended)
22
+
23
+ ## Installation
24
+
25
+ ```bash
26
+ # Clone the repository
27
+ git clone https://github.com/ujisati/anki-mcp.git
28
+ cd anki-mcp
29
+
30
+ # Install dependencies (using uv)
31
+ uv pip install -e .
32
+ ```
33
+
34
+ ## Usage
35
+
36
+ To run the MCP server:
37
+
38
+ ```bash
39
+ uv run anki-mcp
40
+ ```
41
+
42
+ The server will start and listen for MCP requests, typically interfacing with AnkiConnect at `http://127.0.0.1:8765`.
43
+
44
+ ### Inspecting the Server
45
+
46
+ You can use the MCP Inspector to view the available tools:
47
+
48
+ ```bash
49
+ npx @modelcontextprotocol/inspector uv run anki-mcp
50
+ ```
51
+
52
+ ## Configuration for MCP Clients
53
+
54
+ If you're integrating this with an MCP client (like an AI assistant framework), you'll need to configure it to find this server. Here's an example configuration snippet:
55
+
56
+ ```json
57
+ {
58
+ "mcpServers": {
59
+ "anki": {
60
+ "command": "uv",
61
+ "args": [
62
+ "run", // uv will find anki-mcp if run from project root
63
+ "anki-mcp"
64
+ ],
65
+ // If running from outside the project directory, specify the path:
66
+ // "args": [
67
+ // "--directory",
68
+ // "/ABSOLUTE/PATH/TO/anki-mcp", // Replace with actual path
69
+ // "run",
70
+ // "anki-mcp"
71
+ // ]
72
+ }
73
+ }
74
+ }
75
+ ```
76
+
77
+ ## Available MCP Tools
78
+
79
+ This MCP server provides access to Anki functionality through tools grouped by services. The tool names correspond directly to AnkiConnect actions.
80
+
81
+ ### Deck Service (`deck.*`)
82
+ - **`deck.deckNamesAndIds`**: Gets the complete list of deck names and their respective IDs.
83
+ - **`deck.getDeckConfig`**: Gets the configuration group object for a given deck name.
84
+ - **`deck.deckNames`**: Gets the complete list of deck names for the current user.
85
+ - **`deck.createDeck`**: Creates a new empty deck.
86
+ - **`deck.deleteDecks`**: Deletes specified decks.
87
+ - **`deck.changeDeck`**: Moves cards to a different deck.
88
+ - **`deck.saveDeckConfig`**: Saves a deck configuration group.
89
+
90
+ ### Note Service (`note.*`)
91
+ - **`note.findNotes`**: Returns note IDs for a given Anki search query.
92
+ - **`note.notesInfo`**: Returns information for specified note IDs.
93
+ - **`note.getNoteTags`**: Gets the tags for a specific note ID.
94
+ - **`note.addNote`**: Creates a new note.
95
+ - **`note.updateNoteFields`**: Modifies the fields of an existing note.
96
+ - **`note.deleteNotes`**: Deletes specified notes.
97
+ - **`note.addNotes`**: Creates multiple notes.
98
+ - **`note.addTags`**: Adds tags to specified notes.
99
+ - **`note.removeTags`**: Removes tags from specified notes.
100
+ - **`note.updateNote`**: Modifies the fields and/or tags of an existing note.
101
+
102
+ ### Card Service (`card.*`)
103
+ - **`card.findCards`**: Returns card IDs for a given Anki search query.
104
+ - **`card.cardsInfo`**: Returns information for specified card IDs.
105
+ - **`card.cardsToNotes`**: Returns note IDs for given card IDs.
106
+ - **`card.areSuspended`**: Checks if specified cards are suspended.
107
+ - **`card.cardsModTime`**: Returns modification time for specified card IDs.
108
+ - **`card.suspended`**: Checks if a single card is suspended.
109
+ - **`card.suspend`**: Suspends specified cards.
110
+ - **`card.unsuspend`**: Unsuspends specified cards.
111
+ - **`card.setSpecificValueOfCard`**: Sets specific values of a single card (use with caution).
112
+
113
+ ### Model Service (`model.*`) (Note Types)
114
+ - **`model.modelNamesAndIds`**: Gets the complete list of model (note type) names and their IDs.
115
+ - **`model.findModelsByName`**: Gets model definitions for provided model names.
116
+ - **`model.modelFieldNames`**: Gets field names for a given model name.
117
+ - **`model.modelTemplates`**: Gets template content for each card of a specified model.
118
+ - **`model.modelStyling`**: Gets CSS styling for a given model name.
119
+ - **`model.createModel`**: Creates a new model (note type).
120
+ - **`model.updateModelTemplates`**: Modifies templates of an existing model.
121
+ - **`model.updateModelStyling`**: Modifies CSS styling of an existing model.
122
+ - **`model.modelFieldAdd`**: Adds a new field to an existing model.
123
+ - **`model.modelFieldRemove`**: Removes a field from an existing model.
124
+
125
+ ### Media Service (`media.*`)
126
+ - **`media.retrieveMediaFile`**: Retrieves the base64-encoded contents of a media file.
127
+ - **`media.getMediaFilesNames`**: Gets names of media files matching a glob pattern.
128
+ - **`media.storeMediaFile`**: Stores a media file (from base64, path, or URL).
129
+ - **`media.deleteMediaFile`**: Deletes a specified media file.
130
+
131
+ ## Development
132
+
133
+ To set up for development:
134
+
135
+ ```bash
136
+ uv sync
137
+ source .venv/bin/activate
138
+
139
+ uv pip install -e .
140
+ ```
141
+
142
+ ### Running Tests
143
+
144
+ ```bash
145
+ pytest
146
+ ```
147
+
148
+ ## Todo
149
+
150
+ - [ ] Finish adding all AnkiConnect tools
@@ -0,0 +1,139 @@
1
+ # anki-mcp
2
+
3
+ A Model Context Protocol (MCP) server for interacting with Anki flashcards via the AnkiConnect add-on. This server exposes AnkiConnect actions as MCP tools, organized into logical services.
4
+
5
+ ## Prerequisites
6
+
7
+ - Anki desktop application
8
+ - AnkiConnect add-on installed and configured in Anki
9
+ - Python 3.8+
10
+ - `uv` (for running and installing dependencies, optional but recommended)
11
+
12
+ ## Installation
13
+
14
+ ```bash
15
+ # Clone the repository
16
+ git clone https://github.com/ujisati/anki-mcp.git
17
+ cd anki-mcp
18
+
19
+ # Install dependencies (using uv)
20
+ uv pip install -e .
21
+ ```
22
+
23
+ ## Usage
24
+
25
+ To run the MCP server:
26
+
27
+ ```bash
28
+ uv run anki-mcp
29
+ ```
30
+
31
+ The server will start and listen for MCP requests, typically interfacing with AnkiConnect at `http://127.0.0.1:8765`.
32
+
33
+ ### Inspecting the Server
34
+
35
+ You can use the MCP Inspector to view the available tools:
36
+
37
+ ```bash
38
+ npx @modelcontextprotocol/inspector uv run anki-mcp
39
+ ```
40
+
41
+ ## Configuration for MCP Clients
42
+
43
+ If you're integrating this with an MCP client (like an AI assistant framework), you'll need to configure it to find this server. Here's an example configuration snippet:
44
+
45
+ ```json
46
+ {
47
+ "mcpServers": {
48
+ "anki": {
49
+ "command": "uv",
50
+ "args": [
51
+ "run", // uv will find anki-mcp if run from project root
52
+ "anki-mcp"
53
+ ],
54
+ // If running from outside the project directory, specify the path:
55
+ // "args": [
56
+ // "--directory",
57
+ // "/ABSOLUTE/PATH/TO/anki-mcp", // Replace with actual path
58
+ // "run",
59
+ // "anki-mcp"
60
+ // ]
61
+ }
62
+ }
63
+ }
64
+ ```
65
+
66
+ ## Available MCP Tools
67
+
68
+ This MCP server provides access to Anki functionality through tools grouped by services. The tool names correspond directly to AnkiConnect actions.
69
+
70
+ ### Deck Service (`deck.*`)
71
+ - **`deck.deckNamesAndIds`**: Gets the complete list of deck names and their respective IDs.
72
+ - **`deck.getDeckConfig`**: Gets the configuration group object for a given deck name.
73
+ - **`deck.deckNames`**: Gets the complete list of deck names for the current user.
74
+ - **`deck.createDeck`**: Creates a new empty deck.
75
+ - **`deck.deleteDecks`**: Deletes specified decks.
76
+ - **`deck.changeDeck`**: Moves cards to a different deck.
77
+ - **`deck.saveDeckConfig`**: Saves a deck configuration group.
78
+
79
+ ### Note Service (`note.*`)
80
+ - **`note.findNotes`**: Returns note IDs for a given Anki search query.
81
+ - **`note.notesInfo`**: Returns information for specified note IDs.
82
+ - **`note.getNoteTags`**: Gets the tags for a specific note ID.
83
+ - **`note.addNote`**: Creates a new note.
84
+ - **`note.updateNoteFields`**: Modifies the fields of an existing note.
85
+ - **`note.deleteNotes`**: Deletes specified notes.
86
+ - **`note.addNotes`**: Creates multiple notes.
87
+ - **`note.addTags`**: Adds tags to specified notes.
88
+ - **`note.removeTags`**: Removes tags from specified notes.
89
+ - **`note.updateNote`**: Modifies the fields and/or tags of an existing note.
90
+
91
+ ### Card Service (`card.*`)
92
+ - **`card.findCards`**: Returns card IDs for a given Anki search query.
93
+ - **`card.cardsInfo`**: Returns information for specified card IDs.
94
+ - **`card.cardsToNotes`**: Returns note IDs for given card IDs.
95
+ - **`card.areSuspended`**: Checks if specified cards are suspended.
96
+ - **`card.cardsModTime`**: Returns modification time for specified card IDs.
97
+ - **`card.suspended`**: Checks if a single card is suspended.
98
+ - **`card.suspend`**: Suspends specified cards.
99
+ - **`card.unsuspend`**: Unsuspends specified cards.
100
+ - **`card.setSpecificValueOfCard`**: Sets specific values of a single card (use with caution).
101
+
102
+ ### Model Service (`model.*`) (Note Types)
103
+ - **`model.modelNamesAndIds`**: Gets the complete list of model (note type) names and their IDs.
104
+ - **`model.findModelsByName`**: Gets model definitions for provided model names.
105
+ - **`model.modelFieldNames`**: Gets field names for a given model name.
106
+ - **`model.modelTemplates`**: Gets template content for each card of a specified model.
107
+ - **`model.modelStyling`**: Gets CSS styling for a given model name.
108
+ - **`model.createModel`**: Creates a new model (note type).
109
+ - **`model.updateModelTemplates`**: Modifies templates of an existing model.
110
+ - **`model.updateModelStyling`**: Modifies CSS styling of an existing model.
111
+ - **`model.modelFieldAdd`**: Adds a new field to an existing model.
112
+ - **`model.modelFieldRemove`**: Removes a field from an existing model.
113
+
114
+ ### Media Service (`media.*`)
115
+ - **`media.retrieveMediaFile`**: Retrieves the base64-encoded contents of a media file.
116
+ - **`media.getMediaFilesNames`**: Gets names of media files matching a glob pattern.
117
+ - **`media.storeMediaFile`**: Stores a media file (from base64, path, or URL).
118
+ - **`media.deleteMediaFile`**: Deletes a specified media file.
119
+
120
+ ## Development
121
+
122
+ To set up for development:
123
+
124
+ ```bash
125
+ uv sync
126
+ source .venv/bin/activate
127
+
128
+ uv pip install -e .
129
+ ```
130
+
131
+ ### Running Tests
132
+
133
+ ```bash
134
+ pytest
135
+ ```
136
+
137
+ ## Todo
138
+
139
+ - [ ] Finish adding all AnkiConnect tools
@@ -0,0 +1 @@
1
+ python
@@ -0,0 +1 @@
1
+ iflow-mcp_ujisati_anki-mcp
@@ -0,0 +1,5 @@
1
+ {
2
+ "push_platform": "github",
3
+ "fork_url": "https://github.com/iflow-mcp/ujisati-anki-mcp",
4
+ "fork_branch": "iflow"
5
+ }
@@ -0,0 +1,35 @@
1
+ [project]
2
+ name = "iflow-mcp_ujisati_anki-mcp"
3
+ version = "0.1.0"
4
+ description = "Add your description here"
5
+ readme = "README.md"
6
+ authors = [
7
+ { name = "ujisati", email = "98663233+ujisati@users.noreply.github.com" }
8
+ ]
9
+ requires-python = ">=3.11"
10
+ dependencies = [
11
+ "fastmcp>=2.3.3",
12
+ "httpx>=0.28.1",
13
+ ]
14
+
15
+ [project.scripts]
16
+ anki-mcp = "anki_mcp:main"
17
+
18
+ [build-system]
19
+ requires = ["hatchling"]
20
+ build-backend = "hatchling.build"
21
+
22
+ [dependency-groups]
23
+ dev = [
24
+ "pytest>=8.3.5",
25
+ "pytest-asyncio>=0.26.0",
26
+ ]
27
+
28
+ [tool.pytest.ini_options]
29
+ pythonpath = [
30
+ "."
31
+ ]
32
+ asyncio_default_fixture_loop_scope = "function"
33
+
34
+ [tool.hatch.build.targets.wheel]
35
+ packages = ["src/anki_mcp"]
@@ -0,0 +1,37 @@
1
+ import asyncio
2
+
3
+ from fastmcp import FastMCP
4
+
5
+ from .card_service import card_mcp
6
+ from .deck_service import deck_mcp
7
+ from .media_service import media_mcp
8
+ from .model_service import model_mcp
9
+ from .note_service import note_mcp
10
+
11
+
12
+ anki_mcp = FastMCP(
13
+ name="AnkiConnectMCP",
14
+ instructions="""
15
+ This MCP provides a programmatic interface to Anki flashcard functionality through the AnkiConnect API.
16
+ It allows AI assistants to interact with Anki decks, cards, notes, models, and media
17
+ without needing to understand the underlying API details. All interactions are through tools.
18
+ """,
19
+ )
20
+
21
+
22
+ async def setup(run_server: bool = True):
23
+ await anki_mcp.import_server(deck_mcp)
24
+ await anki_mcp.import_server(note_mcp)
25
+ await anki_mcp.import_server(card_mcp)
26
+ await anki_mcp.import_server(model_mcp)
27
+ await anki_mcp.import_server(media_mcp)
28
+ if run_server:
29
+ await anki_mcp.run_async()
30
+
31
+
32
+ def main():
33
+ asyncio.run(setup(run_server=True))
34
+
35
+
36
+ if __name__ == "__main__":
37
+ main()
@@ -0,0 +1,116 @@
1
+ from typing import Annotated, Any, Dict, List, Optional
2
+
3
+ from fastmcp import FastMCP
4
+ from pydantic import Field
5
+
6
+ from .common import anki_call
7
+
8
+ card_mcp = FastMCP(name="AnkiCardService")
9
+
10
+
11
+ @card_mcp.tool(
12
+ name="findCards",
13
+ description="Returns an array of card IDs for a given Anki search query.",
14
+ )
15
+ async def find_cards_tool(
16
+ query: Annotated[
17
+ str, Field(description="Anki search query (e.g., 'deck:current is:new').")
18
+ ],
19
+ ) -> List[int]:
20
+ return await anki_call("findCards", query=query)
21
+
22
+
23
+ @card_mcp.tool(
24
+ name="cardsInfo",
25
+ description="Returns a list of objects containing information for each card ID provided.",
26
+ )
27
+ async def get_cards_info_tool(
28
+ cards: Annotated[List[int], Field(description="A list of card IDs.")],
29
+ ) -> List[Dict[str, Any]]:
30
+ return await anki_call("cardsInfo", cards=cards)
31
+
32
+
33
+ @card_mcp.tool(
34
+ name="cardsToNotes",
35
+ description="Returns an unordered array of note IDs for the given card IDs.",
36
+ )
37
+ async def convert_cards_to_notes_tool(
38
+ cards: Annotated[List[int], Field(description="A list of card IDs.")],
39
+ ) -> List[int]:
40
+ return await anki_call("cardsToNotes", cards=cards)
41
+
42
+
43
+ @card_mcp.tool(
44
+ name="areSuspended",
45
+ description="Returns an array indicating whether each given card is suspended. Each item is boolean or null if the card doesn't exist.",
46
+ )
47
+ async def check_cards_suspended_tool(
48
+ cards: Annotated[List[int], Field(description="A list of card IDs.")],
49
+ ) -> List[Optional[bool]]:
50
+ return await anki_call("areSuspended", cards=cards)
51
+
52
+
53
+ @card_mcp.tool(
54
+ name="cardsModTime",
55
+ description="Returns modification time for each card ID provided. Result is a list of objects with 'cardId' and 'modTime' (timestamp).",
56
+ )
57
+ async def get_cards_modification_time_tool(
58
+ cards: Annotated[List[int], Field(description="A list of card IDs.")],
59
+ ) -> List[Dict[str, Any]]:
60
+ return await anki_call("cardsModTime", cards=cards)
61
+
62
+
63
+ @card_mcp.tool(
64
+ name="suspended",
65
+ description="Checks if a single card is suspended by its ID. Returns true if suspended, false otherwise.",
66
+ )
67
+ async def check_card_suspended_tool(
68
+ card: Annotated[int, Field(description="The ID of the card.")],
69
+ ) -> bool:
70
+ return await anki_call("suspended", card=card)
71
+
72
+
73
+ @card_mcp.tool(
74
+ name="suspend", description="Suspends the specified cards. Returns true on success."
75
+ )
76
+ async def suspend_cards_tool(
77
+ cards: Annotated[List[int], Field(description="A list of card IDs to suspend.")],
78
+ ) -> bool:
79
+ return await anki_call("suspend", cards=cards)
80
+
81
+
82
+ @card_mcp.tool(
83
+ name="unsuspend",
84
+ description="Unsuspends the specified cards. Returns true on success.",
85
+ )
86
+ async def unsuspend_cards_tool(
87
+ cards: Annotated[List[int], Field(description="A list of card IDs to unsuspend.")],
88
+ ) -> bool:
89
+ return await anki_call("unsuspend", cards=cards)
90
+
91
+
92
+ @card_mcp.tool(
93
+ name="setSpecificValueOfCard",
94
+ description="Sets specific values of a single card. Use with caution. Returns list of booleans indicating success for each key.",
95
+ )
96
+ async def set_specific_card_value_tool(
97
+ card: Annotated[int, Field(description="The ID of the card to modify.")],
98
+ keys: Annotated[
99
+ List[str],
100
+ Field(
101
+ description="List of card property keys to change (e.g., 'flags', 'odue')."
102
+ ),
103
+ ],
104
+ newValues: Annotated[
105
+ List[Any],
106
+ Field(description="List of new values corresponding to the keys."),
107
+ ],
108
+ warning_check: Annotated[
109
+ Optional[bool],
110
+ Field(description="Set to True for potentially risky operations."),
111
+ ] = None,
112
+ ) -> List[bool]:
113
+ params: Dict[str, Any] = {"card": card, "keys": keys, "newValues": newValues}
114
+ if warning_check is not None:
115
+ params["warning_check"] = warning_check
116
+ return await anki_call("setSpecificValueOfCard", **params)