Skip to content

fix(mcp): default new servers to the selected project - #1954

Closed
Linuxdazhao wants to merge 2 commits into
vastsa:mainfrom
Linuxdazhao:codex/mcp-project-default-upstream-20261028-01a18190
Closed

Linuxdazhao wants to merge 2 commits into
vastsa:mainfrom
Linuxdazhao:codex/mcp-project-default-upstream-20261028-01a18190

Conversation

@Linuxdazhao

@Linuxdazhao Linuxdazhao commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

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 level and projectPath to select the owner and omit the ignored legacy scope field. Host still accepts that compatibility input and derives the returned record scope itself.

Closes #1953.

Validation:

  • The original interaction fixtures reproduce two failures on 93620a806354 before the ownership fix.
  • 19 focused tests pass across mcp-create-scope, mcp-market-install-owner, mcp-market-panel, and mcp-editor-timeout. They cover real draft serialization, create/edit/market ownership, explicit filters, project changes, missing selections, and omission of the ignored scope input.
  • Desktop TypeScript 5.9.3 typecheck, whitespace checks and the latest-base gate pass.
  • IPC specification and the existing E2E scenario are updated. Native Electron E2E was not run locally; this uses existing Host calls and preserves ownership behavior.

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 muzimu217 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.
@Linuxdazhao

Copy link
Copy Markdown
Contributor Author

Addressed in f4ab2ba.

Removed the ignored scope input from both editor draft serialization and marketplace upserts, along with the market-only GLOBAL_SCOPE import and projectPath! assertion. The existing interaction tests now verify level/projectPath ownership and that the outgoing payload has no scope field. Host compatibility handling and derived record scopes remain unchanged.

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.

vastsa commented Oct 29, 2026

Copy link
Copy Markdown
Owner

Thanks for the careful ownership tests. I verified the current Settings contract: docs/spec/04-ux/06-settings-ia.md explicitly says new capabilities created under All go to Global, and the Add tooltip names that destination. Changing All to follow the selected project changes that documented default, so the central change here is a feature request rather than a fix. The temporary contribution policy accepts outside fix/perf PRs only, and I cannot merge this combined change under a fix title. The marketplace path under an explicit Project filter appears separable; please submit that as a focused fix with its own reproduction while retaining the current All default. I’m closing this PR under the current policy. Thank you for the work.

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.

[Bug] MCP creation under All ignores the selected project and defaults to global

3 participants