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.
Before installing the MCP Frontend Testing Server, ensure you have:
Clone the repository:
git clone mcp-frontend-testing
Navigate to the project directory:
cd mcp-frontend-testing
Install dependencies:
npm install
The server supports multiple transport methods for communication.
To run the server with HTTP transport:
# Build the server
npm run build
# Start the server with HTTP transport
npm run start:http
For stdio-based communication:
# Build the server
npm run build
# Start the server with Stdio transport
npm run start:stdio
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
Analyze JavaScript/TypeScript code to determine appropriate testing strategies:
Parameters:
code
(string, required): The source code to analyzelanguage
(enum, optional): Language of the code (javascript
, typescript
, jsx
, or tsx
)Generate unit and component tests for Jest and Cypress:
Parameters:
code
(string, required): The source code to generate tests forframework
(enum, required): Testing framework (jest
or cypress
)type
(enum, required): Type of test (unit
, component
, or e2e
)language
(enum, optional): Language of the codedescription
(string, optional): Description of the test caseRun tests using Jest and Cypress and get results:
Parameters:
sourceCode
(string, required): The source code being testedtestCode
(string, required): The test code to executeframework
(enum, required): Testing framework (jest
or cypress
)type
(enum, required): Type of test (unit
, component
, or e2e
)config
(record, optional): Configuration object for test executionTest React components specifically:
Parameters:
componentCode
(string, required): The source code of the React componenttestCode
(string, optional): Test code for the componentframework
(enum, optional): Testing framework (default: jest
)props
(record, optional): Props to pass to the component during testingautoGenerateTest
(boolean, optional): Automatically generate test code if not providedAccess 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
)Access documentation for testing frameworks:
URI: docs://{topic}
Parameters:
topic
(string, required): Documentation topic (jest
, cypress
, or react-testing-library
)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.
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"
]
}
}
}
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.
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.