Skip to content

feat(installer): save the MCP tool profile once for every launch path - #836

Merged
sumithr merged 6 commits into
mainfrom
feat/issue-809-profile-launch-paths
Oct 4, 2026
Merged

sumithr merged 6 commits into
mainfrom
feat/issue-809-profile-launch-paths

Conversation

@sumithr

@sumithr sumithr commented Oct 4, 2026 •

Copy link
Copy Markdown
Owner

Summary

The MCP tool profile (core / full) could only be set per launch through SUMO_QA_MCP_PROFILE, so each launch path (direct CLI, pip/uvx, the Claude and Codex plugins, installer-written VS Code and Claude Desktop entries, JetBrains/Junie) needed its own env, and the plugin entry could not carry one at all. There is now one saved profile file, <global data dir>/sumo-qa/mcp-profile, written by sumo-qa-install --profile core|full. Every launch reads it when SUMO_QA_MCP_PROFILE is unset; the env var still overrides it for one launch.

Related issue

Closes #809

Changes

  • src/sumo_qa/tool_registry.py: resolve_profile(env) reads env, then the saved file, then defaults to full. An invalid or unreadable file is a config error naming the file. The file is read as UTF-8 (BOM tolerated) or UTF-16 with a BOM, so a PowerShell-written file works.
  • src/sumo_qa/server.py and the skill tools/resources/load_skill_context: the profile is resolved once in main() and passed through, so a file changed mid-session cannot make skill tools disagree with tools/list or sumo_qa_capabilities.
  • src/sumo_qa/paths.py: mcp_profile_path(env) / _global_root(env) resolve the data dir from a given env, so the doctor checks the file the launched server reads. On Windows the LOCALAPPDATA fallback resolves the home from that env exactly as ntpath.expanduser does (case-insensitive names, USERPROFILE, then HOMEDRIVE+HOMEPATH).
  • src/sumo_qa/installer.py: --profile core|full saves the file (temp file in the same dir + os.replace, umask mode, works through a symlinked data dir), then configures hosts as before. --profile with --uninstall is rejected. A warning is printed when the shell's SUMO_QA_MCP_PROFILE differs from the saved value. The install verify builds the profile it is keyed on.
  • src/sumo_qa/doctor.py: an invalid saved profile points at sumo-qa-install --profile; the Claude Desktop probe drops the shell's XDG_DATA_HOME like a GUI launch does.
  • tests/conftest.py, scripts/regen_tools_list_snapshot.py: every test and the snapshot regen use an empty data dir, so a developer's saved profile cannot change what they build; temp dirs are cleaned up.
  • Docs: docs/CONFIGURATION.md (Tool profiles: precedence, per-host coverage, plugin-only hand-written file incl. PowerShell encoding, XDG_DATA_HOME caveat), docs/INSTALL.md, AGENTS.md, docs/TOOLS.md.

