Skip to main content
Glama
lucad87

MCP Server - Test Migration (WDIO to Playwright)

by lucad87

detect_project_state

Analyzes project structure to detect existing Playwright configuration, migrated tests, page objects, and WDIO setup for understanding current migration state.

Instructions

Analyzes project structure to detect existing Playwright configuration, migrated tests, page objects, and WDIO setup. Helps understand current migration state.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectFilesYesJSON string containing file paths and their contents to analyze

Implementation Reference

  • The implementation of the `handleDetectProjectState` function, which analyzes project files to identify test frameworks, config files, and project structure.
    export async function handleDetectProjectState(args) {
      const { projectFiles } = args;
    
      let files = {};
      try {
        files = JSON.parse(projectFiles);
      } catch (e) {
        return {
          content: [{
            type: 'text',
            text: 'Error: projectFiles must be a valid JSON object with file paths as keys and contents as values',
          }],
          isError: true,
        };
      }
    
      const state = {
        hasPlaywrightConfig: false,
        hasWdioConfig: false,
        playwrightConfigPath: null,
        wdioConfigPath: null,
        playwrightTests: [],
        wdioTests: [],
        mixedTests: [],
        pageObjects: [],
        existingStructure: {
          testsDir: null,
          pagesDir: null,
          fixturesDir: null,
        },
        packageJson: null,
        recommendations: [],
      };
    
      for (const [filePath, content] of Object.entries(files)) {
        const lowerPath = filePath.toLowerCase();
    
        if (lowerPath.includes('playwright.config')) {
          state.hasPlaywrightConfig = true;
          state.playwrightConfigPath = filePath;
          state.existingConfig = parsePlaywrightConfig(content);
        }
        
        if (lowerPath.includes('wdio.conf')) {
          state.hasWdioConfig = true;
          state.wdioConfigPath = filePath;
        }
    
        if (lowerPath.match(/\.(spec|test)\.(js|ts)$/)) {
          const ast = parseCode(content);
          const framework = detectFramework(ast);
    
          if (framework.isPlaywright) {
            state.playwrightTests.push(filePath);
          } else if (framework.isWdio) {
            state.wdioTests.push(filePath);
          } else if (framework.isMixed) {
            state.mixedTests.push(filePath);
          }
        }
    
        if (lowerPath.includes('page') && lowerPath.match(/\.(js|ts)$/)) {
          if (content.includes('export class') && content.includes('constructor(page)')) {
            state.pageObjects.push(filePath);
          }
        }
    
        if (lowerPath.includes('/tests/') || lowerPath.includes('/test/')) {
          state.existingStructure.testsDir = filePath.split('/tests/')[0] + '/tests/' ||
                                              filePath.split('/test/')[0] + '/test/';
        }
        if (lowerPath.includes('/pages/')) {
          state.existingStructure.pagesDir = filePath.split('/pages/')[0] + '/pages/';
        }
        if (lowerPath.includes('/fixtures/')) {
          state.existingStructure.fixturesDir = filePath.split('/fixtures/')[0] + '/fixtures/';
        }
    
        if (lowerPath.endsWith('package.json')) {
          try {
            state.packageJson = JSON.parse(content);
          } catch (e) {
            // Ignore
          }
        }
      }
    
      // Generate recommendations
      if (state.hasPlaywrightConfig && state.wdioTests.length > 0) {
        state.recommendations.push('Playwright already configured. Migrate remaining WDIO tests.');
      }
      if (!state.hasPlaywrightConfig && state.hasWdioConfig) {
        state.recommendations.push('Use migrate_config tool to convert wdio.conf to playwright.config');
      }
      if (state.mixedTests.length > 0) {
        state.recommendations.push(`${state.mixedTests.length} tests have mixed WDIO/Playwright code - complete migration`);
      }
      if (state.pageObjects.length > 0) {
        state.recommendations.push(`${state.pageObjects.length} existing page objects found - can be reused or extended`);
      }
      if (state.existingStructure.pagesDir) {
        state.recommendations.push(`Use existing pages directory: ${state.existingStructure.pagesDir}`);
      }
    
      return {
        content: [{
          type: 'text',
          text: JSON.stringify(state, null, 2),
        }],
      };
    }
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations provided, so description carries full burden. 'Analyzes' and 'detect' imply read-only behavior, but the description lacks explicit safety guarantees, side effect warnings, or output format disclosure despite having no output schema to reference.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two efficient sentences with zero waste. First sentence establishes capability, second establishes value proposition. Front-loaded with the action verb and appropriately sized for the tool's complexity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

With no output schema and no annotations, the description adequately lists detectable artifacts but omits return value description, error scenarios, or prerequisites. Sufficient for a single-parameter analysis tool but leaves gaps in behavioral contract.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100% (projectFiles is fully described in schema), establishing baseline 3. The description mentions 'analyzes project structure' which loosely implies the input, but adds no specific semantics about the JSON string format, size limits, or content expectations beyond the schema description.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

Clear specific action ('Analyzes project structure') and resources detected (Playwright configuration, WDIO setup, page objects). The phrase 'Helps understand current migration state' distinguishes it from sibling migration tools like migrate_to_playwright, though it doesn't explicitly contrast with analyze_wdio_test.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Implies usage context through 'migration state' but lacks explicit when-to-use guidance (e.g., 'Use this before migrating to assess current state') or when-not-to-use (e.g., 'Do not use for analyzing individual test logic—use analyze_wdio_test instead').

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/lucad87/mcp-server-tests-migration'

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