create_action
Generate actions or controllers for Webasyst framework applications by specifying app ID, module, and action names to implement backend or frontend functionality.
Instructions
Создать action или controller
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| app_id | Yes | ID приложения | |
| module | Yes | Название модуля (backend, frontend и т.д.) | |
| action_type | No | Тип action | action |
| action_names | Yes | Названия actions |
Implementation Reference
- webasyst-mcp.js:434-502 (handler)The core handler function for the 'create_action' MCP tool. It generates PHP class files for Webasyst actions/controllers (single action, actions class, JSON controllers, etc.) and corresponding HTML templates in the specified app's module directory.async function createActionTool({ app_id, module, action_type = 'action', action_names }) { const rootPath = await findWebasystRoot(); const appPath = path.join(rootPath, 'wa-apps', app_id); if (!(await fileExists(appPath))) throw new Error(`Приложение ${app_id} не найдено`); const classTypes = { 'action': 'waViewAction', 'actions': 'waViewActions', 'long': 'waLongActionController', 'json': 'waJsonController', 'jsons': 'waJsonActions' }; const baseClass = classTypes[action_type] || 'waViewAction'; const createdFiles = []; for (const actionName of action_names) { const actionsDir = path.join(appPath, 'lib', 'actions', module); await ensureDir(actionsDir); const className = `${app_id}${toCamelCase(module)}${toCamelCase(actionName)}${action_type === 'json' || action_type === 'jsons' ? 'Controller' : 'Action'}`; const fileName = action_type === 'actions' || action_type === 'jsons' ? `${app_id}${toCamelCase(module)}.actions.php` : `${app_id}${toCamelCase(module)}${toCamelCase(actionName)}.action.php`; const filePath = path.join(actionsDir, fileName); let code; if (action_type === 'actions' || action_type === 'jsons') { code = `<?php class ${app_id}${toCamelCase(module)}Actions extends ${baseClass} { public function ${actionName}Action() { // TODO: implement } } `; } else { code = `<?php class ${className} extends ${baseClass} { public function execute() { // TODO: implement } } `; } await fs.writeFile(filePath, code); createdFiles.push(filePath); // Create template for view actions if (action_type === 'action' || action_type === 'actions') { const templatesDir = path.join(appPath, 'templates', 'actions', module); await ensureDir(templatesDir); const templateName = `${toCamelCase(module)}${toCamelCase(actionName)}.html`; const templatePath = path.join(templatesDir, templateName); await fs.writeFile(templatePath, `{* ${actionName} template *}\n`); createdFiles.push(templatePath); } } return { content: [{ type: 'text', text: `Созданы файлы:\n${createdFiles.join('\n')}` }] }; }
- webasyst-mcp.js:1774-1774 (registration)Registration of the create_action tool handler in the MCP server's CallToolRequestSchema switch statement.case 'create_action': return await createActionTool(args);
- webasyst-mcp.js:1712-1713 (schema)Tool schema and metadata registration in the ListToolsRequestSchema response, defining input parameters and requirements for the create_action tool.{ name: 'create_action', description: 'Создать action или controller', inputSchema: { type: 'object', properties: { app_id: { type: 'string', description: 'ID приложения' }, module: { type: 'string', description: 'Название модуля (backend, frontend и т.д.)' }, action_type: { type: 'string', enum: ['action', 'actions', 'long', 'json', 'jsons'], default: 'action', description: 'Тип action' }, action_names: { type: 'array', items: { type: 'string' }, description: 'Названия actions' } }, required: ['app_id', 'module', 'action_names'] } }, { name: 'create_model', description: 'Создать модель для работы с БД', inputSchema: { type: 'object', properties: { app_id: { type: 'string', description: 'ID приложения' }, table_name: { type: 'string', description: 'Название таблицы в БД' } }, required: ['app_id', 'table_name'] } },