Skip to main content
Glama

generate_app

Create a Next.js application to manage workflow data with customizable stages, dashboard, API endpoints, database setup, and approval features.

Instructions

Generate a Next.js app for managing workflow data within the current project

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesName of the app directory (e.g., "app", "dashboard")
stagesNoWorkflow stages for pipeline view (default: created, processing, review, completed)
featuresNoFeatures to include in the app

Implementation Reference

  • The main tool handler for 'generate_app'. Parses input arguments, creates an AppGenerator instance with the project path, calls generateApp with config, handles success/error responses with detailed user feedback including next steps.
    case 'generate_app':
      const appName = args?.name as string;
      const stages = args?.stages as string[] || ['created', 'processing', 'review', 'completed'];
      const features = args?.features || {
        dashboard: true,
        api: true,
        database: true,
        webhooks: true,
        approvals: false
      };
    
      // Get project path (parent of workflows directory)
      const projectPath = path.dirname(this.workflowsPath);
    
      // Create app generator
      const appGenerator = new AppGenerator(projectPath);
    
      try {
        await appGenerator.generateApp({
          name: appName,
          projectPath,
          features,
          stages
        });
    
        return {
          content: [{
            type: 'text',
            text: `βœ… Successfully generated Next.js app: ${appName}\\n\\n` +
              `πŸ“ Location: ${path.join(projectPath, appName)}\\n\\n` +
              `Features included:\\n` +
              `β€’ Dashboard: ${features.dashboard ? 'Yes' : 'No'}\\n` +
              `β€’ API Endpoints: ${features.api ? 'Yes' : 'No'}\\n` +
              `β€’ Database (SQLite): ${features.database ? 'Yes' : 'No'}\\n` +
              `β€’ Webhook Receivers: ${features.webhooks ? 'Yes' : 'No'}\\n` +
              `β€’ Approval System: ${features.approvals ? 'Yes' : 'No'}\\n\\n` +
              `Pipeline Stages: ${stages.join(' β†’ ')}\\n\\n` +
              `Next steps:\\n` +
              `1. cd ${appName}\\n` +
              `2. npm install\\n` +
              `3. npm run dev\\n\\n` +
              `The app will be available at http://localhost:3000\\n\\n` +
              `To integrate with n8n workflows:\\n` +
              `β€’ Use the tracking system: mcflow add_tracking --storageUrl http://localhost:3000\\n` +
              `β€’ Or add HTTP Request nodes manually to your workflows`
          }]
        };
      } catch (error: any) {
        return {
          content: [{
            type: 'text',
            text: `❌ Failed to generate app: ${error.message}`
          }]
        };
      }
  • Input schema for the generate_app tool, specifying required 'name' parameter and optional 'stages' array and 'features' object with booleans for dashboard, api, database, webhooks, approvals.
    inputSchema: {
      type: 'object',
      properties: {
        name: {
          type: 'string',
          description: 'Name of the app directory (e.g., "app", "dashboard")',
        },
        stages: {
          type: 'array',
          items: { type: 'string' },
          description: 'Workflow stages for pipeline view (default: created, processing, review, completed)',
        },
        features: {
          type: 'object',
          properties: {
            dashboard: {
              type: 'boolean',
              description: 'Include dashboard with stats and tables',
            },
            api: {
              type: 'boolean',
              description: 'Include API endpoints for workflow integration',
            },
            database: {
              type: 'boolean',
              description: 'Include SQLite database setup',
            },
            webhooks: {
              type: 'boolean',
              description: 'Include webhook receivers for n8n',
            },
            approvals: {
              type: 'boolean',
              description: 'Include approval/reject functionality',
            },
          },
          description: 'Features to include in the app',
        },
      },
      required: ['name'],
  • Registration of the 'generate_app' tool in the MCP tools definitions array exported by getToolDefinitions().
    {
      name: 'generate_app',
      description: 'Generate a Next.js app for managing workflow data within the current project',
      inputSchema: {
        type: 'object',
        properties: {
          name: {
            type: 'string',
            description: 'Name of the app directory (e.g., "app", "dashboard")',
          },
          stages: {
            type: 'array',
            items: { type: 'string' },
            description: 'Workflow stages for pipeline view (default: created, processing, review, completed)',
          },
          features: {
            type: 'object',
            properties: {
              dashboard: {
                type: 'boolean',
                description: 'Include dashboard with stats and tables',
              },
              api: {
                type: 'boolean',
                description: 'Include API endpoints for workflow integration',
              },
              database: {
                type: 'boolean',
                description: 'Include SQLite database setup',
              },
              webhooks: {
                type: 'boolean',
                description: 'Include webhook receivers for n8n',
              },
              approvals: {
                type: 'boolean',
                description: 'Include approval/reject functionality',
              },
            },
            description: 'Features to include in the app',
          },
        },
        required: ['name'],
      },
    },
  • Core generateApp method of AppGenerator class. Orchestrates creation of Next.js app: checks existence, creates directories, generates package.json, DB schema, API routes, dashboard pages, components, styles, env files, and gitignore.
    async generateApp(config: AppConfig): Promise<void> {
      const appPath = path.join(this.projectPath, config.name);
    
      // Check if app already exists
      try {
        await fs.access(appPath);
        throw new Error(`App directory ${config.name} already exists`);
      } catch (error: any) {
        if (error.code !== 'ENOENT') throw error;
      }
    
      // Create app structure
      await this.createAppStructure(appPath);
    
      // Generate files based on features
      await this.generatePackageJson(appPath, config);
      await this.generateDatabaseSchema(appPath);
      await this.generateApiEndpoints(appPath, config);
      await this.generateDashboard(appPath, config);
      await this.generateComponents(appPath, config);
      await this.generateStyles(appPath);
      await this.generateEnvFile(appPath);
    
      // Initialize git ignore
      await this.generateGitIgnore(appPath);
    }
  • TypeScript interface AppConfig defining the configuration structure passed to generateApp method, matching the tool input schema.
    export interface AppConfig {
      name: string;
      projectPath: string;
      features?: {
        dashboard?: boolean;
        api?: boolean;
        database?: boolean;
        webhooks?: boolean;
        approvals?: boolean;
      };
      stages?: string[];
    }

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/mckinleymedia/mcflow-mcp'

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