Skip to main content
Glama
find_notes.py1.75 kB
import mcp.types as types from .utils import make_anki_request from datetime import datetime def _format_note(note: dict) -> str: """Format a single note for display.""" tags = ", ".join(note["tags"]) if note["tags"] else "(no tags)" mod_time = datetime.fromtimestamp(note["mod"]).strftime("%Y-%m-%d %H:%M:%S") fields_text = [ f" - {name}: {data['value']}" for name, data in note["fields"].items() ] return ( f"Note ID: {note['noteId']}\n" f"Model: {note['modelName']}\n" f"Tags: {tags}\n" f"Modified: {mod_time}\n" f"Fields:\n" + "\n".join(fields_text) + "\n" ) async def find_notes(query: str, limit: int = 20) -> list[types.TextContent]: result = await make_anki_request("notesInfo", query=query) if not result["success"]: return [ types.TextContent( type="text", text=f"Failed to retrieve notes: {result['error']}", ) ] notes = result["result"] if not notes: return [ types.TextContent( type="text", text=f"No notes found matching query: '{query}'", ) ] total_count = len(notes) limited_notes = notes[:limit] notes_info = [_format_note(note) for note in limited_notes] if total_count > limit: header = f"Showing {len(limited_notes)} of {total_count} notes matching query: '{query}' (use a more specific query or increase limit to see more)" else: header = f"Found {total_count} notes matching query: '{query}'" return [ types.TextContent( type="text", text=header + "\n\n" + "\n\n".join(notes_info), ) ]

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