Skip to content

feat(ai-mcp): block MCP server autostart in untrusted workspaces#16891

Merged
ndoschek merged 2 commits intomasterfrom
GH-16872
Jan 29, 2026
Merged

feat(ai-mcp): block MCP server autostart in untrusted workspaces#16891
ndoschek merged 2 commits intomasterfrom
GH-16872

Conversation

@ndoschek
Copy link
Member

What it does

Resolves GH-16872

This PR integrates workspace trust into the MCP autostart logic:

  • MCP servers defined at the workspace/folder scope are blocked from autostarting in untrusted workspaces
  • User-level MCP servers continue to start regardless of the trust state, as they are user-controlled
  • When workspace trust is granted, previously blocked servers are automatically started
  • When trust is revoked, workspace-scoped servers are stopped

Additionally, this introduces a WorkspaceRestrictionContribution API, allowing packages to contribute information about restricted features to the "Restricted Mode" status bar tooltip.

Remark: This might be replaced later on by a separate Restricted Mode view widget to control different functions and give better overview later on, but for now the information should be sufficient in the status bar item tooltip.

How to test

  1. Create a new test folder with .theia/settings.json containing an mcp server definition, e.g.:
     {
       "ai-features.mcp.mcpServers": {
          "Context7": {
             "type": "http",
             "serverUrl": "https://mcp.context7.com/mcp",
             "autostart": true
          },
       }
     }
  1. Open the folder in Theia - workspace trust dialog should appear
  2. Choose "Don't Trust"
  3. Open the AI Configuration view (Alt+a) and verify the MCP server does NOT start
  4. Check the "Restricted Mode" status bar item tooltip: it should list the blocked MCP server(s)
  5. Grant trust via the status bar item: verify the MCP server starts automatically
  6. Also verify that user-level MCP servers (in user settings) still start regardless of trust state
  7. Optional: You can also toggle the trust state via the command Manage Workspace Trust

Follow-ups

  • Consider moving restricted mode details to a dedicated view widget for better overview and possible actions (e.g., selectively enabling features). The tooltip seems to be sufficient for now.

Breaking changes

  • This PR introduces breaking changes and requires careful review. If yes, the breaking changes section in the changelog has been updated.

Attribution

Review checklist

Reminder for reviewers

@github-project-automation github-project-automation bot moved this to Waiting on reviewers in PR Backlog Jan 27, 2026
Comment on lines +64 to +69
`The workspace trust feature is currently under development in Theia.

If you trust the authors, code in this folder may be executed.

If not, some features will be disabled. Please note that not all features are yet integrated with workspace trust (e.g., debug, tasks).
Check the 'Restricted Mode' indicator in the status bar for details.`
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
`The workspace trust feature is currently under development in Theia.
If you trust the authors, code in this folder may be executed.
If not, some features will be disabled. Please note that not all features are yet integrated with workspace trust (e.g., debug, tasks).
Check the 'Restricted Mode' indicator in the status bar for details.`
`If you trust the authors, code in this folder may be executed.
If not, some features will be disabled.
The workspace trust feature is currently under development in Theia; not all features are integrated with workspace trust yet.
Check the 'Restricted Mode' indicator in the status bar for details.`

Comment on lines +197 to +217
protected getWorkspaceScopedServerNames(): Set<string> {
const workspaceScopedNames = new Set<string>();

const inspection = this.preferenceService.inspect<JSONObject>(MCP_SERVERS_PREF);
if (!inspection) {
return workspaceScopedNames;
}

if (inspection.workspaceValue) {
for (const name of Object.keys(inspection.workspaceValue)) {
workspaceScopedNames.add(name);
}
}

if (inspection.workspaceFolderValue) {
for (const name of Object.keys(inspection.workspaceFolderValue)) {
workspaceScopedNames.add(name);
}
}

return workspaceScopedNames;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it makes sense that these are the servers we'd really want to make sure don't autostart, but maybe it would make sense not to autostart any MCP servers, even though specified in user scope if workspace trust is denied? Basically, it's hard to know how the servers / LLM's using them might interact with malicious content in a workspace, so from a security perspective, it may be better to just block the autostart feature entirely? Particularly if the user can manually start any they're fully confident in.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks, that's a good point! I've updated it to block all MCP server autostart when workspace trust is denied. Users can still manually start servers they trust.

ndoschek and others added 2 commits January 28, 2026 14:10
Resolves GH-16872

- Block workspace-scoped MCP servers with autostart in untrusted workspaces
- Start blocked servers when trust is granted
- Add WorkspaceRestrictionContribution API for packages to report restricted features in status bar tooltip
Co-authored-by: Colin Grant <cgrant.ext@eclipsesource.com>
Copy link
Contributor

@colin-grant-work colin-grant-work left a comment

Choose a reason for hiding this comment

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

Changes look good 👍

@github-project-automation github-project-automation bot moved this from Waiting on reviewers to Needs merge in PR Backlog Jan 28, 2026
@ndoschek ndoschek merged commit 213804e into master Jan 29, 2026
11 checks passed
@ndoschek ndoschek deleted the GH-16872 branch January 29, 2026 07:27
@github-project-automation github-project-automation bot moved this from Needs merge to Done in PR Backlog Jan 29, 2026
@github-actions github-actions bot added this to the 1.68.0 milestone Jan 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Prevent implicit execution of MCP configurations in untrusted workspaces

2 participants