-
Notifications
You must be signed in to change notification settings - Fork 3k
Pluggable Transport Abstractions #1591
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
base: main
Are you sure you want to change the base?
Pluggable Transport Abstractions #1591
Conversation
fix imports
|
The session objects aren't transport specific, what problem are you trying to solve? Why does this PR has so many "👍" ? |
Hey @Kludex , Thanks for your reply. Currently Since gRPC Transport does not require read write streams, we have created abstract classes in this PR following interface segregation principle so that the abstract classes could be inherited by the current transport in this sdk as well as any future transport like This is part of modelcontextprotocol/modelcontextprotocol#1352 initiative. Please let me know if I need to explain further. Thanks. |
Yeah, I don't think there's any problem in that. Again, the session classes do not depend on any transport.
The minimum is having the streams, check the
Are you talking about what is implemented in: #1936 ? Streams are the same as queue, you do require queues in that PR, replace the |
Motivation and Context
Add support for Pluggable Transport Abstractions in MCP Python SDK.
Add abstractions to support
Pluggable Transport.This PR majorly adds two abstract classes and APIs that every transport must implement. The abstract classes are
src/mcp/client/transport_session.py->ClientTransportSessionsrc/mcp/server/transport_session.py->ServerTransportSessionBoth the above classes have minimal APIs that every transport must implement in order to achieve the features defined in MCP Specification
Additionally existing transport classes which are based on
JSONRPCinherits from these two new classes.src/mcp/client/session.py->ClientSession-> inherits fromsrc/mcp/client/transport_session.py->ClientTransportSessionsrc/mcp/server/session.py->ServerSession-> inherits fromsrc/mcp/server/transport_session.py->ServerTransportSessionType Hints Fixes
Since
ClientSessionandServerSessionhas a higher level abstraction so this PR also updates the type hints to the parent classes. Precisely - places where we useClientSessionare updated to useClientTransportSessionand similarlyServerSessiontype hints are updated to useServerTransportSession.How Has This Been Tested?
Tested using
pyrightanduv run pytest. Changes are also validated usingCIruns.Breaking Changes
No.
Types of changes
Checklist
Additional context
In future if we want to add more transports, those could implement abstract classes introduced in the PR which are -
ClientTransportSesssionandServerTransportSession.