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
parent d55cb2bf4e
commit 7f94bef85e
3 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(