ucode MCP cleanup: dedup cursor mcp.json writers (follow-up to #560) - #623
Merged
sunishsheth2009 merged 3 commits intoSep 15, 2026
Merged
Conversation
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
marked this pull request as ready for review
September 15, 2026 02:06
sunishsheth2009
enabled auto-merge (squash)
September 15, 2026 03:45
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.
What
Cleanup follow-up to #560. Two independent tidy-ups:
agents/cursor.pydedup.write_mcp_server_config(stdio proxy) andwrite_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.Move the Claude MCP-registration helpers into
agents/claude.py.add_claude_mcp_server,add_claude_http_mcp_server, andremove_claude_mcp_serverlived inucode.mcpeven though every other agent's registration lives in its ownagents/<agent>.py. They now sit next to the Claude agent, somcp.pydispatches uniformly (claude.X, likecursor.X/opencode.X).MCP_USER_SCOPE,MCP_CLEANUP_SCOPES) move to the leafucode.constantsso bothmcpandagents.claudeimport them with no import cycle (verified both import orders load clean)._is_missing_mcp_server_outputstays inmcp.py(shared by the codex/gemini removers);claude.remove_claude_mcp_serverimports it lazily to avoid themcp -> agents.claudeload cycle — the same lazy-import patternclaude.pyalready used for these helpers.claude.py's web_search register/unregister now call the local helpers directly.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.pyis 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.