@@ -76,11 +76,18 @@ public function getCapabilities(): ServerCapabilities
7676 if (!$ this ->hasElements ()) {
7777 $ this ->logger ->info ('No capabilities registered on server. ' );
7878 }
79- if (!isset ($ this ->serverCapabilities )) {
80- $ this ->setServerCapabilities (null );
81- }
8279
83- return $ this ->serverCapabilities ;
80+ return $ this ->serverCapabilities ?? new ServerCapabilities (
81+ tools: [] !== $ this ->tools ,
82+ toolsListChanged: $ this ->eventDispatcher instanceof EventDispatcherInterface,
83+ resources: [] !== $ this ->resources || [] !== $ this ->resourceTemplates ,
84+ resourcesSubscribe: false ,
85+ resourcesListChanged: $ this ->eventDispatcher instanceof EventDispatcherInterface,
86+ prompts: [] !== $ this ->prompts ,
87+ promptsListChanged: $ this ->eventDispatcher instanceof EventDispatcherInterface,
88+ logging: false ,
89+ completions: true ,
90+ );
8491 }
8592
8693 public function registerTool (Tool $ tool , callable |array |string $ handler , bool $ isManual = false ): void
@@ -449,22 +456,8 @@ private function paginateResults(array $items, int $limit, ?string $cursor = nul
449456 return array_values (\array_slice ($ items , $ offset , $ limit ));
450457 }
451458
452- public function setServerCapabilities (? ServerCapabilities $ serverCapabilities ): void
459+ public function setServerCapabilities (ServerCapabilities $ serverCapabilities ): void
453460 {
454- if ($ serverCapabilities ) {
455- $ this ->serverCapabilities = $ serverCapabilities ;
456- } else {
457- $ this ->serverCapabilities = new ServerCapabilities (
458- tools: [] !== $ this ->tools ,
459- toolsListChanged: $ this ->eventDispatcher instanceof EventDispatcherInterface,
460- resources: [] !== $ this ->resources || [] !== $ this ->resourceTemplates ,
461- resourcesSubscribe: false ,
462- resourcesListChanged: $ this ->eventDispatcher instanceof EventDispatcherInterface,
463- prompts: [] !== $ this ->prompts ,
464- promptsListChanged: $ this ->eventDispatcher instanceof EventDispatcherInterface,
465- logging: false ,
466- completions: true ,
467- );
468- }
461+ $ this ->serverCapabilities = $ serverCapabilities ;
469462 }
470463}
0 commit comments