pages_create_document
Generate a new Pages document with plain text content using AppleScript on macOS. Ideal for creating unformatted documents programmatically within LLM applications.
Instructions
[Pages document operations] Create a new Pages document with plain text content (no formatting)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| content | Yes | The plain text content to add to the document (no formatting) |
Implementation Reference
- src/categories/pages.ts:24-37 (handler)Handler function that generates the AppleScript executed when the pages_create_document tool is called. It creates a new Pages document and sets its body text to the provided plain text content.script: (args) => ` try tell application "Pages" -- Create new document set newDoc to make new document set the body text of newDoc to "${args.content.replace(/"/g, '\\"')}" activate return "Document created successfully with plain text content" end tell on error errMsg return "Failed to create document: " & errMsg end try `
- src/categories/pages.ts:14-22 (schema)JSON Schema for input validation of the pages_create_document tool, requiring a 'content' parameter of type string.schema: { type: "object", properties: { content: { type: "string", description: "The plain text content to add to the document (no formatting)" } }, required: ["content"]
- src/categories/pages.ts:11-38 (registration)Registration of the create_document script within the pages category. The full tool name 'pages_create_document' is formed by combining category.name + '_' + script.name during MCP tool listing.{ name: "create_document", description: "Create a new Pages document with plain text content (no formatting)", schema: { type: "object", properties: { content: { type: "string", description: "The plain text content to add to the document (no formatting)" } }, required: ["content"] }, script: (args) => ` try tell application "Pages" -- Create new document set newDoc to make new document set the body text of newDoc to "${args.content.replace(/"/g, '\\"')}" activate return "Document created successfully with plain text content" end tell on error errMsg return "Failed to create document: " & errMsg end try ` }
- src/index.ts:32-32 (registration)Registers the entire pages category (including create_document script) with the AppleScriptFramework server, making pages_create_document available as an MCP tool.server.addCategory(pagesCategory);