Add possibility to set custom ServerCapabilities. (#95)
This commit is contained in:
parent
2dbd411194
commit
709a815cde
1 changed files with 68 additions and 1 deletions
|
|
@ -63,6 +63,8 @@ final class Registry implements ReferenceProviderInterface, ReferenceRegistryInt
|
|||
*/
|
||||
private array $resourceTemplates = [];
|
||||
|
||||
private ServerCapabilities $serverCapabilities;
|
||||
|
||||
public function __construct(
|
||||
private readonly ?EventDispatcherInterface $eventDispatcher = null,
|
||||
private readonly LoggerInterface $logger = new NullLogger(),
|
||||
|
|
@ -75,7 +77,7 @@ final class Registry implements ReferenceProviderInterface, ReferenceRegistryInt
|
|||
$this->logger->info('No capabilities registered on server.');
|
||||
}
|
||||
|
||||
return new ServerCapabilities(
|
||||
return $this->serverCapabilities ?? new ServerCapabilities(
|
||||
tools: [] !== $this->tools,
|
||||
toolsListChanged: $this->eventDispatcher instanceof EventDispatcherInterface,
|
||||
resources: [] !== $this->resources || [] !== $this->resourceTemplates,
|
||||
|
|
@ -453,4 +455,9 @@ final class Registry implements ReferenceProviderInterface, ReferenceRegistryInt
|
|||
|
||||
return array_values(\array_slice($items, $offset, $limit));
|
||||
}
|
||||
|
||||
public function setServerCapabilities(ServerCapabilities $serverCapabilities): void
|
||||
{
|
||||
$this->serverCapabilities = $serverCapabilities;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue