Skip to content

ucode MCP cleanup: dedup cursor mcp.json writers (follow-up to #560) - #623

Merged
sunishsheth2009 merged 3 commits into
databricks:mainfrom
sunishsheth2009:mcp-oauth-cleanup
Sep 15, 2026
Merged

sunishsheth2009 merged 3 commits into
databricks:mainfrom
sunishsheth2009:mcp-oauth-cleanup

Conversation

@sunishsheth2009

@sunishsheth2009 sunishsheth2009 commented Sep 14, 2026

Copy link
Copy Markdown
Collaborator

What

Cleanup follow-up to #560. Two independent tidy-ups:

  1. agents/cursor.py dedup. write_mcp_server_config (stdio proxy) and write_http_mcp_server_config (OAuth HTTP) were byte-for-byte identical except the entry they store, so the read → merge → write logic is factored into a single _upsert_mcp_server(name, entry) helper and both writers are thin wrappers.

  2. Move the Claude MCP-registration helpers into agents/claude.py. add_claude_mcp_server, add_claude_http_mcp_server, and remove_claude_mcp_server lived in ucode.mcp even though every other agent's registration lives in its own agents/<agent>.py. They now sit next to the Claude agent, so mcp.py dispatches uniformly (claude.X, like cursor.X / opencode.X).

    • Shared scope constants (MCP_USER_SCOPE, MCP_CLEANUP_SCOPES) move to the leaf ucode.constants so both mcp and agents.claude import them with no import cycle (verified both import orders load clean).
    • _is_missing_mcp_server_output stays in mcp.py (shared by the codex/gemini removers); claude.remove_claude_mcp_server imports it lazily to avoid the mcp -> agents.claude load cycle — the same lazy-import pattern claude.py already used for these helpers.
    • claude.py's web_search register/unregister now call the local helpers directly.
    • The corresponding unit tests move to tests/test_agent_claude.py.

Why

Removes duplicated JSON-merge logic and puts each agent's MCP-registration code in that agent's module, so mcp.py is orchestration-only.

Testing

uv run pytest tests/test_mcp.py tests/test_agent_claude.py tests/test_agent_cursor.py tests/test_mcp_oauth.py (330 passed); full suite green except 7 pre-existing failures unrelated to this change (smart-routing v2 / e2e-user-agent, fail on master too). ruff format/check + ty clean. Behavior-identical.

This pull request and its description were written by Isaac.

sunishsheth2009 and others added 2 commits September 14, 2026 23:06
write_mcp_server_config (stdio) and write_http_mcp_server_config (OAuth HTTP) were
identical except the entry builder — both now delegate to _upsert_mcp_server, so the
read/merge/write is defined once. Behavior-identical.

Co-authored-by: Isaac <no-reply@databricks.com>
The claude-specific `claude mcp add/add-json/remove` wrappers
(add_claude_mcp_server, add_claude_http_mcp_server, remove_claude_mcp_server)
lived in ucode.mcp even though every other agent's registration lives in its
own agents/<agent>.py module. Move them next to the Claude agent so mcp.py
dispatches uniformly (claude.X, like cursor.X / opencode.X).

- Shared MCP scope constants (MCP_USER_SCOPE, MCP_CLEANUP_SCOPES) move to the
  leaf ucode.constants so both mcp and agents.claude import them with no cycle;
  claude.py's default args can then reference them at module load.
- _is_missing_mcp_server_output stays in mcp.py (shared by the codex/gemini
  removers); claude.remove_claude_mcp_server imports it lazily to avoid the
  mcp -> agents.claude load cycle (the same pattern claude.py already used).
- claude.py's web_search register/unregister now call the local helpers
  directly instead of lazily importing them from mcp.
- Relocate the corresponding unit tests to tests/test_agent_claude.py.

Co-authored-by: Isaac <no-reply@databricks.com>
@sunishsheth2009
sunishsheth2009 marked this pull request as ready for review September 15, 2026 02:06

@xsh310 xsh310 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@sunishsheth2009
sunishsheth2009 enabled auto-merge (squash) September 15, 2026 03:45
@sunishsheth2009
sunishsheth2009 merged commit 92ccedb into databricks:main Sep 15, 2026
16 checks passed
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.

2 participants