Skip to main content
Glama

media_getMediaFilesNames

Retrieve media file names from Anki flashcards using a glob pattern to locate specific files in your collection.

Instructions

Gets the names of media files matching the glob pattern. Returns a list of filenames.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
patternYesA glob pattern to match filenames (e.g., '*.jpg').

Implementation Reference

  • Handler function implementing the tool logic for 'media_getMediaFilesNames'. Takes a glob pattern as input, calls AnkiConnect's 'getMediaFilesNames' via anki_call helper, returns list of filenames. Includes inline schema and description.
    @media_mcp.tool( name="getMediaFilesNames", description="Gets the names of media files matching the glob pattern. Returns a list of filenames.", ) async def list_media_files_names_tool( pattern: Annotated[ str, Field(description="A glob pattern to match filenames (e.g., '*.jpg').") ], ) -> List[str]: return await anki_call("getMediaFilesNames", pattern=pattern)
  • Registers the media_mcp server (containing the tool) into the main anki_mcp with 'media' prefix, exposing the tool as 'media_getMediaFilesNames'.
    await anki_mcp.import_server("media", media_mcp)
  • Imports the media_mcp instance which defines and registers the local tool.
    from .media_service import media_mcp
  • Shared utility function that performs HTTP calls to AnkiConnect API, used by the handler to invoke 'getMediaFilesNames' action.
    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