Skip to main content
Glama

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
NameRequiredDescriptionDefault
plugin_nameYes
plugin_titleYes
descriptionNo
webasyst_pathYes

Implementation Reference

  • 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}` }] }; }
  • 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'] } },
  • Dispatcher switch case in CallToolRequestSchema handler that invokes the createShopPluginTool when the tool is called.
    case 'create_shop_plugin': return await createShopPluginTool(args);
  • 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());
  • Helper function used to create directories recursively for the plugin structure.
    const ensureDir = async (...parts) => fs.mkdir(path.join(...parts), { recursive: true });

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/emmy-design/webasyst-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server