Skip to main content
Glama

card_findCards

Search Anki flashcards to retrieve card IDs using Anki search queries, enabling targeted card management and review.

Instructions

Returns an array of card IDs for a given Anki search query.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesAnki search query (e.g., 'deck:current is:new').

Implementation Reference

  • The handler function `find_cards_tool` that executes the core logic of the `card_findCards` tool by invoking AnkiConnect's `findCards` API with the search query.
    @card_mcp.tool(
        name="findCards",
        description="Returns an array of card IDs for a given Anki search query.",
    )
    async def find_cards_tool(
        query: Annotated[
            str, Field(description="Anki search query (e.g., 'deck:current is:new').")
        ],
    ) -> List[int]:
        return await anki_call("findCards", query=query)
  • Registers the `card_mcp` FastMCP instance with the prefix 'card', transforming local tool name 'findCards' into the global tool name 'card_findCards'.
    await anki_mcp.import_server("card", card_mcp)
  • Pydantic-based input schema (query: str) and output type (List[int]) for the card_findCards tool.
    async def find_cards_tool(
        query: Annotated[
            str, Field(description="Anki search query (e.g., 'deck:current is:new').")
        ],
    ) -> List[int]:
        return await anki_call("findCards", query=query)
  • Shared helper function `anki_call` used by the handler to communicate with 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                                                                        
Behavior2/5

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

No annotations are provided, so the description carries the full burden. It states the tool returns an array of card IDs but doesn't disclose behavioral traits such as error handling (e.g., invalid queries), performance (e.g., large result sets), or side effects (e.g., read-only operation). This leaves gaps for a tool with no annotation coverage.

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 key information (returns array of card IDs) and includes a helpful example. There is no wasted verbiage, making it easy to parse quickly.

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's low complexity (one parameter, no output schema, no annotations), the description is adequate but incomplete. It covers the basic purpose and parameter but lacks details on usage guidelines, behavioral transparency, and output specifics (e.g., format of returned IDs), leaving room for improvement.

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

Parameters3/5

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

Schema description coverage is 100%, with the query parameter fully documented in the schema. The description adds minimal value beyond the schema by mentioning 'Anki search query' and providing an example ('deck:current is:new'), but it doesn't elaborate on query syntax or constraints. Baseline 3 is appropriate as the schema does the heavy lifting.

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 ('Returns') and resource ('array of card IDs'), specifying it's for Anki search queries. It distinguishes from siblings like card_cardsInfo (which returns detailed card info) and note_findNotes (which finds notes rather than cards), though it doesn't explicitly name these alternatives.

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

Usage Guidelines2/5

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

No guidance is provided on when to use this tool versus alternatives. It doesn't mention when to prefer card_findCards over card_cardsInfo (for IDs vs. detailed info) or note_findNotes (for cards vs. notes), nor does it specify prerequisites like needing a valid query format.

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

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