Repository navigation
feat(mcp): cloud MCP doctor — direct probe trace, engine refresh, advanced diagnostics - #2975
Merged
reachjalil merged 2 commits intoJul 22, 2026
Merged
Conversation
…ed diagnostics The openwork-cloud meta-MCP fails opaquely today: OpenCode stores only Error.message for a failed remote connect (a TLS/proxy failure collapses to the literal "fetch failed"), never retries on its own, and the desktop card reduces everything to "Couldn't apply Cloud access to this workspace". Server: - Direct endpoint probe now records a per-step trace (initialize, initialized notice, tools/list) with HTTP status, latency, endpoint server info, and — on transport errors — the full cause chain (code/errno/syscall) that the engine discards. - New POST /workspace/:id/mcp/openwork-cloud/engine-refresh: disconnects the engine's MCP client, re-registers from the persisted desired config (an unconditional fresh connect on the engine side), and returns ordered refresh steps plus probed health. - Health now carries engineInspection — the engine's full MCP server map with per-server states and raw error strings — so support can tell "everything failed" (host network path) from "only openwork-cloud failed" (endpoint or token) from "entry lost after an engine restart". - Health gains durationMs; reconcilePersistedOpenworkCloudMcp accepts providerModel. App: - Test now requests probe=1, verifying the Cloud endpoint directly from the OpenWork server instead of only reading the engine's cached state; the Advanced settings page refresh does the same. - The Agent access card gains a collapsed-by-default Advanced diagnostics section: failure code/stage/retryability, the raw engine error, delivery revisions, probe step trace, engine MCP server map, token expiry, versions, a Refresh engine connection action, and a redacted copyable support bundle. Co-Authored-By: Claude Fable 5 <[email protected]>
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
Contributor
|
@reachjalil is attempting to deploy a commit to the Different AI Team on Vercel. A member of the Team first needs to authorize it. |
reachjalil
marked this pull request as ready for review
July 22, 2026 05:08
…rors Two hardening guards from a behavior-impact audit: - inferFailedStatus: certificate/TLS transport errors (which can contain "expired", "auth"(ority), or "revoked" wording — especially once engines preserve error cause chains) are never classified as token or session problems; they stay generic connection failures. Prevents richer engine error strings from changing the repair verdict. - engine-refresh route: an empty body stays allowed, but malformed JSON is now a hard 400 instead of being silently treated as empty. Co-Authored-By: Claude Fable 5 <[email protected]>
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Field reports showed the Agent access card stuck on Degraded — "Couldn't apply Cloud access to this workspace" with no way to see what actually broke. Three structural problems make this failure opaque:
{status:"failed"}and the client is dropped; there is no timer, no on-tool-call reconnect, no on-session reconnect. It stays failed until something external re-drives it. Dynamically-registered entries are also lost entirely on an engine state rebuild.Error.message. A TLS/proxy/network failure collapses to the literal stringfetch failed; the cause chain (code,errno,syscall) is discarded and is not written to the engine log either.probe=1), but "Test now" never requested it, and none of the rich health detail (failure code/stage, raw engine error, delivery revisions) was visible anywhere near the card.What
Server (
apps/server)initialize → initialized_notice → tools_listwith HTTP status, per-step latency, endpointserverInfo/protocol, and — on transport failure — the full error cause chain that the engine discards (tools.direct.trace,failure.details.transport).POST /workspace/:id/mcp/openwork-cloud/engine-refresh: explicit engine-side retry. Disconnects the engine'sopenwork-cloudclient (closing a wedged transport), re-registers from the persisted desired config (an unconditional fresh connect on the engine side), polls to connected, and returns ordered refresh steps plus fully probed health. Also recovers the "entry lost after engine restart" case.engineInspection: health now includes the engine's full MCP server map (per-server status + raw error), read over the OpenCode SDK. Support can now distinguish everything failed (engine host network path) from only openwork-cloud failed (endpoint/token) from entry not registered (lost dynamic registration).durationMs;reconcilePersistedOpenworkCloudMcpacceptsproviderModel.App (
apps/app)probe=1) from the OpenWork server, independent of the engine's cached state. The Advanced settings page refresh does the same.cloud-mcp-diagnostics.ts(rows/trace/bundle formatting), fully unit-tested.Behavior impact: none outside diagnostics (audited, not just intended)
tools.direct.trace,engineInspection,durationMs) live only in the health JSON consumed by the settings card, the Advanced settings page, and the clipboard bundle. Nothing reaches the model: no system-prompt, plugin, instruction, or tool-surface changes;openwork-cloudtool registration is untouched.GET …/healthwithoutprobeandPOST …/reconcilebehave exactly as before; all new fields are additive/optional (older clients ignore them, older servers simply omit them). The engine-refresh endpoint is new and opt-in.refresh.stepsand the health verdict. On the new endpoint an empty body is allowed but malformed JSON is a hard 400.Error.causecan emit cert/TLS strings containing "expired"/"auth"/"revoked";inferFailedStatusnow explicitly keeps those classified as connection failures instead of newly misclassifying them as token/session problems (regression-tested in both directions).firstFailurefeeds the chat send gate (useCloudMcpSubmitReadiness/ensureCloudMcpSubmissionReadiness) and background session maintenance; both consume onlyusable,usableByCurrentModel, and the code-derived fixed sentences (failure.message/recommendedAction) — never raw engine strings, which stay indetails(Advanced/bundle only). Neither path requests the probe (their health calls are unchanged), and with the classification guard above, gate decisions, banner text, and token-remint triggers stay byte-identical for transport failures.Support-call flow this enables
Open the card → expand Advanced diagnostics → read three signals side by side:
Then Refresh engine connection (engine drop + fresh connect) or Repair and test (token remint + re-apply), and Copy sanitized diagnostic into the ticket.
Verification
apps/server:bun test src/cloud-mcp-health.test.ts src/cloud-mcp-reconcile.e2e.test.ts— 38 pass (11 new: probe trace, 401 step capture, transport cause chain, engine inspection map, engine-refresh e2e happy path / desired-missing / engine-down / malformed-body 400, cert-error classification guard in both directions).apps/server:bun test src/mcp.engine-sync.e2e.test.ts src/extensions-connect-gating.test.ts— 25 pass.apps/app:bun test tests/cloud-mcp-diagnostics.test.ts tests/cloud-mcp-health.test.ts tests/connect-view.test.ts— 33 pass (new: advanced rows incl. lost-registration flag and transport cause, trace/refresh line formatting, bundle redaction, probe flag passthrough, engine-refresh runner mapping).tsc --noEmitclean inapps/serverandapps/app;git diff --checkclean.Deliberately out of scope: no engine modifications
Everything here lives in
apps/serverandapps/app— the OpenCode engine is intentionally untouched, and its known gaps are compensated from outside:Error.message("fetch failed") → the server-side direct probe recovers the transport cause chain independently, on our own network path.devalready containsbd738a0a7("reconnect closed remote MCP clients"), which OpenWork inherits with a future engine version pin — no fork patch needed.🤖 Generated with Claude Code