From 3fdd800a2efd4529a2c2738ff2106ab3a9906d60 Mon Sep 17 00:00:00 2001 From: Christopher Hertel Date: Sat, 6 Dec 2025 14:30:34 +0100 Subject: [PATCH] Kicking off adoption of conformance testing --- .gitignore | 2 ++ Makefile | 6 +++++ tests/Conformance/Server/server.php | 41 +++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+) create mode 100644 tests/Conformance/Server/server.php diff --git a/.gitignore b/.gitignore index 8f118b26..05d63cdd 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,5 @@ vendor examples/**/dev.log examples/**/cache examples/**/sessions +results +tests/Conformance/**/sessions diff --git a/Makefile b/Makefile index 119e9d40..bcc2e1cc 100644 --- a/Makefile +++ b/Makefile @@ -21,6 +21,12 @@ unit-tests: inspector-tests: vendor/bin/phpunit --testsuite=inspector +conformance-server: + php -S localhost:8000 tests/Conformance/Server/server.php + +conformance-tests: + npx @modelcontextprotocol/conformance server --url http://localhost:8000/ + coverage: XDEBUG_MODE=coverage vendor/bin/phpunit --testsuite=unit --coverage-html=coverage diff --git a/tests/Conformance/Server/server.php b/tests/Conformance/Server/server.php new file mode 100644 index 00000000..cdb508b4 --- /dev/null +++ b/tests/Conformance/Server/server.php @@ -0,0 +1,41 @@ +setServerInfo('mcp-conformance-test-server', '1.0.0') + ->setSession(new FileSessionStore(__DIR__.'/sessions')) + ->addTool(fn () => 'This is a simple text response for testing.', 'test_simple_text', 'Tests simple text content response') + ->addTool(fn () => new ImageContent(TEST_IMAGE_BASE64, 'image/png'), 'test_image_content', 'Tests image content response') + ->addTool(fn () => new AudioContent(TEST_AUDIO_BASE64, 'audio/wav'), 'test_audio_content', 'Tests audio content response') + ->build(); + +$transport = new StreamableHttpTransport( + (new Psr17Factory())->createServerRequestFromGlobals(), +); + +$result = $server->run($transport); + +(new SapiEmitter())->emit($result);