Skip to content

Commit bb94990

Browse files
Allow timeout if ping succeeds
1 parent 5c945cf commit bb94990

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

src/mcp_importer/api.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ async def _list_tools_only() -> Any:
222222
result = obj.shutdown() # type: ignore[attr-defined]
223223
await asyncio.wait_for(result, timeout=2.0) # type: ignore[func-returns-value]
224224
# Otherwise, avoid triggering OAuth flows during verification
225+
ping_succeeded = False
225226
try:
226227
if oauth_info is None:
227228
oauth_info = await get_oauth_manager().check_oauth_requirement(
@@ -243,13 +244,19 @@ async def _list_tools_only() -> Any:
243244
log.debug(f"Connection established to '{server.name}'; pinging...")
244245
await asyncio.wait_for(client.ping(), timeout=connection_timeout)
245246
log.info(f"Ping received from '{server.name}'; shutting down client")
247+
ping_succeeded = True
246248
log.debug(f"Client '{server.name}' shut down")
247-
return True
249+
return ping_succeeded
248250
except TimeoutError:
249-
log.error(
250-
f"MCP remote verification timed out (more than {connection_timeout}s) for '{server.name}'"
251-
)
252-
return False
251+
if ping_succeeded:
252+
log.warning(
253+
f"Ping received from '{server.name}' but shutting down client timed out. Marking as success."
254+
)
255+
else:
256+
log.error(
257+
f"MCP remote verification timed out (more than {connection_timeout}s) for '{server.name}', marking as failure."
258+
)
259+
return ping_succeeded
253260
except Exception as e: # noqa: BLE001
254261
log.error("MCP remote verification failed for '{}': {}", server.name, e)
255262
return False

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)