agent: Store if context server should be enabled/disabled in the settings (#32994)

- [x] Show disabled MCP servers in the list so you can enable them again
- [x] If MCP is not present in the settings, add it

Closes #ISSUE

Release Notes:

- agent: Allow to enable/disable context servers permanently in the
agent configuration view

---------

Co-authored-by: Danilo Leal <daniloleal09@gmail.com>
This commit is contained in:
Bennet Bo Fenner 2025-06-21 14:46:36 +02:00 committed by GitHub
parent dfdd2b9558
commit 834cdc1271
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 260 additions and 41 deletions

View file

@ -88,12 +88,18 @@ pub struct DapSettings {
#[serde(tag = "source", rename_all = "snake_case")]
pub enum ContextServerSettings {
Custom {
/// Whether the context server is enabled.
#[serde(default = "default_true")]
enabled: bool,
/// The command to run this context server.
///
/// This will override the command set by an extension.
command: ContextServerCommand,
},
Extension {
/// Whether the context server is enabled.
#[serde(default = "default_true")]
enabled: bool,
/// The settings for this context server specified by the extension.
///
/// Consult the documentation for the context server to see what settings
@ -102,6 +108,22 @@ pub enum ContextServerSettings {
},
}
impl ContextServerSettings {
pub fn enabled(&self) -> bool {
match self {
ContextServerSettings::Custom { enabled, .. } => *enabled,
ContextServerSettings::Extension { enabled, .. } => *enabled,
}
}
pub fn set_enabled(&mut self, enabled: bool) {
match self {
ContextServerSettings::Custom { enabled: e, .. } => *e = enabled,
ContextServerSettings::Extension { enabled: e, .. } => *e = enabled,
}
}
}
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize, JsonSchema)]
pub struct NodeBinarySettings {
/// The path to the Node binary.
@ -478,6 +500,7 @@ impl Settings for ProjectSettings {
Some((
k.clone().into(),
ContextServerSettings::Custom {
enabled: true,
command: serde_json::from_value::<VsCodeContextServerCommand>(
v.clone(),
)