Skip to content

Conversation

@asheshvidyut
Copy link

@asheshvidyut asheshvidyut commented Nov 7, 2025

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 -> ClientTransportSession
  • src/mcp/server/transport_session.py -> ServerTransportSession

Both 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 JSONRPC inherits from these two new classes.

src/mcp/client/session.py -> ClientSession -> inherits from src/mcp/client/transport_session.py -> ClientTransportSession
src/mcp/server/session.py -> ServerSession -> inherits from src/mcp/server/transport_session.py -> ServerTransportSession

Type Hints Fixes

Since ClientSession and ServerSession has a higher level abstraction so this PR also updates the type hints to the parent classes. Precisely - places where we use ClientSession are updated to use ClientTransportSession and similarly ServerSession type hints are updated to use ServerTransportSession.

How Has This Been Tested?

Tested using pyright and uv run pytest. Changes are also validated using CI runs.

Breaking Changes

No.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

In future if we want to add more transports, those could implement abstract classes introduced in the PR which are - ClientTransportSesssion and ServerTransportSession.

@asheshvidyut asheshvidyut marked this pull request as ready for review November 7, 2025 09:48
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.

1 participant