Skip to content

Commit fad8a42

Browse files
committed
Update README with information about SSE client transport
1 parent 9353c6e commit fad8a42

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

README.md

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,29 @@ For remote server communication:
8383

8484
```swift
8585
// Create a streaming HTTP transport
86+
// This uses Server-Sent Events (SSE) for real-time updates when streaming is enabled.
87+
// It aligns with the "Streamable HTTP transport" from the 2025-03-26 MCP specification.
8688
let transport = HTTPClientTransport(
8789
endpoint: URL(string: "http://localhost:8080")!,
88-
streaming: true // Enable Server-Sent Events for real-time updates
90+
streaming: true
8991
)
9092
try await client.connect(transport: transport)
9193
```
9294

95+
#### SSE Transport (Legacy)
96+
97+
For direct SSE communication, particularly with servers expecting the older HTTP with SSE transport mechanism:
98+
99+
```swift
100+
// Create an SSE client transport
101+
// This implements the "HTTP with SSE" transport, an earlier specification.
102+
// For new implementations, prefer HTTPClientTransport with streaming: true.
103+
let sseTransport = SSEClientTransport(
104+
endpoint: URL(string: "http://localhost:8080/sse")! // Ensure endpoint is SSE-specific if needed
105+
)
106+
try await client.connect(transport: sseTransport)
107+
```
108+
93109
### Tools
94110

95111
Tools represent functions that can be called by the client:
@@ -644,7 +660,8 @@ The Swift SDK provides multiple built-in transports:
644660
| Transport | Description | Platforms | Best for |
645661
|-----------|-------------|-----------|----------|
646662
| [`StdioTransport`](/Sources/MCP/Base/Transports/StdioTransport.swift) | Implements [stdio transport](https://modelcontextprotocol.io/specification/2025-03-26/basic/transports#stdio) using standard input/output streams | Apple platforms, Linux with glibc | Local subprocesses, CLI tools |
647-
| [`HTTPClientTransport`](/Sources/MCP/Base/Transports/HTTPClientTransport.swift) | Implements [Streamable HTTP transport](https://modelcontextprotocol.io/specification/2025-03-26/basic/transports#streamable-http) using Foundation's URL Loading System | All platforms with Foundation | Remote servers, web applications |
663+
| [`HTTPClientTransport`](/Sources/MCP/Base/Transports/HTTPClientTransport.swift) | Implements [Streamable HTTP transport](https://modelcontextprotocol.io/specification/2025-03-26/basic/transports#streamable-http) using Foundation's URL Loading System. Can use Server-Sent Events (SSE) when `streaming` is enabled. | All platforms with Foundation | Remote servers, web applications |
664+
| [`SSEClientTransport`](/Sources/MCP/Base/Transports/SSEClientTransport.swift) | Implements the [HTTP with SSE transport](https://modelcontextprotocol.io/specification/2024-11-05/basic/transports#http-with-sse) (an earlier specified mechanism). The current [Streamable HTTP transport](https://modelcontextprotocol.io/specification/2025-03-26/basic/transports#streamable-http) (implemented by `HTTPClientTransport` with `streaming: true`) is now preferred. | All platforms with Foundation | Legacy systems or direct SSE communication with servers designed for the older SSE-specific mechanism. |
648665
| [`NetworkTransport`](/Sources/MCP/Base/Transports/NetworkTransport.swift) | Custom transport using Apple's Network framework for TCP/UDP connections | Apple platforms only | Low-level networking, custom protocols |
649666

650667
### Custom Transport Implementation

0 commit comments

Comments
 (0)