media_deleteMediaFile
Remove unwanted files from Anki's media folder to manage storage and organize your flashcard resources.
Instructions
Deletes the specified file from Anki's media folder.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filename | Yes | The name of the file to delete from the media collection. |
Implementation Reference
- src/anki_mcp/media_service.py:81-92 (handler)The handler function `delete_media_file_tool` that executes the `media_deleteMediaFile` tool logic. It takes a filename parameter and calls AnkiConnect's `deleteMediaFile` via `anki_call`.@media_mcp.tool( name="deleteMediaFile", description="Deletes the specified file from Anki's media folder.", ) async def delete_media_file_tool( filename: Annotated[ str, Field(description="The name of the file to delete from the media collection."), ], ) -> None: return await anki_call("deleteMediaFile", filename=filename)
- src/anki_mcp/__init__.py:27-27 (registration)The `import_server` call registers all tools from `media_mcp` (including `deleteMediaFile`) with the 'media_' prefix under the main `anki_mcp`, making it available as 'media_deleteMediaFile'.await anki_mcp.import_server("media", media_mcp)
- src/anki_mcp/common.py:8-24 (helper)The `anki_call` helper function used by the handler to make HTTP POST requests to AnkiConnect API, handling errors and returning results.async def anki_call(action: str, **params: Any) -> Any: async with httpx.AsyncClient() as client: payload = {"action": action, "version": 6, "params": params} result = await client.post(ANKICONNECT_URL, json=payload) result.raise_for_status() result_json = result.json() error = result_json.get("error") if error: raise Exception(f"AnkiConnect error for action '{action}': {error}") response = result_json.get("result") if "result" in result_json: return response return result_json