Skip to main content
Glama

media_retrieveMediaFile

Retrieve base64-encoded contents of a media file from Anki’s collection using the specified filename. Returns the encoded string or false if the file is not found.

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

  • The tool handler function for media_retrieveMediaFile, decorated with @media_mcp.tool(name='retrieveMediaFile'). It calls anki_call to invoke AnkiConnect's retrieveMediaFile API.
    @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)
  • Registration of the media service into the main anki_mcp server under the 'media' namespace, which prefixes the tool name to 'media_retrieveMediaFile'.
    await anki_mcp.import_server("media", media_mcp)
  • The helper function 'anki_call' used by the tool handler to communicate with the AnkiConnect server via HTTP POST requests.
    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
  • Pydantic schema definition for the 'filename' input parameter of the tool.
    filename: Annotated[ str, Field(description="The name of the media file in Anki's collection.") ],

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