You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The MCP client (SSE) has to connect in less than 1000ms or it will fail with the error: Error from mcp-server: Transport was not connected or is already closed (in amongst some other trace).
The code leads the reader to believe that it is a 5000ms timeout, but that is not the case.
To Reproduce
Steps to reproduce the behavior:
Have an MCP server that takes more than 1000ms to connect and serve up the POST endpoint as part of the SSE protocol
Launch Goose with configuration to connect to that server.
(I discovered this because my native internet takes 800ms to connect - yay Australia! - vs. 1300ms with the VPN turned on)
Expected behavior
The MCP client should allow this POST endpoint URL to be sent up to 5s (according to code).
Actual behavior
Goose fails after waiting for ~1s.
The cause (IIUC)
See crates/mcp-client/src/transport/sse.rs
The code implies that the timeout for endpoint discovery is 5 seconds.
// Timeout for the endpoint discoveryconstENDPOINT_TIMEOUT_SECS:u64 = 5;
// Wait for the endpoint to be discovered before returning the handlematchtimeout(Duration::from_secs(ENDPOINT_TIMEOUT_SECS),Self::wait_for_endpoint(post_endpoint_clone),)
However the wait_for_endpoint code actually succeeds / fails in around 1000ms - 10 attempts x 100ms
/// Waits for the endpoint to be set, up to 10 attempts.asyncfnwait_for_endpoint(post_endpoint:Arc<RwLock<Option<String>>>,) -> Result<String,Error>{// Check every 100ms for the endpoint, for up to 10 attemptslet check_interval = Duration::from_millis(100);letmut attempts = 0;let max_attempts = 10;while attempts < max_attempts {ifletSome(url) = post_endpoint.read().await.clone(){returnOk(url);}
tokio::time::sleep(check_interval).await;
attempts += 1;}Err(Error::SseConnection("No endpoint discovered".to_string()))}
Fixes
The wait_for_endpoint code should be amended to
try "forever" and wait for the caller's timeout to trigger
set max_attempts to ENDPOINT_TIMEOUT_SECS * 1000 / 100 (which would be 50 in the current scenario).
The text was updated successfully, but these errors were encountered:
bwalding
added a commit
to bwalding/goose
that referenced
this issue
Feb 26, 2025
bwalding
changed the title
MCP client (SSE) has a endpoint discovery timeout that is too short
MCP client (SSE) has an endpoint discovery timeout that is too short
Feb 26, 2025
My other comment is that would be good if that error was more consistent with the root cause of the problem.
Currently: Error from mcp-server: Transport was not connected or is already closed
Better (but not great): Error from mcp-server: Transport error: SSE connection error: deadline has elapsed (this is what my change does).
But I think specifically saying "Timed out waiting for SSE endpoint discovery" would have pointed me in the right direction a lot quicker.
Describe the bug
The MCP client (SSE) has to connect in less than 1000ms or it will fail with the error:
Error from mcp-server: Transport was not connected or is already closed
(in amongst some other trace).The code leads the reader to believe that it is a 5000ms timeout, but that is not the case.
To Reproduce
Steps to reproduce the behavior:
(I discovered this because my native internet takes 800ms to connect - yay Australia! - vs. 1300ms with the VPN turned on)
Expected behavior
The MCP client should allow this POST endpoint URL to be sent up to 5s (according to code).
Actual behavior
Goose fails after waiting for ~1s.
The cause (IIUC)
See
crates/mcp-client/src/transport/sse.rs
The code implies that the timeout for endpoint discovery is 5 seconds.
However the
wait_for_endpoint
code actually succeeds / fails in around 1000ms -10 attempts x 100ms
Fixes
The
wait_for_endpoint
code should be amended tomax_attempts
toENDPOINT_TIMEOUT_SECS * 1000 / 100
(which would be 50 in the current scenario).The text was updated successfully, but these errors were encountered: