Skip to main content
Glama
arslankhanali

Apple Notes MCP Server

search_notes

Find specific notes in Apple Notes by searching content with text queries, optionally filtering by account.

Instructions

Search for notes containing the specified text.

Args:
    query: Text to search for in note content
    account: Optional account name to search within

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYes
accountNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The main handler function for the 'search_notes' tool. It uses AppleScript via osascript to search notes by content or name in a specified account or all accounts, parses the results, and returns a formatted list of matching notes.
    @mcp.tool()
    async def search_notes(query: str, account: Optional[str] = None) -> str:
        """Search for notes containing the specified text.
        
        Args:
            query: Text to search for in note content
            account: Optional account name to search within
        """
        if account:
            script = f'''
            tell application "Notes"
                set accountName to "{escape_applescript_string(account)}"
                set searchResults to {{}}
                try
                    set targetAccount to account accountName
                    repeat with aNote in notes of targetAccount
                        set noteContent to body of aNote
                        if noteContent contains "{escape_applescript_string(query)}" or name of aNote contains "{escape_applescript_string(query)}" then
                            set end of searchResults to (name of aNote) & "|" & (id of aNote)
                        end if
                    end repeat
                end try
                return searchResults
            end tell
            '''
        else:
            script = f'''
            tell application "Notes"
                set searchResults to {{}}
                repeat with anAccount in accounts
                    repeat with aNote in notes of anAccount
                        set noteContent to body of aNote
                        if noteContent contains "{escape_applescript_string(query)}" or name of aNote contains "{escape_applescript_string(query)}" then
                            set end of searchResults to (name of anAccount) & "::" & (name of aNote) & "|" & (id of aNote)
                        end if
                    end repeat
                end repeat
                return searchResults
            end tell
            '''
        
        output, success = run_applescript(script)
        if not success:
            return output
        
        if not output or output == "{}":
            return f"No notes found containing '{query}'."
        
        results = []
        for item in output.split(", "):
            item = item.strip().strip('"').strip("'")
            if "|" in item:
                parts = item.split("|")
                if len(parts) >= 2:
                    results.append({
                        "name": parts[0],
                        "id": parts[1]
                    })
        
        if not results:
            return f"No notes found containing '{query}'."
        
        result = f"Found {len(results)} note(s) containing '{query}':\n"
        for i, note in enumerate(results, 1):
            result += f"{i}. {note['name']} (ID: {note['id']})\n"
        
        return result
  • Helper function used by search_notes to execute AppleScript commands and handle subprocess output and errors.
    def run_applescript(script: str) -> tuple[str, bool]:
        """Run an AppleScript command and return the output."""
        try:
            result = subprocess.run(
                ["osascript", "-e", script],
                capture_output=True,
                text=True,
                timeout=30
            )
            if result.returncode == 0:
                return result.stdout.strip(), True
            else:
                error_msg = result.stderr.strip() or result.stdout.strip()
                return f"Error: {error_msg}", False
        except subprocess.TimeoutExpired:
            return "Error: AppleScript execution timed out", False
        except Exception as e:
            return f"Error: {str(e)}", False
  • Helper function used by search_notes to properly escape strings for safe inclusion in AppleScript.
    def escape_applescript_string(text: str) -> str:
        """Escape special characters for AppleScript strings."""
        # Replace backslashes, quotes, and newlines
        text = text.replace("\\", "\\\\")
        text = text.replace('"', '\\"')
        text = text.replace("\n", "\\n")
        return text
  • apple_notes.py:129-129 (registration)
    The @mcp.tool() decorator registers the search_notes function as an MCP tool.
    @mcp.tool()
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 of behavioral disclosure. It states the tool searches notes, but doesn't describe key behaviors such as whether the search is case-sensitive, supports wildcards, returns partial matches, includes metadata, handles pagination, or has rate limits. For a search tool with zero annotation coverage, this leaves significant gaps in understanding how it operates.

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 highly concise and well-structured: a clear purpose statement followed by a bullet-point list of parameters with brief explanations. Every sentence earns its place, with no redundant information, making it easy to scan and understand 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 moderate complexity (search function with 2 parameters), no annotations, and the presence of an output schema (which likely handles return values), the description is partially complete. It covers the basic purpose and parameters but lacks behavioral details like search specifics or error handling. With an output schema, it doesn't need to explain return values, but other contextual gaps remain.

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

Parameters4/5

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

The description adds meaningful context for both parameters: 'query' is described as 'Text to search for in note content', and 'account' as 'Optional account name to search within'. This clarifies the purpose of each parameter beyond the schema, which has 0% description coverage and only provides titles and types. The description effectively compensates for the low schema coverage by explaining what each parameter does.

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 tool's purpose: 'Search for notes containing the specified text.' It specifies the verb ('search') and resource ('notes'), making the function unambiguous. However, it doesn't explicitly differentiate from sibling tools like 'list_notes', which might also retrieve notes but without text-based filtering.

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

Usage Guidelines3/5

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

The description implies usage through the action of searching notes by text content, but it doesn't provide explicit guidance on when to use this tool versus alternatives like 'list_notes' (which might list all notes without filtering) or 'read_note' (which might retrieve a specific note by ID). No exclusions or prerequisites are mentioned.

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/arslankhanali/apple-notes-mcp'

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