@@ -50,6 +50,21 @@ public static function getResources(): array
5050 ];
5151 }
5252
53+ private function isPsr17FactoryAvailable (): bool
54+ {
55+ try {
56+ if (!class_exists ('Http\Discovery\Psr17FactoryDiscovery ' )) {
57+ return false ;
58+ }
59+
60+ \Http \Discovery \Psr17FactoryDiscovery::findServerRequestFactory ();
61+
62+ return true ;
63+ } catch (\Throwable ) {
64+ return false ;
65+ }
66+ }
67+
5368 public function testGetMcpOperation (): void
5469 {
5570 if (!class_exists (McpBundle::class)) {
@@ -60,6 +75,10 @@ public function testGetMcpOperation(): void
6075 $ this ->markTestSkipped ('MCP is not supported with MongoDB ' );
6176 }
6277
78+ if (!$ this ->isPsr17FactoryAvailable ()) {
79+ $ this ->markTestSkipped ('PSR-17 HTTP factory implementation not available (required for MCP) ' );
80+ }
81+
6382 $ client = self ::createClient ();
6483 $ res = $ client ->request ('POST ' , '/mcp ' , [
6584 'headers ' => [
@@ -152,6 +171,10 @@ public function testMcpJsonSchemaValidation(): void
152171 $ this ->markTestSkipped ('MCP is not supported with MongoDB ' );
153172 }
154173
174+ if (!$ this ->isPsr17FactoryAvailable ()) {
175+ $ this ->markTestSkipped ('PSR-17 HTTP factory implementation not available (required for MCP) ' );
176+ }
177+
155178 $ client = self ::createClient ();
156179 $ res = $ client ->request ('POST ' , '/mcp ' , [
157180 'headers ' => [
@@ -226,6 +249,10 @@ public function testMcpToolAttribute(): void
226249 $ this ->markTestSkipped ('MCP is not supported with MongoDB ' );
227250 }
228251
252+ if (!$ this ->isPsr17FactoryAvailable ()) {
253+ $ this ->markTestSkipped ('PSR-17 HTTP factory implementation not available (required for MCP) ' );
254+ }
255+
229256 $ client = self ::createClient ();
230257 $ res = $ client ->request ('POST ' , '/mcp ' , [
231258 'headers ' => [
@@ -313,6 +340,10 @@ public function testMcpWithEntity(): void
313340 $ this ->markTestSkipped ('MCP is not supported with MongoDB ' );
314341 }
315342
343+ if (!$ this ->isPsr17FactoryAvailable ()) {
344+ $ this ->markTestSkipped ('PSR-17 HTTP factory implementation not available (required for MCP) ' );
345+ }
346+
316347 $ client = self ::createClient ();
317348 $ res = $ client ->request ('POST ' , '/mcp ' , [
318349 'headers ' => [
@@ -372,6 +403,10 @@ public function testMcpCustomCallToolResult(): void
372403 $ this ->markTestSkipped ('MCP is not supported with MongoDB ' );
373404 }
374405
406+ if (!$ this ->isPsr17FactoryAvailable ()) {
407+ $ this ->markTestSkipped ('PSR-17 HTTP factory implementation not available (required for MCP) ' );
408+ }
409+
375410 $ client = self ::createClient ();
376411 $ res = $ client ->request ('POST ' , '/mcp ' , [
377412 'headers ' => [
@@ -462,6 +497,10 @@ public function testMcpValidation(): void
462497 $ this ->markTestSkipped ('MCP is not supported with MongoDB ' );
463498 }
464499
500+ if (!$ this ->isPsr17FactoryAvailable ()) {
501+ $ this ->markTestSkipped ('PSR-17 HTTP factory implementation not available (required for MCP) ' );
502+ }
503+
465504 $ client = self ::createClient ();
466505 $ res = $ client ->request ('POST ' , '/mcp ' , [
467506 'headers ' => [
@@ -553,6 +592,10 @@ public function testMcpResource(): void
553592 $ this ->markTestSkipped ('MCP is not supported with MongoDB ' );
554593 }
555594
595+ if (!$ this ->isPsr17FactoryAvailable ()) {
596+ $ this ->markTestSkipped ('PSR-17 HTTP factory implementation not available (required for MCP) ' );
597+ }
598+
556599 $ client = self ::createClient ();
557600 $ res = $ client ->request ('POST ' , '/mcp ' , [
558601 'headers ' => [
@@ -643,6 +686,10 @@ public function testMcpMarkdownContent(): void
643686 $ this ->markTestSkipped ('MCP is not supported with MongoDB ' );
644687 }
645688
689+ if (!$ this ->isPsr17FactoryAvailable ()) {
690+ $ this ->markTestSkipped ('PSR-17 HTTP factory implementation not available (required for MCP) ' );
691+ }
692+
646693 $ client = self ::createClient ();
647694 $ res = $ client ->request ('POST ' , '/mcp ' , [
648695 'headers ' => [
0 commit comments