model_findModelsByName
Retrieve detailed model definitions from Anki flashcards by specifying a list of model names. Simplifies managing and organizing flashcard models in Anki.
Instructions
Gets a list of model definitions for the provided model names.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| modelNames | Yes | A list of model names. |
Implementation Reference
- src/anki_mcp/model_service.py:19-26 (handler)The main handler function for the tool, decorated with @model_mcp.tool(name="findModelsByName"). It defines the input schema (modelNames: list[str]) and executes the logic by calling AnkiConnect's findModelsByName API.@model_mcp.tool( name="findModelsByName", description="Gets a list of model definitions for the provided model names.", ) async def find_models_by_name_tool( modelNames: Annotated[List[str], Field(description="A list of model names.")], ) -> List[Dict[str, Any]]: return await anki_call("findModelsByName", modelNames=modelNames)
- src/anki_mcp/__init__.py:26-26 (registration)Final registration of all model service tools into the main Anki MCP server with the "model_" prefix, making this tool available as "model_findModelsByName".await anki_mcp.import_server("model", model_mcp)
- src/anki_mcp/model_service.py:8-8 (registration)Creates the model_mcp FastMCP instance where the tool is registered locally before being imported with prefix.model_mcp = FastMCP(name="AnkiModelService")
- src/anki_mcp/common.py:8-23 (helper)Helper function used by the handler to make HTTP calls to AnkiConnect API.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