Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/ucode/mcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,8 +487,8 @@ def configure_client_mcp_server(
claude.add_claude_mcp_server(name, argv, MCP_USER_SCOPE, always_load=always_load)
return removed_scopes
if client == "codex":
removed = remove_codex_mcp_server(name)
add_codex_mcp_server(name, argv)
# Codex filters subprocess env; forward auth names without persisting their values.
removed = codex.write_user_mcp_servers({name: codex.managed_mcp_entry(argv)}, {name})
return [MCP_USER_SCOPE] if removed else []
if client == "gemini":
removed = remove_gemini_mcp_server(name)
Expand Down
4 changes: 3 additions & 1 deletion tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,9 @@ unit checks mock the sudo write. `integration/test_ug_configure_scope.py` covers
`test_mcp.py` and `test_cli.py` cover Claude/Codex MCP setup without their CLIs:
finding an existing config, creating one with `--agents`, and reporting status
from the file. They also check malformed config errors and stale client choices.
They use temporary files; real desktop apps remain untested.
Codex stdio registration with the CLI installed also forwards authentication variable names,
never their values, while preserving personal settings and replacing obsolete transport fields.
These component checks use temporary files; native desktop coverage is listed below.

`test_integration_contract.py` checks that isolated test sessions set Antigravity's
`AGY_CLI_DISABLE_AUTO_UPDATE` to the required literal `true`, overriding an inherited `1`.
Expand Down
4 changes: 4 additions & 0 deletions tests/integration/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,10 @@ accessibility tree captured before the fatal error in command evidence.
Automation: each screen gets 60 seconds and the answer four minutes, with no retries, and it saves
a screenshot of the app window as evidence. It also requires the app's model picker to list only
the managed model, under its readable name (`5.6 Sol`) rather than the raw id.
`../test_mcp.py` checks that Codex stdio registration forwards authentication environment names
without persisting credentials, including with the CLI installed, and preserves unrelated config.
Those are component checks, not native MCP startup proof.

`scripts/run_integration.py` ignores both modules unless `--desktop-app` is passed, which only the
desktop CI jobs do, so a local run never drives a developer's installed app.

Expand Down
39 changes: 39 additions & 0 deletions tests/test_mcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import json
import re
import threading
import tomllib
from unittest.mock import MagicMock

import pytest
Expand Down Expand Up @@ -201,6 +202,44 @@ def test_saved_client_without_cli_or_config_needs_explicit_selection(self, monke


class TestAddCodexMcpServer:
def test_registration_forwards_auth_names_without_persisting_credentials(
self, tmp_path, monkeypatch
):
path = tmp_path / "config.toml"
path.write_text(
'model = "personal-model"\n[mcp_servers.personal]\ncommand = "personal-tool"\n'
'[mcp_servers.github]\nurl = "https://old.example/mcp"\n'
)
monkeypatch.setattr(mcp.codex, "user_mcp_config_path", lambda: path)
monkeypatch.setattr(mcp.shutil, "which", lambda binary: f"/tools/{binary}")
monkeypatch.setattr(mcp, "_oauth_http_client", lambda *a, **kw: None)
monkeypatch.setenv("DATABRICKS_BEARER", "secret-bearer-value")
monkeypatch.setenv("DATABRICKS_BEARER_COMMAND", "secret-command-value")
monkeypatch.setenv("DATABRICKS_CONFIG_FILE", "private-config-path")
monkeypatch.setattr(
mcp.subprocess_cross_os, "run", lambda *a, **kw: MagicMock(returncode=0)
)

assert mcp.configure_client_mcp_server("codex", "github", GH_URL, WS, "p") == [
mcp.MCP_USER_SCOPE
]

contents = path.read_text()
config = tomllib.loads(contents)
assert config["model"] == "personal-model"
assert config["mcp_servers"]["personal"] == {"command": "personal-tool"}
assert config["mcp_servers"]["github"] == {
"command": "/tools/ug",
"args": PROXY_TAIL,
"env_vars": [
"DATABRICKS_BEARER",
"DATABRICKS_BEARER_COMMAND",
"DATABRICKS_CONFIG_FILE",
],
}
for secret in ("secret-bearer-value", "secret-command-value", "private-config-path"):
assert secret not in contents

def test_registers_stdio_proxy_command(self, monkeypatch):
calls: list[dict] = []

Expand Down
Loading