|
27 | 27 | from src.mcp_importer.merge import MergePolicy, merge_servers |
28 | 28 | from src.oauth_manager import OAuthStatus, get_oauth_manager |
29 | 29 | from src.oauth_override import OpenEdisonOAuth |
| 30 | +from src.tools.io import suppress_fds |
30 | 31 |
|
31 | 32 |
|
32 | 33 | class CLIENT(str, Enum): |
@@ -202,9 +203,11 @@ async def _verify_async() -> bool: # noqa: C901 |
202 | 203 | proxy_remote: FastMCP[Any] | None = None |
203 | 204 | host_remote: FastMCP[Any] | None = None |
204 | 205 | try: |
205 | | - proxy_remote = FastMCP.as_proxy(backend_cfg_remote) |
206 | | - host_remote = FastMCP(name=f"open-edison-verify-host-{server.name}") |
207 | | - host_remote.mount(proxy_remote, prefix=server.name) |
| 206 | + # TODO: In debug mode, do not suppress child process output. |
| 207 | + with suppress_fds(suppress_stdout=False, suppress_stderr=True): |
| 208 | + proxy_remote = FastMCP.as_proxy(backend_cfg_remote) |
| 209 | + host_remote = FastMCP(name=f"open-edison-verify-host-{server.name}") |
| 210 | + host_remote.mount(proxy_remote, prefix=server.name) |
208 | 211 |
|
209 | 212 | async def _list_tools_only() -> Any: |
210 | 213 | return await host_remote._tool_manager.list_tools() # type: ignore[attr-defined] |
@@ -233,21 +236,23 @@ async def _list_tools_only() -> Any: |
233 | 236 | if oauth_info.status in (OAuthStatus.NEEDS_AUTH, OAuthStatus.AUTHENTICATED): |
234 | 237 | return True |
235 | 238 | # NOT_REQUIRED: quick unauthenticated ping |
| 239 | + # TODO: In debug mode, do not suppress child process output. |
| 240 | + questionary.print(f"Testing connection to '{server.name}'...", style="bold fg:ansigreen") |
236 | 241 | log.debug(f"Establishing contact with remote server '{server.name}'") |
237 | | - # Async timeout |
238 | 242 | async with asyncio.timeout(connection_timeout): |
239 | 243 | async with FastMCPClient( |
240 | 244 | remote_url, |
241 | 245 | auth=None, |
242 | 246 | timeout=connection_timeout, |
243 | 247 | init_timeout=connection_timeout, |
244 | | - ) as client: # type: ignore |
| 248 | + ) as client: |
245 | 249 | log.debug(f"Connection established to '{server.name}'; pinging...") |
246 | | - await asyncio.wait_for(client.ping(), timeout=connection_timeout) |
| 250 | + with suppress_fds(suppress_stdout=True, suppress_stderr=True): |
| 251 | + await asyncio.wait_for(fut=client.ping(), timeout=1.0) |
247 | 252 | log.info(f"Ping received from '{server.name}'; shutting down client") |
248 | 253 | ping_succeeded = True |
249 | 254 | log.debug(f"Client '{server.name}' shut down") |
250 | | - return ping_succeeded |
| 255 | + return ping_succeeded |
251 | 256 | except TimeoutError: |
252 | 257 | if ping_succeeded: |
253 | 258 | questionary.print( |
@@ -281,9 +286,13 @@ async def _list_tools_only() -> Any: |
281 | 286 | proxy_local: FastMCP[Any] | None = None |
282 | 287 | host_local: FastMCP[Any] | None = None |
283 | 288 | try: |
284 | | - proxy_local = FastMCP.as_proxy(backend_cfg_local) |
285 | | - host_local = FastMCP(name=f"open-edison-verify-host-{server.name}") |
286 | | - host_local.mount(proxy_local, prefix=server.name) |
| 289 | + # TODO: In debug mode, do not suppress child process output. |
| 290 | + log.info("Checking properties of '{}'...", server.name) |
| 291 | + with suppress_fds(suppress_stdout=False, suppress_stderr=True): |
| 292 | + proxy_local = FastMCP.as_proxy(backend_cfg_local) |
| 293 | + host_local = FastMCP(name=f"open-edison-verify-host-{server.name}") |
| 294 | + host_local.mount(proxy_local, prefix=server.name) |
| 295 | + log.info("MCP properties check succeeded for '{}'", server.name) |
287 | 296 |
|
288 | 297 | async def _list_tools_only() -> Any: |
289 | 298 | return await host_local._tool_manager.list_tools() # type: ignore[attr-defined] |
|
0 commit comments