Skip to main content
Glama

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
NameRequiredDescriptionDefault
modelNamesYesA list of model names.

Implementation Reference

  • 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)
  • Registers all model service tools under the 'model_' prefix, making 'findModelsByName' available as 'model_findModelsByName'.
    await anki_mcp.import_server("model", model_mcp)
  • 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]]:
  • 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                                                                        

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