Skip to content

Conversation

@felixweinberger
Copy link
Contributor

Summary

Adds a Transport protocol and concrete transport implementations (HttpTransport, SseTransport, InMemoryTransport) so that different transports can be used via the Client interface.

Motivation and Context

The Client class currently only supports in-memory connections to server instances. This change introduces a transport abstraction so that Client can connect over Streamable HTTP, SSE, or in-memory, with automatic inference from the target type.

How Has This Been Tested?

  • Unit tests for transport inference (test_transport_inference.py)
  • Unit tests for client transports (test_client_transports.py)

Breaking Changes

None - this is additive.

Types of changes

  • New feature (non-breaking change which adds functionality)

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

ClientTarget = Server[Any] | FastMCP | Transport | str - the Client now accepts server instances directly, transport instances, or URL strings, and infers the appropriate transport automatically.

- Add transports subpackage with Transport protocol
- Add HttpTransport for Streamable HTTP connections
- Add SSETransport for legacy SSE connections
- Move InMemoryTransport to transports subpackage
- Update Client to accept Server, FastMCP, Transport, or URL string
- Add _infer_transport() helper for automatic transport selection
- URL strings automatically use HttpTransport (modern standard)
- Add comprehensive tests for transport inference and Client usage

This enables connecting to MCP servers over HTTP in addition to
the existing in-memory transport for testing.
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.

2 participants