Skip to content

fix(code): report MCP server changes on reload - #5504

Merged
Mason Daugherty (mdrxy) merged 13 commits into
mainfrom
mdrxy/code/reload-mcp-summary
Aug 17, 2026
Merged

fix(code): report MCP server changes on reload#5504
Mason Daugherty (mdrxy) merged 13 commits into
mainfrom
mdrxy/code/reload-mcp-summary

Conversation

@mdrxy

@mdrxy Mason Daugherty (mdrxy) commented Aug 14, 2026

Copy link
Copy Markdown
Member

/reload now shows MCP server changes. It reports servers that loaded, servers that were removed, servers that failed to load, and servers that recovered.


Before, /reload did not report MCP server state. The command now compares the MCP server list before and after the reload and shows the difference to the user.

The report can include these lines:

  • Loaded: <names> — servers that were added and are ready to use.
  • Removed: <names> — servers that are no longer configured.
  • Failed to load: <names> — servers that are new or that moved to an error state.
  • Recovered: <names> — servers that had an error before and are healthy now.
  • Status changed: <names> — servers whose status changed in another way.
  • Config errors: <names> — configuration files that failed to parse.
  • Resolved config errors: <names> — configuration files that parse again.

When MCP is disabled with --no-mcp, the reload skips the MCP metadata refresh and reports MCP server changes: no changes detected.

When the reload cannot refresh the MCP metadata, the report says so and tells the user to run /mcp to check the state. When nothing changed but some servers are still in an error state, the report says how many servers still need attention.

Made by Open SWE

Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com>
@github-actions github-actions Bot added dcode Related to `deepagents-code` fix A bug fix (PATCH) internal User is a member of the `langchain-ai` GitHub organization size: S 50-199 LOC labels Aug 14, 2026
@mdrxy
Mason Daugherty (mdrxy) marked this pull request as ready for review August 17, 2026 16:36

@open-swe open-swe Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Open SWE Review found 1 potential issue.

Open in WebView Open SWE trace

Comment thread libs/code/deepagents_code/app.py Outdated
`/reload` called the new `_restart_server_manual_result` while
`test_updates_loaded_ids_only_after_successful_restart` still patched
`_restart_server_manual`, so the real respawn ran against a MagicMock
server proc and failed before updating plugin state. Patch the method the
reload path actually invokes.

When MCP is disabled (`--no-mcp`), both server-info snapshots are None,
which the report misread as unavailable metadata ("couldn't be
determined; use /mcp to check."). The app already knows MCP is off when
`_mcp_preload_kwargs` is None, so report no changes definitively instead.
@github-actions github-actions Bot added size: M 200-499 LOC and removed size: S 50-199 LOC labels Aug 17, 2026
`_respawn_server` splatted `self._mcp_preload_kwargs` unconditionally, but
that attribute is `None` exactly when the session ran with `--no-mcp`.
`**None` raises `TypeError`, which the surrounding `except Exception`
swallowed into an error-level traceback plus a warning toast reading "MCP
tool metadata could not be refreshed" — shown to a user who had explicitly
turned MCP off. Every `/reload` and `/restart` in such a session logged a
spurious exception, and the `/reload` report simultaneously claimed "no
changes detected".

Guard the preload the way the two sibling call sites already do, and carry
the reason on the result rather than re-deriving it at the call site:
`_ServerRespawnResult` gains an `mcp_status` discriminant separating
`fresh` from `disabled` and `unavailable`, which `mcp_server_info=None`
previously conflated. `/reload` now branches on that instead of reaching
back into `_mcp_preload_kwargs`.

Also make the change summary honest about failures it previously hid:

- A server that keeps its name but goes `ok` -> `error` is reported under
  "Failed to load" instead of "no changes detected" — the case `/reload`
  most exists to serve.
- Config-load failures arrive as synthetic `<config:...>` entries; they are
  now listed as "Config errors" rather than announced as loaded servers.
- A still-broken server qualifies the "no changes" line instead of letting
  it read as all-clear.
- A missing baseline reports what is loaded now rather than a bare
  "couldn't be determined".

Drop the now-unnecessary `ty: ignore[invalid-argument-type]`, and correct
the `_respawn_server` "Used by" list, which named a non-caller and omitted
three real ones.
@github-actions github-actions Bot added size: L 500-999 LOC and removed size: M 200-499 LOC labels Aug 17, 2026

@open-swe open-swe Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Open SWE Review found 1 potential issue.

Open in WebView Open SWE trace

Comment thread libs/code/deepagents_code/app.py Outdated
The `/reload` MCP summary could report a clean state it had not verified.

- Name still-broken servers alongside real changes; the attention qualifier
  previously ran only when nothing else changed, so a successful load
  reported as unqualified good news while another server sat erroring.
- Count unrepaired config errors as needing attention. They are excluded
  from the server map, so a reload run to check a config fix read as success.
- Report transport and tool-count changes under an unchanged name, so
  editing a server and reloading to apply it is not "no changes detected".
- Stop calling erroring servers "loaded" when no baseline exists, and
  surface the config errors that branch already computed and discarded.
- Thread the preload failure text into the toast and report; it identifies
  the offending server and previously reached only the log.
- Derive `fresh` from the returned metadata rather than from the preload
  not raising: it is typed `list[...] | None` and could pair `fresh` with
  `None`, inverting the report.
- Cross-check `disabled` against the session's `no_mcp` flag instead of
  inferring it from absent preload kwargs. That inference drives an
  unconditional all-clear.
- Keep the last-known MCP snapshot in the UI when a refresh fails. Posting
  `ServerReady(None)` zeroed every warning counter and rendered "No MCP
  servers configured" — an all-clear on the screen the report points to.
- Say MCP is disabled rather than "no changes detected", which read as a
  load next to the plugin MCP count printed above it.
- Tell remote-server sessions that MCP config cannot be reloaded.

Also corrects `_respawn_server`'s caller list, which omitted the
post-install and web-search restarts and `/goal model`, along with the two
log strings naming only `/restart` and `/reload`.
@github-actions github-actions Bot added size: XL 1000+ LOC and removed size: L 500-999 LOC labels Aug 17, 2026

@open-swe open-swe Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Open SWE Review found 1 potential issue.

Open in WebView Open SWE trace

Comment thread libs/code/deepagents_code/app.py Outdated
…report

The /reload MCP branch keyed on the absence of a server process, which
also matches a deferred local session (owned kwargs cached, no process
yet — e.g. first launch before credentials/default model). Such a
session was told it "uses a remote server and cannot reload MCP config"
moments before the deferred start booted the local server from the very
config the reload just read.

Key the remote branch on missing server kwargs instead, and give the
deferred case its own line: the --no-mcp notice when MCP is off, else a
"hasn't started yet" line pointing at /mcp.
…-summary

# Conflicts:
#	libs/code/deepagents_code/app.py
#	libs/code/tests/unit_tests/test_reload.py
@mdrxy
Mason Daugherty (mdrxy) merged commit b16a740 into main Aug 17, 2026
57 checks passed
@mdrxy
Mason Daugherty (mdrxy) deleted the mdrxy/code/reload-mcp-summary branch August 17, 2026 20:20
Mason Daugherty (mdrxy) pushed a commit that referenced this pull request Aug 18, 2026
> [!CAUTION]
> Merging this PR will automatically publish to **PyPI** and create a
**GitHub release**.

For the full release process, see
[`.github/RELEASING.md`](https://github.com/langchain-ai/deepagents/blob/main/.github/RELEASING.md).

---

_Release notes preview: keep this section in sync with the package
`CHANGELOG.md`. Publish reads the merged CHANGELOG via `release.yml`,
not this PR description — keep them aligned anyway so the PR stays an
accurate historical record for reviewers and anyone returning later._

---


##
[0.1.57](deepagents-code==0.1.56...deepagents-code==0.1.57)
(2026-08-18)

### Features

- Added warnings before expensive cold-cache turns and trust
user-declared endpoints for cold-cache policies
([#5439](#5439),
[#5462](#5462)).
- Made the chat input resizable by dragging its top border
([#5524](#5524)).
- Added a `multi_select` question type to `ask_user`
([#5097](#5097)).
- Added support for ACP approval modes
([#5394](#5394)).
- Added `DeepSeek-V4-Pro-0813` to the model picker
([#5512](#5512)).
- Show conversation turns alongside message counts
([#5571](#5571)).
- Include `TERM_PROGRAM` in the resume hint
([#5548](#5548)).

### Bug Fixes

- Report total context after `/offload`
([#5488](#5488)).
- Fixed transcript and thread restoration issues, including hydration
lag, scrolling resumed threads to the bottom, and hiding empty
previous-thread hints
([#5479](#5479),
[#5543](#5543),
[#5552](#5552)).
- Fixed Auto-mode approval handling by binding “yes” to the paired
`ask_user` question and avoiding duplicate Auto denial notices
([#5038](#5038),
[#5501](#5501)).
- Improved reload behavior by keeping the chat input responsive during
`/reload`, reporting MCP server changes, and avoiding plugin reload
prompt flashes or startup hints
([#5529](#5529),
[#5504](#5504),
[#5500](#5500),
[#5502](#5502)).
- Improved dependency update UI by preserving editable fields and hiding
dependency details after updates
([#5521](#5521),
[#5519](#5519)).
- Fixed chat UI polish issues, including detached spacer mount anchors,
the unfocused input cursor, and relative timestamp toggle display
([#5516](#5516),
[#5258](#5258),
[#5503](#5503)).
- Refresh the splash version after updates
([#5520](#5520)).

_End release notes preview._

---

> [!NOTE]
> A **community contributors** list and a **Special thanks** section
(crediting the users who filed the issues this release's PRs closed) are
appended to the GitHub release notes automatically at publish time (see
[Release
Pipeline](https://github.com/langchain-ai/deepagents/blob/main/.github/RELEASING.md#release-pipeline),
step 3).

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: langchain-oss-automated-triage[bot] <248757908+langchain-oss-automated-triage[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dcode Related to `deepagents-code` fix A bug fix (PATCH) internal User is a member of the `langchain-ai` GitHub organization size: XL 1000+ LOC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant