Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/agent/src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2524,7 +2524,7 @@ fn setup_context_server(
let mut settings = ProjectSettings::get_global(cx).clone();
settings.context_servers.insert(
name.into(),
project::project_settings::ContextServerSettings::Custom {
project::project_settings::ContextServerSettings::Stdio {
enabled: true,
command: ContextServerCommand {
path: "somebinary".into(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ impl ConfigurationSource {
parse_input(&editor.read(cx).text(cx)).map(|(id, command)| {
(
id,
ContextServerSettings::Custom {
ContextServerSettings::Stdio {
enabled: true,
command,
},
Expand Down Expand Up @@ -403,7 +403,7 @@ impl ConfigureContextServerModal {

window.spawn(cx, async move |cx| {
let target = match settings {
ContextServerSettings::Custom {
ContextServerSettings::Stdio {
enabled: _,
command,
} => Some(ConfigurationTarget::Existing {
Expand Down Expand Up @@ -635,7 +635,6 @@ impl ConfigureContextServerModal {
}

fn render_modal_content(&self, cx: &App) -> AnyElement {
// All variants now use single editor approach
let editor = match &self.source {
ConfigurationSource::New { editor, .. } => editor,
ConfigurationSource::Existing { editor, .. } => editor,
Expand Down Expand Up @@ -712,12 +711,12 @@ impl ConfigureContextServerModal {
)
} else if let ConfigurationSource::New { is_http, .. } = &self.source {
let label = if *is_http {
"Run command"
"Configure Local"
} else {
"Connect via HTTP"
"Configure Remote"
};
let tooltip = if *is_http {
"Configure an MCP serevr that runs on stdin/stdout."
"Configure an MCP server that runs on stdin/stdout."
} else {
"Configure an MCP server that you connect to over HTTP"
};
Expand Down
2 changes: 1 addition & 1 deletion crates/extension_host/src/wasm_host/wit/since_v0_6_0.rs
Original file line number Diff line number Diff line change
Expand Up @@ -972,7 +972,7 @@ impl ExtensionImports for WasmState {
});

match settings {
project::project_settings::ContextServerSettings::Custom {
project::project_settings::ContextServerSettings::Stdio {
enabled: _,
command,
} => Ok(serde_json::to_string(&settings::ContextServerSettings {
Expand Down
6 changes: 6 additions & 0 deletions crates/migrator/src/migrations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,9 @@ pub(crate) mod m_2025_11_20 {

pub(crate) use settings::SETTINGS_PATTERNS;
}

pub(crate) mod m_2025_11_25 {
mod settings;

pub(crate) use settings::remove_context_server_source;
}
17 changes: 17 additions & 0 deletions crates/migrator/src/migrations/m_2025_11_25/settings.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
use anyhow::Result;
use serde_json::Value;

pub fn remove_context_server_source(settings: &mut Value) -> Result<()> {
if let Some(obj) = settings.as_object_mut() {
if let Some(context_servers) = obj.get_mut("context_servers") {
if let Some(servers) = context_servers.as_object_mut() {
for (_, server) in servers.iter_mut() {
if let Some(server_obj) = server.as_object_mut() {
server_obj.remove("source");
}
}
}
}
}
Ok(())
}
55 changes: 49 additions & 6 deletions crates/migrator/src/migrator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ pub fn migrate_settings(text: &str) -> Result<Option<String>> {
migrations::m_2025_11_20::SETTINGS_PATTERNS,
&SETTINGS_QUERY_2025_11_20,
),
MigrationType::Json(migrations::m_2025_11_25::remove_context_server_source),
];
run_migrations(text, migrations)
}
Expand Down Expand Up @@ -1334,7 +1335,6 @@ mod tests {
r#"{
"context_servers": {
"some-mcp-server": {
"source": "custom",
"command": {
"path": "npx",
"args": [
Expand All @@ -1354,7 +1354,6 @@ mod tests {
r#"{
"context_servers": {
"some-mcp-server": {
"source": "custom",
"command": "npx",
"args": [
"-y",
Expand All @@ -1376,7 +1375,6 @@ mod tests {
r#"{
"context_servers": {
"server-with-extras": {
"source": "custom",
"command": {
"path": "/usr/bin/node",
"args": ["server.js"]
Expand All @@ -1389,7 +1387,6 @@ mod tests {
r#"{
"context_servers": {
"server-with-extras": {
"source": "custom",
"command": "/usr/bin/node",
"args": ["server.js"],
"settings": {}
Expand All @@ -1404,7 +1401,6 @@ mod tests {
r#"{
"context_servers": {
"simple-server": {
"source": "custom",
"command": {
"path": "simple-mcp-server"
}
Expand All @@ -1415,7 +1411,6 @@ mod tests {
r#"{
"context_servers": {
"simple-server": {
"source": "custom",
"command": "simple-mcp-server"
}
}
Expand Down Expand Up @@ -2311,4 +2306,52 @@ mod tests {
),
);
}

#[test]
fn test_remove_context_server_source() {
assert_migrate_settings(
&r#"
{
"context_servers": {
"extension_server": {
"source": "extension",
"settings": {
"foo": "bar"
}
},
"custom_server": {
"source": "custom",
"command": "foo",
"args": ["bar"],
"env": {
"FOO": "BAR"
}
},
}
}
"#
.unindent(),
Some(
&r#"
{
"context_servers": {
"extension_server": {
"settings": {
"foo": "bar"
}
},
"custom_server": {
"command": "foo",
"args": ["bar"],
"env": {
"FOO": "BAR"
}
},
}
}
"#
.unindent(),
),
);
}
}
14 changes: 7 additions & 7 deletions crates/project/src/context_server_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ impl ContextServerConfiguration {
cx: &AsyncApp,
) -> Option<Self> {
match settings {
ContextServerSettings::Custom {
ContextServerSettings::Stdio {
enabled: _,
command,
} => Some(ContextServerConfiguration::Custom { command }),
Expand Down Expand Up @@ -1003,7 +1003,7 @@ mod tests {
),
(
server_2_id.0.clone(),
settings::ContextServerSettingsContent::Custom {
settings::ContextServerSettingsContent::Stdio {
enabled: true,
command: ContextServerCommand {
path: "somebinary".into(),
Expand Down Expand Up @@ -1044,7 +1044,7 @@ mod tests {
),
(
server_2_id.0.clone(),
settings::ContextServerSettingsContent::Custom {
settings::ContextServerSettingsContent::Stdio {
enabled: true,
command: ContextServerCommand {
path: "somebinary".into(),
Expand Down Expand Up @@ -1127,7 +1127,7 @@ mod tests {
json!({"code.rs": ""}),
vec![(
SERVER_1_ID.into(),
ContextServerSettings::Custom {
ContextServerSettings::Stdio {
enabled: true,
command: ContextServerCommand {
path: "somebinary".into(),
Expand Down Expand Up @@ -1180,7 +1180,7 @@ mod tests {
set_context_server_configuration(
vec![(
server_1_id.0.clone(),
settings::ContextServerSettingsContent::Custom {
settings::ContextServerSettingsContent::Stdio {
enabled: false,
command: ContextServerCommand {
path: "somebinary".into(),
Expand Down Expand Up @@ -1209,7 +1209,7 @@ mod tests {
set_context_server_configuration(
vec![(
server_1_id.0.clone(),
settings::ContextServerSettingsContent::Custom {
settings::ContextServerSettingsContent::Stdio {
enabled: true,
command: ContextServerCommand {
path: "somebinary".into(),
Expand Down Expand Up @@ -1328,7 +1328,7 @@ mod tests {
}

fn dummy_server_settings() -> ContextServerSettings {
ContextServerSettings::Custom {
ContextServerSettings::Stdio {
enabled: true,
command: ContextServerCommand {
path: "somebinary".into(),
Expand Down
38 changes: 19 additions & 19 deletions crates/project/src/project_settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,24 +117,14 @@ pub struct GlobalLspSettings {
#[derive(Deserialize, Serialize, Clone, PartialEq, Eq, JsonSchema, Debug)]
#[serde(tag = "source", rename_all = "snake_case")]
pub enum ContextServerSettings {
Custom {
Stdio {
/// Whether the context server is enabled.
#[serde(default = "default_true")]
enabled: bool,

#[serde(flatten)]
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
/// are supported.
settings: serde_json::Value,
},
Http {
/// Whether the context server is enabled.
#[serde(default = "default_true")]
Expand All @@ -145,13 +135,23 @@ pub enum ContextServerSettings {
#[serde(skip_serializing_if = "HashMap::is_empty", default)]
headers: HashMap<String, String>,
},
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
/// are supported.
settings: serde_json::Value,
},
}

impl From<settings::ContextServerSettingsContent> for ContextServerSettings {
fn from(value: settings::ContextServerSettingsContent) -> Self {
match value {
settings::ContextServerSettingsContent::Custom { enabled, command } => {
ContextServerSettings::Custom { enabled, command }
settings::ContextServerSettingsContent::Stdio { enabled, command } => {
ContextServerSettings::Stdio { enabled, command }
}
settings::ContextServerSettingsContent::Extension { enabled, settings } => {
ContextServerSettings::Extension { enabled, settings }
Expand All @@ -171,8 +171,8 @@ impl From<settings::ContextServerSettingsContent> for ContextServerSettings {
impl Into<settings::ContextServerSettingsContent> for ContextServerSettings {
fn into(self) -> settings::ContextServerSettingsContent {
match self {
ContextServerSettings::Custom { enabled, command } => {
settings::ContextServerSettingsContent::Custom { enabled, command }
ContextServerSettings::Stdio { enabled, command } => {
settings::ContextServerSettingsContent::Stdio { enabled, command }
}
ContextServerSettings::Extension { enabled, settings } => {
settings::ContextServerSettingsContent::Extension { enabled, settings }
Expand Down Expand Up @@ -200,17 +200,17 @@ impl ContextServerSettings {

pub fn enabled(&self) -> bool {
match self {
ContextServerSettings::Custom { enabled, .. } => *enabled,
ContextServerSettings::Extension { enabled, .. } => *enabled,
ContextServerSettings::Stdio { enabled, .. } => *enabled,
ContextServerSettings::Http { 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,
ContextServerSettings::Stdio { enabled: e, .. } => *e = enabled,
ContextServerSettings::Http { enabled: e, .. } => *e = enabled,
ContextServerSettings::Extension { enabled: e, .. } => *e = enabled,
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions crates/settings/src/settings_content/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ pub struct SessionSettingsContent {
#[derive(Deserialize, Serialize, Clone, PartialEq, Eq, JsonSchema, MergeFrom, Debug)]
#[serde(untagged, rename_all = "snake_case")]
pub enum ContextServerSettingsContent {
Custom {
Stdio {
/// Whether the context server is enabled.
#[serde(default = "default_true")]
enabled: bool,
Expand Down Expand Up @@ -225,7 +225,7 @@ pub enum ContextServerSettingsContent {
impl ContextServerSettingsContent {
pub fn set_enabled(&mut self, enabled: bool) {
match self {
ContextServerSettingsContent::Custom {
ContextServerSettingsContent::Stdio {
enabled: custom_enabled,
..
} => {
Expand Down
2 changes: 1 addition & 1 deletion crates/settings/src/vscode_import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ impl VsCodeSettings {
.filter_map(|(k, v)| {
Some((
k.clone().into(),
ContextServerSettingsContent::Custom {
ContextServerSettingsContent::Stdio {
enabled: true,
command: serde_json::from_value::<VsCodeContextServerCommand>(v.clone())
.ok()
Expand Down
Loading
Loading