diff --git a/README.md b/README.md index 8e7d2a44..a0513d00 100644 --- a/README.md +++ b/README.md @@ -104,6 +104,7 @@ let sseTransport = SSEClientTransport( endpoint: URL(string: "http://localhost:8080/sse")! // Ensure endpoint is SSE-specific if needed ) try await client.connect(transport: sseTransport) +try await client.initialize() ``` ### Tools @@ -773,4 +774,4 @@ see the [GitHub Releases page](https://github.com/modelcontextprotocol/swift-sdk This project is licensed under the MIT License. [mcp]: https://modelcontextprotocol.io -[mcp-spec-2025-03-26]: https://modelcontextprotocol.io/specification/2025-03-26 \ No newline at end of file +[mcp-spec-2025-03-26]: https://modelcontextprotocol.io/specification/2025-03-26 diff --git a/Sources/MCP/Base/Transports/SSEClientTransport.swift b/Sources/MCP/Base/Transports/SSEClientTransport.swift index 27158728..bd944d30 100644 --- a/Sources/MCP/Base/Transports/SSEClientTransport.swift +++ b/Sources/MCP/Base/Transports/SSEClientTransport.swift @@ -416,7 +416,18 @@ import Logging // For relative paths, preserve the scheme, host, and port let pathToUse = path.starts(with: "/") ? path : "/\(path)" - components.path = pathToUse + + // Parse the path to separate path and query components + if let pathComponents = URLComponents(string: pathToUse) { + components.path = pathComponents.path + // Preserve any query parameters from the endpoint path + if let queryItems = pathComponents.queryItems { + components.queryItems = queryItems + } + } else { + components.path = pathToUse + } + return components.url } }