create_shop_plugin
Create a Shop-Script plugin for Webasyst framework projects by specifying plugin name, title, description, and installation path.
Instructions
Создать плагин Shop-Script
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| plugin_name | Yes | ||
| plugin_title | Yes | ||
| description | No | ||
| webasyst_path | Yes |
Implementation Reference
- webasyst-mcp.js:712-736 (handler)The core handler function implementing the tool logic: creates directories for the Shop plugin, generates plugin.php config file, and creates the main PHP class file extending shopPlugin.async function createShopPluginTool({ plugin_name, plugin_title, description = '', webasyst_path }) { const p = path.join(webasyst_path, 'wa-apps', 'shop', 'plugins', plugin_name); for (const d of ['lib', 'lib/config', 'templates', 'css', 'js', 'img', 'locale']) await ensureDir(p, d); const pluginConfig = `<?php return array( 'name' => /*_wp*/('${plugin_title}'), 'description' => /*_wp*/('${description}'), 'img' => 'img/${plugin_name}.png', 'version' => '1.0.0', 'vendor' => 'custom', 'handlers' => array(), ); `; await fs.writeFile(path.join(p, 'lib', 'config', 'plugin.php'), pluginConfig); const cls = `<?php class shop${toCamelCase(plugin_name)}Plugin extends shopPlugin { // Plugin methods } `; await fs.writeFile(path.join(p, 'lib', `shop${toCamelCase(plugin_name)}Plugin.class.php`), cls); return { content: [{ type: 'text', text: `Shop plugin "${plugin_title}" создан: ${p}` }] }; }
- webasyst-mcp.js:1723-1723 (registration)Registration of the tool in the MCP server's listTools response, including name, description, and inputSchema defining parameters.{ name: 'create_shop_plugin', description: 'Создать плагин Shop-Script', inputSchema: { type: 'object', properties: { plugin_name: { type: 'string' }, plugin_title: { type: 'string' }, description: { type: 'string' }, webasyst_path: { type: 'string' } }, required: ['plugin_name', 'plugin_title', 'webasyst_path'] } },
- webasyst-mcp.js:1785-1785 (registration)Dispatcher switch case in CallToolRequestSchema handler that invokes the createShopPluginTool when the tool is called.case 'create_shop_plugin': return await createShopPluginTool(args);
- webasyst-mcp.js:19-19 (helper)Utility function used within the handler to convert plugin_name (snake_case) to CamelCase for generating the PHP class name.const toCamelCase = (s) => s.replace(/[-_](.)/g, (_, c) => c.toUpperCase()).replace(/^./, (m) => m.toUpperCase());
- webasyst-mcp.js:20-20 (helper)Helper function used to create directories recursively for the plugin structure.const ensureDir = async (...parts) => fs.mkdir(path.join(...parts), { recursive: true });