Drift from the issue text (recorded on #809): the profile was env-only before this; the installer writes no JetBrains config (it prints Settings UI steps, Junie's entry is hand-written), so those use the direct-CLI path; the plugin path launches through uvx and needs the network, so the suite cannot run it (manual evidence below).

How it was verified

  • tests/test_e2e_mcp_initialize.py::test_every_launch_path_serves_the_saved_profile_across_a_restart: direct CLI/JetBrains/Junie, installer-written VS Code and Claude Desktop entries, and the plugin .mcp.json env, each launched twice; active_profile is core and tools/list equals the core set. A reviewer's five mutants (a path ignoring the file, an entry env overriding it, a redirected data dir) each fail it.
  • Red/green for every fix round: resolver precedence, BOM/UTF-16, profile pinned at build time (rewriting the file mid-session no longer changes skill tools), doctor reading the entry's data dir, the Claude Desktop probe, --uninstall --profile, the shell-override warning, atomic save (prior file intact, no temp left), symlinked data dir, umask mode.
  • Real runs (temp HOME and cwd, clone venv): sumo-qa-install --profile core --vscode saved core, the written VS Code entry launched with active_profile=core and 40 tools matching tools/list; rewriting the file to full and bogus mid-session left core and no traceback; a symlinked data dir saved with mode 0644. uvx --from <checkout> sumo-qa (plugin path) from an empty uv cache, launched twice: core, 40 tools, matching.
  • CI on the final head (fc04e813): all 28 checks green incl. Windows; mutation gate run 37202436773 green (0 survivors); pre-push full suite and scoped mutmut passed; mypy clean.
  • Behaviour on the real surface: every launch path (direct CLI, uvx, the plugin .mcp.json, the installer-written VS Code entry, the JetBrains command and Junie JSON) launched twice from a clean venv serves the saved core profile with the exact 40-tool core set; SUMO_QA_MCP_PROFILE=full overrides for one launch; origin/main serves full from the same file. Full ledger in the proof comment.
  • Review: sumo-qa per-file review of every changed file and /code-review high on the whole diff, then on each fix delta (6 rounds). Fixed along the way: per-call profile re-reads, the doctor's data-dir mismatch, the Claude Desktop probe, BOM/UTF-16 files, --uninstall --profile, non-atomic save, temp-dir leaks, a symlinked data dir being refused, the Windows fallback home ignoring the supplied env (review bot), and doc wording for --profile and Junie.

Not changed, noted for later: if mcp-profile itself (not its directory) is a symlink, the save replaces the link with a regular file; an interrupt (Ctrl-C) between creating the temp file and the replace can leave a harmless .mcp-profile.<id>.tmp; a re-save resets an existing file's mode to the umask default; no retry if a Windows reader briefly holds the file; no directory fsync after the replace; --uninstall removes host configuration only and leaves the saved mcp-profile; the sumo_qa_capabilities activation hint still names only SUMO_QA_MCP_PROFILE=full; --profile saves for the installer's own environment, so a host entry that overrides LOCALAPPDATA/USERPROFILE/XDG_DATA_HOME reads a different file (the doctor now reports that correctly).

Checklist

  • PR title follows Conventional Commits
  • Tests pass locally (pytest) and lint/type checks are green (pre-commit run --all-files, python -m mypy)
  • Added or updated tests covering the change
  • Updated the relevant docs in this same PR
  • No breaking changes (or they are called out above)

The server resolved its profile only from SUMO_QA_MCP_PROFILE, so each
launch path (direct CLI, the uvx plugins, installer-written host entries,
JetBrains/Junie) had to carry the env var itself, and the shipped plugin
.mcp.json could not carry one at all.

The server now falls back to a saved profile file in the global data dir
(<data dir>/sumo-qa/mcp-profile) when the env var is unset or empty; the
env var still overrides it for one launch. `sumo-qa-install --profile
core|full` writes the file, so the choice reaches every host and survives
a restart. An unknown value in the file stops the server naming the file,
and the doctor points at the installer flag to fix it.

The test suite and the snapshot regen script use an empty data dir, so a
developer's saved profile never changes what they build or pin.

Closes #809
…ch host does

- The server resolves the profile once in main() and passes it through
  build_mcp_server to the skill tools, load_skill_context and the skill
  resources, so a mid-session edit of the saved file can no longer make them
  disagree with tools/list or raise.
- The doctor finds the saved file from the probed entry's env
  (XDG_DATA_HOME / LOCALAPPDATA / HOME), and the Claude Desktop probe drops
  the shell's XDG_DATA_HOME as the GUI app does.
- The saved file is read as utf-8-sig; a non-UTF-8 file is refused naming it.
- --profile is rejected with --uninstall, warns when the shell's
  SUMO_QA_MCP_PROFILE overrides it, writes atomically and reports an
  unwritable path in one line.
- The suite's and the regen script's temp data dirs are removed.
- Docs: --profile also configures every detected host; Junie's entry is
  hand-written.
…mode

- resolve_profile decodes the saved file by BOM: UTF-16 (PowerShell 5.1 `>`)
  or UTF-8; the undecodable-file error now says how to rewrite it by hand
- _required_tool_names_for builds the profile it is cached on
- --profile saves through ingest's _write_atomic and gives the file the
  umask mode instead of the temp file's 0600
- CONFIGURATION.md: a host without the shell's XDG_DATA_HOME reads the default dir
- conftest: unconfigure cleans up only when configure ran

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0033a60563

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/sumo_qa/paths.py Resolved
Match env names case-insensitively (last-written spelling wins) and mirror
ntpath.expanduser: USERPROFILE if present even empty, else HOMEDRIVE joined
to HOMEPATH if HOMEPATH is present, else Path.home().
@sumithr

sumithr commented Oct 4, 2026

Copy link
Copy Markdown
Owner Author

Merge-readiness evidence, head fc04e813

CI: all 28 checks green on fc04e8136a9d617965102e64cb8a0897de0ad78d (pytest on ubuntu/macOS/Windows py3.10 to py3.14, plugin-dir handshake, install-smoke, mypy, ruff, CodeQL).

Mutation gate: triggered (tests/**). Run 37202436773: every module at or above baseline, 0 survivors, strict gate passed.

Review threads: 0 open. The review bot's P2 (Windows fallback home ignored the supplied env) is fixed in 4ae06d92 and fc04e813 (the fallback now resolves the home exactly as ntpath.expanduser does, with case-insensitive env names) and the thread is resolved.

Per-file review (sumo-qa reviewing_before_merge, each changed file's full content vs origin/main): SAFE on every file (tool_registry.py, paths.py, installer.py, server.py, skill_prompts.py, skill_resources.py, skill_manifest.py, doctor.py, the regen script, 8 test files, 4 docs). Two low notes kept as "noted for later" in the PR body.

/code-review (high): whole diff, then every fix delta (6 rounds). Fixed along the way: per-call profile re-reads, the doctor's data-dir mismatch, the Claude Desktop probe, BOM/UTF-16 profile files, --uninstall --profile, non-atomic save, temp-dir leaks, a refused symlinked data dir, the Windows fallback home, and doc wording.

Behavioural verification (step 4.7), 8 of 8 rows met. Branch wheel and origin/main wheel each in a clean venv; every launch with a temp HOME, unset XDG_DATA_HOME/SUMO_QA_MCP_PROFILE, cwd a fresh clone of this repo; core saved once with sumo-qa-install --profile core.

# launch path observed (each launched twice) met
1 direct CLI active_profile: core, tools/list = the 40-tool core set yes
2 uvx --from <wheel> (empty uv cache) core / 40, both launches yes
3-4 shipped .mcp.json (Claude Code and Codex plugins both point at it) core / 40, both launches yes
5 installer-written VS Code entry core / 40, both launches yes
6 JetBrains command the installer prints; Junie JSON from docs/INSTALL.md core / 40, both launches yes
7 survives restart; discovery matches tools/list every path, both launches yes
8 SUMO_QA_MCP_PROFILE=full overrides for one launch full / 48, next launch back to core yes

Control: origin/main reading the same saved file serves full/48. Real agent: a headless haiku agent on the VS Code entry reported active_profile: core (40 mcp__sumo-qa__* tools in its session). Existing flow: using_sumo_qa, sumo_qa_load_classifications and sumo_qa_capabilities byte-identical on branch and origin/main with no saved profile. Evals: not run, no eval config loads the changed modules and the served skill bodies are byte-identical.

Acceptance criteria (#809): both met. One config source for every launch path (env, then the saved file, then full); a per-path smoke test (tests/test_e2e_mcp_initialize.py::test_every_launch_path_serves_the_saved_profile_across_a_restart) plus the real runs above. Drift recorded on #809: JetBrains/Junie use the direct-CLI path; the real uvx plugin launch is evidenced manually.

@sumithr
sumithr merged commit b9215a8 into main Oct 4, 2026
29 checks passed
@sumithr
sumithr deleted the feat/issue-809-profile-launch-paths branch October 4, 2026 12:46
sumithr added a commit that referenced this pull request Oct 4, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.74.0](v0.73.1...v0.74.0)
(2026-10-04)


### Features

* **installer:** save the MCP tool profile once for every launch path
([#836](#836))
([b9215a8](b9215a8))
* **release:** ship SBOM, build provenance and digests, and pin every
action to a commit SHA
([#838](#838))
([df310e6](df310e6))


### Miscellaneous Chores

* **evals:** grade a judge reply only when its verdict is unambiguous,
retry once, and keep the reply
([#839](#839))
([237ea59](237ea59))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

---------

Co-authored-by: release-please[bot] <release-please[bot]@users.noreply.github.com>
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.

[Task]: resolve the MCP profile identically across every launch path

1 participant