Skip to content

Commit 5c945cf

Browse files
Harder timeout
1 parent b999280 commit 5c945cf

File tree

3 files changed

+22
-15
lines changed

3 files changed

+22
-15
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "open-edison"
3-
version = "0.1.51"
3+
version = "0.1.52"
44
description = "Open-source MCP security, aggregation, and monitoring. Single-user, self-hosted MCP proxy."
55
readme = "README.md"
66
authors = [

src/mcp_importer/api.py

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ async def _verify_async() -> bool: # noqa: C901
180180

181181
# Remote servers
182182
if server.is_remote_server():
183+
connection_timeout = 10.0
183184
remote_url = server.get_remote_url()
184185
if remote_url:
185186
# If inline headers are specified (e.g., API key), verify via proxy to honor headers
@@ -230,19 +231,25 @@ async def _list_tools_only() -> Any:
230231
if oauth_info.status in (OAuthStatus.NEEDS_AUTH, OAuthStatus.AUTHENTICATED):
231232
return True
232233
# NOT_REQUIRED: quick unauthenticated ping
233-
# print(f"Pinging remote server '{server.name}' without OAuth")
234-
async with FastMCPClient(remote_url, auth=None, timeout=10.0) as client: # type: ignore
235-
# print(
236-
# f"Pinging remote server '{server.name}' without OAuth - Inside client with-statement"
237-
# )
238-
await asyncio.wait_for(client.ping(), timeout=10.0)
239-
# print(
240-
# f"Pinging remote server '{server.name}' without OAuth - Inside client with-statement but after ping"
241-
# )
242-
# print(
243-
# f"Pinging remote server '{server.name}' without OAuth - After client with-statement"
244-
# )
245-
return True
234+
log.debug(f"Establishing contact with remote server '{server.name}'")
235+
# Async timeout
236+
async with asyncio.timeout(connection_timeout):
237+
async with FastMCPClient(
238+
remote_url,
239+
auth=None,
240+
timeout=connection_timeout,
241+
init_timeout=connection_timeout,
242+
) as client: # type: ignore
243+
log.debug(f"Connection established to '{server.name}'; pinging...")
244+
await asyncio.wait_for(client.ping(), timeout=connection_timeout)
245+
log.info(f"Ping received from '{server.name}'; shutting down client")
246+
log.debug(f"Client '{server.name}' shut down")
247+
return True
248+
except TimeoutError:
249+
log.error(
250+
f"MCP remote verification timed out (more than {connection_timeout}s) for '{server.name}'"
251+
)
252+
return False
246253
except Exception as e: # noqa: BLE001
247254
log.error("MCP remote verification failed for '{}': {}", server.name, e)
248255
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)