Skip to content

MCP connection failures swallow the actual error message — only logs 'server unavailable' #1121

Description

@kn0wsnothing

Problem

When an MCP server fails to connect, the log only shows:

WARN message="server unavailable" key=exodus-mcp type=remote status=failed

The connectRemote function in src/mcp/index.ts stores the actual error in lastStatus.error:

lastStatus = { status: "failed" as const, error: lastError.message }

But the logWarning call only logs status.status (always the string "failed"), never status.error (the actual error message, e.g. "401 Unauthorized" or "Streamable HTTP error: ..."):

yield* Effect.logWarning("server unavailable", { key, type: mcp.type, status: status.status })

Impact

This makes debugging MCP connection failures extremely difficult. A token-expired 401, a network timeout, a TLS error, and a server misconfiguration all produce the identical log line status=failed with no distinguishing detail. We spent significant time theorising about SDK transport bugs when the actual cause was an expired bearer token returning 401 — something the error message would have revealed immediately.

Suggested fix

Include status.error in the logWarning call:

yield* Effect.logWarning("server unavailable", { key, type: mcp.type, status: status.status, error: status.error ?? "unknown" })

This is a one-line change that would have saved a lot of debugging time. The error field is already populated — it just needs to be logged.


Metadata

Field Value
CLI Version 0.9.5
Platform darwin
Architecture arm64
OS Release 25.5.0
Category improvement
Working Directory editorial-intelligence
Session ID ses_fe273aefdffeKVRGOtYcW574qX

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions