diff --git a/crates/op-editor-core/src/agent_settings.rs b/crates/op-editor-core/src/agent_settings.rs index c4810a399..390e2c6a0 100644 --- a/crates/op-editor-core/src/agent_settings.rs +++ b/crates/op-editor-core/src/agent_settings.rs @@ -96,12 +96,19 @@ impl Default for McpServer { } impl McpServer { - pub fn client_config_text(self) -> String { + pub fn client_config_display_text(self) -> String { format!( r#"{{ "type": "http", "url": "http://127.0.0.1:{}/mcp" }}"#, self.port ) } + + pub fn client_config_clipboard_text(self) -> String { + format!( + "{{\n \"type\": \"http\",\n \"url\": \"http://127.0.0.1:{}/mcp\"\n}}", + self.port + ) + } } /// Editable inputs on the settings modal that aren't tied to a `Node` diff --git a/crates/op-editor-ui/src/widgets/agent_settings_mcp.rs b/crates/op-editor-ui/src/widgets/agent_settings_mcp.rs index c515be34f..21ac3c953 100644 --- a/crates/op-editor-ui/src/widgets/agent_settings_mcp.rs +++ b/crates/op-editor-ui/src/widgets/agent_settings_mcp.rs @@ -396,7 +396,7 @@ fn paint_client_config( theme.muted_foreground, 1.5, ); - let config = settings.mcp_server.client_config_text(); + let config = settings.mcp_server.client_config_display_text(); let config = ellipsize( cx, &config, diff --git a/crates/op-host-native/src/widget_host/agent_settings_tests.rs b/crates/op-host-native/src/widget_host/agent_settings_tests.rs index c4c10d043..457f85387 100644 --- a/crates/op-host-native/src/widget_host/agent_settings_tests.rs +++ b/crates/op-host-native/src/widget_host/agent_settings_tests.rs @@ -464,7 +464,7 @@ fn copy_mcp_client_config_queues_clipboard_text() { assert_eq!( host.editor_state().chat.pending_copy_text.as_deref(), - Some(r#"{ "type": "http", "url": "http://127.0.0.1:4123/mcp" }"#) + Some("{\n \"type\": \"http\",\n \"url\": \"http://127.0.0.1:4123/mcp\"\n}") ); } diff --git a/crates/op-host-native/src/widget_host/press_helpers.rs b/crates/op-host-native/src/widget_host/press_helpers.rs index c17453855..db7dbf81e 100644 --- a/crates/op-host-native/src/widget_host/press_helpers.rs +++ b/crates/op-host-native/src/widget_host/press_helpers.rs @@ -109,7 +109,7 @@ impl WidgetHostNative { .editor_ui .agent_settings .mcp_server - .client_config_text(); + .client_config_clipboard_text(); self.editor_state.chat.queue_copy_text(config); } AgentSettingsHit::ToggleImagesAdvanced => { diff --git a/crates/op-host-web/src/widget_host/agent_settings_press.rs b/crates/op-host-web/src/widget_host/agent_settings_press.rs index 35fb1383e..7f618bcbb 100644 --- a/crates/op-host-web/src/widget_host/agent_settings_press.rs +++ b/crates/op-host-web/src/widget_host/agent_settings_press.rs @@ -67,7 +67,7 @@ impl WidgetHost { .editor_ui .agent_settings .mcp_server - .client_config_text(); + .client_config_clipboard_text(); self.editor_state.chat.queue_copy_text(config); } AgentSettingsHit::ToggleImagesAdvanced => {