Skip to content

Commit ef8127a

Browse files
committed
add mcp server
1 parent ca575c9 commit ef8127a

File tree

5 files changed

+1642
-2
lines changed

5 files changed

+1642
-2
lines changed

README.md

Lines changed: 79 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[![Stand With Ukraine](https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/banner-direct-single.svg)](https://stand-with-ukraine.pp.ua)
22

33
[<img src="https://img.shields.io/badge/slack-@codeceptjs-purple.svg?logo=slack">](https://join.slack.com/t/codeceptjs/shared_invite/enQtMzA5OTM4NDM2MzA4LWE4MThhN2NmYTgxNTU5MTc4YzAyYWMwY2JkMmZlYWI5MWQ2MDM5MmRmYzZmYmNiNmY5NTAzM2EwMGIwOTNhOGQ) [<img src="https://img.shields.io/badge/discourse-codeceptjs-purple">](https://codecept.discourse.group) [![NPM version][npm-image]][npm-url] [<img src="https://img.shields.io/badge/dockerhub-images-blue.svg?logo=codeceptjs">](https://hub.docker.com/r/codeceptjs/codeceptjs)
4-
[![AI features](https://img.shields.io/badge/AI-features?logo=openai&logoColor=white)](https://github.com/codeceptjs/CodeceptJS/edit/3.x/docs/ai.md) [![StandWithUkraine](https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/badges/StandWithUkraine.svg)](https://github.com/vshymanskyy/StandWithUkraine/blob/main/docs/README.md)
4+
[![AI features](https://img.shields.io/badge/AI-features?logo=openai&logoColor=white)](https://github.com/codeceptjs/CodeceptJS/edit/3.x/docs/ai.md) [![MCP Server](https://img.shields.io/badge/MCP-server?logo=anthropic&logoColor=white)](https://github.com/codeceptjs/CodeceptJS/blob/main/docs/mcp.md) [![StandWithUkraine](https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/badges/StandWithUkraine.svg)](https://github.com/vshymanskyy/StandWithUkraine/blob/main/docs/README.md)
55

66
## Build Status
77

@@ -276,6 +276,84 @@ Full support for Gherkin scenarios with proper feature formatting:
276276

277277
The HTML reporter generates self-contained reports that can be easily shared with your team. Learn more about configuration and features in the [HTML Reporter documentation](https://codecept.io/plugins/#htmlreporter).
278278

279+
## MCP Server
280+
281+
CodeceptJS includes a [Model Context Protocol (MCP)](https://modelcontextprotocol.io) server that enables AI agents (like Claude, ChatGPT) to interact with and control your tests programmatically. This allows AI to:
282+
283+
- **List all tests** in your project
284+
- **List all available actions** (I.* methods) from enabled helpers
285+
- **Run arbitrary CodeceptJS code** and capture artifacts (ARIA snapshots, screenshots, HTML, logs)
286+
- **Run specific tests** with AI-friendly trace files generated by the aiTrace plugin
287+
- **Run tests step by step** for detailed debugging and analysis
288+
- **Control browser sessions** (start/stop)
289+
290+
### Features
291+
292+
- **AI-Friendly Trace Files**: When enabled, the aiTrace plugin generates comprehensive trace files with screenshots, HTML, ARIA snapshots, browser logs, and HTTP requests
293+
- **Real-time Monitoring**: Get trace file URLs at the start of test execution so AI can monitor tests in real-time
294+
- **Artifact Capture**: Automatically capture ARIA snapshots, page source, console logs, and more
295+
- **Browser Management**: Automatic or manual browser lifecycle control
296+
- **Timeout Control**: Configurable timeouts for all operations
297+
298+
### Quick Start
299+
300+
1. Install the MCP SDK:
301+
```sh
302+
npm install @modelcontextprotocol/sdk
303+
```
304+
305+
2. Configure your MCP client (e.g., Claude Desktop):
306+
```json
307+
{
308+
"mcpServers": {
309+
"codeceptjs": {
310+
"command": "node",
311+
"args": ["path/to/codeceptjs/bin/mcp-server.js"]
312+
}
313+
}
314+
}
315+
```
316+
317+
3. Enable the aiTrace plugin in `codecept.conf.js`:
318+
```javascript
319+
plugins: {
320+
aiTrace: {
321+
enabled: true
322+
}
323+
}
324+
```
325+
326+
### Usage Examples
327+
328+
**List all tests:**
329+
```json
330+
{
331+
"name": "list_tests"
332+
}
333+
```
334+
335+
**Run CodeceptJS code:**
336+
```json
337+
{
338+
"name": "run_code",
339+
"arguments": {
340+
"code": "await I.amOnPage('/'); await I.see('Welcome')"
341+
}
342+
}
343+
```
344+
345+
**Run a test with trace:**
346+
```json
347+
{
348+
"name": "run_test",
349+
"arguments": {
350+
"test": "tests/login_test.js"
351+
}
352+
}
353+
```
354+
355+
Learn more about the MCP Server in the [MCP documentation](https://github.com/codeceptjs/CodeceptJS/blob/main/docs/mcp.md).
356+
279357
## PageObjects
280358

281359
CodeceptJS provides the most simple way to create and use page objects in your test.

0 commit comments

Comments
 (0)