Skip to content

Client SSE Initialization Error #105

@AtaaEddin

Description

@AtaaEddin

Describe the bug
Client failed to establish SSE connection with an MCP server (Python FastMCP server)

To Reproduce
Steps to reproduce the behavior:

  1. Get MCP Alchemy server.
  2. Install Python packages and in server.py change mcp.run() to mcp.run(transport="sse") (make sure the execution of code can reach this line)
  3. Download any SQLite sample to hook it with the server
  4. Run Python 'uv run fastmcp run .\server.py'
  5. Create .Net project and try to call any tool from the Python server

Expected behavior
Client should be able to connect to the server or/and when it fails it must propagate inner exceptions to see the real reason of why the connection was terminated.

Logs
info: ModelContextProtocol.Client.McpClientFactory[77006853])
Creating client for Client (: )
info: ModelContextProtocol.Protocol.Transport.SseClientTransport[1308141342]
Transport reading messages for Client (SSE) for (: )
Host lock lease acquired by instance ID '000000000000000000000000F59729FC'.
info: ModelContextProtocol.Client.McpClient[521904914]
Sending request for Client (: ) with method initialize
info: ModelContextProtocol.Protocol.Transport.SseClientTransport[1187853503]
Transport received message parsed for Client (SSE) for (: ): 2
info: ModelContextProtocol.Protocol.Transport.SseClientTransport[1712499148]
Transport message written for Client (SSE) for (: ) with ID 2
info: ModelContextProtocol.Client.McpClient[924059928]
Request response received payload for Client (: ): {"protocolVersion":"2024-11-05","capabilities":{"experimental":{},"prompts":{"listChanged":false},"resources":{"subscribe":false,"listChanged":false},"tools":{"listChanged":false}},"serverInfo":{"name":"MCP Alchemy","version":"1.2.0rc1"}}
info: ModelContextProtocol.Client.McpClient[685278258]
Request response received for Client (: ) with method initialize
info: ModelContextProtocol.Client.McpClient[1727685551]
Server Client (: ) capabilities received: {"experimental":{},"prompts":{"listChanged":false},"resources":{"subscribe":false,"listChanged":false},"tools":{"listChanged":false}}, server info: {"name":"MCP Alchemy","version":"1.2.0rc1"}
fail: ModelContextProtocol.Client.McpClient[403959396]
Client server Client (: ) initialization error
System.Net.Http.HttpRequestException: An error occurred while sending the request.
---> System.Net.Http.HttpIOException: The response ended prematurely. (ResponseEnded)
at System.Net.Http.HttpConnection.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
--- End of inner exception stack trace ---
at System.Net.Http.HttpConnection.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.SendWithVersionDetectionAndRetryAsync(HttpRequestMessage request, Boolean async, Boolean doRequestAuth, CancellationToken cancellationToken)
at System.Net.Http.DiagnosticsHandler.SendAsyncCore(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
at System.Net.Http.HttpClient.g__Core|83_0(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationTokenSource cts, Boolean disposeCts, CancellationTokenSource pendingRequestsCts, CancellationToken originalCancellationToken)
at ModelContextProtocol.Protocol.Transport.SseClientTransport.SendMessageAsync(IJsonRpcMessage message, CancellationToken cancellationToken)
at ModelContextProtocol.Client.McpClient.InitializeAsync(CancellationToken cancellationToken)
at ModelContextProtocol.Client.McpClient.ConnectAsync(CancellationToken cancellationToken)
info: ModelContextProtocol.Client.McpClient[471153486]
Cleaning up endpoint Client (: )
info: ModelContextProtocol.Client.McpClient[52599573]
Endpoint message processing cancelled for Client (: )
info: ModelContextProtocol.Protocol.Transport.SseClientTransport[956819713]
Transport read messages cancelled for Client (SSE) for (: )
info: ModelContextProtocol.Client.McpClient[883836513]
Endpoint cleaned up for Client (: )

Additional context
MCP server and client settings:
"McpSqlConfig": {
"McpServerConfig": {
//"Id": "MCP Alchemy",
//"Name": "MCP Alchemy",
"TransportType": "sse",
"TransportOptions": {
"connectionTimeout": "10",
"maxReconnectAttempts": "1",
"reconnectDelay": "5"
},
"Location": "http://localhost:8000/sse"
},
"McpClientOptions": {
"ClientInfo": {
"Name": "SqlClient",
"Version": "1.0.0"
}
}
}

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