Add Cursor as an MCP client#192
Open
sunishsheth2009 wants to merge 2 commits into
Open
Conversation
7e10377 to
a40057e
Compare
rohita5l
previously approved these changes
Jul 9, 2026
Every coding agent now registers Databricks MCP servers as one identical local
stdio command — `ucode mcp-proxy --url <endpoint> --host <ws> --profile <p>` —
instead of per-client HTTP-bearer entries. This replaces five divergent auth
paths (claude `${OAUTH_TOKEN}` header, codex `--bearer-token-env-var`, gemini
`--header`, opencode `{env:OAUTH_TOKEN}`, copilot `Bearer ${OAUTH_TOKEN}`), none
of which refreshed the token mid-session, with a single mechanism.
Why a proxy: MCP clients disagree on HTTP-auth config and none expose a
per-request auth hook (except Claude's headersHelper), so a static bearer froze
at launch and expired after ~1h. A local stdio proxy sidesteps all of that: the
client spawns it as a child process (and reaps it — ucode owns no long-lived
process or refresh thread), and the proxy mints a fresh OAuth token from the
Databricks CLI profile on every upstream request. The proxy is an invisible
implementation detail baked into each client's config; users never invoke it.
- src/ucode/mcp_proxy.py (new): stdio<->streamable-HTTP bridge built on the
official `mcp` SDK. `httpx.Auth` injects a fresh `get_databricks_token(...)`
bearer per request; a transport-level pump forwards messages both ways, so new
MCP methods/capabilities pass through untouched.
- cli.py: hidden `ucode mcp-proxy --url --host --profile --use-pat` command.
- databricks.py: `build_mcp_proxy_argv(...)` (mirrors build_auth_token_argv).
- mcp.py: add_{claude,codex,gemini}_mcp_server + opencode/copilot writers now
register the stdio proxy argv; removed build_mcp_http_entry / OAUTH_TOKEN
header. add_claude_mcp_server stays polymorphic so the web_search stdio entry
(a dict with its own env) still registers via add-json.
- pyproject: add `mcp>=1.28.0`.
Verified against a live workspace: `ucode mcp-proxy` handshakes stdio and returns
the endpoint's tools (initialize OK, tools/list OK); ucode's real codex
registration lists the proxy as an enabled stdio server. Tests: 864 pass
(2 pre-existing e2e network failures unrelated); ruff + ty clean.
Co-authored-by: Isaac
Cursor runs models on the user's own Cursor account, so ucode configures no models for it. It registers Databricks MCP servers in ~/.cursor/mcp.json using the same uniform mechanism as every other client: a local stdio server that runs `ucode mcp-proxy`, which mints a fresh OAuth token per request. So Cursor needs no token in its config and no launch-time token export. - agents/cursor.py: build/write/remove ~/.cursor/mcp.json entries + thin launch() - mcp.py: register cursor in MCP_CLIENTS + MCP_ONLY_CLIENTS; configure/remove branches - cli.py: `ucode cursor` launcher; accept `cursor` in `--agents` - README + tests (test_agent_cursor.py, cursor coverage in test_mcp.py) Co-authored-by: Isaac
a40057e to
05e841f
Compare
Author
|
Reworked on top of the uniform Dependency: this PR is stacked on #201 — merge that first. Until #201 lands, its proxy commit appears in this PR's diff. What changed from the earlier revision:
Re-verified end-to-end against |
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
Adds Cursor as an MCP client in ucode, so
ucode configure mcpcan register Databricks managed MCP servers into~/.cursor/mcp.json, plus aucode cursorlauncher.Cursor is MCP-only:
cursor-agentruns models on the user's own Cursor account and exposes no gateway base URL, so ucode configures no models for it (it stays out ofagents.__init__._MODULES). What ucode does is register Databricks MCP servers in Cursor's config via the existingucode configure mcpflow.Auth: the uniform
ucode mcp-proxybridge (no per-client logic)This PR is reworked on top of the
ucode mcp-proxyfoundation (#201). Cursor uses the exact same mechanism as every other client: each Databricks MCP server is registered as a local stdio server that runsucode mcp-proxy, which bridges to the Databricks streamable-HTTP endpoint and mints a fresh OAuth token per request. So there is no literal token in~/.cursor/mcp.json, no${env:...}expansion, and no background refresh thread — Cursor just spawns the proxy like any stdio server, and auth never expires mid-session.This also sidesteps the earlier DCR failure: with no bearer in the config,
cursor-agentdoesn't attempt the dynamic-client-registration flow that Databricks managed MCP doesn't support.Changes
src/ucode/agents/cursor.py(new):build_mcp_server_entry(argv)→{command, args}stdio entry;write_/remove_mcp_server_configmerge surgically into the shared~/.cursor/mcp.json(preserving the user's own entries);launch()is a thinexecofcursor-agent(no token wiring — the proxy authenticates itself).src/ucode/mcp.py: registercursorinMCP_CLIENTS; configure/remove branches dispatch the proxy argv to cursor;MCP_ONLY_CLIENTSso cursor is eligible whenevercursor-agentis installed (it never lands inavailable_tools).src/ucode/cli.py:ucode cursorlauncher; acceptcursorin--agents(partitioned out of the model-agent path, workspace-only configure).src/ucode/agents/__init__.py: comment documenting why cursor is intentionally not a model-routing agent.tests/test_agent_cursor.py, cursor coverage intests/test_mcp.py) + README.Verification
Verified end-to-end against a live workspace (
uc-dogfood,e2-dogfoodUC):ucode mcp-proxystdio handshake against.../api/2.0/mcp/functions/system/ai:initialize→DatabricksMCPServer,tools/list→ 4 live tools (system__ai__ai_classify,ai_extract,ai_parse_document,python_exec).configure_client_mcp_server("cursor", ...)through the real code path writes the correct{command, args}proxy entry into~/.cursor/mcp.json(merging, not clobbering).cursor-agentis installed and reads~/.cursor/mcp.json; the registered entry is the proxy argv, so auth is handled byucode mcp-proxyper request.uv run pytest→ 876 passed (2 pre-existingtest_e2e_user_agentnetwork failures unrelated to this change);uv run ruff format --checkanduv run ty check src/clean.This pull request and its description were written by Isaac.