model_findModelsByName
Retrieve Anki flashcard model definitions by specifying model names to access their structure and configuration.
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)Handler function implementing the tool logic: calls AnkiConnect's findModelsByName API with the provided modelNames list and returns the list of model definitions.@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)Registers all model service tools under the 'model_' prefix, making 'findModelsByName' available as 'model_findModelsByName'.await anki_mcp.import_server("model", model_mcp)
- src/anki_mcp/model_service.py:24-25 (schema)Pydantic-based input schema defining modelNames as a list of strings; output as list of dicts.modelNames: Annotated[List[str], Field(description="A list of model names.")], ) -> List[Dict[str, Any]]:
- src/anki_mcp/common.py:8-23 (helper)Utility function that sends requests to AnkiConnect API and handles responses/errors.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