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:
parent
ccb070f2f0
commit
48c19c282b
1 changed files with 222 additions and 20 deletions
23
README.md
23
README.md
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue