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                                                                        
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It states the tool returns a list of filenames, which is helpful, but lacks critical behavioral details such as whether it's read-only, if it requires specific permissions, how it handles errors, or if there are rate limits. This is a significant gap for a tool with no annotation coverage.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is two sentences that are front-loaded and efficient. The first sentence states the purpose, and the second specifies the return value, with no wasted words. It's appropriately sized for the tool's complexity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool has no annotations and no output schema, the description is incomplete. It covers the basic purpose and return type but misses behavioral context like error handling or permissions. For a simple read operation, it's minimally adequate but lacks depth to fully guide an agent.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, with the parameter 'pattern' well-documented as a glob pattern (e.g., '*.jpg'). The description adds minimal value beyond the schema by reiterating the glob pattern matching, but doesn't provide additional semantics like examples of complex patterns or constraints. Baseline 3 is appropriate given the high schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb 'Gets' and the resource 'names of media files matching the glob pattern', which is specific and unambiguous. However, it doesn't explicitly differentiate from sibling tools like media_retrieveMediaFile or media_storeMediaFile, which handle different operations on media files.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites, exclusions, or compare it to sibling tools like media_retrieveMediaFile (which retrieves file content) or media_deleteMediaFile (which deletes files), leaving the agent to infer usage context.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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