Skip to main content
Glama

find_and_replace_in_models

Efficiently find and replace text in Anki card templates, including front, back, and CSS, for specified models to streamline content updates.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
backYesWhether to search in back templates
cssYesWhether to search in CSS
fieldTextYesText to find
frontYesWhether to search in front templates
modelNameYesName of the model to search in
replaceTextYesText to replace with

Implementation Reference

  • The handler function that executes the find and replace operation in Anki models using the ankiClient.
    async ({ modelName, fieldText, replaceText, front, back, css }) => { try { const count = await ankiClient.model.findAndReplaceInModels({ model: { modelName, fieldText, replaceText, front, back, css, }, }); return { content: [ { type: 'text', text: `Successfully replaced ${count} occurrences of "${fieldText}" with "${replaceText}" in model "${modelName}"`, }, ], }; } catch (error) { throw new Error( `Failed to find and replace in model "${modelName}": ${error instanceof Error ? error.message : String(error)}` ); } }
  • Zod input schema defining parameters for the find_and_replace_in_models tool.
    { modelName: z.string().describe('Name of the model to search in'), fieldText: z.string().describe('Text to find'), replaceText: z.string().describe('Text to replace with'), front: z.boolean().describe('Whether to search in front templates'), back: z.boolean().describe('Whether to search in back templates'), css: z.boolean().describe('Whether to search in CSS'), },
  • Registration of the 'find_and_replace_in_models' tool on the MCP server, including name, schema, and handler.
    server.tool( 'find_and_replace_in_models', { modelName: z.string().describe('Name of the model to search in'), fieldText: z.string().describe('Text to find'), replaceText: z.string().describe('Text to replace with'), front: z.boolean().describe('Whether to search in front templates'), back: z.boolean().describe('Whether to search in back templates'), css: z.boolean().describe('Whether to search in CSS'), }, async ({ modelName, fieldText, replaceText, front, back, css }) => { try { const count = await ankiClient.model.findAndReplaceInModels({ model: { modelName, fieldText, replaceText, front, back, css, }, }); return { content: [ { type: 'text', text: `Successfully replaced ${count} occurrences of "${fieldText}" with "${replaceText}" in model "${modelName}"`, }, ], }; } catch (error) { throw new Error( `Failed to find and replace in model "${modelName}": ${error instanceof Error ? error.message : String(error)}` ); } } );

Other Tools

Related 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/arielbk/anki-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server