Skip to content

Conversation

@Kludex
Copy link
Member

@Kludex Kludex commented Jan 20, 2026

No description provided.

self,
params: types.PaginatedRequestParams | None = None,
) -> types.ListResourcesResult:
async def list_resources(self, *, cursor: str | None = None) -> types.ListResourcesResult:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR started from this. I understand that in the typescript world this is the best practice, but it's not in Python.

Comment on lines +61 to 62
# TODO(Marcelo): When do `raise_exceptions=True` actually raises?
raise_exceptions: bool = False,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't test this. What it is supposed to raise?

timeout = request_read_timeout_seconds
elif self._session_read_timeout_seconds is not None: # pragma: no cover
timeout = self._session_read_timeout_seconds
timeout = request_read_timeout_seconds or self._session_read_timeout_seconds
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've simplified this.

addopts = """
--color=yes
--capture=fd
--numprocesses auto
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually forgot to remove this when I added the scripts/test script.

You need to be able to run pytest without -n auto, because you may want to run a single test, and you don't need multiple cores for it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@maxisbey @felixweinberger please check the changes in this file.

@Kludex Kludex changed the title Flatten the methods in Client refactor: flatten the methods in Client Jan 20, 2026
self,
params: types.PaginatedRequestParams | None = None,
) -> types.ListResourcesResult:
async def list_resources(self, *, cursor: str | None = None) -> types.ListResourcesResult:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will need to update migration docs

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Client is a new class, it doesn't need any migration docs.

caps = client.server_capabilities
assert caps is not None
assert caps.tools is not None
assert client.server_capabilities == snapshot(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

never seen this before, that's cool

"""Send a notification that the roots list has changed."""
await self.session.send_roots_list_changed()
# TODO(Marcelo): Currently, there is no way for the server to handle this. We should add support.
await self.session.send_roots_list_changed() # pragma: no cover
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is there a new pragma?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the test was not testing anything, and the server actually doesn't do anything with this notification. We need to solve the TODO, which will result in dropping the pragma.

async def __aexit__(self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: Any) -> None:
"""Exit the async context manager."""
if self._exit_stack:
if self._exit_stack: # pragma: no branch
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why a new pragma?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because I don't think it's necessary to test this. If you can suggest a cute test, please push it.

@Kludex Kludex requested a review from maxisbey January 20, 2026 11:50
@Kludex Kludex merged commit bcb07c2 into main Jan 20, 2026
26 checks passed
@Kludex Kludex deleted the flatten-the-client-api branch January 20, 2026 12:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants