list_webasyst_apps
Retrieve all Webasyst applications for framework management. Optionally include system apps to view complete project structure.
Instructions
Получить список всех приложений Webasyst
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| include_system | No | Включить системные приложения |
Implementation Reference
- webasyst-mcp.js:78-90 (handler)The main execution logic for the 'list_webasyst_apps' tool. Locates Webasyst root, iterates over wa-apps directories, parses lib/config/app.php configs using helpers, filters system app, and returns a formatted text list of apps with names and versions.async function listWebasystAppsTool({ include_system = false } = {}) { const rootPath = await findWebasystRoot(); const appsPath = path.join(rootPath, 'wa-apps'); const result = []; for (const appDir of await fs.readdir(appsPath)) { const configPath = path.join(appsPath, appDir, 'lib', 'config', 'app.php'); if (!(await fileExists(configPath))) continue; const appInfo = await readPHPConfigArray(configPath).catch(() => ({})); if (appDir === 'webasyst' && !include_system) continue; result.push({ id: appDir, name: appInfo.name || appDir, version: appInfo.version || '0.0.1' }); } return { content: [{ type: 'text', text: `Найдено приложений: ${result.length}\n\n${result.map(a => `- ${a.name} (${a.id}) - v${a.version}`).join('\n')}` }] }; }
- webasyst-mcp.js:1698-1698 (schema)Input schema for the tool, defining an optional boolean parameter 'include_system' to include system apps like 'webasyst'.{ name: 'list_webasyst_apps', description: 'Получить список всех приложений Webasyst', inputSchema: { type: 'object', properties: { include_system: { type: 'boolean', default: false, description: 'Включить системные приложения' } } } },
- webasyst-mcp.js:1760-1760 (registration)Tool handler registration in the CallToolRequestSchema switch statement, mapping the tool name to the listWebasystAppsTool function.case 'list_webasyst_apps': return await listWebasystAppsTool(args);
- webasyst-mcp.js:31-45 (helper)Helper function used by the tool to locate the Webasyst installation root by walking up directories until finding 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:48-75 (helper)Helper function to parse PHP config arrays from app.php files, extracting string, boolean, and numeric key-value pairs.async function readPHPConfigArray(phpFilePath) { const content = await fs.readFile(phpFilePath, 'utf-8'); const match = content.match(/return\s+(array\s*\([\s\S]*?\)|\[[\s\S]*?\]);/); if (!match) return {}; const body = match[1]; const result = {}; // Parse string values: 'key' => 'value' const stringPairs = body.matchAll(/'([^']+)'\s*=>\s*'([^']*)'/g); for (const m of stringPairs) { result[m[1]] = m[2]; } // Parse boolean values: 'key' => true/false const boolPairs = body.matchAll(/'([^']+)'\s*=>\s*(true|false)/gi); for (const m of boolPairs) { result[m[1]] = m[2].toLowerCase() === 'true'; } // Parse numeric values: 'key' => 123 const numPairs = body.matchAll(/'([^']+)'\s*=>\s*(\d+)/g); for (const m of numPairs) { result[m[1]] = parseInt(m[2], 10); } return result; }