Skip to main content
Glama
ailenshen

Apple Notes MCP Server

create_note

Create Apple Notes from Markdown content, using the first line as the title and optionally specifying a target folder.

Instructions

Create a new note in Apple Notes from Markdown content. The first line becomes the title. Optionally specify a target folder (defaults to 'Notes').

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
markdownYesMarkdown content for the note. First line (with or without #) becomes the title.
folderNoTarget folder name (e.g. 'Projects'). Defaults to 'Notes'.

Implementation Reference

  • The MCP tool handler for 'create_note', which calls the underlying 'createNote' function and formats the response.
    async ({ markdown, folder }) => {
      try {
        const title = await createNote(markdown, folder);
        return {
          content: [{ type: "text", text: `Note "${title}" created successfully${folder ? ` in folder "${folder}"` : ""}.` }],
        };
      } catch (e: unknown) {
        return {
          content: [{ type: "text", text: `Error: ${(e as Error).message}` }],
          isError: true,
        };
      }
    }
  • The core 'createNote' function implementation that generates and runs an AppleScript to interact with the Notes application.
    export async function createNote(
      markdown: string,
      targetFolder?: string
    ): Promise<string> {
      // 1. Extract title from first line
      const firstLine = markdown.split("\n")[0].replace(/^#\s*/, "").trim();
      const title = firstLine || "Untitled";
    
      // 2. Write temp .md file
      const tmpPath = join(tmpdir(), `note-${randomUUID()}.md`);
      await writeFile(tmpPath, markdown, "utf-8");
    
      try {
        // 3. Remember current frontmost app, open file, auto-confirm Import sheet
        const importScript = `
    -- Remember which app is currently active
    tell application "System Events"
      set frontApp to name of first process whose frontmost is true
    end tell
    
    do shell script "open -g -a Notes " & quoted form of "${tmpPath}"
    delay 0.5
    
    tell application "System Events"
      tell process "Notes"
        repeat 20 times
          repeat with w in every window
            try
              repeat with s in every sheet of w
                if (name of every button of s) contains "Import" then
                  click button "Import" of s
                  return frontApp
                end if
              end repeat
            end try
          end repeat
          delay 0.2
        end repeat
      end tell
    end tell
    
    return "no_sheet"
    `;
        const importResult = await runAppleScript(importScript);
    
        if (importResult === "no_sheet") {
          throw new Error("Failed to confirm Import sheet within timeout");
        }
    
        const frontApp = importResult;
  • src/index.ts:89-109 (registration)
    Registration of the 'create_note' MCP tool with input schema validation using Zod.
    server.tool(
      "create_note",
      "Create a new note in Apple Notes from Markdown content. The first line becomes the title. Optionally specify a target folder (defaults to 'Notes').",
      {
        markdown: z.string().describe("Markdown content for the note. First line (with or without #) becomes the title."),
        folder: z.string().optional().describe("Target folder name (e.g. 'Projects'). Defaults to 'Notes'."),
      },
      async ({ markdown, folder }) => {
        try {
          const title = await createNote(markdown, folder);
          return {
            content: [{ type: "text", text: `Note "${title}" created successfully${folder ? ` in folder "${folder}"` : ""}.` }],
          };
        } catch (e: unknown) {
          return {
            content: [{ type: "text", text: `Error: ${(e as Error).message}` }],
            isError: true,
          };
        }
      }
    );

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

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