
Automation Script Generator MCP Server
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.
README
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
// 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
- 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:
git clone <repository-url>
cd automation-script-generator
- Install dependencies:
npm install
- 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 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:
// 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:
- 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:
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
- 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
directory - Review the user prompt examples in
USER-PROMPT-EXAMPLES.md
- Review the MCP documentation at https://modelcontextprotocol.io
- Open an issue in the repository
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.