Skip to main content
Glama
arslankhanali

Apple Notes MCP Server

create_note

Create new notes in Apple Notes with specified titles, content, and optional organization into accounts and folders.

Instructions

Create a new note with the specified title and content.

Args:
    title: Title/name for the new note
    content: Content/body of the note
    account: Optional account name (defaults to default account)
    folder: Optional folder name within the account

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
titleYes
contentYes
accountNo
folderNo

Implementation Reference

  • The primary handler function for the 'create_note' tool. It is registered via the @mcp.tool() decorator and implements the logic to create a new note in the Apple Notes application using dynamically generated AppleScript, supporting optional account and folder specifications.
    @mcp.tool()
    async def create_note(title: str, content: str, account: Optional[str] = None, folder: Optional[str] = None) -> str:
        """Create a new note with the specified title and content.
        
        Args:
            title: Title/name for the new note
            content: Content/body of the note
            account: Optional account name (defaults to default account)
            folder: Optional folder name within the account
        """
        escaped_title = escape_applescript_string(title)
        escaped_content = escape_applescript_string(content)
        
        if account and folder:
            script = f'''
            tell application "Notes"
                set accountName to "{escape_applescript_string(account)}"
                set folderName to "{escape_applescript_string(folder)}"
                try
                    set targetAccount to account accountName
                    set targetFolder to folder folderName of targetAccount
                    make new note at targetFolder with properties {{name:"{escaped_title}", body:"{escaped_content}"}}
                    return "SUCCESS"
                on error errMsg
                    return "ERROR: " & errMsg
                end try
            end tell
            '''
        elif account:
            script = f'''
            tell application "Notes"
                set accountName to "{escape_applescript_string(account)}"
                try
                    set targetAccount to account accountName
                    make new note at targetAccount with properties {{name:"{escaped_title}", body:"{escaped_content}"}}
                    return "SUCCESS"
                on error errMsg
                    return "ERROR: " & errMsg
                end try
            end tell
            '''
        else:
            script = f'''
            tell application "Notes"
                try
                    make new note with properties {{name:"{escaped_title}", body:"{escaped_content}"}}
                    return "SUCCESS"
                on error errMsg
                    return "ERROR: " & errMsg
                end try
            end tell
            '''
        
        output, success = run_applescript(script)
        if not success or "ERROR" in output:
            return output if output else "Failed to create note."
        
        return f"Successfully created note '{title}'."
  • Helper function used by create_note (and other tools) to execute AppleScript commands via subprocess, returning output and success status.
    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 create_note to properly escape title and content 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
  • Input schema defined by function parameters with type hints and detailed Arg descriptions in docstring. Returns a string message indicating success or error.
    async def create_note(title: str, content: str, account: Optional[str] = None, folder: Optional[str] = None) -> str:
        """Create a new note with the specified title and content.
        
        Args:
            title: Title/name for the new note
            content: Content/body of the note
            account: Optional account name (defaults to default account)
            folder: Optional folder name within the account
        """

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