Pull requests / #3141

#3141 web: retry a failed GET /mcp instead of hiding the MCP tools for the session (#3113)

open · @ctr-137 · 0 comentarios · En GitHub

Server & APIDocumentationWindows

Descripción

Issue: #3113 (the web-app half; #3135 fixed the server half)

## Summary

`loadMcp()` returned on `!r.ok` and on a fetch exception, and scheduled a retry only while a server's status was
literally `starting`. One failed `GET /mcp` - a 401 before the API key was entered, a server restart, a proxy hiccup
- disabled the MCP tools for the life of the tab: the card was hidden, `mcpInfo.tools` stayed 0, and every chat
request left `strata_mcp` off. That is the second way #3113's "the backend loaded 14 tools, the page does not use
them" can happen.

## What changed

- `serve/web/app.js`
  - A failed status fetch (network error, 5xx, 401, or a body that stops arriving) is retried after 3, 6, 12 and then
    every 30 seconds; a success resets the backoff.
  - A 404 (an older server without `/mcp`) is not retried, and it clears a stale tool list.
  - The Monitor's MCP card says why the status is missing ("MCP status needs the API key (About > Settings)", "the
    server is unreachable; retrying") instead of silently disappearing. A list from the last successful fetch stays
    visible and is labelled "last known state shown".
  - Entering or changing the API key asks again immediately instead of waiting out the backoff; turning the MCP
    toggle on does the same when no tools are known.
- `docs/DETAILS.md`: one sentence on the retry schedule.
- `serve/test_web_mcp_retry.py`: a node test pins the schedule, the 404 stop, the 401 message, the success reset and
  the `starting` poll (skipped without node, like `test_web_sampling`).

## How this was checked

- `node --check serve/web/app.js` - syntax OK.
- `python -m unittest serve.test_web_mcp_retry serve.test_web_sampling` - **5 tests, OK**.
- **Manual, in the browser**, against a real `python -m serve.server --engine mock --port 8096 --api-key k
  --mcp-config ...` and the Streamable HTTP fake MCP server:
  - before the key: the Monitor card shows **"MCP status needs the API key (About > Settings)"**;
  - after entering the key in About > Settings: **"6 tools · 1 of 1 servers connected"** with the fake server's
    tools, without a reload.
- Regression: with `serve/web/app.js` reverted (the test kept), the node test fails (`mcpError is not defined`);
  with the change it passes.
- The full `serve` suite: **849 tests; the only error is `test_winjob.TestWinJob`** (a Windows `tasklist` call
  returning `None` here), the same one as on unmodified `main` (848 tests). `test_keepawake` is timing-flaky under
  the full run and passes alone; neither is related to this change.

## What I left alone

- The hard-coded 10 s MCP start wait is a separate change.
- A cut-off HTTP transport answer is PR #3139.
- The retry stops at a 404 on purpose: an older server has no `/mcp`, and retrying forever would only fill the
  console.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

En el sitio

Enlaces a install, modelos, releases.