Commit 28d4f81
authored
refactor(mcp-optimizer): remove the feature and migrate legacy users on startup (#2086)
* refactor(mcp-optimizer): remove sunset UI, route, and feature module
Follows the deprecation shipped in #1910. Deletes the /mcp-optimizer route,
the sunset banner, the features/meta-mcp module, and every optimizer-specific
branch that lived across MCP server orchestration, group actions, client
registration, and routing. Stops tracking the toolhive-mcp-optimizer image in
Renovate and drops the sunset blog URL constant. Trims constants.ts down to
the identifiers still used by the legacy-user cleanup migration.
* feat(mcp-optimizer): run cleanup once on startup for legacy users
Users who had MCP Optimizer enabled still have the __mcp-optimizer__ group,
its meta-mcp workload, and their clients registered to the optimizer group
after the feature is removed. On first launch post-upgrade, wait for the
ToolHive daemon to become ready and then run the same teardown that used to
fire when the experimental toggle was flipped off: restore clients to the
ALLOWED_GROUPS target and delete the optimizer group with its workloads.
- Add useMcpOptimizerStartupCleanup and wire it into RootComponent. It polls
electronAPI.isToolhiveRunning before marking itself as run, so a slow
daemon start cannot cause the migration to silently no-op.
- Rewrite useCleanupMetaOptimizer to fetch groups and the meta-mcp workload
at call-time via queryClient.fetchQuery, decoupling it from React Query
closures and from the feature-flag gate.
- Flip META_OPTIMIZER to isDisabled: true so the flag key is still defined
(for one release) and the UI no longer surfaces it, while the cleanup path
remains callable.
* test(e2e): cover MCP optimizer startup cleanup migration
Two-session Playwright spec that relaunches the app against the same
userDataDir to exercise the one-shot startup hook:
- Session 1 creates a custom group via the UI, then seeds __mcp-optimizer__,
registers a client against it, and creates a meta-mcp workload pointing
at a local test MCP server with ALLOWED_GROUPS set to the custom group.
- Session 2 polls the thv HTTP API until the optimizer group is gone, the
client is re-registered to the custom group, and the meta-mcp workload
returns 404 — with a best-effort thv CLI teardown in afterAll as a
safety net.
Adds a reusable launchApp + thvFetch helper so future multi-session specs
don't have to re-implement Electron + userDataDir wiring.
* fix(mcp-optimizer): harden startup cleanup against edge cases
Addresses review feedback on #2086:
- useMcpOptimizerStartupCleanup no longer latches `hasRunCleanup` before
awaiting ToolHive readiness. If the 60s readiness wait times out the hook
can now retry on a subsequent effect re-fire. An `inFlight` ref still
prevents concurrent starts.
- useCleanupMetaOptimizer parses ALLOWED_GROUPS defensively (trim, first
non-empty comma entry) and only restores clients when the target group
still exists in the fetched groups list. Unregister + group delete still
proceed regardless, so the optimizer state never lingers.
- mcp-optimizer-startup-cleanup.spec.ts bumps the cleanup poll timeout
from 60s to 120s so slow CI runners don't flake when the app-side
readiness wait consumes most of the original budget.
Adds a regression test that asserts restoration is skipped when
ALLOWED_GROUPS points to a group that no longer exists.
Made-with: Cursor
* fix(mcp-optimizer): address deeper review feedback on startup migration
Second follow-up on #2086, addressing the more nuanced review points:
- useMcpOptimizerStartupCleanup now logs the elapsed cleanup duration on
success, making slow CI runs easier to diagnose.
- useCleanupMetaOptimizer aborts before touching the optimizer group when
restoring clients to the ALLOWED_GROUPS target fails. The startup hook
retries on the next launch, so clients are never left orphaned between
"removed from optimizer" and "restored to target".
- useCleanupMetaOptimizer wraps the final deleteGroup call in a try/catch
that swallows 404s. In the rare race where the group is removed between
our fetch and the delete (e.g. concurrent CLI teardown), the migration
treats the end state as success instead of surfacing a phantom error.
- useDeleteServer drops the unused `group` param from its type and from
its sole caller in RemoveServerMenuItem, keeping the hook contract
honest now that the optimizer-specific notification path is gone.
Adds a regression test asserting that a failing clients/register call
leaves the optimizer group untouched (no unregister, no delete).
Made-with: Cursor
* fix(e2e): force-exit electron between sessions in optimizer cleanup test
On Linux CI, `ElectronApplication.close()` hung for the full 180s test
timeout after the first session seeded a running workload via the thv
API - the before-quit / graceful-shutdown path waits on a workload that
never drains. Add a `close()` helper on `LaunchedApp` that force-exits
via `app.exit(0)`, races `app.close()` against a 5s fallback, and
SIGKILLs the leftover process. Use it from both session teardowns in
the optimizer cleanup spec.
Made-with: Cursor1 parent 4edcbff commit 28d4f81
68 files changed
Lines changed: 754 additions & 4417 deletions
File tree
- common
- e2e-tests
- helpers
- main/src/feature-flags
- __tests__
- renderer/src
- common
- components
- __tests__
- layout
- hooks
- __tests__
- lib
- features
- clients
- components
- __tests__
- hooks
- mcp-servers
- components
- card-mcp-server/server-actions
- items
- groups-manager
- local-mcp
- __tests__
- hooks
- lib
- __tests__
- sub-pages/logs-page
- __tests__
- meta-mcp
- components
- __tests__
- hooks
- __tests__
- registry-servers/hooks
- routes
- (registry)
- __tests__
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
52 | | - | |
53 | | - | |
54 | 52 | | |
55 | 53 | | |
56 | 54 | | |
57 | 55 | | |
58 | 56 | | |
59 | | - | |
60 | 57 | | |
61 | 58 | | |
62 | 59 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
0 commit comments