Skip to content

Commit 51ee1c4

Browse files
wpfleger96npub1mn7jgtj4w2pd0g0zeuhxsa6jy6p0rewxz4kujt98my82ahfmp72sxjexk7
andauthored
feat(desktop): show read-only MCP server config (#1780)
Signed-off-by: Will Pfleger <[email protected]> Co-authored-by: npub1mn7jgtj4w2pd0g0zeuhxsa6jy6p0rewxz4kujt98my82ahfmp72sxjexk7 <dcfd242e557282d7a1e2cf2e6877522682f1e5c6156dc92ca7d90eaedd3b0f95@sprout-oss.stage.blox.sqprod.co>
1 parent deed64a commit 51ee1c4

11 files changed

Lines changed: 304 additions & 40 deletions

File tree

‎desktop/scripts/check-file-sizes.mjs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,8 @@ const overrides = new Map([
198198
// loginHint fields on AcpRuntimeCatalogEntry (+14 lines). Load-bearing new feature.
199199
// agent-lifecycle-fixes: GlobalAgentConfigSaveResult type grows with
200200
// failed_restart_count (+2 lines). Queued to split with the rest of this list.
201-
["src/shared/api/types.ts", 1030],
201+
// mcp-readonly-view rebase: PR2 MCP config surface FE-type fields force +1 over the grandfathered ceiling.
202+
["src/shared/api/types.ts", 1031],
202203
// readiness-gate: PersonaDialog.tsx threads computeLocalModeGate +
203204
// requiredCredentialEnvKeys + RequiredFieldLabel so the "New agent" dialog
204205
// shows required markers and credential amber rows (parity with

‎desktop/src-tauri/src/managed_agents/config_bridge/codex.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ fn toml_string(table: &toml::Table, key: &str) -> Option<String> {
122122
.map(str::to_string)
123123
}
124124

125-
fn codex_config_path() -> Option<std::path::PathBuf> {
125+
pub(crate) fn codex_config_path() -> Option<std::path::PathBuf> {
126126
if let Ok(home) = std::env::var("CODEX_HOME") {
127127
return Some(std::path::PathBuf::from(home).join("config.toml"));
128128
}

‎desktop/src-tauri/src/managed_agents/config_bridge/goose.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ fn mapping_string(map: &serde_yaml::Mapping, key: &str) -> Option<String> {
154154
.map(str::to_string)
155155
}
156156

157-
fn goose_config_path() -> Option<PathBuf> {
157+
pub(crate) fn goose_config_path() -> Option<PathBuf> {
158158
if let Ok(root) = std::env::var("GOOSE_PATH_ROOT") {
159159
return Some(PathBuf::from(root).join("config").join("config.yaml"));
160160
}

‎desktop/src-tauri/src/managed_agents/config_bridge/reader.rs‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,8 @@ pub(crate) fn read_config_surface(
167167
let config_file_path = runtime_meta
168168
.and_then(|m| m.config_file_path)
169169
.map(resolve_tilde);
170+
let mcp_config_file_path = runtime_meta.and_then(mcp_config_file_path_for_runtime);
171+
let extensions = file_config.extensions.clone();
170172

171173
let sources = ConfigSourceReport {
172174
acp_native: if supports_acp_native {
@@ -197,6 +199,7 @@ pub(crate) fn read_config_surface(
197199
ConfigTierStatus::NotApplicable
198200
},
199201
config_file_path,
202+
mcp_config_file_path,
200203
};
201204

202205
RuntimeConfigSurface {
@@ -205,10 +208,24 @@ pub(crate) fn read_config_surface(
205208
is_pre_spawn,
206209
normalized,
207210
advanced,
211+
extensions,
208212
sources,
209213
}
210214
}
211215

216+
fn mcp_config_file_path_for_runtime(runtime: &KnownAcpRuntime) -> Option<String> {
217+
match runtime.id {
218+
"goose" => {
219+
super::goose::goose_config_path().map(|path| path.to_string_lossy().into_owned())
220+
}
221+
"claude" => Some(resolve_tilde("~/.claude.json")),
222+
"codex" => {
223+
super::codex::codex_config_path().map(|path| path.to_string_lossy().into_owned())
224+
}
225+
_ => None,
226+
}
227+
}
228+
212229
#[allow(clippy::too_many_arguments)]
213230
fn build_model_field(
214231
record_model: &Option<String>,

‎desktop/src-tauri/src/managed_agents/config_bridge/reader_tests.rs‎

Lines changed: 82 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,31 @@
22
//! `reader.rs` stays under the 1000-line budget; `#[path]`-included from
33
//! there).
44
5-
use std::collections::BTreeMap;
5+
use std::{collections::BTreeMap, path::Path, sync::Mutex};
66

77
use super::*;
88
use crate::managed_agents::discovery::KnownAcpRuntime;
99
use crate::managed_agents::types::ManagedAgentRecord;
1010

11+
static GOOSE_PATH_ROOT_LOCK: Mutex<()> = Mutex::new(());
12+
13+
fn with_goose_path_root<T>(value: Option<&str>, body: impl FnOnce() -> T) -> T {
14+
let _guard = GOOSE_PATH_ROOT_LOCK
15+
.lock()
16+
.unwrap_or_else(|err| err.into_inner());
17+
let prior = std::env::var_os("GOOSE_PATH_ROOT");
18+
match value {
19+
Some(value) => std::env::set_var("GOOSE_PATH_ROOT", value),
20+
None => std::env::remove_var("GOOSE_PATH_ROOT"),
21+
}
22+
let output = body();
23+
match prior {
24+
Some(value) => std::env::set_var("GOOSE_PATH_ROOT", value),
25+
None => std::env::remove_var("GOOSE_PATH_ROOT"),
26+
}
27+
output
28+
}
29+
1130
fn test_runtime() -> &'static KnownAcpRuntime {
1231
&KnownAcpRuntime {
1332
id: "goose",
@@ -111,6 +130,68 @@ fn pre_spawn_surface_reports_pending_acp_tiers() {
111130
assert_eq!(surface.sources.env_vars, ConfigTierStatus::Available);
112131
}
113132

133+
#[test]
134+
fn surface_reports_mcp_specific_config_path() {
135+
let record = test_record();
136+
let runtime = test_runtime();
137+
let surface = with_goose_path_root(None, || {
138+
read_config_surface(&record, Some(runtime), None, None)
139+
});
140+
141+
let path = surface
142+
.sources
143+
.mcp_config_file_path
144+
.expect("mcp config path");
145+
let expected_suffix = Path::new(".config").join("goose").join("config.yaml");
146+
assert!(
147+
Path::new(&path).ends_with(&expected_suffix),
148+
"unexpected MCP config path: {path}"
149+
);
150+
}
151+
152+
#[test]
153+
fn goose_mcp_config_path_follows_path_root_override() {
154+
let record = test_record();
155+
let runtime = test_runtime();
156+
let surface = with_goose_path_root(Some("/tmp/buzz-goose-root"), || {
157+
read_config_surface(&record, Some(runtime), None, None)
158+
});
159+
160+
let expected_path = Path::new("/tmp/buzz-goose-root")
161+
.join("config")
162+
.join("config.yaml");
163+
assert_eq!(
164+
surface
165+
.sources
166+
.mcp_config_file_path
167+
.as_deref()
168+
.map(Path::new),
169+
Some(expected_path.as_path())
170+
);
171+
}
172+
173+
#[test]
174+
fn claude_surface_uses_mcp_config_path_not_settings_path() {
175+
let record = test_record();
176+
let runtime = &KnownAcpRuntime {
177+
id: "claude",
178+
config_file_path: Some("~/.claude/settings.json"),
179+
..*test_runtime()
180+
};
181+
let surface = read_config_surface(&record, Some(runtime), None, None);
182+
183+
assert!(surface
184+
.sources
185+
.config_file_path
186+
.as_deref()
187+
.is_some_and(|path| path.ends_with(".claude/settings.json")));
188+
assert!(surface
189+
.sources
190+
.mcp_config_file_path
191+
.as_deref()
192+
.is_some_and(|path| path.ends_with(".claude.json")));
193+
}
194+
114195
#[test]
115196
fn record_model_overrides_file_model() {
116197
let mut record = test_record();

‎desktop/src-tauri/src/managed_agents/config_bridge/types.rs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ pub struct ConfigSourceReport {
123123
pub env_vars: ConfigTierStatus,
124124
pub config_file: ConfigTierStatus,
125125
pub config_file_path: Option<String>,
126+
pub mcp_config_file_path: Option<String>,
126127
}
127128

128129
/// Full config surface returned to the frontend.
@@ -134,6 +135,7 @@ pub struct RuntimeConfigSurface {
134135
pub is_pre_spawn: bool,
135136
pub normalized: NormalizedConfig,
136137
pub advanced: Vec<ConfigField>,
138+
pub extensions: Vec<ExtensionEntry>,
137139
pub sources: ConfigSourceReport,
138140
}
139141

‎desktop/src/features/agents/ui/AgentConfigPanel.tsx‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { useAgentConfigSurface } from "../hooks";
1717
import { cn } from "@/shared/lib/cn";
1818
import { copyTextToClipboard } from "@/shared/lib/clipboard";
1919
import { Spinner } from "@/shared/ui/spinner";
20+
import { McpServersSection } from "./McpServersSection";
2021
import type {
2122
ConfigField,
2223
ConfigOrigin,
@@ -365,7 +366,8 @@ export function AgentConfigPanel({
365366
);
366367
}
367368

368-
const { normalized, advanced, sources, isPreSpawn } = data;
369+
const { normalized, advanced, extensions, runtimeId, sources, isPreSpawn } =
370+
data;
369371
const configFilePath = sources.configFilePath;
370372

371373
const normalizedEntries = (
@@ -416,8 +418,17 @@ export function AgentConfigPanel({
416418
)}
417419
</div>
418420

421+
<McpServersSection
422+
extensions={extensions}
423+
runtimeId={runtimeId}
424+
variant={advancedMode === "flat" ? "profile" : "compact"}
425+
/>
426+
419427
{advanced.length > 0 && advancedMode === "flat" ? (
420428
<div className="divide-y divide-border/50 border-t border-border/50">
429+
<p className="px-4 py-3 text-xs font-medium text-foreground">
430+
Advanced
431+
</p>
421432
{advanced.map((field) => (
422433
<AdvancedRow
423434
key={field.key}
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
import type * as React from "react";
2+
import { CheckCircle2, CircleSlash } from "lucide-react";
3+
import type { ExtensionEntry } from "@/shared/api/types";
4+
import { cn } from "@/shared/lib/cn";
5+
6+
type McpServersSectionProps = {
7+
extensions: ExtensionEntry[];
8+
runtimeId: string | null;
9+
variant?: "compact" | "profile";
10+
buzzAgentSlot?: React.ReactNode;
11+
};
12+
13+
export function McpServersSection({
14+
buzzAgentSlot,
15+
extensions,
16+
runtimeId,
17+
variant = "compact",
18+
}: McpServersSectionProps) {
19+
const isBuzzAgent = runtimeId === "buzz-agent";
20+
21+
if (!isBuzzAgent && extensions.length === 0) {
22+
return null;
23+
}
24+
25+
return (
26+
<div
27+
className={cn(
28+
"border-t border-border/50",
29+
variant === "compact" ? "mt-3 pt-2" : "divide-y divide-border/50",
30+
)}
31+
>
32+
<p
33+
className={cn(
34+
"text-xs font-medium text-foreground",
35+
variant === "compact" ? "py-2" : "px-4 py-3",
36+
)}
37+
>
38+
MCP Servers
39+
</p>
40+
41+
{isBuzzAgent && buzzAgentSlot ? buzzAgentSlot : null}
42+
43+
{extensions.length > 0 ? (
44+
<div className="divide-y divide-border/50">
45+
{extensions.map((extension) => (
46+
<McpServerRow
47+
extension={extension}
48+
key={`${extension.kind}:${extension.name}`}
49+
variant={variant}
50+
/>
51+
))}
52+
</div>
53+
) : (
54+
<p
55+
className={cn(
56+
"text-sm text-muted-foreground",
57+
variant === "compact" ? "py-2" : "px-4 py-3",
58+
)}
59+
>
60+
No custom servers configured
61+
</p>
62+
)}
63+
</div>
64+
);
65+
}
66+
67+
function McpServerRow({
68+
extension,
69+
variant,
70+
}: {
71+
extension: ExtensionEntry;
72+
variant: "compact" | "profile";
73+
}) {
74+
const StatusIcon = extension.enabled ? CheckCircle2 : CircleSlash;
75+
76+
return (
77+
<div
78+
className={cn(
79+
"flex min-w-0 items-center gap-3",
80+
variant === "compact" ? "py-2" : "px-4 py-3",
81+
)}
82+
>
83+
<span className="flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-muted/50">
84+
<StatusIcon
85+
className={cn(
86+
"h-4 w-4",
87+
extension.enabled ? "text-emerald-600" : "text-muted-foreground",
88+
)}
89+
/>
90+
</span>
91+
<span className="min-w-0 flex-1">
92+
<span className="block truncate text-sm font-medium text-foreground">
93+
{extension.name}
94+
</span>
95+
<span className="mt-0.5 block truncate text-2xs text-muted-foreground/70">
96+
{extension.kind}
97+
{extension.enabled ? " enabled" : " disabled"}
98+
</span>
99+
</span>
100+
</div>
101+
);
102+
}

‎desktop/src/shared/api/types.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -679,8 +679,11 @@ export type ConfigSourceReport = {
679679
envVars: ConfigTierStatus;
680680
configFile: ConfigTierStatus;
681681
configFilePath: string | null;
682+
mcpConfigFilePath: string | null;
682683
};
683684

685+
export type ExtensionEntry = { name: string; kind: string; enabled: boolean };
686+
684687
export type NormalizedConfig = {
685688
model: NormalizedField | null;
686689
provider: NormalizedField | null;
@@ -697,6 +700,7 @@ export type RuntimeConfigSurface = {
697700
isPreSpawn: boolean;
698701
normalized: NormalizedConfig;
699702
advanced: ConfigField[];
703+
extensions: ExtensionEntry[];
700704
sources: ConfigSourceReport;
701705
};
702706

0 commit comments

Comments
 (0)