Skip to main content
Glama

create_plugin_structure

Generate the initial file structure for a new Webasyst plugin by specifying the application ID, plugin ID, and plugin name.

Instructions

Создать структуру нового плагина

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
app_idYesID приложения
plugin_idYesID плагина
plugin_nameYesНазвание плагина

Implementation Reference

  • The handler function implementing the create_plugin_structure tool logic. Creates directories, plugin.php config file, and the main plugin class file in the Webasyst app's plugins directory.
    async function createPluginStructureTool({ app_id, plugin_id, plugin_name }) { const rootPath = await findWebasystRoot(); const pluginPath = path.join(rootPath, 'wa-apps', app_id, 'plugins', plugin_id); if (await fileExists(pluginPath)) throw new Error(`Плагин ${plugin_id} уже существует`); const dirs = ['lib/config', 'lib', 'templates', 'css', 'js', 'img', 'locale']; for (const d of dirs) await ensureDir(pluginPath, d); const pluginPhp = `<?php return array( 'name' => /*_wp*/('${plugin_name}'), 'description' => /*_wp*/(''), 'img' => 'img/${plugin_id}.png', 'version' => '1.0.0', 'vendor' => 'custom', 'handlers' => array(), ); `; await fs.writeFile(path.join(pluginPath, 'lib', 'config', 'plugin.php'), pluginPhp); const className = `${app_id}${toCamelCase(plugin_id)}Plugin`; const classPhp = `<?php class ${className} extends waPlugin { public function __construct(\$info) { parent::__construct(\$info); } } `; await fs.writeFile(path.join(pluginPath, 'lib', `${className}.class.php`), classPhp); return { content: [{ type: 'text', text: `Структура плагина ${plugin_name} (${plugin_id}) создана для ${app_id}:\n${pluginPath}` }] };
  • Registration of the tool in the ListToolsRequestSchema handler, including the tool name, description, and input schema definition.
    { name: 'create_plugin_structure', description: 'Создать структуру нового плагина', inputSchema: { type: 'object', properties: { app_id: { type: 'string', description: 'ID приложения' }, plugin_id: { type: 'string', description: 'ID плагина' }, plugin_name: { type: 'string', description: 'Название плагина' } }, required: ['app_id', 'plugin_id', 'plugin_name'] } }, { name: 'create_widget', description: 'Создать виджет для Dashboard', inputSchema: { type: 'object', properties: { app_id: { type: 'string', description: 'ID приложения (webasyst для системного виджета)' }, widget_id: { type: 'string', description: 'ID виджета' }, widget_name: { type: 'string', description: 'Название виджета' }, has_settings: { type: 'boolean', default: false, description: 'Имеет настройки' } }, required: ['app_id', 'widget_id', 'widget_name'] } }, { 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'] } },
  • Registration and dispatching of the tool call in the CallToolRequestSchema switch statement.
    case 'create_plugin_structure': return await createPluginStructureTool(args);
  • Input schema definition for the create_plugin_structure tool, specifying required parameters: app_id, plugin_id, plugin_name.
    { name: 'create_widget', description: 'Создать виджет для Dashboard', inputSchema: { type: 'object', properties: { app_id: { type: 'string', description: 'ID приложения (webasyst для системного виджета)' }, widget_id: { type: 'string', description: 'ID виджета' }, widget_name: { type: 'string', description: 'Название виджета' }, has_settings: { type: 'boolean', default: false, description: 'Имеет настройки' } }, required: ['app_id', 'widget_id', 'widget_name'] } }, { 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'] } },
  • Utility function toCamelCase used in createPluginStructureTool to generate class names from plugin_id.
    const toCamelCase = (s) => s.replace(/[-_](.)/g, (_, c) => c.toUpperCase()).replace(/^./, (m) => m.toUpperCase()); 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