#8047·QwenPaw

[Bug]: `server/discover` HTTP 422 with plain-text body (DBX MCP) is not treated as legacy-protocol evidence — streamable_http driver never activates (status=inactive, Console 503)

Author: weiminghaooCreated Sep 30, 2026Updated Sep 30, 2026

QwenPaw Version

2.2.1 (Docker image agentscope/qwenpaw:latest, QwenPaw Hub deployment, Linux container runtime)

Description

An MCP card of type streamable_http pointing at DBX (local database tool, server version 0.4.102) fails Driver construction with Failed to build Driver 'dbx': MCP server/discover rejected with HTTP 422. The client card stays status=inactive forever and the Console reports 503: MCP client 'dbx' is saved but not active yet.

Root cause — same negotiation gap as #7728 / #7827 but a different status code and body shape:

  • The server rejects the unknown server/discover probe with HTTP 422 and a plain-text body Unexpected message, expect initialize request (it mandates initialize as the first message and answers unknown/misordered requests with 422, no JSON-RPC error envelope).
  • In _unwrap_jsonrpc_result, the 422 body is not a JSON-RPC envelope → raises httpx.HTTPStatusError.
  • In _negotiate, the except httpx.HTTPStatusError branch only classifies bare 400/404/405 as legacy-protocol evidence (_is_legacy_protocol_evidence → status_code in {400, 404, 405}) → 422 propagates → the whole Driver build fails.

Control group: the same server completes a classic initialize handshake (HTTP 200, protocol 2025-03-26) and answers tools/list with 25 tools — it works perfectly via the legacy HttpStatefulClient path once the fallback triggers.

Component(s) Affected

  • Core / Backend (app, agents, config, providers, utils, local_models)

Environment

  • QwenPaw version: 2.2.1
  • OS: macOS host + Docker Linux runtime (QwenPaw Hub, one container per user)
  • Install method: Docker
  • MCP server: DBX 0.4.102, streamable_http at http://host:5225/mcp (Bearer auth)

Steps to Reproduce

  1. Configure an MCP card (streamable_http) pointing at a DBX MCP server.
  2. Let QwenPaw build the Driver (startup or card hot-reload).
  3. Driver build fails, card stays inactive, Console tool queries return 503.

Minimal probe against the same server (from any HTTP client):

POST /mcp  {"jsonrpc":"2.0","id":1,"method":"server/discover","params":{"_meta":{"protocolVersion":"2026-07-28"}}}
→ HTTP 422  "Unexpected message, expect initialize request"

POST /mcp  {"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-03-26",...}}
→ HTTP 200  (SSE, serverInfo dbx 0.4.102, capabilities tools+resources)

Actual vs Expected

  • Actual: Failed to build Driver 'dbx': MCP server/discover rejected with HTTP 422; legacy fallback never triggers because 422 is not in the legacy-evidence status set.
  • Expected: the 422 response is recognized as "server does not support server/discover" and negotiation falls back to the legacy handshake, which connects successfully.

Logs / Screenshots

WARNING | drivers/manager.py:159 | Failed to build Driver 'dbx': MCP server/discover rejected with HTTP 422
WARNING | app/mcp/config_service.py:141 | Failed to list tools for MCP client 'dbx': 503: MCP client 'dbx' is saved but not active yet (status=inactive)

Additional Notes

Suggested fix (any one suffices; the first is one line and verified locally):

  1. Add 422 to the status set in _is_legacy_protocol_evidence ({400, 404, 405} → {400, 404, 405, 422}); or more generally treat any 4xx discover response whose body is not a standard JSON-RPC envelope as legacy evidence.
  2. Same direction as the pending PR #7729 (Java jsonRpcError envelope, HTTP 500). It would be great to unify the three known shapes — bare 400/404/405 (#current), non-standard 5xx envelopes (#7728), bare 500 empty body (#7827), and 422 non-JSON-RPC (this issue) — into one "discover probe failed with a non-modern answer → let the legacy handshake arbitrate" rule.

Local workaround (deployed and verified): patched image with the one-line change from suggestion 1. Log then shows the expected path and full tool list:

INFO | mcp_streamable_http.py:969 | MCP client 'dbx' falling back to legacy: MCP server/discover rejected with HTTP 422
INFO | mcp_stateful_client.py:251 | MCP client connected: dbx
(list_tools → 25 tools)

Related: #7728 (500 + jsonRpcError envelope), #7827 (bare 500 empty body), PR #7729.