create_folder
Create new folders in Apple Notes to organize your notes and documents. Use this tool to structure your note collection by adding named folders for better content management.
Instructions
Create a new folder in Apple Notes
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Name of the folder to create |
Implementation Reference
- src/notes/index.ts:411-429 (handler)Handler for the 'create_folder' tool. Parses the folder name argument, runs AppleScript via runAppleScript helper to create a new folder in Apple Notes, and returns success message.
case 'create_folder': { const { name: folderName } = z.object({ name: z.string() }).parse(args); const script = ` tell application "Notes" make new folder with properties {name:"${folderName}"} return "Folder '${folderName}' created successfully" end tell `; const result = await runAppleScript(script); return { content: [ { type: 'text', text: result, }, ], }; } - src/notes/index.ts:170-183 (registration)Tool registration in listTools handler, defining name, description, and input schema for 'create_folder' requiring 'name' string.
{ name: 'create_folder', description: 'Create a new folder in Apple Notes', inputSchema: { type: 'object', properties: { name: { type: 'string', description: 'Name of the folder to create' } }, required: ['name'] }, } - src/notes/index.ts:412-412 (schema)Inline Zod schema validation for create_folder input arguments.
const { name: folderName } = z.object({ name: z.string() }).parse(args); - src/notes/index.ts:28-43 (helper)Shared helper function runAppleScript used by create_folder (and other tools) to execute AppleScript safely via temporary files and osascript.
async function runAppleScript(script: string): Promise<string> { try { // Write script to temporary file to avoid shell escaping issues const tempFile = join(tmpdir(), `applescript-${Date.now()}.scpt`); writeFileSync(tempFile, script, 'utf8'); try { const { stdout } = await execAsync(`osascript "${tempFile}"`); return stdout.trim(); } finally { unlinkSync(tempFile); } } catch (error: any) { throw new McpError(ErrorCode.InternalError, `AppleScript error: ${error.message}`); } }