Frontend Testing (Jest & Cypress) MCP server

Enables automated frontend testing by analyzing JavaScript/TypeScript code, generating Jest and Cypress tests, and executing them in isolated environments with proper configurations and dependencies.
Back to servers
Provider
StudentOfJS
Release date
Mar 23, 2025
Language
TypeScript
Stats
3 stars

This MCP server provides tools for frontend testing, offering code analysis, test generation, execution capabilities, and component testing specifically for React. It enables you to automate and enhance your frontend testing workflow through a structured API.

Installation

Prerequisites

Before installing the MCP Frontend Testing Server, ensure you have:

  • Git installed on your system
  • Node.js and npm installed

Setup Steps

  1. Clone the repository:

    git clone mcp-frontend-testing
    
  2. Navigate to the project directory:

    cd mcp-frontend-testing
    
  3. Install dependencies:

    npm install
    

Running the Server

The server supports multiple transport methods for communication.

HTTP Transport

To run the server with HTTP transport:

# Build the server
npm run build

# Start the server with HTTP transport
npm run start:http

Stdio Transport

For stdio-based communication:

# Build the server
npm run build

# Start the server with Stdio transport
npm run start:stdio

Docker Deployment

Alternatively, you can run the server using Docker:

# Build the Docker image
docker build -t mcp-frontend-testing .

# Run the container exposing port 3000
docker run -p 3000:3000 mcp-frontend-testing

Using the Server Tools

Code Analysis

Analyze JavaScript/TypeScript code to determine appropriate testing strategies:

Parameters:

  • code (string, required): The source code to analyze
  • language (enum, optional): Language of the code (javascript, typescript, jsx, or tsx)

Test Generation

Generate unit and component tests for Jest and Cypress:

Parameters:

  • code (string, required): The source code to generate tests for
  • framework (enum, required): Testing framework (jest or cypress)
  • type (enum, required): Type of test (unit, component, or e2e)
  • language (enum, optional): Language of the code
  • description (string, optional): Description of the test case

Test Execution

Run tests using Jest and Cypress and get results:

Parameters:

  • sourceCode (string, required): The source code being tested
  • testCode (string, required): The test code to execute
  • framework (enum, required): Testing framework (jest or cypress)
  • type (enum, required): Type of test (unit, component, or e2e)
  • config (record, optional): Configuration object for test execution

React Component Testing

Test React components specifically:

Parameters:

  • componentCode (string, required): The source code of the React component
  • testCode (string, optional): Test code for the component
  • framework (enum, optional): Testing framework (default: jest)
  • props (record, optional): Props to pass to the component during testing
  • autoGenerateTest (boolean, optional): Automatically generate test code if not provided

Accessing Resources

Test Templates

Access test templates for different frameworks:

URI: templates://{framework}/{type}

Parameters:

  • framework (string, required): Testing framework (jest or cypress)
  • type (string, required): Type of template (unit or component)

Documentation

Access documentation for testing frameworks:

URI: docs://{topic}

Parameters:

  • topic (string, required): Documentation topic (jest, cypress, or react-testing-library)

How to add this MCP server to Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-mcp"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later