Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Client SSE Initialization Error #105

Open
AtaaEddin opened this issue Mar 26, 2025 · 4 comments
Open

Client SSE Initialization Error #105

AtaaEddin opened this issue Mar 26, 2025 · 4 comments
Labels
bug Something isn't working

Comments

@AtaaEddin
Copy link

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"
}
}
}

@AtaaEddin AtaaEddin added the bug Something isn't working label Mar 26, 2025
@FlorianAuer
Copy link

Had it replicated and having the same issue

@stephentoub
Copy link
Contributor

@halter73, is this also addressed by your SSE buffering fix?

@halter73
Copy link
Contributor

halter73 commented Apr 4, 2025

No. They're not connecting to an ASP.NET Core server. They're testing against MCP Alchemy. This is on my radar, but not my top priority.

@FlorianAuer
Copy link

@halter73 Can you point me in the right direction, so I can prepare a fix? Where do you think is the problem rooted?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants