Skip to main content
Glama
arslankhanali

Apple Notes MCP Server

read_note

Retrieve content from Apple Notes by specifying a note name and optional account, enabling access to stored information for review or processing.

Instructions

Read the content of a specific note by name.

Args:
    note_name: Name of the note to read
    account: Optional account name where the note is located

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
note_nameYes
accountNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The main handler function for the 'read_note' tool, decorated with @mcp.tool() for registration. It constructs and executes AppleScript to retrieve the content of a specified note from Apple Notes.app, handling optional account specification.
    @mcp.tool()
    async def read_note(note_name: str, account: Optional[str] = None) -> str:
        """Read the content of a specific note by name.
        
        Args:
            note_name: Name of the note to read
            account: Optional account name where the note is located
        """
        if account:
            script = f'''
            tell application "Notes"
                set accountName to "{escape_applescript_string(account)}"
                set noteName to "{escape_applescript_string(note_name)}"
                try
                    set targetAccount to account accountName
                    set targetNote to note noteName of targetAccount
                    return (body of targetNote)
                on error
                    return "ERROR: Note not found"
                end try
            end tell
            '''
        else:
            script = f'''
            tell application "Notes"
                set noteName to "{escape_applescript_string(note_name)}"
                repeat with anAccount in accounts
                    try
                        set targetNote to note noteName of anAccount
                        return (body of targetNote)
                    end try
                end repeat
                return "ERROR: Note not found"
            end tell
            '''
        
        output, success = run_applescript(script)
        if not success or output == "ERROR: Note not found":
            return output if output else f"Note '{note_name}' not found."
        
        return f"Note: {note_name}\n\n{output}"
  • Helper function to execute AppleScript commands via subprocess, used by read_note to interact with Notes.app.
    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 to properly escape strings for safe insertion into AppleScript, used in read_note script construction.
    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

Tool Definition Quality

Score is being calculated. Check back soon.

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