Skip to main content
Glama

model_modelNamesAndIds

Retrieve all Anki note type names with their corresponding IDs to manage and organize flashcard templates effectively.

Instructions

Gets the complete list of model (note type) names and their IDs. Returns a dictionary mapping model names to IDs.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The core handler function for the 'model_modelNamesAndIds' tool. It invokes the AnkiConnect 'modelNamesAndIds' action via anki_call to fetch model names and IDs.
    @model_mcp.tool( name="modelNamesAndIds", description="Gets the complete list of model (note type) names and their IDs. Returns a dictionary mapping model names to IDs.", ) async def list_model_names_and_ids_tool() -> Dict[str, int]: return await anki_call("modelNamesAndIds")
  • Registers the model_mcp FastMCP instance with the prefix 'model' to the main anki_mcp server, resulting in tools prefixed like 'model_modelNamesAndIds'.
    await anki_mcp.import_server("model", model_mcp)
  • Defines the tool schema via FastMCP decorator: no input parameters, returns Dict[str, int] of model names to IDs.
    @model_mcp.tool( name="modelNamesAndIds", description="Gets the complete list of model (note type) names and their IDs. Returns a dictionary mapping model names to IDs.", ) async def list_model_names_and_ids_tool() -> Dict[str, int]: return await anki_call("modelNamesAndIds")
  • Helper function used by the handler to make HTTP POST requests 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

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