Implements robust input validation using AJV (Another JSON Schema Validator) to validate all tool inputs against defined schemas before execution, providing type checking, required field validation, and detailed error messages.
Supports environment configuration through .env files for setting parameters like repository paths, output paths, and WDIO configuration paths.
Requires Node.js 18+ as a runtime environment for the MCP server operation.
Fetches test scenarios from Notion databases, including scenario titles, tags, Gherkin syntax, selectors, and data items for test generation.
Generates complete test suites with the WebDriverIO framework, including feature files (Gherkin syntax), step definition files, Page Object Model files, and component files for automated testing.
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
Feature Similarity Analysis: Compares new scenarios with existing features using keyword matching
Selector Overlap Detection: Identifies when new tests share page elements with existing page objects
Step Definition Reuse: Finds existing step definitions that can be extended rather than duplicated
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
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
Testing Validation
Run the validation demo to see schema validation in action:
Process Flow
Input from Notion: Fetch scenario_title, tags (test_id), gherkin syntax, selectors, and data items
Repository Analysis: Read existing patterns and validate formats
Code Generation: Create feature, steps, page, and component files
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
Clone or create the project:
Install dependencies:
Configure environment:
Environment Configuration
Create a .env
file with the following variables (optional):
Usage
Starting the MCP Server
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 scenariogherkin_syntax
(required): Complete Gherkin syntax with Given/When/Then stepsselectors
(required): UI element selectors as key-value pairsoutput_directory
(required): Base directory for generated filestags
(optional): Test ID tags (e.g., ["@login", "@smoke", "@TEST-001"])data_items
(optional): Test data items and configurationsrepo_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:
This single call will:
Analyze existing repository patterns (if repo_path provided)
Generate feature file with Gherkin syntax
Generate step definitions with WDIO functions
Generate page object with selectors and methods
Generate test data component (if data_items provided)
Review and enhance all generated code
Return summary of all generated files
Generated File Structure
The server generates files following WDIO best practices:
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:
User Prompt Format
See USER-PROMPT-EXAMPLES.md for detailed examples of how to format user prompts for the MCP server.
Contributing
Fork the repository
Create a feature branch
Make changes following the coding standards
Add tests for new functionality
Submit a pull request
License
ISC License
Support
For issues and questions:
Check the examples in the
/examples
directoryReview the user prompt examples in
USER-PROMPT-EXAMPLES.md
Review the MCP documentation at https://modelcontextprotocol.io
Open an issue in the repository
Tools
Processes test scenarios from user prompts to generate complete WDIO test suites with intelligent file management that analyzes existing files to determine whether to update them or create new ones.
Related MCP Servers
- AsecurityFlicenseAqualityEnables 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
- -securityFlicense-qualityCaptures 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 -
- -securityAlicense-qualityAI-powered agent that streamlines web testing workflows by allowing developers to record, execute, and discover tests using natural language prompts in their AI coding assistants.Last updated -59Apache 2.0
- AsecurityFlicenseAqualityEnables comprehensive directory analysis and file management operations including project structure exploration, intelligent file search, full CRUD operations on files and directories, batch operations with rollback capabilities, and Git integration.Last updated -134