[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:
parent
eb20453f49
commit
c4b163b4c4
1 changed files with 38 additions and 0 deletions
|
|
@ -250,6 +250,23 @@ class ClientGateway
|
|||
return \array_key_exists('elicitation', $capabilities);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the connected client supports sampling.
|
||||
*
|
||||
* Sampling lets a server borrow the client's model during tool execution.
|
||||
* This method checks the client's advertised capabilities to determine if
|
||||
* sampling/createMessage requests are supported.
|
||||
*
|
||||
* @return bool True if the client supports sampling, false otherwise
|
||||
*/
|
||||
public function supportsSampling(): bool
|
||||
{
|
||||
$capabilities = (array) $this->session->get('client_capabilities', []);
|
||||
|
||||
// MCP spec: capability presence indicates support (value is typically {} or [])
|
||||
return \array_key_exists('sampling', $capabilities);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a request to the client and wait for a response (blocking).
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in a new issue