Repository navigation
fix(mcp): default new servers to the selected project - #1954
Linuxdazhao wants to merge 2 commits into
Conversation
Use the selected project for new MCP definitions under All, while honoring explicit Global/Project filters and retaining existing definition owners. Forward the same destination into marketplace installation and scope its installed ids to that owner. Add renderer interaction coverage through the real draft serializer and market install action, including missing-project refusals, explicit global ownership and project changes. Update the Settings specification and E2E scenario. Closes vastsa#1953. Validation: 44 targeted tests and desktop TypeScript 5.9.3 typecheck pass after an isolated frozen install and workspace dependency build for the pinned 1.4.0 runtime. No native Electron E2E or live provider/MCP endpoint calls were run.
muzimu217
left a comment
There was a problem hiding this comment.
The ownership rule is the right one and the guard is in the right place: filter === "project" || (filter === "all" && selectedProjectPath) means an explicit Project choice wins, All follows the selected project, and with no project selected it stays global — which is the only sane fallback. Disabling creation when the target is project-without-a-project, and refusing a marketplace install with a missing project instead of silently writing globally, is the important half: the bug was that a project selection could be dropped without telling anyone.
One thing I would remove or annotate before this lands: the scope field passed on create is inert.
McpServerInput does accept scope (crates/host-core/src/mcp_servers.rs:96), but nothing in create reads input.scope — the record's scope is derived from the level and owner project at mcp_servers.rs:262 (scope: scope_for(level, owner_project_path.as_deref())), and set_scope is deliberately a no-op for all three capability kinds. So scope: level === "global" ? GLOBAL_SCOPE : { mode: "projects", projects: [projectPath!] } travels over IPC, is deserialized, and is then ignored.
It is harmless today, but it reads as the thing that decides the owner, and the next person to touch this will assume removing it changes behaviour. Either drop the field from the create payload (level + projectPath already carry the whole decision) or add one line saying it is accepted for symmetry and not consulted. I would drop it: the non-null assertion on projectPath! also disappears with it.
The two regression fixtures reproducing the pre-fix behaviour on 93620a806 are what makes this reviewable, and covering marketplace installation through the same destination is the part that would otherwise have been missed.
Address the review on vastsa#1954: level and projectPath select the owner, and Host derives the returned scope. Drop the unused input from editor draft serialization and market installation, together with the market-only GLOBAL_SCOPE import and projectPath non-null assertion. Existing interaction tests assert owner fields and omission of scope. Update the IPC contract and E2E scenario while retaining the Host compatibility field. Validation: 19 focused MCP tests, desktop TypeScript 5.9.3 typecheck and whitespace checks pass. No native E2E or live endpoint calls were run.
|
Addressed in f4ab2ba. Removed the ignored All 19 focused MCP create/edit/market tests and the desktop TypeScript check pass. The IPC specification and E2E scenario now state the ownership rule explicitly. |
|
Thanks for the careful ownership tests. I verified the current Settings contract: |
With All selected in Settings > MCP, adding a server ignores the selected project and saves globally. All now defaults creation and inline import to the selected project; explicit Global/Project choices and existing definitions retain their owners. Marketplace installation receives the same destination and refuses a missing project instead of writing globally.
Editor and market upsert payloads use
levelandprojectPathto select the owner and omit the ignored legacyscopefield. Host still accepts that compatibility input and derives the returned record scope itself.Closes #1953.
Validation:
93620a806354before the ownership fix.mcp-create-scope,mcp-market-install-owner,mcp-market-panel, andmcp-editor-timeout. They cover real draft serialization, create/edit/market ownership, explicit filters, project changes, missing selections, and omission of the ignored scope input.