Skip to main content
Glama

add-or-update-notes

Add or update notes in Anki by specifying note details, including name, ID, deck, model, fields, and tags. Use this tool to manage your Anki notes efficiently.

Instructions

Add new notes or update existing ones in Anki

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
notesYes

Implementation Reference

  • Main tool handler function that processes a list of notes, adding new ones or updating existing ones by calling helper functions and returning success/error messages.
    async def add_or_update_notes(notes: list[Note]) -> list[types.TextContent]:
        """Add one or more notes to Anki.
        
        Notes are processed individually to allow partial success. This means
        if some notes fail to add, others can still be added successfully.
        """
        if not notes:
            raise ValueError("No notes provided")
    
        response_lines = []
        
        for note in notes:
            if note.id:
                response = await update_note(note)
                response_lines.append(
                    f"Updated note '{note.name}' with ID {note.id}"
                    if response['success']
                    else f"Failed to update note '{note.name}' with ID {note.id}: {response['error']}"
                )
            else:
                response = await add_note(note)
                response_lines.append(
                    f"Added note '{note.name}' with ID {response['result']}"
                    if response['success']
                    else f"Failed to add note '{note.name}': {response['error']}"
                )
        
        return [
            types.TextContent(
                type="text",
                text="\n".join(response_lines)
            )
        ]
  • Pydantic model defining the structure of each note for input validation.
    class Note(BaseModel):
        name: Annotated[str, Field(description="Name of the note", max_length=64)]
        id: Annotated[int | None, Field(description="Note ID, if the note already exists. If this is populated the existing note will be updated. If this is `None` a new note will be created.")]
        deck: Annotated[str, Field(description="Deck name (optional)", default=DEFAULT_DECK_NAME)]
        model: Annotated[str, Field(description="Model name (optional)", default=DEFAULT_MODEL_NAME)]
        fields: Annotated[Dict[str, str], Field(description="Field values for the note (varies by model)")]
        tags: Annotated[Optional[List[str]], Field(description="Tags to assign to the note (optional)", default=None)]
  • Tool registration using FastMCP's app.tool decorator, binding the handler function.
    app.tool(name='add-or-update-notes', description="Add new notes or update existing ones in Anki")(add_or_update_notes)
  • Helper function to update an existing note's fields or tags in Anki.
    async def update_note(note: Note):
        if not note.fields and note.tags is None:
            return {'success': False, 'error': "Either fields or tags must be provided"}
            
        # Prepare the note update data
        note_data = {
            "id": note.id
        }
            
        # Add fields if provided
        if note.fields:
            note_data["fields"] = note.fields
            
        # Add tags if provided
        if note.tags is not None:
            note_data["tags"] = note.tags
            
        # Update the note in Anki
        return await make_anki_request("updateNote", note=note_data)
  • Helper function to add a new note to a specified deck and model in Anki.
    async def add_note(note: Note):
        if not note.fields:
            return {"success": False, "error": "Note has no fields"}
            
        note_data = {
            "deckName": note.deck,
            "modelName": note.model,
            "fields": note.fields,
            "options": {"allowDuplicate": False},
        }
    
        # Add tags if provided
        if note.tags is not None:
            note_data["tags"] = note.tags
            
        # Add note to Anki
        result = await make_anki_request("addNote", note=note_data)
            
        return result
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions adding or updating notes but fails to explain critical behaviors: whether this requires specific permissions, if updates are destructive or reversible, rate limits, or what happens on partial failures. This leaves significant gaps for a mutation tool.

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 directly states the tool's purpose without unnecessary words. It is appropriately sized and front-loaded, making it easy to parse quickly.

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

Completeness2/5

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

Given the complexity of a mutation tool with 1 parameter (but nested objects in schema), no annotations, no output schema, and 0% schema description coverage, the description is incomplete. It lacks details on behavior, parameters, error handling, and output, making it insufficient for safe and effective use by an AI agent.

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 0%, so the description must compensate for undocumented parameters. However, it adds no parameter-specific information beyond the tool's name implying 'notes' as input. The schema details parameters like 'notes', 'id', 'fields', etc., but the description doesn't explain their semantics or usage, resulting in a baseline score due to inadequate compensation.

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 action ('Add new notes or update existing ones') and the target resource ('in Anki'), which provides a specific verb+resource combination. However, it doesn't differentiate from sibling tools like 'find-notes' beyond the basic add/update vs. find distinction, missing explicit comparison.

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. The description lacks context about prerequisites, when to choose this over other tools, or any exclusions. It merely states what the tool does without usage instructions.

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