Skip to content

Classify "subprocess exited before MCP initialize" instead of MCPX_UNKNOWN_UNCLASSIFIED; surface captured stderr #599

Closed

Description

@algis-dumbris

Summary

When an stdio upstream subprocess starts but exits before completing the MCP initialize handshake (e.g. a misconfigured server printing a fatal error and exiting non-zero), mcpproxy reports MCPX_UNKNOWN_UNCLASSIFIED with cause transport error: transport closed. The real, actionable error is captured on the child's stderr but is not reflected in the classified error or the UI banner — so the UI tells the user to "file a bug" for what is actually a self-serviceable config error.

Related precedent: #483 surfaced the same MCPX_UNKNOWN_UNCLASSIFIED symptom for a different docker failure mode. This is a recurring classification gap.

Environment

  • mcpproxy-go macOS app v0.37.0, macOS (darwin 23.5.0)
  • Upstream: stdio transport, command=docker, args=["run","-i","--rm","mcp/brave-search"], env=null

Repro

  1. Add a docker-transport stdio server whose image exits immediately on a missing required env var — e.g. mcp/brave-search with no BRAVE_API_KEY.
  2. Enable it and let mcpproxy connect.

Actual

UI banner:

Server Error: MCPX_UNKNOWN_UNCLASSIFIED
mcpproxy could not classify this failure. Please file a bug report so we can add a specific code.
Cause: failed to connect: stdio transport (command="docker", docker_isolation=true): transport error: transport closed

The per-server log captured the real cause but it is neither classified nor surfaced:

stderr | Status: Downloaded newer image for mcp/brave-search:latest
stderr | Error: --brave-api-key is required. You can get one at https://brave.com/search/api/.
stderr | Invalid configuration
stderr stream closed
ERROR core/connection_stdio.go:227 | MCP initialize JSON-RPC call failed | error: "transport error: transport closed"

Confirmed by direct run: docker run --rm -i mcp/brave-search → prints the same message and exits with code 1; the same image with -e BRAVE_API_KEY=… starts cleanly and blocks on stdio.

Expected

  • A specific error code for "subprocess exited before MCP initialize" (e.g. MCPX_SUBPROCESS_EXITED_BEFORE_INIT / MCPX_STDIO_PREMATURE_EXIT), distinct from generic transport-closed.
  • Include the child exit code and the last N lines of captured stderr in the classified error and the UI banner — mcpproxy already captures stderr via core/monitoring.go.
  • For docker transport specifically, detect non-zero container exit and hint at likely missing env/config.

Why it matters

The diagnostic needed to self-serve (the missing-key message) is already captured by mcpproxy but discarded from the surfaced error, forcing users into per-server logs and producing a misleading "please file a bug" prompt for a user-config error.

Relevant spots from the logs: core/connection_stdio.go:227, managed/client.go:212, core/monitoring.go:53.

Activity

  1. Dumbris commented on Jun 5, 2026

    @Dumbris
    Member

    Scope note for PR #606 (maintainer decision): This fix lands the actionable half — the classified MCPX_STDIO_EXIT_BEFORE_INITIALIZE code plus the captured stderr tail surfaced in the error/banner (e.g. Error: --brave-api-key is required), gated to the stdio transport. Child exit-code surfacing is intentionally deferred to a follow-up: on this failure path mcp-go has not reaped the subprocess (no Wait), so ProcessState is unset and any exit code would be unreliable. Reliably capturing the exit code needs subprocess-lifecycle work (extract the child cmd + Wait) and will be a separate change. The Expected section is narrowed accordingly for #606.

  2. Dumbris commented on Jun 8, 2026

    @Dumbris
    Member

    Fixed in v0.38.0 (#606, commit ebd5136): subprocess exit before the MCP initialize handshake now classifies as MCPX_STDIO_EXIT_BEFORE_INITIALIZE (not MCPX_UNKNOWN_UNCLASSIFIED), with captured stderr + exit code surfaced. Closing.

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

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