Skip to main content
Glama

list_decks_and_notes

Retrieve all decks and note types with their associated fields, excluding specified patterns, to manage and organize Anki flashcards effectively.

Instructions

Get all decks (excluding specified patterns) and note types with their fields.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The list_decks_and_notes tool handler function. It is decorated with @mcp.tool() for registration and @handle_anki_connection_error for error handling. It lists filtered decks and note types with their fields from AnkiConnect.
    @mcp.tool() @handle_anki_connection_error # Apply decorator async def list_decks_and_notes() -> str: """Get all decks (excluding specified patterns) and note types with their fields.""" async with get_anki_client() as anki: all_decks = await anki.deck_names() # Filter decks based on EXCLUDE_STRINGS decks = [d for d in all_decks if not any(ex.lower() in d.lower() for ex in EXCLUDE_STRINGS)] logger.info(f"Filtered decks: {decks}") all_model_names = await anki.model_names() note_types = [] for model in all_model_names: if any(ex.lower() in model.lower() for ex in EXCLUDE_STRINGS): continue try: fields = await anki.model_field_names(model) note_types.append({"name": model, "fields": fields}) except Exception as e: logger.warning(f"Could not get fields for model '{model}': {e}. Skipping this model.") # Format the output string deck_list_str = f"You have {len(decks)} filtered decks: {', '.join(decks)}" if decks else "No filtered decks found." note_type_list = [] if note_types: for note in note_types: # Format fields as "FieldName": "type" (assuming string for simplicity) field_str = ', '.join([f'"{field}": "string"' for field in note['fields']]) note_type_list.append(f"- {note['name']}: {{ {field_str} }}") note_types_str = f"Your filtered note types and their fields are:\n" + "\n".join(note_type_list) else: note_types_str = "No filtered note types found." return f"{deck_list_str}\n\n{note_types_str}"
  • The @mcp.tool() decorator registers the list_decks_and_notes tool with the FastMCP server.
    @mcp.tool()

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/samefarrar/mcp-ankiconnect'

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