Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## Unreleased

### Fixed
- The MCP Server window's transport status labels now refresh after a Transport Mode switch actually completes. Switching to/from Broker Mode restarts the server asynchronously, but the header ("Running on …" / "Attached to existing server …") and the transport line ("Transport: Direct HTTP." / "Broker running …") were refreshed on a fixed 2-frame `delayCall` that raced the async broker bring-up, so they kept showing the pre-switch transport after the switch had already taken effect. The refresh now runs once the restart has settled (and still reflects a direct-HTTP fallback if broker mode fails to start).

## [0.5.3] - 2026-07-18

### Added
Expand Down
37 changes: 30 additions & 7 deletions Editor/MCP/Server/FunplayMCPServerControlsPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,19 @@ public void AddTo(VisualElement parent)

if (_settings.MCPServerEnabled)
{
_ = _server.StopAsync();
EditorApplication.delayCall += () => _ = _server.StartAsync();
// Restart, then refresh the status labels once the transport has actually
// settled. A fixed 2-frame delayCall raced the async broker bring-up, so the
// labels kept showing "Transport: Direct HTTP." / "Running on ..." after a
// switch to broker mode had already completed.
RestartServerAndRefreshStatus();
}
else if (!enabled)
else
{
MCPBrokerProcessManager.Stop();
if (!enabled)
MCPBrokerProcessManager.Stop();
UpdateBrokerStatus();
InvokeRefreshStatus();
}

EditorApplication.delayCall += () =>
EditorApplication.delayCall += () => { UpdateBrokerStatus(); InvokeRefreshStatus(); };
});
transportModeDropdown.style.marginBottom = 4;
parent.Add(transportModeDropdown);
Expand Down Expand Up @@ -131,6 +134,26 @@ private void InvokeRefreshStatus()
_refreshStatus?.Invoke();
}

// Restarts the server for a transport-mode change and refreshes the status labels only
// after the restart has fully settled. Awaiting captures the editor main-thread context,
// so the post-await refresh runs on the main thread against the real, final transport
// state (broker up + attached, or a direct-HTTP fallback) instead of an in-between state.
private async void RestartServerAndRefreshStatus()
{
try
{
await _server.StopAsync();
await _server.StartAsync();
}
catch (Exception ex)
{
Debug.LogWarning("[Funplay MCP Server] Server restart after transport-mode change failed: " + ex.Message);
}

UpdateBrokerStatus();
InvokeRefreshStatus();
}

private void UpdateBrokerControls(bool enabled)
{
if (_brokerMonoPathField != null)
Expand Down
Loading