docs: rewrite JsonRpcBundle docs, add SDK docs, move them under docs/api
en/docs/api/mcp-bundle/developers/testing.md
new file +44
ā0
1
+
# Testing
2
+
3
+
The bundle's tests run in Docker (image `ufotech/php:8.4-fpm`, see the repository's `docker-compose.yaml`):
4
+
5
+
```bash
6
+
make up-d
7
+
make composer-install
8
+
make test # all suites
9
+
make test ARGS="--testsuite Unit" # one suite
10
+
```
11
+
12
+
`make test` needs a TTY; without one (for example, in scripts):
13
+
14
+
```bash
15
+
docker exec -w /app php_mcp vendor/bin/phpunit --testsuite Functional
16
+
```
17
+
18
+
| Suite | What it checks | How |
19
+
| --- | --- | --- |
20
+
| `Unit` | The configuration tree and the typed configuration, `server.json`, client manifests, the session store, the request carrier, the tool executor, route import, default extension points | PHPUnit, mocks |
21
+
| `Functional` | The bundle inside an application: routing, 404/401/403, `initialize`, `tools/list` (groups, versions, translations, schemas, annotations), `tools/call` (results, errors, events, cache, batch), sessions, the stateless protocol, CORS, DNS rebinding, body limit, `server.json`, manifests, extension points | `Fixtures\TestKernel`, HTTP requests through `handle()` + `terminate()` |
22
+
| `E2E` | The official `mcp/sdk` client over real HTTP in three protocol versions (2025-06-18, 2025-11-25, 2026-07-28) | PHP built-in server with `tests/Fixtures/public/index.php` |
23
+
24
+
The fixture application (`tests/Fixtures`): procedures in the groups `mcp`, `internal`, `off`, `bad`, a version 2 procedure, translations, routes like an application's `config/routes/ufo_mcp.yaml`. `TestKernel::$mcpConfig` and `TestKernel::$serviceOverrides` change the configuration or replace a service for one test.
25
+
26
+
## Coverage
27
+
28
+
:::warning
29
+
With Xdebug 3.4.2 (image `ufotech/php:8.4-fpm`), collecting coverage for the tests that start the SDK server ends in a segmentation fault. Use pcov.
30
+
:::
31
+
32
+
```bash
33
+
docker exec php_mcp pecl install pcov # once per container
34
+
docker exec -w /app -e XDEBUG_MODE=off php_mcp php -d extension=pcov.so -d pcov.enabled=1 \
35
+
vendor/bin/phpunit --testsuite Unit,Functional --coverage-text
36
+
```
37
+
38
+
## Checking with MCP Inspector
39
+
40
+
```bash
41
+
docker exec -d -w /app php_mcp php -S 0.0.0.0:8099 tests/Fixtures/public/index.php
42
+
docker run --rm --network container:php_mcp node:22-alpine npx -y @modelcontextprotocol/inspector --cli \
43
+
http://127.0.0.1:8099/mcp --transport http --header "Ufo-RPC-Token: test-token" --method tools/list
44
+
```