Skip to main content
Glama

card_findCards

Retrieve card IDs from Anki decks using a specific search query. This tool helps users quickly locate cards within their flashcard collections based on custom criteria.

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

  • Handler function for the 'card_findCards' tool (prefixed from 'findCards'). It takes an Anki search query and calls the AnkiConnect 'findCards' API via the anki_call helper to return a list of card IDs.
    @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 service (containing the findCards tool) with the 'card_' prefix into the main AnkiConnect MCP server.
    await anki_mcp.import_server("card", card_mcp)
  • Pydantic schema definition for the tool's input parameter 'query' using Annotated and Field.
    query: Annotated[ str, Field(description="Anki search query (e.g., 'deck:current is:new').") ], ) -> List[int]: return await anki_call("findCards", query=query)
  • Utility function that all tool handlers use to make HTTP requests to the AnkiConnect server.
    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