textedit_create_document
Create new TextEdit documents on macOS with optional initial content. Use this tool to generate text files quickly for notes, drafts, or any text-based work.
Instructions
Create new TextEdit document with optional content
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| content | No | Optional initial content for the document |
Implementation Reference
- src/index.ts:1449-1507 (handler)The handler case for 'textedit_create_document' that executes an AppleScript via osascript to create a new TextEdit document, optionally pre-filling it with provided content, and returns the document name or error.case 'textedit_create_document': try { const content = (args?.content as string) || ''; const command = `osascript -e 'on run argv set docContent to item 1 of argv tell application "TextEdit" set newDoc to make new document if docContent is not "" then set text of newDoc to docContent end if set docName to name of newDoc return "Created document: " & docName end tell end run' -- "${content}"`; const { stdout, stderr } = await execAsync(command); if (stderr.trim()) { return { content: [ { type: 'text', text: `Error creating TextEdit document: ${stderr.trim()}`, }, ], }; } const output = stdout.trim(); if (!output || output === '') { return { content: [ { type: 'text', text: 'Document created but name could not be retrieved', }, ], }; } return { content: [ { type: 'text', text: output, }, ], }; } catch (error: any) { return { content: [ { type: 'text', text: `Error executing TextEdit create document command: ${error.message}`, }, ], }; }
- src/index.ts:206-218 (schema)The tool definition in the ListTools response, including name, description, and input schema for validation.{ name: 'textedit_create_document', description: 'Create new TextEdit document with optional content', inputSchema: { type: 'object', properties: { content: { type: 'string', description: 'Optional initial content for the document', }, }, }, },