download_page_to_file
Download a WordPress page by its ID, including Elementor meta fields, and save it to a specified file path. Optionally, save only the _elementor_data field for targeted use.
Instructions
Downloads a specific page from WordPress by its ID, including meta fields like _elementor_data, and saves it to a file.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filePath | Yes | The path to save the file to, have to be the absolute path. | |
| onlyElementorData | No | Whether to only save the _elementor_data field to the file, defaults to false. | |
| pageId | Yes | The ID of the page to download. |
Implementation Reference
- src/index.js:119-132 (handler)The handler function that executes the download_page_to_file tool logic: retrieves page data via getPage and saves to file using fs.writeFileSync, optionally only Elementor data.async (input) => { const pageData = await getPage(input.pageId); if (input.onlyElementorData) { fs.writeFileSync( input.filePath, JSON.stringify(pageData.meta._elementor_data, null, 0) ); } else { fs.writeFileSync(input.filePath, JSON.stringify(pageData, null, 0)); } return { content: [{ type: "text", text: "true" }], }; }
- src/index.js:100-118 (schema)Input schema for download_page_to_file tool, defining parameters pageId, filePath, and optional onlyElementorData using Zod.{ pageId: z .number() .int() .positive() .describe("The ID of the page to download."), filePath: z .string() .describe( "The path to save the file to, have to be the absolute path." ), onlyElementorData: z .boolean() .optional() .default(false) .describe( "Whether to only save the _elementor_data field to the file, defaults to false." ), },
- src/index.js:97-133 (registration)Registration of the download_page_to_file tool using McpServer's server.tool method.server.tool( "download_page_to_file", "Downloads a specific page from WordPress by its ID, including meta fields like _elementor_data, and saves it to a file.", { pageId: z .number() .int() .positive() .describe("The ID of the page to download."), filePath: z .string() .describe( "The path to save the file to, have to be the absolute path." ), onlyElementorData: z .boolean() .optional() .default(false) .describe( "Whether to only save the _elementor_data field to the file, defaults to false." ), }, async (input) => { const pageData = await getPage(input.pageId); if (input.onlyElementorData) { fs.writeFileSync( input.filePath, JSON.stringify(pageData.meta._elementor_data, null, 0) ); } else { fs.writeFileSync(input.filePath, JSON.stringify(pageData, null, 0)); } return { content: [{ type: "text", text: "true" }], }; } );