Skip to main content
Glama

media_retrieveMediaFile

Retrieve base64-encoded media files from Anki's collection to access and use stored audio, images, or other media content in your flashcards.

Instructions

Retrieves the base64-encoded contents of the specified media file. Returns the base64 string or false if not found.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filenameYesThe name of the media file in Anki's collection.

Implementation Reference

  • Handler function executing the tool logic for retrieving Anki media files as base64, proxying to AnkiConnect 'retrieveMediaFile' action.
    @media_mcp.tool( name="retrieveMediaFile", description="Retrieves the base64-encoded contents of the specified media file. Returns the base64 string or false if not found.", ) async def retrieve_media_file_tool( filename: Annotated[ str, Field(description="The name of the media file in Anki's collection.") ], ) -> Any: return await anki_call("retrieveMediaFile", filename=filename)
  • Main registration step that imports the media service tools under the 'media_' namespace, creating the 'media_retrieveMediaFile' tool.
    await anki_mcp.import_server("media", media_mcp)
  • Supporting utility `anki_call` that handles HTTP communication with AnkiConnect API, invoked by the handler with action='retrieveMediaFile'.
    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
  • Creates the sub-MCP server 'AnkiMediaService' where the retrieveMediaFile tool is initially registered (before namespacing).
    media_mcp = FastMCP(name="AnkiMediaService")

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