Skip to main content
Glama

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
NameRequiredDescriptionDefault
filenameYesThe name of the file to delete from the media collection.

Implementation Reference

  • 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)
  • 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)
  • 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

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ujisati/anki-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server