setup-upgrade
Update Magento 2 database schema and data to apply system changes and maintain database integrity during development.
Instructions
Run Magento 2 setup upgrade to update database schema and data
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| keepGenerated | No | Keep generated files during upgrade |
Implementation Reference
- src/index.ts:993-1018 (handler)The handler function executes the 'magerun2 setup:upgrade' command, optionally appending '--keep-generated' if specified, calls executeMagerun2Command, and returns formatted success or error content.async ({ keepGenerated }) => { let command = `magerun2 setup:upgrade`; if (keepGenerated) { command += ` --keep-generated`; } const result = await executeMagerun2Command(command); if (!result.success) { return { content: [{ type: "text", text: result.error }], isError: true }; } return { content: [{ type: "text", text: `Setup upgrade completed:\n\n${result.data}` }] }; }
- src/index.ts:987-991 (schema)Input schema defining optional 'keepGenerated' boolean parameter for keeping generated files.inputSchema: { keepGenerated: z.boolean() .optional() .describe("Keep generated files during upgrade") }
- src/index.ts:982-1019 (registration)Registration of the 'setup-upgrade' tool with server.registerTool, specifying name, title, description, input schema, and inline handler function.server.registerTool( "setup-upgrade", { title: "Setup Upgrade", description: "Run Magento 2 setup upgrade to update database schema and data", inputSchema: { keepGenerated: z.boolean() .optional() .describe("Keep generated files during upgrade") } }, async ({ keepGenerated }) => { let command = `magerun2 setup:upgrade`; if (keepGenerated) { command += ` --keep-generated`; } const result = await executeMagerun2Command(command); if (!result.success) { return { content: [{ type: "text", text: result.error }], isError: true }; } return { content: [{ type: "text", text: `Setup upgrade completed:\n\n${result.data}` }] }; } );