Commit b220762
authored
🤖 feat: add per-workspace MCP server and tool configuration (#1180)
## Summary
Adds per-workspace MCP server and tool configuration. Users can now
customize which MCP servers are enabled and which tools are exposed for
each workspace, without modifying the project-level `.mux/mcp.jsonc`.
## Changes
### Backend
- **Types & Schemas**: Added `WorkspaceMCPOverrides` schema with
`disabledServers` and `toolAllowlist` fields
- **Config helpers**: `getWorkspaceMCPOverrides()` and
`setWorkspaceMCPOverrides()` methods in Config class
- **ORPC endpoints**: `workspace.mcp.get` and `workspace.mcp.set` for
frontend access
- **MCPServerManager**: Updated to filter servers and tools based on
workspace overrides
- **AIService**: Fetches and passes overrides when getting MCP tools
### Frontend
- **WorkspaceMCPModal**: New modal component for per-workspace MCP
configuration
- **WorkspaceHeader**: Added Server button (⚙️) to open the modal
- UI features:
- Toggle servers enabled/disabled for the workspace
- Fetch tools from each server
- Checkbox allowlist to select which tools to expose
- "Allow all" shortcut button
### Tests
- 5 tests for workspace override filtering in MCPServerManager
- 6 tests for workspace MCP override Config helpers
## How it works
1. **Server definitions remain per-project** in `.mux/mcp.jsonc`
2. **Per-workspace overrides** are stored in `~/.mux/config.json` under
each workspace entry
3. Effective servers = (project servers) - (workspace `disabledServers`)
4. Effective tools = filtered by `toolAllowlist[server]` if set
---
<details>
<summary>📋 Implementation Plan</summary>
# Plan: Selective MCP tools + per-workspace configuration
## Goals
1. **Selective MCP tools** — For each workspace, expose only an
allowlisted subset of MCP tools to the model.
2. **Per-workspace MCP configuration** — Allow enabling/disabling MCP
servers (and tool allowlists) **per workspace**, without impacting other
workspaces.
3. **Backwards compatible** — Existing per-project `.mux/mcp.jsonc`
continues to work unchanged.
## Proposed approach (recommended)
### 1) Keep server *definitions* per-project; add per-workspace
*overrides*
- **Per-project** (existing): `PROJECT_ROOT/.mux/mcp.jsonc`
- Source of truth for **server commands**.
- **Per-workspace** (new, stored in mux global config
`~/.mux/config.json` under each workspace entry):
- Which servers are enabled for that workspace.
- Which tools are allowlisted (per server) for that workspace.
This avoids needing to read/write config inside SSH workspaces (remote
filesystem) and keeps the current "configure once per project"
ergonomics, while still enabling workspace-specific behavior.
### 2) Workspace MCP override schema
Add an optional `mcp` field on `WorkspaceConfigSchema`:
```ts
// Stored under each workspace entry in ~/.mux/config.json
export interface WorkspaceMCPOverrides {
/** If set, these servers are disabled for this workspace (after project config). */
disabledServers?: string[];
/**
* Optional per-server allowlist of tools.
* Key: server name (from .mux/mcp.jsonc)
* Value: raw MCP tool names (NOT namespaced)
*
* If omitted for a server => expose all tools from that server.
*/
toolAllowlist?: Record<string, string[]>;
}
```
Semantics:
- Effective servers for a workspace = (project-config enabled servers)
minus `disabledServers`.
- Effective tools for a server:
- If `toolAllowlist[server]` present => only expose those tool names.
- Else => expose all tools from that server.
### 3) Runtime behavior changes
- `MCPServerManager.getToolsForWorkspace(...)` filters the returned tool
map using the workspace allowlists *before* it is merged into
`getToolsForModel`.
- `MCPServerManager.listServers(...)` gains a workspace-aware variant so
the system prompt lists **only the servers enabled for that workspace**.
- **No restart required** when only tool allowlists change (servers stay
running; we just filter what we expose).
</details>
---
_Generated with `mux` • Model: `anthropic:claude-opus-4-5` • Thinking:
`high`_1 parent 9aee49b commit b220762
File tree
19 files changed
+1862
-83
lines changed- .storybook/mocks
- src
- browser
- components
- Settings/sections
- hooks
- stories
- common
- orpc/schemas
- types
- node
- orpc
- services
19 files changed
+1862
-83
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
73 | 85 | | |
74 | 86 | | |
75 | 87 | | |
| |||
100 | 112 | | |
101 | 113 | | |
102 | 114 | | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
103 | 118 | | |
104 | 119 | | |
105 | 120 | | |
| |||
159 | 174 | | |
160 | 175 | | |
161 | 176 | | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
162 | 191 | | |
163 | 192 | | |
164 | 193 | | |
| |||
239 | 268 | | |
240 | 269 | | |
241 | 270 | | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
242 | 275 | | |
243 | 276 | | |
244 | 277 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
540 | 540 | | |
541 | 541 | | |
542 | 542 | | |
| 543 | + | |
543 | 544 | | |
544 | 545 | | |
545 | 546 | | |
| |||
Lines changed: 138 additions & 49 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
| 16 | + | |
15 | 17 | | |
16 | 18 | | |
17 | 19 | | |
| |||
26 | 28 | | |
27 | 29 | | |
28 | 30 | | |
29 | | - | |
30 | | - | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
31 | 49 | | |
32 | | - | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
33 | 54 | | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
| 55 | + | |
| 56 | + | |
40 | 57 | | |
41 | | - | |
42 | | - | |
43 | | - | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
44 | 61 | | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
62 | 86 | | |
63 | | - | |
| 87 | + | |
64 | 88 | | |
65 | 89 | | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
73 | 102 | | |
74 | | - | |
75 | | - | |
76 | | - | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
77 | 117 | | |
78 | | - | |
79 | | - | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
80 | 168 | | |
81 | 169 | | |
82 | 170 | | |
| |||
478 | 566 | | |
479 | 567 | | |
480 | 568 | | |
481 | | - | |
482 | | - | |
483 | | - | |
484 | | - | |
485 | | - | |
486 | | - | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
487 | 576 | | |
488 | 577 | | |
489 | 578 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
0 commit comments