diff --git a/.gitignore b/.gitignore index 8f118b2..05d63cd 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 119e9d4..bcc2e1c 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 0000000..cdb508b --- /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);