get_media_files_names
Extract and list media file names matching a specific pattern from the Anki MCP server. Specify the pattern (e.g., "*.jpg") to retrieve desired files efficiently.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| pattern | Yes | Pattern to match media file names (e.g., "*.jpg", "*audio*") |
Implementation Reference
- src/tools/media.ts:54-76 (handler)MCP tool registration and handler for 'get_media_files_names'. Defines input schema (pattern: string), executes by calling ankiClient.media.getMediaFilesNames(pattern), and returns formatted list of matching media files or throws error.server.tool( 'get_media_files_names', { pattern: z.string().describe('Pattern to match media file names (e.g., "*.jpg", "*audio*")'), }, async ({ pattern }) => { try { const filenames = await ankiClient.media.getMediaFilesNames({ pattern }); return { content: [ { type: 'text', text: `Media files matching pattern "${pattern}": ${JSON.stringify(filenames, null, 2)}`, }, ], }; } catch (error) { throw new Error( `Failed to get media file names: ${error instanceof Error ? error.message : String(error)}` ); } } );
- src/tools/media.ts:56-58 (schema)Zod input schema for the get_media_files_names tool: requires a 'pattern' string parameter.{ pattern: z.string().describe('Pattern to match media file names (e.g., "*.jpg", "*audio*")'), },
- src/tools/media.ts:8-8 (registration)Function that registers all media tools including get_media_files_names on the MCP server (though not called in main server setup).export function registerMediaTools(server: McpServer) {
- src/tools/miscellaneous.ts:248-248 (helper)Lists 'getMediaFilesNames' as a supported AnkiConnect action in the 'multi' tool's action enum.'getMediaFilesNames',
- src/tools/consolidated.ts:1133-1133 (helper)Usage of the underlying ankiClient.media.getMediaFilesNames in the 'anki_operations' tool's 'list_media' case.const files = await ankiClient.media.getMediaFilesNames({ pattern });