Skip to content

Commit fe6a072

Browse files
committed
Applied cahnges
1 parent e4a665c commit fe6a072

File tree

2 files changed

+16
-21
lines changed

2 files changed

+16
-21
lines changed

src/Capability/Registry.php

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}

src/Server/Builder.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,9 @@ public function build(): Server
357357
$registry = new Registry($this->eventDispatcher, $logger);
358358

359359
$this->registerCapabilities($registry, $logger);
360-
$registry->setServerCapabilities($this->serverCapabilities);
360+
if ($this->serverCapabilities) {
361+
$registry->setServerCapabilities($this->serverCapabilities);
362+
}
361363

362364
if (null !== $this->discoveryBasePath) {
363365
$this->performDiscovery($registry, $logger);

0 commit comments

Comments
 (0)