Document Client usage with HTTPClientTransport (#77)

* Add test coverage for Client with HTTPClientTransport

* Configure HTTP client transport to stream by default

* Add example usage of streaming HTTP transport to README

* Explicitly set streaming to false in test
This commit is contained in:
Mattt 2025-04-27 09:29:24 -07:00 • committed by GitHub
commit 48c19c282b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -39,6 +39,29 @@ try await client.connect(transport: transport)
let result = try await client.initialize()
```
### Streaming HTTP Transport
The HTTP transport supports streaming mode for real-time communication using Server-Sent Events (SSE):
```swift
import MCP
// Create a streaming HTTP transport
let transport = HTTPClientTransport(
endpoint: URL(string: "http://localhost:8080")!,
)
// Initialize the client with streaming transport
let client = Client(name: "MyApp", version: "1.0.0")
try await client.connect(transport: transport)
// Initialize the connection
let result = try await client.initialize()
// The transport will automatically handle SSE events
// and deliver them through the client's notification handlers
```
### Basic Server Setup
```swift