Skip to main content
Glama

get-collection-overview

Retrieve detailed insights about an Anki collection, including decks, models, and fields, to manage and organize note-taking data effectively.

Instructions

Get comprehensive information about the Anki collection including decks, models, and fields

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Registration of the 'get-collection-overview' tool, binding the FastMCP app.tool decorator to the handler function get_collection_overview.
    app.tool(name="get-collection-overview", description="Get comprehensive information about the Anki collection including decks, models, and fields")(get_collection_overview)
  • The handler function implementing the tool logic: asynchronously fetches decks, models, tags, and field information from AnkiConnect API using helper, formats into TextContent blocks, handles errors.
    async def get_collection_overview() -> list[types.TextContent]:
        """
        Get comprehensive information about the Anki collection:
        - Available decks
        - Available note models
        - Fields for each model
        - Tags used
        
        Returns a list of TextContent objects with formatted information.
        """
        results = []
        
        # Get decks
        decks_result = await make_anki_request("deckNames")
        if not decks_result["success"]:
            return [types.TextContent(
                type="text", 
                text=f"\nFailed to retrieve decks: {decks_result['error']}"
            )]
            
        decks = decks_result["result"]
        results.append(
            types.TextContent(
                type="text",
                text=f"\nAvailable decks in Anki ({len(decks)}):\n" + 
                     "\n".join(f"- {deck}" for deck in decks)
            )
        )
        
        # Get models
        models_result = await make_anki_request("modelNames")
        if not models_result["success"]:
            return [types.TextContent(
                type="text",
                text=f"\nFailed to retrieve models: {models_result['error']}"
            )]
            
        models = models_result["result"]
        results.append(
            types.TextContent(
                type="text",
                text=f"\nAvailable note models in Anki ({len(models)}):\n" + 
                     "\n".join(f"- {model}" for model in models)
            )
        )
    
        tags_result = await make_anki_request("getTags")
        if not tags_result["success"]:
            return [types.TextContent(
                type="text",
                text=f"\nFailed to retrieve tags: {tags_result['error']}"
            )]
        if tags := tags_result["result"]:
            results.append(
                types.TextContent(
                    type="text",
                    text=f"\nTags used in Anki ({len(tags)}): {', '.join(tags)}"
                )
            )
        
        # Get fields for each model
        for model_name in models:
            # Get field names
            names_result = await make_anki_request("modelFieldNames", modelName=model_name)
            
            # Get field descriptions
            descriptions_result = await make_anki_request("modelFieldDescriptions", modelName=model_name)
            
            if names_result["success"] and descriptions_result["success"]:
                field_names = names_result["result"]
                field_descriptions = descriptions_result["result"]
                
                # Combine fields and descriptions
                field_info = []
                for name, description in zip(field_names, field_descriptions):
                    desc_text = f": {description}" if description else ""
                    field_info.append(f"  - {name}{desc_text}")
                
                results.append(
                    types.TextContent(
                        type="text",
                        text=f"\nFields for model '{model_name}' ({len(field_names)}):\n" + 
                             "\n".join(field_info)
                    )
                )
            elif not names_result["success"]:
                results.append(
                    types.TextContent(
                        type="text",
                        text=f"\nFailed to retrieve field names for '{model_name}': {names_result['error']}"
                    )
                )
            else:
                results.append(
                    types.TextContent(
                        type="text",
                        text=f"\nFailed to retrieve field descriptions for '{model_name}': {descriptions_result['error']}"
                    )
                )
        
        return results 
  • Shared helper utility function for making HTTP requests to AnkiConnect API, used extensively in the get_collection_overview handler and other tools.
    async def make_anki_request(action: str, **params) -> Dict[str, Any]:
        """Make a request to the Anki Connect API with proper error handling."""
        request_data = {
            "action": action,
            "version": ANKI_CONNECT_VERSION
        }
        
        if params:
            request_data["params"] = params
        
        async with httpx.AsyncClient() as client:
            try:
                response = await client.post(ANKI_CONNECT_URL, json=request_data, timeout=30.0)
                response.raise_for_status()
                result = response.json()
                
                # Anki Connect returns an object with either a result or error field
                if "error" in result and result["error"]:
                    return {"success": False, "error": result["error"]}
                
                return {"success": True, "result": result.get("result")}
            except Exception as e:
                return {"success": False, "error": str(e)}
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden but only states it 'gets' information without disclosing behavioral traits like permissions needed, rate limits, response format, or whether it's a heavy operation. It mentions 'comprehensive information' but doesn't clarify depth or structure, leaving gaps in transparency for a tool with potential complexity.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the purpose ('Get comprehensive information') and specifies key components without waste. Every word contributes to understanding the tool's function, making it appropriately sized and well-structured.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool has 0 parameters and no output schema, the description adequately covers the purpose and scope. However, with no annotations and potential complexity in 'comprehensive information', it lacks details on behavioral aspects like response format or performance, making it minimally viable but incomplete for full agent guidance.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The tool has 0 parameters with 100% schema description coverage, so no parameter documentation is needed. The description adds value by specifying what information is retrieved ('decks, models, and fields'), which goes beyond the empty schema, earning a baseline score above 3 for clarity in output scope.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('Get') and resource ('comprehensive information about the Anki collection'), specifying the scope includes 'decks, models, and fields'. It distinguishes this as a read operation from sibling tools like 'add-or-update-notes' (write) and 'find-notes' (search), though it doesn't explicitly name alternatives.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage for retrieving collection metadata, which contrasts with sibling tools focused on notes or cards. However, it lacks explicit guidance on when to use this tool versus alternatives (e.g., for overview vs. detailed queries) or any prerequisites, leaving usage context inferred rather than stated.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

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

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