Skip to content

Commit dd84c6f

Browse files
committed
Add example usage of streaming HTTP transport to README
1 parent 9a6653d commit dd84c6f

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,29 @@ try await client.connect(transport: transport)
3939
let result = try await client.initialize()
4040
```
4141

42+
### Streaming HTTP Transport
43+
44+
The HTTP transport supports streaming mode for real-time communication using Server-Sent Events (SSE):
45+
46+
```swift
47+
import MCP
48+
49+
// Create a streaming HTTP transport
50+
let transport = HTTPClientTransport(
51+
endpoint: URL(string: "http://localhost:8080")!,
52+
)
53+
54+
// Initialize the client with streaming transport
55+
let client = Client(name: "MyApp", version: "1.0.0")
56+
try await client.connect(transport: transport)
57+
58+
// Initialize the connection
59+
let result = try await client.initialize()
60+
61+
// The transport will automatically handle SSE events
62+
// and deliver them through the client's notification handlers
63+
```
64+
4265
### Basic Server Setup
4366

4467
```swift

0 commit comments

Comments
 (0)