Client sampling and roots capabilities set to None if not implemented (#802)

Co-authored-by: ihrpr <inna@anthropic.com>
This commit is contained in:
Lorenzo 2025-05-29 05:56:34 -03:00 • committed by GitHub
commit 7f94bef85e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 177 additions and 4 deletions

View file

@ -116,12 +116,18 @@ class ClientSession(
self._message_handler = message_handler or _default_message_handler
async def initialize(self) -> types.InitializeResult:
sampling = types.SamplingCapability()
roots = types.RootsCapability(
sampling = (
types.SamplingCapability()
if self._sampling_callback is not _default_sampling_callback
else None
)
roots = (
# TODO: Should this be based on whether we
# _will_ send notifications, or only whether
# they're supported?
listChanged=True,
types.RootsCapability(listChanged=True)
if self._list_roots_callback is not _default_list_roots_callback
else None
)
result = await self.send_request(

View file

@ -218,7 +218,7 @@ class RootsCapability(BaseModel):
class SamplingCapability(BaseModel):
"""Capability for logging operations."""
"""Capability for sampling operations."""
model_config = ConfigDict(extra="allow")