Skip to content

fix(mcp): add debug/warning logging for server connection attempts and failures - #331

Open
sridhar-3009 wants to merge 1 commit into
HKUDS:mainfrom
sridhar-3009:fix/315-mcp-connection-logging
Open

fix(mcp): add debug/warning logging for server connection attempts and failures#331
sridhar-3009 wants to merge 1 commit into
HKUDS:mainfrom
sridhar-3009:fix/315-mcp-connection-logging

Conversation

@sridhar-3009

Copy link
Copy Markdown

Summary

Relates to #315

When users configure MCP servers and run oh --verbose --debug, they saw no indication that OpenHarness was even trying to connect — and no actionable error when a connection failed. The failures were silently caught in connect_all() / _connect_stdio() / _connect_http() and stored in the status dict, but never emitted to any logger.

Added logging in McpClientManager:

Event Level Message
Before each connection attempt DEBUG MCP: connecting to server 'mcp-mini' (transport=http)
HTTP: about to dial DEBUG MCP: connecting to HTTP server 'mcp-mini' at http://…/jsonrpc
stdio: about to spawn DEBUG MCP: spawning stdio process for 'mcp-server': npx …
Successful connect DEBUG MCP: 'mcp-mini' connected — 3 tools, 0 resources
Connection failed WARNING MCP: 'mcp-mini' failed to connect — <error detail>
Unsupported transport WARNING MCP: server 'ws-server' skipped — Unsupported MCP transport: ws

Now oh --verbose surfaces connection failures at WARNING level (always visible) and --debug adds connection-attempt detail so users can trace exactly where things go wrong.

Test plan

  • Configure a valid stdio MCP server, run oh --debug — verify connection attempt and success appear in output.
  • Configure an HTTP MCP server with an unreachable URL, run oh --verbose — verify warning appears with the error detail.
  • Verify no regression for working servers (connected status unchanged).

…d failures

MCP server connection failures were silently caught and stored in status
objects only. With --verbose --debug, users saw no indication that
OpenHarness was even attempting to connect to their configured servers,
and no actionable error when the connection failed.

Add structured logging to McpClientManager:
- debug log before each connection attempt (transport + address/command)
- debug log on successful connect with tool/resource count
- warning log on failure with the full error detail

The same warning-level log fires for unsupported transport types (e.g.
a WebSocket server in a build that only ships stdio + HTTP) so the
failure is visible in --verbose output rather than being silently
recorded in the status dict.

Relates to HKUDS#315
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant