Skip to content

fix(tui): rebuild agent tool schema when background MCP discovery completes (fixes #38945) - #39007

Closed
Morad37 wants to merge 1 commit into
NousResearch:mainfrom
Morad37:fix/38945-tui-mcp-tools-not-exposed
Closed

fix(tui): rebuild agent tool schema when background MCP discovery completes (fixes #38945)#39007
Morad37 wants to merge 1 commit into
NousResearch:mainfrom
Morad37:fix/38945-tui-mcp-tools-not-exposed

Conversation

@Morad37

@Morad37 Morad37 commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

MCP tool discovery runs in a background thread at TUI/Desktop startup so a slow server cant freeze the shell. The agent snapshots its tool list once at build time, so servers that take longer than the 750ms wait_for_mcp_discovery() timeout are invisible for the whole session.

This adds a threading.Event that signals when background discovery finishes. The server watches for it after the first agent build and rebuilds the tool schema once any remaining servers connect, without requiring /reload-mcp or /new.

Closes #38945

…pletes (fixes NousResearch#38945)

MCP tool discovery runs in a background daemon thread at TUI/Desktop startup
to avoid blocking the shell on slow HTTP MCP servers. The agent snapshots its
tool list once at build time, so servers that take longer than the 750ms
wait_for_mcp_discovery() timeout are invisible for the whole session.

Adds a threading.Event in entry.py that signals when background discovery
completes. The server watches for this event after the first agent build
and rebuilds the tool schema (agent.tools + agent.valid_tool_names) once
the remaining servers land, without requiring /reload-mcp or /new.
@alt-glitch alt-glitch added type/bug Something isn't working comp/tui Terminal UI (ui-tui/ + tui_gateway/) tool/mcp MCP client and OAuth P2 Medium — degraded but workaround exists labels Jun 4, 2026
@teknium1

Copy link
Copy Markdown
Contributor

Thanks for the focused MCP late-discovery fix. This is an automated hermes-sweeper review; current main already provides this guarantee through a broader, cache-safe implementation.

  • tui_gateway/server.py:4370 schedules a late MCP refresh and updates the active agent only while it is safe to do so.
  • agent/turn_context.py:176 refreshes late-registered MCP tools at the next turn boundary before the request tool schema is assembled.
  • tests/agent/test_turn_context.py:257 covers a late MCP tool becoming present in both the wire schema and valid_tool_names.
  • The superseding implementation shipped in 93d6e730288e4ffab8076a0539f25e37a71f238f and is included in v2026.6.19.

Closing as implemented on main.

@teknium1 teknium1 closed this Jul 14, 2026
@teknium1 teknium1 added the sweeper:implemented-on-main Sweeper: behavior already present on current main label Jul 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/tui Terminal UI (ui-tui/ + tui_gateway/) P2 Medium — degraded but workaround exists sweeper:implemented-on-main Sweeper: behavior already present on current main tool/mcp MCP client and OAuth type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Desktop/TUI sessions do not reliably expose enabled MCP tools (Todoist)

3 participants