remove stale uc securable mcp entries#158
Open
asujithan wants to merge 1 commit into
Open
Conversation
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.
Drop stale system.ai.* MCP entries when UC discovery is disabled
Summary
Follow-up to #151. When
uc_enabledflipstrue → falseon a workspace (typically by re-running plainucode configureafter a previousucode configure --enable-uc), anysystem.ai.*UC MCP service entries that were configured under the previous run linger in~/.ucode/state.jsonand in each agent CLI's MCP config. They keep pointing at/ai-gateway/mcp-services/<name>and look like normal MCPs to the user even though UC discovery is now off.This change adds a one-shot purge that runs as part of
configure_shared_statewhenever the previous workspace state haduc_enabled=trueand the resolved value for this run isfalse:purge_uc_mcp_residue(state)(insrc/ucode/mcp.py) drops every entry whose URL contains/ai-gateway/mcp-services/fromstate["mcp_servers"]and de-registers it from each installed MCP client.configure_shared_statereads the target workspace's persisteduc_enabledonce, then callspurge_uc_mcp_residueon thetrue → falsetransition only. Cross-workspace residue is still handled by the existingpurge_cross_workspace_mcp_residuepath.Non-UC MCP entries (workspace HTTP connections, Genie, Databricks SQL, etc.) are untouched.
Test plan
tests/test_mcp.pycoverpurge_uc_mcp_residue: drops onlysystem.ai.*entries, leaves non-UC MCPs alone, no-ops when there's nothing to drop, removes per-client registrations, and warns once per purge.tests/test_e2e_uc.pyexercises the--enable-uc→ plainucode configureflow against a real workspace and asserts thesystem.ai.*entries disappear from state and from every agent's MCP config.uv run ruff check .uv run pytestUCODE_TEST_WORKSPACE=<ws> uv run pytest tests/test_e2e_uc.py -v