Skip to content

mcp: --mcp / configure mcp --location no longer clobbers other MCP servers - #340

Open
sunishsheth2009 wants to merge 1 commit into
databricks:mainfrom
sunishsheth2009:sunish-sheth_data/mcp-flag-no-clobber
Open

mcp: --mcp / configure mcp --location no longer clobbers other MCP servers#340
sunishsheth2009 wants to merge 1 commit into
databricks:mainfrom
sunishsheth2009:sunish-sheth_data/mcp-flag-no-clobber

Conversation

@sunishsheth2009

Copy link
Copy Markdown
Collaborator

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 (and ucode 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-run configure mcp to restore the rest.

Cause

_resolve_location_mcp_servers returned only the services discovered at the target location (plus skills). apply_mcp_server_changes then 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 like system.ai.sub.x and schema-prefix lookalikes like system.aiX.y). Behavior preserved:

  • The location's own services are still strictly replaced — a stale in-location service that's no longer discovered is removed.
  • Skills connections stay owned by configure skills (carried through untouched, as before).

How do you know it works?

  • Verified via the real resolver: --mcp system.ai.github against a config holding a custom external (jira-mcp), a Genie space, and an other-schema service (main.tools.x) preserves all three and adds system-ai-github.
  • Tests (tests/test_mcp.py, 132 pass): rewrote the test that codified the old clobber (test_replaces_servers_outside_locationtest_preserves_servers_outside_the_location), added test_replaces_stale_service_within_the_location, and added TestIsMcpServiceInLocation edge-case coverage (nested names, prefix lookalikes, non-service entries, missing URL).
  • Full suite: 1801 passed; the only 2 failures are the pre-existing test_e2e_user_agent live-gateway network tests (fail identically on main). 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.

…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
sunishsheth2009 force-pushed the sunish-sheth_data/mcp-flag-no-clobber branch from 80295cc to d221c0a Compare August 14, 2026 22:27
@sunishsheth2009
sunishsheth2009 marked this pull request as ready for review August 14, 2026 22:30
@sunishsheth2009
sunishsheth2009 requested a review from xsh310 August 14, 2026 22:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant