[Server] Add ClientGateway::supportsSampling() (#418)

Sampling was the one client capability a tool could not check before asking.
`supportsRoots()` and `supportsElicitation()` both read the capabilities the
client advertised during the handshake; sampling is stored in that same session
data but had no accessor, so a tool had to issue the request and catch the
refusal.
This commit is contained in:
Christopher Hertel 2026-08-15 02:11:15 +02:00 • committed by GitHub
commit c4b163b4c4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -43,6 +43,26 @@ final class ClientGatewayTest extends TestCase
$this->assertFalse($gateway->supportsRoots());
}
public function testSupportsSamplingReturnsTrueWhenAdvertised(): void
{
$session = $this->createMock(SessionInterface::class);
$session->method('get')->with('client_capabilities', [])->willReturn(['sampling' => []]);
$gateway = new ClientGateway($session);
$this->assertTrue($gateway->supportsSampling());
}
public function testSupportsSamplingReturnsFalseWhenNotAdvertised(): void
{
$session = $this->createMock(SessionInterface::class);
$session->method('get')->with('client_capabilities', [])->willReturn(['roots' => []]);
$gateway = new ClientGateway($session);
$this->assertFalse($gateway->supportsSampling());
}
public function testListRootsReturnsRootsFromClient(): void
{
$session = $this->createMock(SessionInterface::class);