mcp: --mcp / configure mcp --location no longer clobbers other MCP servers - #340
Open
sunishsheth2009 wants to merge 1 commit into
Open
Conversation
…rvers `ucode configure --mcp system.ai.slack` (and `configure mcp --location <s>` / `--services`) removed every other registered MCP server, forcing a full re-run of `configure mcp` to get the built-in ones back. Cause: `_resolve_location_mcp_servers` returned only the services discovered at the target location (+ skills), and `apply_mcp_server_changes` deletes any original server absent from that working set — so external connections, Genie spaces, apps, Vector Search / UC functions, and mcp-services in *other* schemas all got wiped. Fix: scope the replacement to mcp-services *in the target location*. The resolver now carries through every original server that isn't a service in that location (matched via `_is_mcp_service_in_location`, which guards against nested names and schema-prefix lookalikes like `system.aiX`). The location's own services are still strictly replaced (a stale in-location service is removed), and skills stay owned by `configure skills`. Verified via the real resolver: `--mcp system.ai.github` against a config with a custom external + Genie + other-schema service preserves all three and adds the new one. test_mcp.py: 132 pass (rewrote the test that codified the old clobber; added out-of-location preservation, stale-in-location replacement, and `_is_mcp_service_in_location` edge-case coverage). Full suite 1801 passed (2 pre-existing live-gateway e2e failures unrelated). ruff + ty clean. Co-authored-by: Isaac
sunishsheth2009
force-pushed
the
sunish-sheth_data/mcp-flag-no-clobber
branch
from
August 14, 2026 22:27
80295cc to
d221c0a
Compare
sunishsheth2009
marked this pull request as ready for review
August 14, 2026 22:30
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.
Summary
Reported bug: "When I use the CLI parameter for a custom mcp it clears all my existing mcp configurations and I have to rerun configure again to get the built-in ones."
ucode configure --mcp system.ai.slack(anducode configure mcp --location <schema>/--services) removed every other registered MCP server — external connections, Genie spaces, apps, Vector Search / UC functions, and mcp-services in other schemas — leaving only the just-configured location's services. The user then had to re-runconfigure mcpto restore the rest.Cause
_resolve_location_mcp_serversreturned only the services discovered at the target location (plus skills).apply_mcp_server_changesthen removes any original server not present in that working set — so everything outside the location was deleted.Fix
Scope the replacement to mcp-services in the target location. The resolver now carries through every original server that isn't a service in that location, matched by
_is_mcp_service_in_location(which correctly rejects nested names likesystem.ai.sub.xand schema-prefix lookalikes likesystem.aiX.y). Behavior preserved:configure skills(carried through untouched, as before).How do you know it works?
--mcp system.ai.githubagainst a config holding a custom external (jira-mcp), a Genie space, and an other-schema service (main.tools.x) preserves all three and addssystem-ai-github.tests/test_mcp.py, 132 pass): rewrote the test that codified the old clobber (test_replaces_servers_outside_location→test_preserves_servers_outside_the_location), addedtest_replaces_stale_service_within_the_location, and addedTestIsMcpServiceInLocationedge-case coverage (nested names, prefix lookalikes, non-service entries, missing URL).test_e2e_user_agentlive-gateway network tests (fail identically onmain).ruff+ty check src/clean.Independent of the mcp-SDK-compat PR (#338) — different code path.
This pull request and its description were written by Isaac.