Skip to content

SSE endpoints not connecting #138

Open
@rhvall

Description

@rhvall

Describe the bug
Using the latest main code 0.9.0 (commit 7a76001) I tried to connect to multiple "SSE" MCP endpoints but there was a problem

To Reproduce

import Foundation
import MCP

// Initialize the client
let mcpList = [
    "https://mcp.deepwiki.com/sse",
    "https://mcp.deepwiki.com/mcp",
    "https://mcp.semgrep.ai/sse",
    "https://remote.mcpservers.org/sequentialthinking/mcp"
]

let connectTest = { (transport: Transport) async -> Bool in

    do {
        let client = Client(name: "MyApp", version: "1.0.0")
        let result = try await client.connect(transport: transport)

        // Check server capabilities
        print(result.capabilities)
        await client.disconnect()
        return true
    } catch {
        return false
    }
}

for link in mcpList {
    let url = URL(string: link)!

    // Create a transport and connect
    let transport = HTTPClientTransport(
        endpoint: url,
        streaming: true
    )

    let res = await connectTest(transport)
    print("HTTP URL: \(link). Result: \(res)")
}

Expected behavior
The client should connect to the SSE MCP server. But it only does with those that end with "/mcp". I tried with "streaming=true/false" but it did not make any change.

The problem is that not every MCP server offers "/mcp", multiple are only "/sse". From this list:
https://mcpservers.org/remote-mcp-servers
Most of them are using "sse" at the end.

Logs
This is the output of the example code above:

HTTP URL: https://mcp.deepwiki.com/sse. Result: false
Capabilities(logging: nil, prompts: nil, resources: nil, sampling: nil, tools: Optional(MCP.Server.Capabilities.Tools(listChanged: Optional(true))))
HTTP URL: https://mcp.deepwiki.com/mcp. Result: true
HTTP URL: https://mcp.semgrep.ai/sse. Result: false
Capabilities(logging: nil, prompts: nil, resources: nil, sampling: nil, tools: Optional(MCP.Server.Capabilities.Tools(listChanged: nil)))
HTTP URL: https://remote.mcpservers.org/sequentialthinking/mcp. Result: true

Additional context
I used as well the branch here: "#101" (commit 5978c71), but it did not work as well changing to "SSEClientTransport"

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions