|
| 1 | +# Behat MCP Server |
| 2 | + |
| 3 | +An [MCP (Model Context Protocol)](https://modelcontextprotocol.io/) server for the [Behat](https://behat.org) BDD testing framework. This server allows AI assistants (such as Claude, Cursor, or other MCP-compatible clients) to run Behat tests directly. |
| 4 | + |
| 5 | +> **Note:** This MCP server currently does not run on Windows due to PHP's limitations with non-blocking pipes. |
| 6 | +
|
| 7 | +## Installation |
| 8 | + |
| 9 | +Install via Composer: |
| 10 | + |
| 11 | +```bash |
| 12 | +composer require behat/mcp-server |
| 13 | +``` |
| 14 | + |
| 15 | +## Starting the MCP Server |
| 16 | + |
| 17 | +The MCP server can be started using the `behat-mcp-server` command: |
| 18 | + |
| 19 | +```bash |
| 20 | +vendor/bin/behat-mcp-server |
| 21 | +``` |
| 22 | + |
| 23 | +### Command Line Options |
| 24 | + |
| 25 | +| Option | Short | Description | Default | |
| 26 | +|--------|-------|-------------|---------| |
| 27 | +| `--transport` | `-t` | Transport type (`stdio` or `http`) | `stdio` | |
| 28 | +| `--host` | `-o` | Host for HTTP transport | `127.0.0.1` | |
| 29 | +| `--port` | `-p` | Port for HTTP transport | `8080` | |
| 30 | + |
| 31 | +### Examples |
| 32 | + |
| 33 | +Start with stdio transport (default): |
| 34 | + |
| 35 | +```bash |
| 36 | +vendor/bin/behat-mcp-server |
| 37 | +``` |
| 38 | + |
| 39 | +Start with HTTP transport: |
| 40 | + |
| 41 | +```bash |
| 42 | +vendor/bin/behat-mcp-server --transport=http --host=127.0.0.1 --port=8080 |
| 43 | +``` |
| 44 | + |
| 45 | +## Available Tools |
| 46 | + |
| 47 | +### `run-behat-tests` |
| 48 | + |
| 49 | +Runs Behat BDD tests in the current project. |
| 50 | + |
| 51 | +#### Parameters |
| 52 | + |
| 53 | +| Parameter | Type | Required | Description | |
| 54 | +|-----------|-------|----------|-------------| |
| 55 | +| `config` | string | No | Path to a Behat configuration file | |
| 56 | +| `profile` | string | No | Name of a profile to use | |
| 57 | +| `suite` | string | No | Name of a suite to use | |
| 58 | +| `paths` | array | No | List of paths to execute (features or scenarios) | |
| 59 | +| `additionalOptions` | array | No | Additional command-line options as key-value pairs | |
| 60 | + |
| 61 | +## Configuring AI Agents |
| 62 | + |
| 63 | +### Stdio Transport |
| 64 | + |
| 65 | +The stdio transport is the recommended method for local development. The MCP server communicates via standard input/output streams. |
| 66 | + |
| 67 | +Add this to your configuration file: |
| 68 | + |
| 69 | +```json |
| 70 | +{ |
| 71 | + "mcpServers": { |
| 72 | + "behat": { |
| 73 | + "command": "php", |
| 74 | + "args": ["/path/to/your/project/vendor/bin/behat-mcp-server"], |
| 75 | + "cwd": "/path/to/your/project" |
| 76 | + } |
| 77 | + } |
| 78 | +} |
| 79 | +``` |
| 80 | + |
| 81 | +### HTTP Transport |
| 82 | + |
| 83 | +The HTTP transport is useful for remote servers or when using Docker. |
| 84 | + |
| 85 | +Start the MCP server using the HTTP transport as described above and add this to your configuration file |
| 86 | +(using the host and port that you used when starting the server): |
| 87 | + |
| 88 | + |
| 89 | +```json |
| 90 | +{ |
| 91 | + "mcpServers": { |
| 92 | + "behat": { |
| 93 | + "url": "http://127.0.0.1:8080/mcp" |
| 94 | + } |
| 95 | + } |
| 96 | +} |
| 97 | +``` |
| 98 | + |
| 99 | +## License |
| 100 | + |
| 101 | +MIT License. See [LICENSE](LICENSE) for details. |
0 commit comments