Repository navigation
feat(webui): profile switcher in header (Profiles v2 T4, MCP-3243) - #765
Merged
Merged
Conversation
Add a Web UI profile switcher that consumes the REST /api/v1/profiles surface shipped in MCP-3241: - GET /api/v1/profiles — configured profiles with effective servers + tool count - GET/PUT /api/v1/profiles/active — read/set the server-level default active profile (empty slug = all servers) New pieces: - ProfileSummary/ActiveProfileResponse types + api.getProfiles/getActiveProfile/ setActiveProfile - useProfilesStore pinia store (fetch, setActive, activeLabel/isAllServers) - ProfileSwitcher.vue dropdown in TopHeader showing each profile's server membership + tool count, active badge, and a zero-profile empty state - vitest coverage for the component + api methods Refs MCP-3243 Co-Authored-By: Paperclip <[email protected]>
5/5 Playwright scenarios green against a live core with two configured profiles; self-contained HTML report + ordered screenshots + the spec. Refs MCP-3243 Co-Authored-By: Paperclip <[email protected]>
Deploying mcpproxy-docs with
|
| Latest commit: |
ce0f9bc
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://04ffb21e.mcpproxy-docs.pages.dev |
| Branch Preview URL: | https://feat-mcp-3243-profile-switch.mcpproxy-docs.pages.dev |
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Contributor
📦 Build ArtifactsWorkflow Run: View Run Available Artifacts
How to DownloadOption 1: GitHub Web UI (easiest)
Option 2: GitHub CLI gh run download 28133780496 --repo smart-mcp-proxy/mcpproxy-go
|
nlaurance
pushed a commit
to nlaurance/mcpproxy-go
that referenced
this pull request
Aug 12, 2026
…S2) (smart-mcp-proxy#555) * docs(070): Registry — make discovery actual & easy to add to upstream spec Close the search-to-add loop + reach surface parity across Web UI, MCP, CLI (all share the unified AddUpstreamServer path, quarantine-by-default). Real gaps from research: CLI has no registry/search/add commands; Web UI Repositories searches but can't one-click-add; registry list hardcoded/rebuild-only; key-less registries error. Adds unified add-from-registry-result, CLI parity, Web UI loop, MCP convenience, config-driven registry list + cache refresh, and a cross-surface consistency regression. Roadmap PILLAR A. Paperclip goal da399902. * docs(070): plan, research, data-model, contracts, tasks for registry easy upstream-add Phase 0/1/2 speckit design artifacts for spec 070. Research found the search->add loop is already partially closed (Web UI Add button, CLI search/list) but via three divergent normalizations; keystone is one backend AddServerFromRegistry core op all surfaces call, guarded by a cross-surface consistency regression (CN-004/FR-010). No implementation yet — submitted for the per-spec design gate (Gate 2). Related smart-mcp-proxy#746 * docs(070): add registry research-refinement notes for planning * feat(registries): AddServerFromRegistry keystone core op (spec 070) Single backend op that turns a registry reference (registryId + serverId + overrides) into a validated, quarantined upstream server. Every surface (REST/MCP/CLI) will funnel through this one normalization (CN-001); identical input yields an identical persisted config (CN-004). The client sends a reference, never a config blob — the server re-derives it (security D1), so a buggy/compromised client cannot smuggle command/args or disable quarantine. - registries.ServerEntry gains RequiredInputs ([]RequiredInput) - registries.FindServerByID + sentinel errors (registry/server not found) - registries.DetectRequiredInputs: explicit + ${VAR}/$VAR heuristic scan - server.AddServerFromRegistry orchestrator + pure buildServerConfigFromEntry - quarantine-by-default (CN-002, never client-overridable); refusals on no_install_info / missing_required_input / duplicate_name - RegistryAddErrorCode maps errors to stable cross-surface codes Phase 1+2 of MCP-746. Tests: go test ./internal/server/ -run TestAddFromRegistry -race (green); registries input/lookup unit tests; build + linter clean. Co-Authored-By: Paperclip <[email protected]> * feat(070): Web UI one-flow registry search→add (T015-T017) Repoint the registry "Add to MCP" button at the backend keystone instead of parsing install_cmd client-side (CN-001 / issue smart-mcp-proxy#483 class of bug): - T015: new api.addServerFromRegistry(registryId, serverId, {name,env,enabled}) POSTs to /api/v1/registries/{id}/servers/{serverId}/add and surfaces the structured cross-surface error (code + missing_inputs). Removes the old addServerFromRepository install_cmd.split path. - T016: required-input prompt dialog in Repositories.vue — opens on a missing_required_input response, renders one field per missing input (rich decl from search required_inputs[] when present, else bare names), blocks Add until all are filled, resubmits as env. data-test hooks added across the search → add flow. - T017: e2e/playwright/registry-add.spec.ts (search→Add→quarantined + prompt path); pending the live REST route to run green. - types: RequiredInput + RepositoryServer.required_inputs[]. Verified: 5 vitest unit tests green, vue-tsc clean, vite build green. Co-Authored-By: Paperclip <[email protected]> * feat(070): CLI registry list/search/add + REST add-from-registry (US2) Phase 3 of spec 070 — close the discover→add loop on the CLI, the genuine net-new gap. After this a user can: mcpproxy registry list → registry search <q> -r <reg> → registry add <reg> <id> and the server appears quarantined in `mcpproxy upstream list`. - cmd/mcpproxy/registry_cmd.go: `registry list|search|add` Cobra group. list/search are daemon-first with an in-process fallback; add requires the daemon because the keystone op (config derivation + quarantine) is server-side (CN-001 / decision D1). Legacy `search-servers` retained. - internal/cliclient: ListRegistries, SearchRegistry, AddFromRegistry + client-side RegistryAddError carrying the stable code + missing inputs. - internal/httpapi: POST /api/v1/registries/{id}/servers/{serverId}/add wired to the keystone via a new AddServerFromRegistryRef controller method; code→HTTP status mapping (404 not-found, 400 derivation/dup/missing-input). - internal/server: AddServerFromRegistryRef adapter projecting failures onto the cross-surface contracts.RegistryAddError (names missing --env keys). - internal/contracts: AddFromRegistryRequest/Data/AddedServerSummary + RegistryAddError. Tests: cliclient httptest units; server adapter units; CLI e2e against a running daemon + mock registry (list→search→add→quarantined) and the missing-required-input actionable-error path. Note: the REST add route was pulled forward from T014 because the CLI is a thin REST client and the e2e ("add via running daemon") cannot pass without a server endpoint; the frontend wiring (T015/T016) remains for US1. Related smart-mcp-proxy#746 Co-Authored-By: Paperclip <[email protected]> * test(070): fix registry-add Playwright spec route + decouple prompt-test registry T017 follow-up after running the e2e green against a live server: - nav to /ui/repositories (history-mode base /ui/), not a hash route - default the no-input happy path to docker-mcp-catalog (reliably addable) - target the required-input server (default fleur/stripe) independently of the no-input registry, so both tests run from one invocation Verified: both tests pass — search→Add→quarantined and search→Add→prompt→quarantined — against a fresh throwaway core. Co-Authored-By: Paperclip <[email protected]> * feat(070): MCP upstream_servers add_from_registry operation (US3) Adds operation=add_from_registry to the upstream_servers MCP tool so agents can add an upstream from a registry reference (registry + id) without hand-constructing command/args/url. Dispatches to the keystone AddServerFromRegistryRef op: the server re-derives the runnable config from the registry entry and persists it quarantined (CN-001 / CN-002 / security decision D1). New params: registry, id (env_json/name/enabled reuse the existing fields). Success returns the slim AddedServerSummary; failure returns a structured error (isError=true) carrying the same stable Code as REST/CLI plus missing_inputs for missing_required_input (FR-003), so the same failure reads identically across every surface. T012/T013 of spec 070 Phase 4. Tests: internal/server/mcp_add_from_registry_test.go (happy path + missing_required_input structured error). * fix(070): complete add_from_registry MCP op + working tests The prior commit added only the upstream_servers enum/param surface; the dispatch case and handler were missing and the test referenced undefined helpers, so the package did not compile. This wires it up end-to-end: - handleAddServerFromRegistry dispatches to the keystone mainServer.AddServerFromRegistryRef; success -> AddedServerSummary, failure -> structured error (code + missing_inputs, isError=true) matching the REST/CLI surfaces (CN-001). - add_from_registry added to the dispatch switch and the agent-token block list (write-op parity). - Tests use a real runtime-backed mainServer plus an httptest registry (SetRegistriesFromConfig): happy path asserts a quarantined stdio config, missing-input path asserts the structured missing_required_input error with the offending input names. Verified: go test ./internal/server (incl. the two new tests), go build ./..., golangci-lint run ./internal/server/... all pass. * fix(070): correct add_from_registry test harness (NewServer(cfg,logger)) * feat(070): merge built-in registry defaults with config by ID (US4 FR-006) SetRegistriesFromConfig previously replaced the registry list wholesale, so a user who added one custom registry in their config dropped all built-in defaults. Change it to merge defaults union config keyed by ID: defaults first, custom appended, colliding IDs override in place. Extract the five built-in registries into config.DefaultRegistries() as the single source of truth shared by DefaultConfig() and the merge. Add RequiresKey to both RegistryEntry types (plumbing for FR-008). Related smart-mcp-proxy#765 * feat(070): skip key-requiring registry when key absent (US4 FR-008) A registry marked RequiresKey is skipped via ErrRegistryKeyMissing when no API key is configured (env MCPPROXY_REGISTRY_<ID>_API_KEY), instead of running a doomed fetch. SearchServers short-circuits before the network call; FindServerByID inherits the behaviour. Calling surfaces map the sentinel to an 'unavailable' marker so the overall search still succeeds. Related smart-mcp-proxy#765 * feat(070): add Invalidate/Refresh/InvalidatePrefix/Peek to cache manager (US4 FR-007) Primitives for registry cache freshness: Invalidate drops a key, Refresh aliases it (lazy re-fetch), InvalidatePrefix drops all keys under a stable prefix (one refresh clears every tag/query variant of a registry), and Peek returns a record without evicting it even when expired so callers can serve stale data while flagging its age. All stats-accounted. Related smart-mcp-proxy#765 * feat(070): registry cache freshness + refresh endpoint, surface key-absent (US4 FR-007/FR-008) Wire the cache primitives into the registry search path: SearchRegistryServers now caches each (registry,tag,query,limit) result and serves it while flagging age/staleness via contracts.RegistryCacheInfo. Add RefreshRegistryCache + POST /api/v1/registries/{id}/refresh to drop a registry's cached lists on demand. A key-requiring registry with no key configured surfaces as an 'unavailable' marker (HTTP 200) on both the REST search endpoint and the MCP search_servers tool instead of failing the surface (FR-008). Regenerate the OpenAPI spec for the new endpoint and response fields. Related smart-mcp-proxy#765 * docs(070): mark US4 tasks T018-T020 complete Related smart-mcp-proxy#765 * fix(070): copy-on-write config in AddServer to avoid data race AddServer mutated the live immutable config snapshot returned by runtime.Config() in place (currentConfig.Servers = append(...)) before publishing via UpdateConfig. Background goroutines that range cfg.Servers concurrently — LoadConfiguredServers during startup and the 2s-delayed DiscoverAndIndexTools — raced that write, which the -race detector flagged on TestHandleUpstreamServers_AddFromRegistry_HappyPath in CI. Clone the config and its server slice, append to the clone, then publish the new snapshot atomically. Behaviour is unchanged; readers holding the prior snapshot are now isolated, as the immutable-snapshot contract intends. Related smart-mcp-proxy#555 * fix(upstream): route concurrent Config reads through GetConfig (MCP-770) DiscoverTools snapshotted client.Config directly while only holding the Manager's m.mu, but the reconcile add path (AddServerConfig) releases m.mu before calling managed.Client.SetConfig, which guards mc.Config with the client's own mc.mu. The two accesses therefore used different mutexes, producing a data race the -race detector flagged intermittently in CI (PR smart-mcp-proxy#555, run 26719908592). Fix the read side: read config via the mutex-guarded GetConfig() accessor in DiscoverTools and in the API-facing status readers (GetStats, GetTotalToolCount, ListServers) that share the identical hazard — they read client.Config after releasing m.mu and run concurrently with reconcile. mc.mu is a leaf lock (only Get/SetConfig take it, never while holding m.mu), so this is deadlock-safe. Add TestDiscoverTools_ConfigRace: drives AddServerConfig (SetConfig) against the readers concurrently; trips -race before the fix, green after. Related: MCP-770 * fix(upstream): make managed.Client config access atomic (MCP-770) The first MCP-770 fix routed Manager-side reads (DiscoverTools, GetStats, GetTotalToolCount, ListServers) through GetConfig(), but the underlying hazard is broader: managed.Client.Config is a pointer field that SetConfig swaps off m.mu (reconcile add path), while it is read concurrently from many sites that do NOT hold the client's mc.mu — including Client.Connect's unlocked phase (client.go:197) and detached state-change callback goroutines (onStateChange, spawned by StateManager.SetError). The CI -race detector flagged the Connect-vs-SetConfig variant on PR smart-mcp-proxy#555's macOS unit job after the first fix was cherry-picked. A mutex-guarded accessor can't cover this: most internal readers run while mc.mu is already held, so routing them through an RLock GetConfig() would deadlock (sync.RWMutex is not reentrant). Instead make the field itself lock-free and data-race-free: - Replace the exported `Config *config.ServerConfig` field with an unexported `cfg atomic.Pointer[config.ServerConfig]`. - GetConfig() returns cfg.Load(); SetConfig() does cfg.Store(). Both are lock-free and safe whether or not mc.mu is held. - Route every reader through GetConfig() across the managed client, the upstream Manager, and the supervisor actor pool. Add TestConnect_ConfigRace: drives AddServerConfig (SetConfig) against Client.Connect concurrently; trips -race on the old field, green after. Verified: go test -race ./internal/upstream/... ./internal/runtime/... and the original CI victims TestHandleUpstreamServers_AddFromRegistry_HappyPath / _AdminAllowed_WriteOps pass x5 under -race; build + linter clean. Related: MCP-770 * test(070): close mainServer storage so Windows temp-dir cleanup succeeds newAddFromRegistryTestServer opened a real Server (and its BBolt config.db under t.TempDir()) but never closed it. On Windows an open file cannot be unlinked, so t.TempDir's RemoveAll failed the AddFromRegistry tests with "config.db ... being used by another process". Unix unlinks open files, so ubuntu/macOS passed and hid it; the failure only surfaced once the MCP-770 race fix stopped aborting the test binary before cleanup ran. Register t.Cleanup(mainSrv.Shutdown) after t.TempDir() so LIFO cleanup closes the runtime/storage (releasing the handle) before the temp dir is removed. Shutdown is nil-httpServer-safe and idempotent. Related: MCP-770, spec 070 * fix(core): serialize stderr/process monitoring lifecycle (MCP-770) StartStderrMonitoring (from connectStdio during a reconcile-driven Connect) and StopStderrMonitoring (from Disconnect during Manager.ShutdownAll) accessed the monitoring lifecycle fields — stderrMonitoringCtx/Cancel/WaitGroup and the process-monitoring equivalents — with no synchronization. When a connect and a shutdown overlap on the same client, the -race detector flags WG.Add (Start) vs WG.Wait (Stop). CI caught this on PR smart-mcp-proxy#555's ubuntu unit job once the earlier MCP-770 fixes (atomic Config) + the Windows temp-dir cleanup made the test's shutdown path actually run concurrently with reconcile. Add a dedicated monitoringMu that makes the four Start*/Stop*Monitoring methods mutually exclusive, so Add never overlaps Wait. The mutex is a leaf (monitor goroutines never acquire it; it is never held across c.mu), so Stop's bounded WG.Wait under the lock cannot deadlock. Add TestStderrMonitoring_StartStopRace: hammers Start/Stop concurrently; trips -race on the unsynchronized fields, green with monitoringMu. Related: MCP-770, spec 070 * fix(core): per-cycle done channel for monitoring stop (MCP-770) The monitoringMu serialization (prev commit) was incomplete: StopStderr/ StopProcessMonitoring ran WG.Wait() in a DETACHED goroutine guarded by a 500ms timeout. When a real child keeps its stderr open, monitorStderr blocks in scanner.Scan(), the wait times out, Stop returns and releases monitoringMu — but the detached WG.Wait goroutine lives on and races the next connect's WG.Add. CI caught this on smart-mcp-proxy#555 (DiscoverTools→Connect StartStderrMonitoring WG.Add vs the lingering StopStderrMonitoring WG.Wait). Replace the reused sync.WaitGroup with a per-cycle `done chan struct{}` the monitor goroutine closes, and pass the context + done as locals so an abandoned (timed-out) monitor never reads the shared ctx/state a later Start overwrites. Stop now waits on done directly under monitoringMu (no detached waiter) and nils the per-cycle fields. monitorStderr/monitorProcess take ctx as a parameter. Strengthen TestStderrMonitoring with an AbandonedMonitorNoRace case: a blocking pipe keeps the monitor alive so Stop hits the timeout/abandon path — the exact escape the WaitGroup version raced on. AddFromRegistry passes 12x under -race. Related: MCP-770, spec 070 * docs(070): document registry add/refresh surfaces (MCP-788, ENG-9) Kimi's dual-AI review of smart-mcp-proxy#555 returned REQUEST_CHANGES on the missing docs per ENG-9. Add docs for the new registry surfaces: - docs/features/registry-add.md — cohesive feature guide covering all three surfaces (CLI `registry list/search/add`, REST add/refresh/browse endpoints, MCP `upstream_servers` add_from_registry op), the CN-001 re-derivation security model, quarantine-by-default, and the cross-surface missing_required_input error contract. - docs/api/rest-api.md — new Registries section listing the four endpoints (list, search, add, refresh) with request/response shapes, linking the feature guide. Docs only; no code change. Clears Kimi's REQUEST_CHANGES for the Gate-3 merge. Related: MCP-788, MCP-785, MCP-761, spec 070 * fix(registry): gate add_from_registry behind allow_server_add; merge defaults in ListRegistries Address the two Codex Gate-3 review findings on PR smart-mcp-proxy#555 (spec 070). Finding 1 (security): the add_from_registry MCP op persisted a new upstream without the AllowServerAdd check that the ordinary `add` op enforces, so a user who set allow_server_add=false could still add a server by registry reference. Gate add_from_registry behind the same check. Finding 2 (FR-006 consistency): Runtime.ListRegistries returned a hard-coded legacy Smithery entry for an empty config, or only cfg.Registries when set — diverging from the merged defaults+custom source that search/add use. Route it through registries.SetRegistriesFromConfig so the daemon/API list always shows built-in defaults merged with custom entries. Tests-first for both (ENG-1). Related smart-mcp-proxy#555 --------- Co-authored-by: Paperclip <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Profiles v2 — T4: Web UI profile switcher (MCP-3243)
Adds a profile switcher to the Web UI header, consuming the REST
/api/v1/profilessurface shipped in MCP-3241 (#761). V1 shipped URL-only profiles with no Web UI switcher — this is net-new.What it does
PUT /api/v1/profiles/active); empty slug = "All servers" (zero-config default).Surface consumed (MCP-3241)
GET /api/v1/profiles→data.profiles: [{name, servers[], tool_count}]GET /api/v1/profiles/active→data.active_profilePUT /api/v1/profiles/activebody{profile}(empty clears)Changes
frontend/src/types/api.ts—ProfileSummary,ListProfilesResponse,ActiveProfileResponse.frontend/src/services/api.ts—getProfiles/getActiveProfile/setActiveProfile.frontend/src/stores/profiles.ts—useProfilesStore(fetch, setActive,activeLabel/isAllServers).frontend/src/components/ProfileSwitcher.vue— dropdown component (mirrors the MCP-endpoints dropdown pattern).frontend/src/components/TopHeader.vue— wires the switcher into the right-side cluster.Tests / DoD
vue-tsc --noEmitclean.dev→ badge follows → clear back to All servers. Report + screenshots indocs/qa/mcp-3243-profile-switcher/.make buildembed path verified (UI loadsMCPProxy Control Panel, switcher renders).Refs MCP-3243 · Parent MCP-33
🤖 Co-Authored-By: Paperclip [email protected]