run_webasyst_cli
Execute Webasyst CLI commands to manage apps, plugins, themes, and configurations for framework projects.
Instructions
Выполнить CLI команду Webasyst
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| command | Yes | CLI команда для выполнения | |
| args | No | Аргументы команды |
Implementation Reference
- webasyst-mcp.js:168-182 (handler)The core handler function that implements the 'run_webasyst_cli' tool logic. It finds the Webasyst root directory, spawns a PHP process to run cli.php with the provided command and arguments, captures stdout and stderr, and returns the output or throws an error if the process fails.async function runWebasystCliTool({ command, args = [] }) { const rootPath = await findWebasystRoot(); const cliPath = path.join(rootPath, 'cli.php'); if (!(await fileExists(cliPath))) throw new Error('CLI файл не найден'); return new Promise((resolve, reject) => { const child = spawn('php', [cliPath, command, ...args], { cwd: rootPath, stdio: 'pipe' }); let output = ''; let error = ''; child.stdout.on('data', d => (output += d.toString())); child.stderr.on('data', d => (error += d.toString())); child.on('close', (code) => { if (code !== 0) reject(new Error(`CLI команда завершилась с кодом ${code}: ${error}`)); else resolve({ content: [{ type: 'text', text: `Результат выполнения команды "${command}":\n\n${output}` }] }); }); }); }
- webasyst-mcp.js:1706-1706 (registration)Registration of the 'run_webasyst_cli' tool in the ListTools response, including its description and input schema definition.{ name: 'run_webasyst_cli', description: 'Выполнить CLI команду Webasyst', inputSchema: { type: 'object', properties: { command: { type: 'string', description: 'CLI команда для выполнения' }, args: { type: 'array', items: { type: 'string' }, description: 'Аргументы команды', default: [] } }, required: ['command'] } },
- webasyst-mcp.js:1768-1768 (registration)Registration of the tool handler in the CallToolRequestSchema switch statement, mapping the tool name to its execution.case 'run_webasyst_cli': return await runWebasystCliTool(args);
- webasyst-mcp.js:31-45 (helper)Helper function used by the tool to locate the Webasyst root directory by searching upwards for index.php and wa-system.async function findWebasystRoot(startCwd = process.cwd()) { let currentDir = startCwd; while (currentDir !== '/') { const indexPath = path.join(currentDir, 'index.php'); const systemPath = path.join(currentDir, 'wa-system'); try { await fs.access(indexPath); await fs.access(systemPath); return currentDir; } catch { currentDir = path.dirname(currentDir); } } throw new Error('Корневая директория Webasyst не найдена'); }
- webasyst-mcp.js:22-29 (helper)Helper utility function used to check if the CLI file exists before spawning the process.async function fileExists(p) { try { await fs.access(p); return true; } catch { return false; } }