#6306 [TUI] Unable add a mcp server to "strata launch" on Linux

open · @code-monkey-101 · 2 commentaires · Sur GitHub

Setup & installServer & APIAMD / HIPNVIDIA / CUDAModels & quantsDocumentationLinux

Description

In my own words:
I'm unable add a mcp server as described [here](https://github.com/Niko1221/Strata/blob/main/docs/DETAILS.md#tools-from-mcp-servers) to my Linux installation which I start with "strata launch". The launcher always deletes it from the config.

The documentation doesn't say  whether it has to go into
~/.local/share/strata/install/strata-<model>.json
~/.local/state/strata/launch/<name>.json
~/.config/strata/profiles/launch-<name>.json
~/.config/strata/launch-presets/<name>.json

It is also unclear where the --mcp-config parameter goes. 
- strata launch doesn't seem to support it
- strata serve doesn't seem to support it
- strata runtime doesn't seem to support it
- It is not listed as an advanced parameter in the launcher UI
- I *think*, the only way is to pass it to run serve/server.py manually

It is also worth noting that the launcher UI also doesn't show the option to limit VRAM usage (--vram-reserve-mib)

In QWEN's words:

# `strata launch` (adopt path) rewrites the run config from scratch and silently drops user keys (`mcp_servers`, `mcp`, `vision`)
## Summary
When `strata launch` cannot set the card up with the built-in installer and falls back to "use the model files I already have", it writes the run config with `strata_cli/launch/adopt.py`. That writer dumps a freshly built dict over the file and never carries over keys it does not manage itself. Every hand-added block — `mcp_servers`, `mcp`, `sampling`, `vision`, `allowed_hosts`, `cors_origins` — is erased on each such launch.
The installer path (`setup.py`) already solves this for re-runs (#629, `write_setup_config` + `carry_over` + `SETUP_KEYS`). The adopt path is a second writer that does not use that mechanism.
## Environment
- Strata Terminal (control) **0.1.61**, engine **0.1.68** (cuda)
- Linux, x86_64
- Launch with already-prepared model files (pack on disk); the launch reports:
  `Used your prepared model files and wrote the run settings (strata-swift-iq3_s.json); this card is not one the built-in downloader sets up. Nothing was downloaded.`
## Steps to reproduce
1. Launch a model. `strata launch` writes `~/.local/share/strata/install/strata-swift-iq3_s.json`.
2. Add MCP servers to that file, exactly as documented in
   [docs/DETAILS.md → Tools from MCP servers](https://github.com/Niko1221/Strata/blob/main/docs/DETAILS.md#tools-from-mcp-servers):
   ```json
   "mcp_servers": {
     "qwen-tts": {
       "command": "/opt/conda/envs/qwen3-tts/bin/python",
       "args": ["-u", "/home/georg/qwen3-tts-mcp/tts_mcp_server.py"]
     }
   },
   "mcp": {"timeout_s": 500, "max_result_chars": 200000, "max_rounds": 8}
   ```
3. Run `strata launch` again.
4. `curl -s http://127.0.0.1:8080/mcp` returns `{"servers": [], "tools": 0}`; the
   "Use tools from MCP servers" row in the chat page disappears (it is hidden when
   there are no servers). Opening the file shows the block is gone.
## Expected
The run config should be re-written the way `setup.py` re-writes it: keys setup does not write are kept, and the user is told what was kept.
```python
# setup.py
# "sampling" or "mcp_servers" block, "allowed_hosts", "cors_origins", "open_browser" —
# and is kept when setup runs again
SETUP_KEYS = frozenset({"exe", "args", "cwd", "tokenizer", ...})
def write_setup_config(cfg_path, cfg, source=None, explicit=None):
    ...
    kept = carry_over(old, cfg, explicit)
    ...
    ok(f"kept from your earlier {old_path.name}: " + ", ".join(kept))
```
## Actual
`strata_cli/launch/adopt.py` builds the config from nothing and writes it whole:
```python
cfg = {"exe": exe, "args": args, "cwd": str(src), "tokenizer": str(tokenizer),
       "model_name": model_name, "log": str(log), "lib_dirs": [], "port": 8080}
...
def write(path: Path, cfg: dict) -> None:
    Path(path).parent.mkdir(parents=True, exist_ok=True)
    Path(path).write_text(json.dumps(cfg, indent=1) + "\n", encoding="utf-8")
```
There is no read of the previous file, no `carry_over`, no `.bak`, no "kept from your earlier …" line. So any key `plan()` does not produce is lost.
Note that the rest of the launch pipeline is fine: `runner.py`'s `derive_config` is
`cfg = json.loads(json.dumps(base))` — a deep copy of the installed config — so MCP
servers *do* reach the private launch config in
`~/.local/state/strata/launch/<name>.json` whenever they are present in the installed
one. The loss happens only at the adopt write.
## Related: vision is turned off by construction
`adopt.py`'s own docstring says it: *"Only the GSQ-RCO families (qwen, swift, coder), Gyro …, Unsloth's sets and the models of the signed feed … are adopted this way; images stay off."*
So an adopted config has no `vision` section, no `--vision` in `args`, and the mmproj is never fetched. The server side is already capable: `serve/server.py` detects a `vision` section without `--vision` in the args and appends it (with `--vram-reserve-mib`). The only missing piece is that nothing writes such a section on this path. A user who previously had pictures working, then launches with prepared files, loses image input with no message explaining why.
## Why this matters
- The feature is documented and supported (`serve/mcp.py`, `hub_from_config`, the chat page's opt-in), so the only thing broken is persistence. It reads as "the launcher does not support MCP".
- `docs/TERMINAL_LAUNCH.md` contains no mention of MCP at all, so a Terminal user has no way to learn that the run config is the place for it, nor that the adopt path regenerates it.
- `strata launch` has no `--mcp-config`, although `serve/server.py` does. On this path the run config is the only place to put servers, and it is the one place that gets wiped.
## Suggested fix
1. Move `SETUP_KEYS` (and the `carry_over` logic) out of `setup.py` into `strata_control`, and call it from `adopt.write()` so both writers share one rule:
   ```python
   def write(path: Path, cfg: dict) -> None:
       path.parent.mkdir(parents=True, exist_ok=True)
       if path.is_file():
           try:
               old = json.loads(path.read_text(encoding="utf-8-sig"))
           except (OSError, ValueError):
               old = None
           if isinstance(old, dict):
               from strata_control import user_keys
               cfg = user_keys.carry_over(old, cfg)     # same rule as setup.py
       path.write_text(json.dumps(cfg, indent=1) + "\n", encoding="utf-8")
   ```
2. Keep the `.bak` copy and print the "kept from your earlier …" line, so the behaviour is visible rather than silent.
3. (Feature request, separate) Let the adopt path honour `--vision`: if the pack contains an mmproj and the engine component ships `strata-vision`, write a `vision` section (gpu when the card is covered, otherwise cpu) instead of forcing images off.
## Workaround that works today
- Start the server from the config without regenerating it:
  `strata serve --config ~/.local/share/strata/install/strata-swift-iq3_s.json`
  or `serve/server.py --engine strata --config <file> --mcp-config <file>`
  (`serve/server.py` accepts `--mcp-config`; `strata launch` does not).
- Patch the launch config `~/.local/state/strata/launch/<name>.json` and start it with
  `strata runtime start --profile launch-<name>`: the runtime reads the profile's
  `source_config` and does not rebuild it.
## How to verify the fix
```bash
python3 -m json.tool ~/.local/share/strata/install/strata-<model>.json   # mcp_servers still there after a launch
curl -s http://127.0.0.1:8080/mcp                                       # servers listed, tools > 0
cd ~/.local/share/strata/components/control/<version>
python3 -m serve.mcp ~/.local/share/strata/install/strata-<model>.json  # prints each server's status and tools
```

Sur le site

Liens install, modèles, releases.