Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 3.8k
Narrow message_handler's parameter to notifications and exceptions#3168
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,28 +1,16 @@ | ||
| """Shared helpers for the interaction suite. | ||
| Keep this module small: it exists only for (a) types that every test would otherwise have to | ||
| assemble from the SDK's internals to annotate a client callback, and (b) the recording transport | ||
| used by the wire-level tests. Server fixtures and assertion helpers belong in the test that uses | ||
| them. | ||
| Keep this module small: it exists only for the recording transport used by the wire-level | ||
| tests. Server fixtures and assertion helpers belong in the test that uses them. | ||
| """ | ||
maxisbey marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| from types import TracebackType | ||
| import anyio | ||
| from mcp_types import ClientResult, ServerNotification, ServerRequest | ||
| from typing_extensions import Self | ||
| from mcp.client._transport import ReadStream, Transport, TransportStreams, WriteStream | ||
| from mcp.shared.message import SessionMessage | ||
| from mcp.shared.session import RequestResponder | ||
| # TODO: this union is the parameter type of every client message handler (MessageHandlerFnT), | ||
| # but the SDK does not export a name for it -- writing a correctly-typed handler requires | ||
| # importing RequestResponder from mcp.shared.session and assembling the union by hand. It | ||
| # should be a named, exported alias next to MessageHandlerFnT (like ClientRequestContext is | ||
| # for the request callbacks), at which point this alias can be deleted. | ||
| IncomingMessage = RequestResponder[ServerRequest, ClientResult] | ServerNotification | Exception | ||
| """Everything a client message handler can receive.""" | ||
| class _RecordingReadStream: | ||
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.