Skip to main content
Glama

Automation Script Generator MCP Server

Automation Script Generator MCP Server

An MCP (Model Context Protocol) server for automated test script generation using the WDIO framework. This server processes test scenarios directly from user prompts and generates complete WDIO test suites with intelligent file management that analyzes existing files to determine whether to update them or create new ones.

Features

  • 🧠 Smart File Analysis: Intelligently analyzes existing test files to prevent duplicates and maintain organized structure
  • Direct User Input: Process test scenarios from user prompts (no external dependencies)
  • Repository Analysis: Analyze existing patterns and conventions
  • WDIO Code Generation: Generate complete test suites with:
    • Feature files (Gherkin syntax)
    • Step definition files (WDIO functions)
    • Page Object Model files (selectors and methods)
    • Component files (test data collections)
  • Schema Validation: Comprehensive input validation using JSON Schema
  • Code Review & Enhancement: Automated code review with improvements
  • Intelligent Decision Making:
    • Updates existing features when similarity > 60%
    • Reuses page objects with matching selectors
    • Extends step definitions when steps are similar
    • Creates new files only when necessary
  • Pattern Recognition: Reuse existing functions and maintain consistency

Schema Validation

The MCP server includes robust input validation using AJV (Another JSON Schema Validator). All tool inputs are validated against their defined schemas before execution.

Validation Features

  • Type Checking: Ensures correct data types (string, object, array, etc.)
  • Required Fields: Validates that all required parameters are provided
  • String Constraints: Enforces minimum length requirements for important fields
  • Additional Properties: Prevents extra/unknown properties in requests
  • Enum Validation: Validates against predefined allowed values
  • Detailed Error Messages: Provides clear feedback on validation failures

🧠 Smart File Analysis

The server now includes intelligent file management that analyzes your existing test structure before generating new files. This prevents duplication and maintains an organized test suite.

How It Works

  1. Feature Similarity Analysis: Compares new scenarios with existing features using keyword matching
  2. Selector Overlap Detection: Identifies when new tests share page elements with existing page objects
  3. Step Definition Reuse: Finds existing step definitions that can be extended rather than duplicated
  4. Strategic Decision Making: Determines whether to update existing files or create new ones

Decision Logic

  • Feature Similarity > 60%: Updates existing feature file with new scenarios
  • Matching Selectors Found: Extends existing page object with new elements
  • Step Similarity > 80%: Reuses and extends existing step definitions
  • No Matches Found: Creates new test files

Smart Analysis Examples

// Scenario: "User Login with 2FA" // Decision: Update existing login.feature (85% similarity) // Action: Add new scenario to existing file // Reason: Keywords match: "user", "login", "credentials" // Scenario: "Product Catalog Search" // Decision: Create new product-catalog.feature // Action: Generate new test suite // Reason: No similar features found (<30% similarity) // Scenario: "Login Page Validation" // Decision: Update existing login.page.js // Action: Add validation selectors to page object // Reason: Selectors overlap: usernameInput, passwordInput

Benefits

  • Maintains Organized Structure: Keeps related tests together
  • Prevents Duplicate Code: Avoids redundant test scenarios and step definitions
  • Reduces Maintenance: Fewer files to maintain and update
  • Improves Reusability: Maximizes reuse of existing test components

Example Validation

// ✅ Valid request { "database_id": "test-db-123", "filter": { "tags": ["LOGIN"], "status": "ready" } } // ❌ Invalid request - missing required field { "filter": { "tags": ["LOGIN"] } // Error: must have required property 'database_id' } // ❌ Invalid request - extra properties { "database_id": "test-db-123", "invalid_property": "not allowed" // Error: must NOT have additional properties }

Testing Validation

Run the validation demo to see schema validation in action:

npm run test:validation # or node validation-demo.js

Process Flow

  1. Input from Notion: Fetch scenario_title, tags (test_id), gherkin syntax, selectors, and data items
  2. Repository Analysis: Read existing patterns and validate formats
  3. Code Generation: Create feature, steps, page, and component files
  4. Code Review: Improve, add docs, enhance, validate POM, check for reusable functions

Setup

Prerequisites

  • Node.js 18+
  • Notion integration token
  • Notion database with test scenarios

Installation

  1. Clone or create the project:
git clone <repository-url> cd automation-script-generator
  1. Install dependencies:
npm install
  1. Configure environment:
cp .env.example .env # Edit .env with your Notion token and database ID

Environment Configuration

Create a .env file with the following variables (optional):

DEFAULT_REPO_PATH=./test-repository OUTPUT_BASE_PATH=./generated WDIO_CONFIG_PATH=./wdio.conf.js

Usage

Starting the MCP Server

npm start

The server will run on stdio and expose the following tool:

Main Tool: process_test_scenario

Process a complete test scenario from user input and generate all necessary WDIO files.

Parameters:

  • scenario_title (required): Title of the test scenario
  • gherkin_syntax (required): Complete Gherkin syntax with Given/When/Then steps
  • selectors (required): UI element selectors as key-value pairs
  • output_directory (required): Base directory for generated files
  • tags (optional): Test ID tags (e.g., ["@login", "@smoke", "@TEST-001"])
  • data_items (optional): Test data items and configurations
  • repo_path (optional): Path to existing repository for pattern analysis

Additional Tools

The following individual tools are also available for granular control:

analyze_repository_patterns

Analyze repository for existing patterns and conventions.

generate_feature_file

Generate WDIO feature file with Gherkin syntax.

generate_steps_file

Generate step definitions file.

generate_page_file

Generate page object file.

generate_component_file

Generate component file with test data.

review_and_enhance_code

Review and enhance generated code.

Example Workflow

Here's how to use the MCP server to generate a complete test suite from a user prompt:

// Single call to process complete scenario await process_test_scenario({ scenario_title: "User Login Functionality", tags: ["@login", "@smoke", "@TEST-001"], gherkin_syntax: `Feature: User Login Scenario: Successful login with valid credentials Given I am on the login page When I enter valid username "user@example.com" And I enter valid password "password123" And I click the login button Then I should be redirected to the dashboard And I should see the welcome message`, selectors: { usernameInput: '[data-testid="username-input"]', passwordInput: '[data-testid="password-input"]', loginButton: '[data-testid="login-button"]', welcomeMessage: ".welcome-message", }, data_items: { validUser: { username: "user@example.com", password: "password123", }, invalidUser: { username: "invalid@example.com", password: "wrongpassword", }, }, output_directory: "./generated-tests", repo_path: "./existing-tests", // Optional: for pattern analysis });

This single call will:

  1. Analyze existing repository patterns (if repo_path provided)
  2. Generate feature file with Gherkin syntax
  3. Generate step definitions with WDIO functions
  4. Generate page object with selectors and methods
  5. Generate test data component (if data_items provided)
  6. Review and enhance all generated code
  7. Return summary of all generated files

Generated File Structure

The server generates files following WDIO best practices:

test/ ├── features/ │ └── *.feature # Gherkin scenarios ├── step-definitions/ │ └── *.steps.js # Step implementations ├── pageobjects/ │ └── *.page.js # Page Object Models └── data/ └── *.data.js # Test data components

Code Quality Features

  • Documentation: Automatic JSDoc comments
  • POM Patterns: Page Object Model best practices
  • Function Reuse: Detection of existing step functions
  • Naming Conventions: Consistent naming across files
  • Error Handling: Proper error handling in generated code
  • WDIO Integration: Full compatibility with WebDriverIO framework

Testing Validation

Run the validation demo to see schema validation in action:

npm run test:validation

User Prompt Format

See USER-PROMPT-EXAMPLES.md for detailed examples of how to format user prompts for the MCP server.

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make changes following the coding standards
  4. Add tests for new functionality
  5. Submit a pull request

License

ISC License

Support

For issues and questions:

  1. Check the examples in the /examples directory
  2. Review the user prompt examples in USER-PROMPT-EXAMPLES.md
  3. Review the MCP documentation at https://modelcontextprotocol.io
  4. Open an issue in the repository

Related MCP Servers

  • A
    security
    F
    license
    A
    quality
    Enables AI models to perform file system operations (reading, creating, and listing files) on a local file system through a standardized Model Context Protocol interface.
    Last updated -
    3
    JavaScript
  • -
    security
    F
    license
    -
    quality
    Captures screenshots and saves them to file paths specified by client applications, primarily designed to facilitate screenshot analysis by AI assistants running in WSL environments.
    Last updated -
    Python
  • A
    security
    A
    license
    A
    quality
    test server to see how clients handle a lot of tools
    Last updated -
    8,816
    3
    Python
    MIT License
  • -
    security
    A
    license
    -
    quality
    An AI-powered MCP server that automates web testing workflows by enabling recording, execution, and discovery of tests through natural language prompts.
    Last updated -
    55
    Python
    Apache 2.0
    • Linux
    • Apple

View all related MCP servers

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/raymondsambur/automation-script-generator'

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